diff --git a/CMakeLists.txt b/CMakeLists.txt index ec528b12..2161138c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") # find needed packages SET(Boost_USE_STATIC_LIBS ON) SET(Boost_USE_MULTITHREADED OFF) -FIND_PACKAGE(Boost COMPONENTS system signals REQUIRED) +FIND_PACKAGE(Boost COMPONENTS system REQUIRED) FIND_PACKAGE(OpenGL REQUIRED) FIND_PACKAGE(Lua REQUIRED) FIND_PACKAGE(PhysFS REQUIRED) @@ -56,7 +56,7 @@ SET(SOURCES src/framework/core/configs.cpp src/framework/core/resources.cpp src/framework/core/engine.cpp - src/framework/core/modules.cpp + src/framework/core/packages.cpp # framework otml src/framework/otml/otmlemitter.cpp @@ -64,9 +64,13 @@ SET(SOURCES src/framework/otml/otmlnode.cpp # framework script - src/framework/script/scriptobject.cpp - src/framework/script/scriptcontext.cpp - src/framework/script/scriptfunctions.cpp + src/framework/script/luastate.cpp + src/framework/script/luavalue.cpp + src/framework/script/luaobject.cpp + src/framework/script/luainterface.cpp + src/framework/script/luafunctions.cpp + src/framework/script/luaexception.cpp + src/framework/script/luavaluecasts.cpp # framework utilities src/framework/util/color.cpp @@ -125,7 +129,7 @@ IF(WIN32) ADD_DEFINITIONS(-DWIN32_NO_CONSOLE) ELSE(WIN32) SET(SOURCES ${SOURCES} src/framework/platform/x11platform.cpp) - ADD_DEFINITIONS(-D_DEBUG_MEMORY) + #ADD_DEFINITIONS(-D_DEBUG_MEMORY) SET(ADDITIONAL_LIBRARIES pthread GLU) ENDIF(WIN32) diff --git a/data/fonts/helvetica-11px-bold.otml b/data/fonts/helvetica-11px-bold.otml new file mode 100644 index 00000000..e69e35cf --- /dev/null +++ b/data/fonts/helvetica-11px-bold.otml @@ -0,0 +1,10 @@ +glyph-height: 14 +glyph-spacing: [1, 1] +top-margin: 2 +image: helvetica-11px-bold.png +image-glyph-size: [16, 16] + +glyph-widths: + 32: 4 + 65: 8 + diff --git a/data/fonts/helvetica-11px-bold.png b/data/fonts/helvetica-11px-bold.png new file mode 100644 index 00000000..3c334571 Binary files /dev/null and b/data/fonts/helvetica-11px-bold.png differ diff --git a/data/fonts/helvetica-11px.otml b/data/fonts/helvetica-11px.otml new file mode 100644 index 00000000..b4f04e1b --- /dev/null +++ b/data/fonts/helvetica-11px.otml @@ -0,0 +1,9 @@ +glyph-height: 14 +glyph-spacing: [1, 1] +top-margin: 1 +image: helvetica-11px.png +image-glyph-size: [16, 16] + +glyph-widths: + 32: 4 + diff --git a/data/fonts/helvetica-11px.png b/data/fonts/helvetica-11px.png new file mode 100644 index 00000000..3f716a7f Binary files /dev/null and b/data/fonts/helvetica-11px.png differ diff --git a/data/fonts/helvetica-12px-bold.otml b/data/fonts/helvetica-12px-bold.otml new file mode 100644 index 00000000..925e0826 --- /dev/null +++ b/data/fonts/helvetica-12px-bold.otml @@ -0,0 +1,10 @@ +glyph-height: 16 +glyph-spacing: [1, 1] +top-margin: 2 +image: helvetica-12px-bold.png +image-glyph-size: [18, 18] + +glyph-widths: + 32: 4 + 65: 9 + diff --git a/data/fonts/helvetica-12px-bold.png b/data/fonts/helvetica-12px-bold.png new file mode 100644 index 00000000..9db4920b Binary files /dev/null and b/data/fonts/helvetica-12px-bold.png differ diff --git a/data/fonts/helvetica-12px.otml b/data/fonts/helvetica-12px.otml new file mode 100644 index 00000000..8ec0b6db --- /dev/null +++ b/data/fonts/helvetica-12px.otml @@ -0,0 +1,9 @@ +glyph-height: 15 +glyph-spacing: [1, 1] +top-margin: 1 +image: helvetica-12px.png +image-glyph-size: [16, 16] + +glyph-widths: + 32: 4 + 65: 8 diff --git a/data/fonts/helvetica-12px.png b/data/fonts/helvetica-12px.png new file mode 100644 index 00000000..079da8f7 Binary files /dev/null and b/data/fonts/helvetica-12px.png differ diff --git a/data/fonts/helvetica-14px-bold.otml b/data/fonts/helvetica-14px-bold.otml new file mode 100644 index 00000000..737ec8af --- /dev/null +++ b/data/fonts/helvetica-14px-bold.otml @@ -0,0 +1,10 @@ +glyph-height: 16 +glyph-spacing: [1, 1] +top-margin: 2 +image: helvetica-14px-bold.png +image-glyph-size: [20, 20] + +glyph-widths: + 32: 4 + 65: 9 + diff --git a/data/fonts/helvetica-14px-bold.png b/data/fonts/helvetica-14px-bold.png new file mode 100644 index 00000000..c89524f3 Binary files /dev/null and b/data/fonts/helvetica-14px-bold.png differ diff --git a/data/fonts/sans-11px-bold.otml b/data/fonts/sans-11px-bold.otml deleted file mode 100644 index 53fd72e0..00000000 --- a/data/fonts/sans-11px-bold.otml +++ /dev/null @@ -1,8 +0,0 @@ -glyph height: 14 -glyph spacing: [0, 1] -top margin: 0 -image: sans-11px-bold.png -image glyph size: [16, 16] - -glyph widths: - 32: 4 diff --git a/data/fonts/sans-11px-bold.png b/data/fonts/sans-11px-bold.png deleted file mode 100644 index 435d0182..00000000 Binary files a/data/fonts/sans-11px-bold.png and /dev/null differ diff --git a/data/fonts/sans-11px.png b/data/fonts/sans-11px.png deleted file mode 100644 index b98b1d6e..00000000 Binary files a/data/fonts/sans-11px.png and /dev/null differ diff --git a/data/fonts/sans-11px.yml b/data/fonts/sans-11px.yml deleted file mode 100644 index ea6dfe4c..00000000 --- a/data/fonts/sans-11px.yml +++ /dev/null @@ -1,8 +0,0 @@ -glyph height: 14 -glyph spacing: [0, 1] -top margin: 0 -image: sans-11px.png -image glyph size: [16, 16] - -glyph widths: - 32: 4 diff --git a/data/fonts/sans-12px-bold.otml b/data/fonts/sans-12px-bold.otml deleted file mode 100644 index 59634586..00000000 --- a/data/fonts/sans-12px-bold.otml +++ /dev/null @@ -1,8 +0,0 @@ -glyph height: 14 -glyph spacing: [0, 1] -top margin: 0 -image: sans-12px-bold.png -image glyph size: [20, 16] - -glyph widths: - 32: 4 diff --git a/data/fonts/sans-12px-bold.png b/data/fonts/sans-12px-bold.png deleted file mode 100644 index b5013c50..00000000 Binary files a/data/fonts/sans-12px-bold.png and /dev/null differ diff --git a/data/fonts/sans-12px.png b/data/fonts/sans-12px.png deleted file mode 100644 index fd3ba30b..00000000 Binary files a/data/fonts/sans-12px.png and /dev/null differ diff --git a/data/fonts/sans-12px.yml b/data/fonts/sans-12px.yml deleted file mode 100644 index f5a2fa21..00000000 --- a/data/fonts/sans-12px.yml +++ /dev/null @@ -1,8 +0,0 @@ -glyph height: 16 -glyph spacing: [0, 1] -top margin: 0 -image: sans-12px.png -image glyph size: [20, 16] - -glyph widths: - 32: 4 diff --git a/data/fonts/tibia-10px-antialised.otml b/data/fonts/tibia-10px-antialised.otml deleted file mode 100644 index 214a1763..00000000 --- a/data/fonts/tibia-10px-antialised.otml +++ /dev/null @@ -1,9 +0,0 @@ -glyph height: 10 -glyph spacing: [1, 4] -top margin: 3 -image: tibia-10px-antialised.png -image glyph size: [8, 16] -first glyph: 32 - -glyph widths: - 32: 2 diff --git a/data/fonts/tibia-10px-antialised.png b/data/fonts/tibia-10px-antialised.png deleted file mode 100644 index e3757851..00000000 Binary files a/data/fonts/tibia-10px-antialised.png and /dev/null differ diff --git a/data/fonts/tibia-10px-monochrome.otml b/data/fonts/tibia-10px-monochrome.otml deleted file mode 100644 index 6350825f..00000000 --- a/data/fonts/tibia-10px-monochrome.otml +++ /dev/null @@ -1,9 +0,0 @@ -glyph height: 10 -glyph spacing: [1, 1] -top margin: 3 -image: tibia-10px-monochrome.png -image glyph size: [8, 16] -first glyph: 32 - -glyph widths: - 32: 2 diff --git a/data/fonts/tibia-10px-monochrome.png b/data/fonts/tibia-10px-monochrome.png deleted file mode 100644 index 9f71d8d3..00000000 Binary files a/data/fonts/tibia-10px-monochrome.png and /dev/null differ diff --git a/data/fonts/tibia-12px-rounded.otml b/data/fonts/tibia-12px-rounded.otml deleted file mode 100644 index 1e974fd7..00000000 --- a/data/fonts/tibia-12px-rounded.otml +++ /dev/null @@ -1,232 +0,0 @@ -glyph height: 12 -glyph spacing: [0, 1] -top margin: 3 -image: tibia-12px-rounded.png -image glyph size: [16, 16] -first glyph: 32 - -glyph widths: - 32: 4 - 33: 4 - 34: 7 - 35: 9 - 36: 8 - 37: 10 - 38: 10 - 39: 4 - 40: 6 - 41: 6 - 42: 8 - 43: 9 - 44: 4 - 45: 7 - 46: 4 - 47: 8 - 48: 8 - 49: 6 - 50: 8 - 51: 8 - 52: 8 - 53: 8 - 54: 8 - 55: 8 - 56: 8 - 57: 8 - 58: 5 - 59: 5 - 60: 10 - 61: 10 - 62: 10 - 63: 7 - 64: 10 - 65: 9 - 66: 8 - 67: 8 - 68: 9 - 69: 8 - 70: 8 - 71: 9 - 72: 9 - 73: 6 - 74: 7 - 75: 8 - 76: 8 - 77: 10 - 78: 9 - 79: 9 - 80: 8 - 81: 9 - 82: 9 - 83: 8 - 84: 10 - 85: 9 - 86: 8 - 87: 10 - 88: 8 - 89: 8 - 90: 8 - 91: 6 - 92: 8 - 93: 6 - 94: 11 - 95: 9 - 96: 7 - 97: 8 - 98: 8 - 99: 7 - 100: 8 - 101: 8 - 102: 7 - 103: 8 - 104: 8 - 105: 4 - 106: 6 - 107: 8 - 108: 4 - 109: 10 - 110: 8 - 111: 8 - 112: 8 - 113: 8 - 114: 7 - 115: 7 - 116: 7 - 117: 8 - 118: 8 - 119: 10 - 120: 8 - 121: 8 - 122: 7 - 123: 8 - 124: 5 - 125: 8 - 126: 9 - 127: 13 - 128: 8 - 129: 13 - 130: 4 - 131: 8 - 132: 6 - 133: 13 - 134: 8 - 135: 8 - 136: 7 - 137: 20 - 138: 8 - 139: 6 - 140: 13 - 141: 13 - 142: 7 - 143: 13 - 144: 13 - 145: 4 - 146: 4 - 147: 6 - 148: 6 - 149: 8 - 150: 8 - 151: 12 - 152: 7 - 153: 11 - 154: 7 - 155: 6 - 156: 13 - 157: 13 - 158: 7 - 159: 9 - 160: 4 - 161: 5 - 162: 8 - 163: 8 - 164: 8 - 165: 8 - 166: 7 - 167: 8 - 168: 7 - 169: 12 - 170: 7 - 171: 9 - 172: 11 - 173: 6 - 174: 12 - 175: 8 - 176: 7 - 177: 11 - 178: 7 - 179: 7 - 180: 7 - 181: 8 - 182: 8 - 183: 5 - 184: 7 - 185: 7 - 186: 7 - 187: 9 - 188: 15 - 189: 15 - 190: 15 - 191: 7 - 192: 10 - 193: 10 - 194: 10 - 195: 10 - 196: 10 - 197: 10 - 198: 13 - 199: 8 - 200: 7 - 201: 7 - 202: 7 - 203: 7 - 204: 5 - 205: 5 - 206: 5 - 207: 5 - 208: 10 - 209: 8 - 210: 9 - 211: 9 - 212: 9 - 213: 9 - 214: 9 - 215: 11 - 216: 9 - 217: 8 - 218: 8 - 219: 8 - 220: 8 - 221: 9 - 222: 9 - 223: 8 - 224: 8 - 225: 8 - 226: 8 - 227: 8 - 228: 8 - 229: 8 - 230: 12 - 231: 6 - 232: 8 - 233: 8 - 234: 8 - 235: 8 - 236: 5 - 237: 5 - 238: 3 - 239: 3 - 240: 8 - 241: 8 - 242: 8 - 243: 8 - 244: 8 - 245: 8 - 246: 8 - 247: 11 - 248: 8 - 249: 8 - 250: 8 - 251: 8 - 252: 8 - 253: 8 - 254: 8 - 255: 8 diff --git a/data/fonts/tibia-12px-rounded.png b/data/fonts/tibia-12px-rounded.png deleted file mode 100644 index 31a11f51..00000000 Binary files a/data/fonts/tibia-12px-rounded.png and /dev/null differ diff --git a/data/fonts/tibia-8px-antialised.otml b/data/fonts/tibia-8px-antialised.otml deleted file mode 100644 index d88a8a7d..00000000 --- a/data/fonts/tibia-8px-antialised.otml +++ /dev/null @@ -1,9 +0,0 @@ -glyph height: 8 -glyph spacing: [0, 1] -top margin: 1 -image: tibia-8px-antialised.png -image glyph size: [8, 8] -first glyph: 32 - -glyph widths: - 32: 2 diff --git a/data/fonts/tibia-8px-antialised.png b/data/fonts/tibia-8px-antialised.png deleted file mode 100644 index 1c526104..00000000 Binary files a/data/fonts/tibia-8px-antialised.png and /dev/null differ diff --git a/data/modules/core/aliases.lua b/data/modules/core/aliases.lua deleted file mode 100644 index e89d69bc..00000000 --- a/data/modules/core/aliases.lua +++ /dev/null @@ -1,4 +0,0 @@ --- some aliases -loadUI = UI.load -rootUI = UI.getRootContainer() - diff --git a/data/modules/core/enums.lua b/data/modules/core/constants.lua similarity index 88% rename from data/modules/core/enums.lua rename to data/modules/core/constants.lua index 0692d973..72d6b395 100644 --- a/data/modules/core/enums.lua +++ b/data/modules/core/constants.lua @@ -3,6 +3,6 @@ AnchorNone = 0 AnchorTop = 1 AnchorBottom = 2 AnchorLeft = 3 -AnchorRight = 4 +AnchorRight = 4 AnchorVerticalCenter = 5 AnchorHorizontalCenter = 6 diff --git a/data/modules/core/core.lua b/data/modules/core/core.lua index 604b5cad..06068672 100644 --- a/data/modules/core/core.lua +++ b/data/modules/core/core.lua @@ -1,4 +1,3 @@ -require 'aliases' -require 'enums' +require 'constants' require 'util' - +require 'messagebox' \ No newline at end of file diff --git a/data/modules/messagebox/messagebox.lua b/data/modules/core/messagebox.lua similarity index 69% rename from data/modules/messagebox/messagebox.lua rename to data/modules/core/messagebox.lua index b4369a06..a29c3e5f 100644 --- a/data/modules/messagebox/messagebox.lua +++ b/data/modules/core/messagebox.lua @@ -10,17 +10,21 @@ function MessageBox.create(title, text, flags) setmetatable(box, MessageBox) -- create messagebox window - local window = UIWindow.new("messageBoxWindow", rootUI) + local window = UIWindow.create() + id = "messageBoxWindow" window.title = title window:centerIn(rootUI) - window:setLocked() + window:setLocked(true) + rootUI:addChild(window) -- create messagebox label - local label = UILabel.new("messageBoxLabel", window) + local label = UILabel.create() + id = "messageBoxLabel" label.text = text - label:addAnchor(AnchorHorizontalCenter, window, AnchorHorizontalCenter) - label:addAnchor(AnchorTop, window, AnchorTop) - label:setMargin(27, 0) + label:addAnchor(AnchorHorizontalCenter, window.id, AnchorHorizontalCenter) + label:addAnchor(AnchorTop, window.id, AnchorTop) + --label:setMargin(27, 0) + window:addChild(label) -- set window size based on label size window.width = label.width + 40 @@ -28,27 +32,29 @@ function MessageBox.create(title, text, flags) -- setup messagebox first button local buttonText - local button1 = UIButton.new("messageBoxButton1", window) - button1:addAnchor(AnchorBottom, window, AnchorBottom) - button1:addAnchor(AnchorRight, window, AnchorRight) - button1:setMargin(10) + local button1 = UIButton.new() + id = "messageBoxButton1" + button1:addAnchor(AnchorBottom, window.id, AnchorBottom) + button1:addAnchor(AnchorRight, window.id, AnchorRight) + --button1:setMargin(10) + button1.width = 64 + window:addChild(button1) if flags == MessageBoxOk then - buttonText = "Ok" + button1.text = "Ok" box.onOk = createEmptyFunction() button1.onClick = function() box.onOk() box:destroy() end elseif flags == MessageBoxCancel then - buttonText = "Cancel" + button1.text = "Cancel" box.onCancel = createEmptyFunction() button1.onClick = function() box.onCancel() box:destroy() end end - button1.text = buttonText box.window = window return box diff --git a/data/modules/core/module.otml b/data/modules/core/module.otml deleted file mode 100644 index 5fa85e5e..00000000 --- a/data/modules/core/module.otml +++ /dev/null @@ -1,8 +0,0 @@ -title: Core -notes: Core utilities used by other modules -author: edubart -version: 1 -website: https://github.com/edubart/otclient -enabled: true -script: core.lua - diff --git a/data/modules/mainmenu/entergame.lua b/data/modules/mainmenu/entergame.lua index 26369bd4..f1a4da23 100644 --- a/data/modules/mainmenu/entergame.lua +++ b/data/modules/mainmenu/entergame.lua @@ -1,6 +1,9 @@ function EnterGame_connectToLoginServer() -- create login protocol - local protocolLogin = ProtocolLogin.new() + local protocolLogin = ProtocolLogin.create() + print(ProtocolLogin_mt) + print(Protocol_mt) + print(getmetatable(protocolLogin)) -- used to recreate enter game window local recreateEnterGame = function() @@ -11,14 +14,14 @@ function EnterGame_connectToLoginServer() local loadBox = displayCancelBox("Please wait", "Connecting..") -- cancel loading callback - loadBox.onCancel = function() + loadBox.onCancel = function(protocol) -- cancel protocol and reacreate enter game window - protocolLogin:cancel() + protocol:cancel() recreateEnterGame() end -- error callback - protocolLogin.onError = function(error) + protocolLogin.onError = function(protocol, error) -- destroy loading message box loadBox:destroy() @@ -26,12 +29,12 @@ function EnterGame_connectToLoginServer() local errorBox = displayErrorBox("Login Error", error) -- cancel protocol and reacreate enter game window - self.cancel() + protocol.cancel() errorBox.onOk = recreateEnterGame end -- motd callback - protocolLogin.onMotd = function(motd) + protocolLogin.onMotd = function(protocol, motd) -- destroy loading message box loadBox:destroy() @@ -41,14 +44,14 @@ function EnterGame_connectToLoginServer() local motdBox = displayInfoBox("Message of the day", motdText) -- cancel protocol and reacreate enter game window - self.cancel() + protocol.cancel() motdBox.onOk = recreateEnterGame end -- get account and password then login - local enterGameWindow = rootUI:child("enterGameWindow") - local account = enterGameWindow:child("accountNameTextEdit").text - local password = enterGameWindow:child("passwordTextEdit").text + local enterGameWindow = rootUI:getChild("enterGameWindow") + local account = enterGameWindow:getChild("accountNameTextEdit").text + local password = enterGameWindow:getChild("passwordTextEdit").text protocolLogin:login(account, password) -- destroy enter game window diff --git a/data/modules/mainmenu/init.lua b/data/modules/mainmenu/init.lua index bce7aeb4..cfa4fee2 100644 --- a/data/modules/mainmenu/init.lua +++ b/data/modules/mainmenu/init.lua @@ -1,16 +1,16 @@ require 'entergame' function initializeApplication() - mainMenu = loadUI("ui/mainmenu") + mainMenu = loadUI("ui/mainmenu", rootUI) end function terminateApplication() - App.exit() + exit() end -- here is where everything starts if not initialized then initializeApplication() - App.onClose = terminateApplication + onClose = terminateApplication initialized = true end diff --git a/data/modules/mainmenu/module.otml b/data/modules/mainmenu/module.otml deleted file mode 100644 index 8056a813..00000000 --- a/data/modules/mainmenu/module.otml +++ /dev/null @@ -1,10 +0,0 @@ -title: Main menu -notes: Used to create the main menu -enabled: true -#dependencies -interface: 020 -author: edubart -version: 0.2 -scripts: - - menustate.lua - - mainmenu.lua diff --git a/data/modules/mainmenu/ui/entergamewindow.otml b/data/modules/mainmenu/ui/entergamewindow.otml index 524920c5..bab0ac88 100644 --- a/data/modules/mainmenu/ui/entergamewindow.otml +++ b/data/modules/mainmenu/ui/entergamewindow.otml @@ -1,67 +1,54 @@ %window#enterGameWindow title: Enter Game - size: [236, 178] + size: [236, 160] anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - onLoad: self:setLocked() %label#accountNameLabel + skin: large text: Account name anchors.left: parent.left anchors.top: parent.top margin.left: 18 - margin.top: 33 + margin.top: 28 - %label#passwordLabel - text: "Password:" + %textEdit#accountNameTextEdit + text: tibialua0 anchors.left: parent.left - anchors.top: parent.top + anchors.right: parent.right + anchors.top: prev.bottom margin.left: 18 - margin.top: 62 + margin.right: 18 - %label#createAccountLabel - text: | - If you don't have - an account yet - anchors.left: parent.left - anchors.top: parent.top - margin.left: 18 - margin.top: 87 + %label#passwordLabel + skin: large + text: Password + anchors.left: prev.left + anchors.top: prev.bottom + margin.top: 8 - %button#createAccountButton - text: Create Account + %textEdit#passwordTextEdit + text: lua123456 anchors.left: parent.left - anchors.top: parent.top - margin.top: 94 - margin.left: 132 - onClick: displayErrorBox("Error", "Not implemented yet") + anchors.right: parent.right + anchors.top: prev.bottom + margin.left: 18 + margin.right: 18 %button#okButton text: Ok - size: [43, 20] - anchors.right: parent.right + width: 64 + anchors.right: next.left anchors.bottom: parent.bottom - margin.bottom: 10 - margin.right: 66 + margin.bottom: 16 + margin.right: 16 onClick: EnterGame_connectToLoginServer() %button#cancelButton text: Cancel - size: [43, 20] + width: 64 anchors.right: parent.right anchors.bottom: parent.bottom - margin.bottom: 10 - margin.right: 13 - onClick: self.parent:destroy() - - %textEdit#accountNameTextEdit - anchors.right: parent.right - anchors.top: parent.top - margin.top: 32 - margin.right: 18 - - %textEdit#passwordTextEdit - anchors.right: parent.right - anchors.top: parent.top - margin.top: 61 - margin.right: 18 + margin.bottom: 16 + margin.right: 16 + onClick: function(self) rootUI:getChild("enterGameWindow"):destroy() end diff --git a/data/modules/mainmenu/ui/infowindow.otml b/data/modules/mainmenu/ui/infowindow.otml index f401536e..afdd7bf7 100644 --- a/data/modules/mainmenu/ui/infowindow.otml +++ b/data/modules/mainmenu/ui/infowindow.otml @@ -3,7 +3,7 @@ size: [244, 221] anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - onLoad: self.locked = true + onLoad: function(self) self:setLocked() end %panel#infoPanel skin: flatPanel @@ -39,7 +39,7 @@ %button#websiteButton text: Github Page - size: [80,22] + size: [88, 24] anchors.right: parent.right anchors.bottom: parent.bottom margin.bottom: 9 @@ -55,9 +55,9 @@ %button#okButton text: Ok - size: [43, 20] + size: [46, 24] anchors.left: parent.left anchors.top: parent.top margin.top: 191 margin.left: 188 - onClick: self.parent:destroy() + onClick: function(self) self.parent:destroy() end diff --git a/data/modules/mainmenu/ui/mainmenu.otml b/data/modules/mainmenu/ui/mainmenu.otml index 68f830ae..d01103b8 100644 --- a/data/modules/mainmenu/ui/mainmenu.otml +++ b/data/modules/mainmenu/ui/mainmenu.otml @@ -7,7 +7,7 @@ %panel#mainMenu skin: roundedGridPanel - size: [117, 171] + size: [144, 162] anchors.left: parent.left anchors.bottom: parent.bottom margin.left: 60 @@ -17,33 +17,26 @@ text: Enter Game anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter - margin.top: 16 - onClick: UI.load("entergamewindow") - - %button#accessAccountButton - text: Access Account - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - margin.top: 46 - onClick: displayErrorBox("Error", "Not implemented yet") + margin.top: 18 + onClick: loadUI("entergamewindow", rootUI) %button#optionsButton text: Options - anchors.top: parent.top + anchors.top: prev.bottom anchors.horizontalCenter: parent.horizontalCenter - margin.top: 76 - onClick: UI.load("optionswindow") + margin.top: 10 + onClick: loadUI("optionswindow", rootUI) %button#infoButton text: Info - anchors.top: parent.top + anchors.top: prev.bottom anchors.horizontalCenter: parent.horizontalCenter - margin.top: 106 - onClick: UI.load("infowindow") + margin.top: 10 + onClick: loadUI("infowindow", rootUI) %button#exitGameButton text: Exit - anchors.top: parent.top + anchors.top: prev.bottom anchors.horizontalCenter: parent.horizontalCenter - margin.top: 136 + margin.top: 10 onClick: terminateApplication() diff --git a/data/modules/mainmenu/ui/optionswindow.otml b/data/modules/mainmenu/ui/optionswindow.otml index 4d05e453..c8df9049 100644 --- a/data/modules/mainmenu/ui/optionswindow.otml +++ b/data/modules/mainmenu/ui/optionswindow.otml @@ -3,7 +3,7 @@ size: [286, 262] anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - onLoad: self.locked = true + onLoad: function(self) self:setLocked(true) end # general %button#generalButton @@ -17,10 +17,10 @@ text: |- Change general game options - anchors.left: parent.left - anchors.top: parent.top - margin.left: 117 - margin.top: 29 + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 # graphics %button#graphicsButton @@ -34,10 +34,10 @@ text: |- Change graphics and performance settings - anchors.left: parent.left - anchors.top: parent.top - margin.left: 117 - margin.top: 62 + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 # console %button#consoleButton @@ -49,10 +49,10 @@ %label#consoleLabel text: Customise the console - anchors.left: parent.left - anchors.top: parent.top - margin.left: 117 - margin.top: 95 + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 # hotkeys %button#hotkeysButton @@ -64,10 +64,10 @@ %label#hotkeysLabel text: Edit your hotkey texts - anchors.left: parent.left - anchors.top: parent.top - margin.left: 117 - margin.top: 128 + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 %lineDecoration#middleSeparator anchors.left: parent.left @@ -89,10 +89,10 @@ text: | Show the most recent Message of the Day - anchors.left: parent.left - anchors.bottom: parent.bottom - margin.left: 117 - margin.bottom: 56 + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 %lineDecoration#bottomSeparator anchors.left: parent.left @@ -110,4 +110,4 @@ anchors.bottom: parent.bottom margin.right: 10 margin.bottom: 13 - onClick: self.parent:destroy() + onClick: function(self) self.parent:destroy() end diff --git a/data/modules/messagebox/module.otml b/data/modules/messagebox/module.otml deleted file mode 100644 index 9e132246..00000000 --- a/data/modules/messagebox/module.otml +++ /dev/null @@ -1,8 +0,0 @@ -title: Message box -notes: Functions for creating message boxes -author: edubart -version: 1 -website: https://github.com/edubart/otclient -enabled: true -script: messagebox.lua - diff --git a/data/skins/tibiaskin/background.png b/data/skins/background.png similarity index 100% rename from data/skins/tibiaskin/background.png rename to data/skins/background.png diff --git a/data/skins/button.png b/data/skins/button.png new file mode 100644 index 00000000..70727e0b Binary files /dev/null and b/data/skins/button.png differ diff --git a/data/skins/button_down.png b/data/skins/button_down.png new file mode 100644 index 00000000..7808d00a Binary files /dev/null and b/data/skins/button_down.png differ diff --git a/data/skins/button_hover.png b/data/skins/button_hover.png new file mode 100644 index 00000000..509268b4 Binary files /dev/null and b/data/skins/button_hover.png differ diff --git a/data/skins/container_bg.png b/data/skins/container_bg.png new file mode 100644 index 00000000..9fe1337c Binary files /dev/null and b/data/skins/container_bg.png differ diff --git a/data/skins/default.otml b/data/skins/default.otml new file mode 100644 index 00000000..0786421a --- /dev/null +++ b/data/skins/default.otml @@ -0,0 +1,80 @@ +default font: helvetica-12px +default font color: [210, 210, 210, 255] + +buttons: + default: + font: helvetica-11px-bold + font color: [240, 173, 77, 255] + default size: [106, 24] + + bordered image: + source: button.png + border: 5 + + hover state: + bordered image: + source: button_hover.png + border: 5 + + down state: + text translate: [1, 1] + bordered image: + source: button_down.png + border: 5 +panels: + default: + # the default panel is empty + + mainMenuBackground: + image: background.png + antialised: true + + roundedGridPanel: + bordered image: + source: panel_rounded.png + border: 4 + + flatPanel: + bordered image: + source: panel_flat.png + border: 1 + +labels: + default: + + large: + font: helvetica-12px-bold + +windows: + default: + font: helvetica-11px-bold + font color: [240, 173, 77, 255] + head: + height: 20 + bordered image: + source: window.png + size: [256, 19] + border: 4 + bottom: 3 + + body: + bordered image: + source: window.png + size: [256, 237] + offset: [0, 19] + border: 4 + top: 0 + +text edits: + default: + default size: [86, 20] + text margin: 3 + bordered image: + source: panel_flat.png + border: 1 + +line decorations: + default: + bordered image: + source: horizontal_separator.png + top: 2 diff --git a/data/skins/horizontal_separator.png b/data/skins/horizontal_separator.png new file mode 100644 index 00000000..16592583 Binary files /dev/null and b/data/skins/horizontal_separator.png differ diff --git a/data/skins/horizotal_separator.png b/data/skins/horizotal_separator.png new file mode 100644 index 00000000..a24cef32 Binary files /dev/null and b/data/skins/horizotal_separator.png differ diff --git a/data/skins/lightness.otml b/data/skins/lightness.otml deleted file mode 100644 index 7b1a4f8a..00000000 --- a/data/skins/lightness.otml +++ /dev/null @@ -1,137 +0,0 @@ -default font: sans-11px-bold -default font color: [51, 51, 51, 255] - -buttons: - default: - default size: [96, 22] - font color: [0, 115, 234, 255] - - bordered image: - source: lightness/button-up.png - left border: [0,2,2,6] - right border: [22,2,2,6] - top border: [2,0,20,2] - bottom border: [2,8,20,2] - top left corner: [0,0,2,2] - top right corner: [22,0,2,2] - bottom left corner: [0,8,2,2] - bottom right corner: [22,8,2,2] - center: [2,2,20,6] - - hover state: - font color: [255, 255, 255, 255] - bordered image: - source: lightness/button-hover.png - left border: [0,2,2,6] - right border: [22,2,2,6] - top border: [2,0,20,2] - bottom border: [2,8,20,2] - top left corner: [0,0,2,2] - top right corner: [22,0,2,2] - bottom left corner: [0,8,2,2] - bottom right corner: [22,8,2,2] - center: [2,2,20,6] - - down state: - font color: [255, 0, 132, 255] - bordered image: - source: lightness/button-down.png - left border: [0,2,2,6] - right border: [22,2,2,6] - top border: [2,0,20,2] - bottom border: [2,8,20,2] - top left corner: [0,0,2,2] - top right corner: [22,0,2,2] - bottom left corner: [0,8,2,2] - bottom right corner: [22,8,2,2] - center: [2,2,20,6] -panels: - default: - # the default panel is empty - - mainMenuBackground: - image: lightness/background.png - antialised: true - - roundedGridPanel: - bordered image: - source: lightness/menupanel.png - left border: [0,2,2,6] - right border: [22,2,2,6] - top border: [2,0,20,2] - bottom border: [2,8,20,2] - top left corner: [0,0,2,2] - top right corner: [22,0,2,2] - bottom left corner: [0,8,2,2] - bottom right corner: [22,8,2,2] - center: [2,2,20,6] - - flatPanel: - bordered image: - source: lightness/panel.png - left border: [0,2,2,6] - right border: [22,2,2,6] - top border: [2,0,20,2] - bottom border: [2,8,20,2] - top left corner: [0,0,2,2] - top right corner: [22,0,2,2] - bottom left corner: [0,8,2,2] - bottom right corner: [22,8,2,2] - center: [2,2,20,6] - -labels: - default: - font: sans-12px - -windows: - default: - font: sans-12px-bold - font color: [80, 80, 80, 255] - head: - text align: left - margin: 8 - height: 26 - bordered image: - source: lightness/window.png - left border: [0,5,5,22] - right border: [251,5,5,22] - top border: [5,0,246,5] - bottom border: [5,27,246,5] - top left corner: [0,0,5,5] - top right corner: [251,0,5,5] - bottom left corner: [0,27,5,5] - bottom right corner: [251,27,5,5] - center: [5,5,246,22] - body: - bordered image: - source: lightness/window.png - left border: [0,32,2,222] - right border: [254,32,2,222] - bottom border: [2,254,252,2] - bottom left corner: [0,254,2,2] - bottom right corner: [254,254,2,2] - center: [2, 32, 92, 92] - -text edits: - default: - default size: [86, 20] - font color: [80, 80, 80, 255] - text margin: 3 - bordered image: - source: lightness/button-down.png - left border: [0,2,2,6] - right border: [22,2,2,6] - top border: [2,0,20,2] - bottom border: [2,8,20,2] - top left corner: [0,0,2,2] - top right corner: [22,0,2,2] - bottom left corner: [0,8,2,2] - bottom right corner: [22,8,2,2] - center: [2,2,20,6] - -line decorations: - default: - bordered image: - source: lightness/window.png - top border: [2,254,252,2] - diff --git a/data/skins/lightness/background.png b/data/skins/lightness/background.png deleted file mode 100644 index 8ffebc34..00000000 Binary files a/data/skins/lightness/background.png and /dev/null differ diff --git a/data/skins/lightness/button-down.png b/data/skins/lightness/button-down.png deleted file mode 100644 index 78034074..00000000 Binary files a/data/skins/lightness/button-down.png and /dev/null differ diff --git a/data/skins/lightness/button-hover.png b/data/skins/lightness/button-hover.png deleted file mode 100644 index f286f595..00000000 Binary files a/data/skins/lightness/button-hover.png and /dev/null differ diff --git a/data/skins/lightness/button-up.png b/data/skins/lightness/button-up.png deleted file mode 100644 index 0f82c2be..00000000 Binary files a/data/skins/lightness/button-up.png and /dev/null differ diff --git a/data/skins/lightness/icos4d.png b/data/skins/lightness/icos4d.png deleted file mode 100644 index b50cbe36..00000000 Binary files a/data/skins/lightness/icos4d.png and /dev/null differ diff --git a/data/skins/lightness/menupanel.png b/data/skins/lightness/menupanel.png deleted file mode 100644 index a8138d43..00000000 Binary files a/data/skins/lightness/menupanel.png and /dev/null differ diff --git a/data/skins/lightness/mouse.png b/data/skins/lightness/mouse.png deleted file mode 100644 index 0bff481d..00000000 Binary files a/data/skins/lightness/mouse.png and /dev/null differ diff --git a/data/skins/lightness/panel.png b/data/skins/lightness/panel.png deleted file mode 100644 index 44f80777..00000000 Binary files a/data/skins/lightness/panel.png and /dev/null differ diff --git a/data/skins/lightness/window.png b/data/skins/lightness/window.png deleted file mode 100644 index d9160cb0..00000000 Binary files a/data/skins/lightness/window.png and /dev/null differ diff --git a/data/skins/panel_flat.png b/data/skins/panel_flat.png new file mode 100644 index 00000000..16510756 Binary files /dev/null and b/data/skins/panel_flat.png differ diff --git a/data/skins/panel_rounded.png b/data/skins/panel_rounded.png new file mode 100644 index 00000000..e4b33872 Binary files /dev/null and b/data/skins/panel_rounded.png differ diff --git a/data/skins/tibiaskin.otml b/data/skins/tibiaskin.otml deleted file mode 100644 index 99943c21..00000000 --- a/data/skins/tibiaskin.otml +++ /dev/null @@ -1,111 +0,0 @@ -default font: tibia-10px-antialised -default font color: [191, 191, 191, 255] -default texture: tibiaskin/skin.png - -buttons: - default: - font: tibia-8px-antialised - font color: [238, 238, 238, 255] - default size: [86, 20] - - bordered image: - left border: [45,139,1,18] - right border: [130,139,1,18] - top border: [46,138,84,1] - bottom border: [46,157,84,1] - top left corner: [45,138,1,1] - top right corner: [130,138,1,1] - bottom left corner: [45,157,1,1] - bottom right corner: [130,157,1,1] - center: [46,139,84,18] - - down state: - text translate: [1, 1] - bordered image: - left border: [45,159,1,18] - right border: [130,159,1,18] - top border: [46,158,84,1] - bottom border: [46,177,84,1] - top left corner: [45,158,1,1] - top right corner: [130,158,1,1] - bottom left corner: [45,177,1,1] - bottom right corner: [130,177,1,1] - center: [46,159,84,18] -panels: - default: - # the default panel is empty - - mainMenuBackground: - image: tibiaskin/background.png - antialised: true - - roundedGridPanel: - bordered image: - left border: [0,214,5,32] - right border: [6,214,5,32] - top border: [43,214,32,5] - bottom border: [43,220,32,5] - top left corner: [43,225,5,5] - top right corner: [49,225,5,5] - bottom left corner: [43,230,5,5] - bottom right corner: [48,231,5,5] - center: [11,214,32,32] - - flatPanel: - bordered image: - left border: [275,0,1,96] - right border: [276,0,1,96] - top border: [2,210,91,1] - bottom border: [2,211,91,1] - top left corner: [275,0,1,1] - top right corner: [276,0,1,1] - bottom left corner: [2,210,1,1] - bottom right corner: [276,95,1,1] - center: [0, 0, 96, 96] - -labels: - default: - -windows: - default: - font color: [143, 143, 143, 255] - head: - height: 17 - bordered image: - left border: [106,187,4,9] - right border: [110,187,4,9] - top border: [114,183,92,4] - bottom border: [114,196,92,4] - top left corner: [106,183,4,4] - top right corner: [110,183,4,4] - bottom left corner: [106,196,4,4] - bottom right corner: [110,196,4,4] - center: [114,187,96,9] - body: - bordered image: - left border: [98,180,4,12] - right border: [99,180,4,12] - bottom border: [2,193,96,4] - bottom left corner: [98,193,4,4] - bottom right corner: [102,193,4,4] - center: [0, 0, 96, 96] - -text edits: - default: - default size: [86, 16] - text margin: 3 - bordered image: - left border: [308,97,1,1] - right border: [319,97,1,10] - top border: [309,96,10,1] - bottom border: [309,107,10,1] - top left corner: [308,96,1,1] - top right corner: [319,96,1,1] - bottom left corner: [308,107,1,1] - bottom right corner: [319,107,1,1] - center: [309,97,10,10] - -line decorations: - default: - bordered image: - top border: [2,210,96,2] diff --git a/data/skins/tibiaskin/skin.png b/data/skins/tibiaskin/skin.png deleted file mode 100644 index ddbef0d8..00000000 Binary files a/data/skins/tibiaskin/skin.png and /dev/null differ diff --git a/data/skins/window.png b/data/skins/window.png new file mode 100644 index 00000000..c57da39f Binary files /dev/null and b/data/skins/window.png differ diff --git a/packages/core/constants.lua b/packages/core/constants.lua index bcb5a924..180925d1 100644 --- a/packages/core/constants.lua +++ b/packages/core/constants.lua @@ -1,4 +1,4 @@ -rootUI = UI.getRootContainer() +rootUI = App.getRootContainer() -- AnchorPoint AnchorNone = 0 diff --git a/packages/mainmenu/ui/entergamewindow.otml b/packages/mainmenu/ui/entergamewindow.otml index 89031337..09a433da 100644 --- a/packages/mainmenu/ui/entergamewindow.otml +++ b/packages/mainmenu/ui/entergamewindow.otml @@ -1,50 +1,60 @@ -window#enterGameWindow +Window + id: enterGameWindow title: Enter Game size: 236 178 anchor.centerIn: parent lockOnLoad: true - %label + Label text: Account name position: 18 33 - %label + Label text: "Password:" position: 18 62 - %label - text: | - If you don't have - an account yet + Label + text: + [[If you don't have + an account yet]] + anchors.top: parent.top anchors.left: parent.left margin: 87 18 - %button.notImplemented + Button text: Create Account anchors.top: parent.top anchors.right: parent.right margin: 94 18 + onClick: + function(self) + displayErrorBox("Error", "Not implemented yet") + self.parent:destroy() + end - %button.small + SmallButton text: Ok anchors.bottomRight: parent.bottomRight margin: 10 66 onClick: EnterGame_connectToLoginServer() - %button.small.closeParent + SmallButton text: Cancel anchors.bottom: parent.bottom anchors.right: parent.right margin: 10 13 + onClick: displayErrorBox("Error", "Not implemented yet") - %textEdit#accountNameTextEdit + TextEdit + id: accountNameTextEdit text: tibialua0 anchors.top: parent.top anchors.right: parent.right margin: 32 18 - %textEdit#passwordTextEdit + TextEdit + id: passwordTextEdit text: lua123456 text-hidden: true anchors.top: parent.top diff --git a/packages/mainmenu/ui/mainmenu.otml b/packages/mainmenu/ui/mainmenu.otml index 8585603b..df52045b 100644 --- a/packages/mainmenu/ui/mainmenu.otml +++ b/packages/mainmenu/ui/mainmenu.otml @@ -1,37 +1,63 @@ -%panel#mainBackground - image: { source: background.png; antialised: true } +@import "additional_elements" + +Panel + id: "mainBackground" + image: + source: "background.png" + antialised: true anchor.fill: parent - - %panel#mainMenuPanel.flat - size: 117 171 + + lista: + - valor1 + - valor2 + - valor3 + + FlatPanel + id: mainMenuPanel + size: {117, 171} anchors.bottom: parent.bottom anchors.left: parent.left - margin: 70 60 + margin: {70, 60} - button - anchors.top: prev.bottom - anchors.horizontalCenter: parent.horizontalCenter - margin.top: 6 - - %button.first + // enter game button + Button + text: "Enter Game" anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter margin.top: 16 - text: Enter Game - onClick: loadUI("entergamewindow") + onClick: | + function(self) + if not mainMenu:getChild("enterGameWindow") then + local enterGame = loadUI("entergamewindow") + enterGame:setLocked(true) + end + end - %button.notImplemented - text: Access Account + Button + text: "Access Account" + anchors.top: prev.bottom + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 6 + onClick: loadUI("entergamewindow") - %button - text: Options + Button + text: "Options" + anchors.top: prev.bottom + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 6 onClick: loadUI("optionswindow") - %button - text: Info + Button + text: "Info" + anchors.top: prev.bottom + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 6 onClick: loadUI("infowindow") - %button - text: Exit + Button + text: "Exit" + anchors.top: prev.bottom + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 6 onClick: terminateApplication() diff --git a/src/framework/core/configs.h b/src/framework/core/configs.h index 56164077..49262a5c 100644 --- a/src/framework/core/configs.h +++ b/src/framework/core/configs.h @@ -4,6 +4,7 @@ #include struct ConfigValueProxy { + ConfigValueProxy(const std::string& v) : value(v) { } operator std::string() const { return convert(value); } operator float() const { return convert(value); } operator int() const { return convert(value); } @@ -20,7 +21,7 @@ public: template void set(const std::string& key, const T& value) { m_confsMap[key] = convert(value); } - ConfigValueProxy get(const std::string& key) { return ConfigValueProxy{m_confsMap[key]}; } + ConfigValueProxy get(const std::string& key) { return ConfigValueProxy(m_confsMap[key]); } private: std::string m_fileName; diff --git a/src/framework/core/dispatcher.cpp b/src/framework/core/dispatcher.cpp index ed74ad22..a7c5e6b6 100644 --- a/src/framework/core/dispatcher.cpp +++ b/src/framework/core/dispatcher.cpp @@ -29,12 +29,12 @@ void Dispatcher::poll() } } -void Dispatcher::scheduleTask(const boost::function& callback, int delay) +void Dispatcher::scheduleTask(const std::function& callback, int delay) { m_scheduledTaskList.push(new ScheduledTask(g_engine.getCurrentFrameTicks() + delay, callback)); } -void Dispatcher::addTask(const boost::function& callback, bool pushFront) +void Dispatcher::addTask(const std::function& callback, bool pushFront) { if(pushFront) m_taskList.push_front(callback); diff --git a/src/framework/core/dispatcher.h b/src/framework/core/dispatcher.h index 49bb6167..5617465d 100644 --- a/src/framework/core/dispatcher.h +++ b/src/framework/core/dispatcher.h @@ -4,15 +4,12 @@ #include #include -#include -#include - struct ScheduledTask { - ScheduledTask(const boost::function& _callback) : ticks(0), callback(_callback) { } - ScheduledTask(int _ticks, const boost::function& _callback) : ticks(_ticks), callback(_callback) { } + ScheduledTask(const std::function& _callback) : ticks(0), callback(_callback) { } + ScheduledTask(int _ticks, const std::function& _callback) : ticks(_ticks), callback(_callback) { } bool operator<(const ScheduledTask& other) const { return ticks > other.ticks; } int ticks; - boost::function callback; + std::function callback; }; struct lessScheduledTask : public std::binary_function { @@ -31,13 +28,13 @@ public: void poll(); /// Add an event - void addTask(const boost::function& callback, bool pushFront = false); + void addTask(const std::function& callback, bool pushFront = false); /// Schedula an event - void scheduleTask(const boost::function& callback, int delay); + void scheduleTask(const std::function& callback, int delay); private: - std::list> m_taskList; + std::list> m_taskList; std::priority_queue, lessScheduledTask> m_scheduledTaskList; }; diff --git a/src/framework/core/engine.cpp b/src/framework/core/engine.cpp index 23a8e432..b95d2eb1 100644 --- a/src/framework/core/engine.cpp +++ b/src/framework/core/engine.cpp @@ -6,7 +6,7 @@ #include #include #include -#include