diff --git a/data/modules/mainmenu/entergame.lua b/data/modules/mainmenu/entergame.lua index 2648c56a..26369bd4 100644 --- a/data/modules/mainmenu/entergame.lua +++ b/data/modules/mainmenu/entergame.lua @@ -45,7 +45,7 @@ function EnterGame_connectToLoginServer() motdBox.onOk = recreateEnterGame end - -- get account and password and login + -- get account and password then login local enterGameWindow = rootUI:child("enterGameWindow") local account = enterGameWindow:child("accountNameTextEdit").text local password = enterGameWindow:child("passwordTextEdit").text diff --git a/packages/core/constants.lua b/packages/core/constants.lua new file mode 100644 index 00000000..bcb5a924 --- /dev/null +++ b/packages/core/constants.lua @@ -0,0 +1,11 @@ +rootUI = UI.getRootContainer() + +-- AnchorPoint +AnchorNone = 0 +AnchorTop = 1 +AnchorBottom = 2 +AnchorLeft = 3 +AnchorRight = 4 +AnchorVerticalCenter = 5 +AnchorHorizontalCenter = 6 + diff --git a/packages/core/core.lua b/packages/core/core.lua new file mode 100644 index 00000000..33e5dda7 --- /dev/null +++ b/packages/core/core.lua @@ -0,0 +1,3 @@ +require 'constants' +require 'util' +require 'messagebox' diff --git a/packages/core/messagebox.lua b/packages/core/messagebox.lua new file mode 100644 index 00000000..b4369a06 --- /dev/null +++ b/packages/core/messagebox.lua @@ -0,0 +1,86 @@ +MessageBox = {} +MessageBox.__index = MessageBox + +-- messagebox flags +MessageBoxOk = 1 +MessageBoxCancel = 2 + +function MessageBox.create(title, text, flags) + local box = {} + setmetatable(box, MessageBox) + + -- create messagebox window + local window = UIWindow.new("messageBoxWindow", rootUI) + window.title = title + window:centerIn(rootUI) + window:setLocked() + + -- create messagebox label + local label = UILabel.new("messageBoxLabel", window) + label.text = text + label:addAnchor(AnchorHorizontalCenter, window, AnchorHorizontalCenter) + label:addAnchor(AnchorTop, window, AnchorTop) + label:setMargin(27, 0) + + -- set window size based on label size + window.width = label.width + 40 + window.height = label.height + 64 + + -- 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) + + if flags == MessageBoxOk then + buttonText = "Ok" + box.onOk = createEmptyFunction() + button1.onClick = function() + box.onOk() + box:destroy() + end + elseif flags == MessageBoxCancel then + buttonText = "Cancel" + box.onCancel = createEmptyFunction() + button1.onClick = function() + box.onCancel() + box:destroy() + end + end + button1.text = buttonText + + box.window = window + return box +end + +function MessageBox:destroy() + if self.onDestroy then + self.onDestroy() + self.onDestroy = nil + end + if self.window then + self.window:destroy() + self.window = nil + end + self.onOk = nil + self.onCancel = nil +end + +-- shortcuts for creating message boxes +function displayMessageBox(title, text, flags) + return MessageBox.create(title, text, flags) +end + +function displayErrorBox(title, text) + return MessageBox.create(title, text, MessageBoxOk) +end + +function displayInfoBox(title, text) + return MessageBox.create(title, text, MessageBoxOk) +end + +function displayCancelBox(title, text) + return MessageBox.create(title, text, MessageBoxCancel) +end + diff --git a/packages/core/package.otml b/packages/core/package.otml new file mode 100644 index 00000000..64604cdc --- /dev/null +++ b/packages/core/package.otml @@ -0,0 +1,9 @@ +title: Core +description: Core utilities used by other modules +author: otclient +version: 1 +website: https://github.com/edubart/otclient +enabled: true +dependencies: [core_fonts, core_styles] +script: core.lua + diff --git a/packages/core/util.lua b/packages/core/util.lua new file mode 100644 index 00000000..7e9c6c4f --- /dev/null +++ b/packages/core/util.lua @@ -0,0 +1,5 @@ +function createEmptyFunction() + local emptyFunction = function() end + return emptyFunction +end + diff --git a/packages/core_fonts/fonts.lua b/packages/core_fonts/fonts.lua new file mode 100644 index 00000000..ad2d430e --- /dev/null +++ b/packages/core_fonts/fonts.lua @@ -0,0 +1,4 @@ +-- load default fonts +App.loadFont("fonts/helvetica-11px") +App.loadFont("fonts/helvetica-11px-bold") + diff --git a/packages/core_fonts/fonts/helvetica-11px-bold.otml b/packages/core_fonts/fonts/helvetica-11px-bold.otml new file mode 100644 index 00000000..1c89fb7f --- /dev/null +++ b/packages/core_fonts/fonts/helvetica-11px-bold.otml @@ -0,0 +1,9 @@ +glyph-height: 14 +glyph-spacing: 1 1 +top-margin: 2 +image: helvetica-11px-bold.png +image-glyph-size: 16 16 + +glyph-widths: + 32: 4 + diff --git a/packages/core_fonts/fonts/helvetica-11px-bold.png b/packages/core_fonts/fonts/helvetica-11px-bold.png new file mode 100644 index 00000000..3c334571 Binary files /dev/null and b/packages/core_fonts/fonts/helvetica-11px-bold.png differ diff --git a/packages/core_fonts/fonts/helvetica-11px.otml b/packages/core_fonts/fonts/helvetica-11px.otml new file mode 100644 index 00000000..c5200e1c --- /dev/null +++ b/packages/core_fonts/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/packages/core_fonts/fonts/helvetica-11px.png b/packages/core_fonts/fonts/helvetica-11px.png new file mode 100644 index 00000000..3f716a7f Binary files /dev/null and b/packages/core_fonts/fonts/helvetica-11px.png differ diff --git a/packages/core_fonts/package.otml b/packages/core_fonts/package.otml new file mode 100644 index 00000000..6111c5db --- /dev/null +++ b/packages/core_fonts/package.otml @@ -0,0 +1,9 @@ +title: Fonts +description: Fonts package +author: otclient +version: 1 +website: https://github.com/edubart/otclient +enabled: true +dependencies: [] +script: fonts.lua + diff --git a/packages/core_styles/package.otml b/packages/core_styles/package.otml new file mode 100644 index 00000000..3ed602e7 --- /dev/null +++ b/packages/core_styles/package.otml @@ -0,0 +1,9 @@ +title: Core styles +description: Core styles used by other modules +author: otclient +version: 1 +website: https://github.com/edubart/otclient +enabled: true +dependencies: [core_fonts] +script: styles.lua + diff --git a/packages/core_styles/styles.lua b/packages/core_styles/styles.lua new file mode 100644 index 00000000..97432480 --- /dev/null +++ b/packages/core_styles/styles.lua @@ -0,0 +1,12 @@ +-- set default font +App.setDefaultFont("helvetica-11px") +App.setDefaultFontColor(Color("#f0ad4dff")) + +-- load styles +App.loadStyle("styles/utilities") +App.loadStyle("styles/panels") +App.loadStyle("styles/buttons") +App.loadStyle("styles/labels") +App.loadStyle("styles/textedits") +App.loadStyle("styles/windows") +App.loadStyle("styles/linedecorations") diff --git a/packages/core_styles/styles/button_standard.png b/packages/core_styles/styles/button_standard.png new file mode 100644 index 00000000..70727e0b Binary files /dev/null and b/packages/core_styles/styles/button_standard.png differ diff --git a/packages/core_styles/styles/button_standard_down.png b/packages/core_styles/styles/button_standard_down.png new file mode 100644 index 00000000..7808d00a Binary files /dev/null and b/packages/core_styles/styles/button_standard_down.png differ diff --git a/packages/core_styles/styles/button_standard_hover.png b/packages/core_styles/styles/button_standard_hover.png new file mode 100644 index 00000000..509268b4 Binary files /dev/null and b/packages/core_styles/styles/button_standard_hover.png differ diff --git a/packages/core_styles/styles/buttons.otml b/packages/core_styles/styles/buttons.otml new file mode 100644 index 00000000..fc9ea015 --- /dev/null +++ b/packages/core_styles/styles/buttons.otml @@ -0,0 +1,25 @@ +button + font: helvetica-11px-bold + font-color: #f0ad4dff + size: 106 24 + bordered-image: { source: button_standard.png; border: 5 } + +button:hover + bordered-image: { source: tibia_flash/button_standard_hover.png; border: 5 } + +button:down + text-translate: 1 1 + bordered-image: { source: tibia_flash/button_standard_down.png; border: 5 } + +button.small + width: 64 + +button.large + width: 144 + +button.notImplemented + onClick: displayErrorBox("Error", "Not implemented yet") + +button.closeParent + onClick: self.parent:destroy() + diff --git a/packages/core_styles/styles/labels.otml b/packages/core_styles/styles/labels.otml new file mode 100644 index 00000000..e69de29b diff --git a/packages/core_styles/styles/linedecorations.otml b/packages/core_styles/styles/linedecorations.otml new file mode 100644 index 00000000..e69de29b diff --git a/packages/core_styles/styles/panels.otml b/packages/core_styles/styles/panels.otml new file mode 100644 index 00000000..e69de29b diff --git a/packages/core_styles/styles/textedits.otml b/packages/core_styles/styles/textedits.otml new file mode 100644 index 00000000..e69de29b diff --git a/packages/core_styles/styles/utilities.otml b/packages/core_styles/styles/utilities.otml new file mode 100644 index 00000000..e69de29b diff --git a/packages/core_styles/styles/windows.otml b/packages/core_styles/styles/windows.otml new file mode 100644 index 00000000..e69de29b diff --git a/packages/mainmenu/entergame.lua b/packages/mainmenu/entergame.lua new file mode 100644 index 00000000..26369bd4 --- /dev/null +++ b/packages/mainmenu/entergame.lua @@ -0,0 +1,57 @@ +function EnterGame_connectToLoginServer() + -- create login protocol + local protocolLogin = ProtocolLogin.new() + + -- used to recreate enter game window + local recreateEnterGame = function() + loadUI("ui/entergamewindow") + end + + -- display loading message box + local loadBox = displayCancelBox("Please wait", "Connecting..") + + -- cancel loading callback + loadBox.onCancel = function() + -- cancel protocol and reacreate enter game window + protocolLogin:cancel() + recreateEnterGame() + end + + -- error callback + protocolLogin.onError = function(error) + -- destroy loading message box + loadBox:destroy() + + -- display error message + local errorBox = displayErrorBox("Login Error", error) + + -- cancel protocol and reacreate enter game window + self.cancel() + errorBox.onOk = recreateEnterGame + end + + -- motd callback + protocolLogin.onMotd = function(motd) + -- destroy loading message box + loadBox:destroy() + + -- display motd + local motdNumber = string.sub(motd, 0, string.find(motd, "\n")) + local motdText = string.sub(motd, string.find(motd, "\n") + 1, string.len(motd)) + local motdBox = displayInfoBox("Message of the day", motdText) + + -- cancel protocol and reacreate enter game window + self.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 + protocolLogin:login(account, password) + + -- destroy enter game window + enterGameWindow:destroy() +end + diff --git a/packages/mainmenu/init.lua b/packages/mainmenu/init.lua new file mode 100644 index 00000000..bce7aeb4 --- /dev/null +++ b/packages/mainmenu/init.lua @@ -0,0 +1,16 @@ +require 'entergame' + +function initializeApplication() + mainMenu = loadUI("ui/mainmenu") +end + +function terminateApplication() + App.exit() +end + +-- here is where everything starts +if not initialized then + initializeApplication() + App.onClose = terminateApplication + initialized = true +end diff --git a/packages/mainmenu/package.otml b/packages/mainmenu/package.otml new file mode 100644 index 00000000..24d9a2c3 --- /dev/null +++ b/packages/mainmenu/package.otml @@ -0,0 +1,9 @@ +title: Main menu +description: Used to create the main menu +author: otclient +version: 1 +website: https://github.com/edubart/otclient +enabled: true +dependencies: [core] +script: init.lua + diff --git a/packages/mainmenu/ui/background.png b/packages/mainmenu/ui/background.png new file mode 100644 index 00000000..2c9c1041 Binary files /dev/null and b/packages/mainmenu/ui/background.png differ diff --git a/packages/mainmenu/ui/entergamewindow.otml b/packages/mainmenu/ui/entergamewindow.otml new file mode 100644 index 00000000..89031337 --- /dev/null +++ b/packages/mainmenu/ui/entergamewindow.otml @@ -0,0 +1,53 @@ +window#enterGameWindow + title: Enter Game + size: 236 178 + anchor.centerIn: parent + lockOnLoad: true + + %label + text: Account name + position: 18 33 + + %label + text: "Password:" + position: 18 62 + + %label + text: | + If you don't have + an account yet + anchors.top: parent.top + anchors.left: parent.left + margin: 87 18 + + %button.notImplemented + text: Create Account + anchors.top: parent.top + anchors.right: parent.right + margin: 94 18 + + %button.small + text: Ok + anchors.bottomRight: parent.bottomRight + margin: 10 66 + onClick: EnterGame_connectToLoginServer() + + %button.small.closeParent + text: Cancel + anchors.bottom: parent.bottom + anchors.right: parent.right + margin: 10 13 + + %textEdit#accountNameTextEdit + text: tibialua0 + anchors.top: parent.top + anchors.right: parent.right + margin: 32 18 + + %textEdit#passwordTextEdit + text: lua123456 + text-hidden: true + anchors.top: parent.top + anchors.right: parent.right + margin: 61 18 + diff --git a/packages/mainmenu/ui/infowindow.otml b/packages/mainmenu/ui/infowindow.otml new file mode 100644 index 00000000..8acf138f --- /dev/null +++ b/packages/mainmenu/ui/infowindow.otml @@ -0,0 +1,54 @@ +%window#infoWindow + title: Info + size: 244 221 + anchor.centerIn: parent + lockOnLoad: true + + %panel.flat + size: 208 129 + anchors.top: parent.top + anchors.left: parent.left + margin: 32 18 + + %label + align: center + text: |- + OTClient + Version 0.2.0 + Created by edubart + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + margin.top: 20 + + %element.bottomSeparator + size: 190 2 + anchors.top: parent.top + anchors.left: parent.left + margin: 83 9 + + %label + text: Official Website + anchors.bottom: parent.bottom + anchors.left: parent.left + margin: 14 9 + + %button + text: Github Page + size: 80 22 + anchors.bottom: parent.bottom + anchors.right: parent.right + margin: 9 + + %element.bottomSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + margin: 40 13 + + %button.closeParent + text: Ok + size: 43 20 + anchors.top: parent.top + anchors.left: parent.left + margin: 191 188 + diff --git a/packages/mainmenu/ui/mainmenu.otml b/packages/mainmenu/ui/mainmenu.otml new file mode 100644 index 00000000..8585603b --- /dev/null +++ b/packages/mainmenu/ui/mainmenu.otml @@ -0,0 +1,37 @@ +%panel#mainBackground + image: { source: background.png; antialised: true } + anchor.fill: parent + + %panel#mainMenuPanel.flat + size: 117 171 + anchors.bottom: parent.bottom + anchors.left: parent.left + margin: 70 60 + + button + anchors.top: prev.bottom + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 6 + + %button.first + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 16 + text: Enter Game + onClick: loadUI("entergamewindow") + + %button.notImplemented + text: Access Account + + %button + text: Options + onClick: loadUI("optionswindow") + + %button + text: Info + onClick: loadUI("infowindow") + + %button + text: Exit + onClick: terminateApplication() + diff --git a/packages/mainmenu/ui/optionswindow.otml b/packages/mainmenu/ui/optionswindow.otml new file mode 100644 index 00000000..66dae4dd --- /dev/null +++ b/packages/mainmenu/ui/optionswindow.otml @@ -0,0 +1,82 @@ +%window#optionsWindow + title: Options + size: 286 262 + anchor.centerIn: parent + lockOnLoad: true + + panel + anchors.left: parent.left + anchors.right: parent.right + anchors.top: prev.bottom + margin.left: 18 + margin.top: 3 + height: 30 + + button + anchors.top: parent.top + anchors.left: parent.left + margin.top: 3 + onClick: displayErrorBox("Error", "Not implemented yet") + + label + anchors.top: parent.top + anchors.left: parent.left + margin.top: 99 + + %panel + anchors.top: parent.top + margin.top: 29 + + %button { text: General } + %label { text: "Change general\ngame options" } + + %panel + %button { text: Graphics } + %label { text: "Change graphics and\nperformance settings" } + + %panel + %button { text: Console } + %label { text: Customise the console } + + %panel + %button { text: Hotkeys } + %label { text: Edit your hotkey texts } + + %element.horizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + margin: 97 18 + + %panel + anchors.top: ~ + anchors.bottom: parent.bottom + margin.top: 29 + + %button + text: Motd + anchors.left: parent.left + anchors.bottom: parent.bottom + margin: 60 18 + + %label + text: | + Show the most recent + Message of the Day + anchors.left: parent.left + anchors.bottom: parent.bottom + margin: 56 117 + + %element.horizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + margin: 40 13 + + %button.closeParent + text: Ok + size: 43 20 + anchors.right: parent.right + anchors.bottom: parent.bottom + margin: 13 10 + diff --git a/src/framework/core/configs.cpp b/src/framework/core/configs.cpp index 9f6bc713..2c929042 100644 --- a/src/framework/core/configs.cpp +++ b/src/framework/core/configs.cpp @@ -20,7 +20,7 @@ bool Configs::load(const std::string& fileName) OTMLParser parser(fin, fileName); parser.getDocument()->read(&m_confsMap); } catch(OTMLException e) { - error("ERROR: Malformed config file: ", e.what()); + logError("ERROR: Malformed config file: ", e.what()); return false; } diff --git a/src/framework/core/engine.cpp b/src/framework/core/engine.cpp index b53a9e24..23a8e432 100644 --- a/src/framework/core/engine.cpp +++ b/src/framework/core/engine.cpp @@ -53,7 +53,7 @@ void Engine::run() // check if root container has elements const UIContainerPtr& rootContainer = UIContainer::getRoot(); if(rootContainer->getChildCount() == 0) - fatal("FATAL ERROR: no ui loaded at all, no reason to continue running"); + logFatal("FATAL ERROR: no ui loaded at all, no reason to continue running"); std::string fpsText; Size fpsTextSize; diff --git a/src/framework/core/resources.cpp b/src/framework/core/resources.cpp index 1959a7e0..c111f7f0 100644 --- a/src/framework/core/resources.cpp +++ b/src/framework/core/resources.cpp @@ -24,20 +24,20 @@ void Resources::init(const char *argv0) bool found = false; foreach(dir, possibleDirs) { if(g_resources.addToSearchPath(dir)) { - info("Using data directory: ", dir.c_str()); + logInfo("Using data directory: ", dir.c_str()); found = true; break; } } if(!found) - fatal("ERROR: could not find data directory"); + logFatal("ERROR: could not find data directory"); // setup write directory dir = Platform::getAppUserDir(); if(g_resources.setWriteDir(dir)) g_resources.addToSearchPath(dir); else - error("ERROR: could not setup write directory"); + logError("ERROR: could not setup write directory"); } void Resources::terminate() @@ -84,7 +84,7 @@ bool Resources::loadFile(const std::string& fileName, std::iostream& out) out.clear(std::ios::goodbit); PHYSFS_file *file = PHYSFS_openRead(fullPath.c_str()); if(!file) { - error("ERROR: Failed to load file '", fullPath.c_str(), "': ", PHYSFS_getLastError()); + logError("ERROR: Failed to load file '", fullPath.c_str(), "': ", PHYSFS_getLastError()); out.clear(std::ios::failbit); return false; } else { @@ -106,7 +106,7 @@ bool Resources::saveFile(const std::string &fileName, const uchar *data, uint si { PHYSFS_file *file = PHYSFS_openWrite(resolvePath(fileName).c_str()); if(!file) { - error("ERROR: Failed to save file '",fileName,"': ",PHYSFS_getLastError()); + logError("ERROR: Failed to save file '",fileName,"': ",PHYSFS_getLastError()); return false; } diff --git a/src/framework/graphics/font.cpp b/src/framework/graphics/font.cpp index e8c5fb94..94b1595f 100644 --- a/src/framework/graphics/font.cpp +++ b/src/framework/graphics/font.cpp @@ -71,7 +71,7 @@ bool Font::load(const std::string& file) { std::stringstream fin; if(!g_resources.loadFile(file, fin)) { - error("ERROR: Coult not load font file '",file,"'"); + logError("ERROR: Coult not load font file '",file,"'"); return false; } @@ -93,7 +93,7 @@ bool Font::load(const std::string& file) // load texture m_texture = g_textures.get(textureName); if(!m_texture) { - error("ERROR: Failed to load image for font file '",file,"'"); + logError("ERROR: Failed to load image for font file '",file,"'"); return false; } @@ -117,7 +117,7 @@ bool Font::load(const std::string& file) m_glyphHeight); } } catch(OTMLException e) { - error("ERROR: Malformed font file \"", file.c_str(), "\":\n ", e.what()); + logError("ERROR: Malformed font file \"", file.c_str(), "\":\n ", e.what()); return false; } diff --git a/src/framework/graphics/fonts.cpp b/src/framework/graphics/fonts.cpp index a41be4d5..0406c101 100644 --- a/src/framework/graphics/fonts.cpp +++ b/src/framework/graphics/fonts.cpp @@ -57,7 +57,7 @@ FontPtr Fonts::get(const std::string& fontName) return font; } - fatal("ERROR: Font '",fontName,"' not found"); + logFatal("ERROR: Font '",fontName,"' not found"); return FontPtr(); } diff --git a/src/framework/graphics/graphics.cpp b/src/framework/graphics/graphics.cpp index 3780bbfd..dd6b4b93 100644 --- a/src/framework/graphics/graphics.cpp +++ b/src/framework/graphics/graphics.cpp @@ -40,8 +40,8 @@ void Graphics::init() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - info("GPU ", glGetString(GL_RENDERER)); - info("OpenGL ", glGetString(GL_VERSION)); + logInfo("GPU ", glGetString(GL_RENDERER)); + logInfo("OpenGL ", glGetString(GL_VERSION)); } void Graphics::terminate() diff --git a/src/framework/graphics/texture.cpp b/src/framework/graphics/texture.cpp index 666d85f5..9b3baaac 100644 --- a/src/framework/graphics/texture.cpp +++ b/src/framework/graphics/texture.cpp @@ -37,7 +37,7 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int GLint texSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize); if(width > texSize || height > texSize) { - error("loading texture with size ",width,"x",height," failed, the maximum size is ",texSize,"x",texSize); + logError("loading texture with size ",width,"x",height," failed, the maximum size is ",texSize,"x",texSize); return 0; } diff --git a/src/framework/graphics/textures.cpp b/src/framework/graphics/textures.cpp index 370c76fc..42add224 100644 --- a/src/framework/graphics/textures.cpp +++ b/src/framework/graphics/textures.cpp @@ -49,14 +49,14 @@ TexturePtr Textures::get(const std::string& textureFile) if(!texture) { // currently only png textures are supported if(!boost::ends_with(textureFile, ".png")) { - error("ERROR: Unable to load texture '",textureFile,"', file format no supported."); + logError("ERROR: Unable to load texture '",textureFile,"', file format no supported."); return texture; } // load texture file data std::stringstream fin; if(!g_resources.loadFile(textureFile, fin)) { - error("ERROR: Unable to load texture '",textureFile,"', file could not be read."); + logError("ERROR: Unable to load texture '",textureFile,"', file could not be read."); return texture; } @@ -64,7 +64,7 @@ TexturePtr Textures::get(const std::string& textureFile) // load the texture texture = TexturePtr(TextureLoader::loadPNG(fin)); if(!texture) - error("ERROR: Unable to load texture '",textureFile,"'"); + logError("ERROR: Unable to load texture '",textureFile,"'"); } return texture; } diff --git a/src/framework/net/inputmessage.cpp b/src/framework/net/inputmessage.cpp index 28311fbb..c2da5b5d 100644 --- a/src/framework/net/inputmessage.cpp +++ b/src/framework/net/inputmessage.cpp @@ -87,6 +87,6 @@ std::string InputMessage::getString() bool InputMessage::canRead(int bytes) { if((m_readPos + bytes > m_messageSize) || (m_readPos + bytes > BUFFER_MAXSIZE)) - fatal("[InputMessage::canRead()]: Cant read. Message is finished or read position has reached buffer's maximum size."); + logFatal("[InputMessage::canRead()]: Cant read. Message is finished or read position has reached buffer's maximum size."); return true; } diff --git a/src/framework/net/outputmessage.cpp b/src/framework/net/outputmessage.cpp index 63dbd503..8ab995b7 100644 --- a/src/framework/net/outputmessage.cpp +++ b/src/framework/net/outputmessage.cpp @@ -105,6 +105,6 @@ void OutputMessage::addPaddingBytes(int bytes, uint8 byte) bool OutputMessage::canWrite(int bytes) { if(m_writePos + bytes > BUFFER_MAXSIZE) - fatal("[OutputMessage::canWrite()]: Can't write. Write position has reached buffer's maxium size."); + logFatal("[OutputMessage::canWrite()]: Can't write. Write position has reached buffer's maxium size."); return true; } diff --git a/src/framework/net/protocol.cpp b/src/framework/net/protocol.cpp index 3267f813..aa9c9da9 100644 --- a/src/framework/net/protocol.cpp +++ b/src/framework/net/protocol.cpp @@ -64,7 +64,7 @@ void Protocol::onRecv(InputMessage *inputMessage) uint32 checksum = getAdlerChecksum(inputMessage->getBuffer() + InputMessage::DATA_POS, inputMessage->getMessageSize() - InputMessage::CHECKSUM_LENGTH); if(inputMessage->getU32() != checksum) { // error - error("Checksum is invalid."); + logError("Checksum is invalid."); return; } @@ -74,7 +74,7 @@ void Protocol::onRecv(InputMessage *inputMessage) void Protocol::onError(const boost::system::error_code& err) { - error("PROTOCOL ERROR: ", err.message()); + logError("PROTOCOL ERROR: ", err.message()); // invalid hostname // connection timeouted diff --git a/src/framework/platform/win32platform.cpp b/src/framework/platform/win32platform.cpp index 7686b852..fabbbd5a 100644 --- a/src/framework/platform/win32platform.cpp +++ b/src/framework/platform/win32platform.cpp @@ -211,7 +211,7 @@ void Platform::init(const char *appName) wc.lpszClassName = win32.appName.c_str(); // Set The Class Name if(!RegisterClassA(&wc)) - fatal("FATAL ERROR: Failed to register the window class."); + logFatal("FATAL ERROR: Failed to register the window class."); // force first tick Platform::getTicks(); @@ -226,7 +226,7 @@ void Platform::terminate() if(win32.instance) { if(!UnregisterClassA(win32.appName.c_str(), win32.instance)) - error("ERROR: Unregister class failed."); + logError("ERROR: Unregister class failed."); win32.instance = NULL; } @@ -286,7 +286,7 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i if(!win32.window) { terminate(); - fatal("FATAL ERROR: Window creation error."); + logFatal("FATAL ERROR: Window creation error."); return false; } @@ -315,31 +315,31 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i if(!(win32.hdc = GetDC(win32.window))) { terminate(); - fatal("FATAL ERROR: Can't Create A GL Device Context."); + logFatal("FATAL ERROR: Can't Create A GL Device Context."); return false; } if(!(pixelFormat = ChoosePixelFormat(win32.hdc, &pfd))) { terminate(); - fatal("FATAL ERROR: Can't Find A Suitable PixelFormat."); + logFatal("FATAL ERROR: Can't Find A Suitable PixelFormat."); return false; } if(!SetPixelFormat(win32.hdc, pixelFormat, &pfd)) { terminate(); - fatal("FATAL ERROR: Can't Set The PixelFormat."); + logFatal("FATAL ERROR: Can't Set The PixelFormat."); return false; } if(!(win32.hrc = wglCreateContext(win32.hdc))) { terminate(); - fatal("FATAL ERROR: Can't Create A GL Rendering Context."); + logFatal("FATAL ERROR: Can't Create A GL Rendering Context."); return false; } if(!wglMakeCurrent(win32.hdc, win32.hrc)) { terminate(); - fatal("FATAL ERROR: Can't Activate The GL Rendering Context."); + logFatal("FATAL ERROR: Can't Activate The GL Rendering Context."); return false; } @@ -350,24 +350,24 @@ void Platform::destroyWindow() { if(win32.hrc) { if(!wglMakeCurrent(NULL, NULL)) - error("ERROR: Release Of DC And RC Failed."); + logError("ERROR: Release Of DC And RC Failed."); if(!wglDeleteContext(win32.hrc)) - error("ERROR: Release Rendering Context Failed."); + logError("ERROR: Release Rendering Context Failed."); win32.hrc = NULL; } if(win32.hdc) { if(!ReleaseDC(win32.window, win32.hdc)) - error("ERROR: Release Device Context Failed."); + logError("ERROR: Release Device Context Failed."); win32.hdc = NULL; } if(win32.window) { if(!DestroyWindow(win32.window)) - error("ERROR: Destroy window failed."); + logError("ERROR: Destroy window failed."); win32.window = NULL; } @@ -502,7 +502,7 @@ std::string Platform::getAppUserDir() std::stringstream sdir; sdir << PHYSFS_getUserDir() << "/." << win32.appName << "/"; if((mkdir(sdir.str().c_str()) != 0) && (errno != EEXIST)) - ferror("ERROR: Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str()); + flogError("ERROR: Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str()); return sdir.str(); } diff --git a/src/framework/platform/x11platform.cpp b/src/framework/platform/x11platform.cpp index 5977d349..9f67ba8c 100644 --- a/src/framework/platform/x11platform.cpp +++ b/src/framework/platform/x11platform.cpp @@ -213,18 +213,18 @@ void Platform::init(const char *appName) // open display x11.display = XOpenDisplay(0); if(!x11.display) - fatal("FATAL ERROR: Failed to open X display"); + logFatal("FATAL ERROR: Failed to open X display"); // check if GLX is supported on this display if(!glXQueryExtension(x11.display, 0, 0)) - fatal("FATAL ERROR: GLX not supported"); + logFatal("FATAL ERROR: GLX not supported"); // retrieve GLX version int glxMajor; int glxMinor; if(!glXQueryVersion(x11.display, &glxMajor, &glxMinor)) - fatal("FATAL ERROR: Unable to query GLX version"); - info("GLX version ",glxMajor,".",glxMinor); + logFatal("FATAL ERROR: Unable to query GLX version"); + logInfo("GLX version ",glxMajor,".",glxMinor); // clipboard related atoms x11.atomClipboard = XInternAtom(x11.display, "CLIPBOARD", False); @@ -328,7 +328,7 @@ void Platform::poll() keysym != XK_Escape && (uchar)(buf[0]) >= 32 ) { - //debug("char: ", buf[0], " code: ", (uint)buf[0]); + //logDebug("char: ", buf[0], " code: ", (uint)buf[0]); inputEvent.type = EV_TEXT_ENTER; inputEvent.keychar = buf[0]; inputEvent.keycode = KC_UNKNOWN; @@ -476,12 +476,12 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i // choose OpenGL, RGBA, double buffered, visual x11.visual = glXChooseVisual(x11.display, DefaultScreen(x11.display), attrList); if(!x11.visual) - fatal("FATAL ERROR: RGBA/Double buffered visual not supported"); + logFatal("FATAL ERROR: RGBA/Double buffered visual not supported"); // create GLX context x11.glxContext = glXCreateContext(x11.display, x11.visual, 0, GL_TRUE); if(!x11.glxContext) - fatal("FATAL ERROR: Unable to create GLX context"); + logFatal("FATAL ERROR: Unable to create GLX context"); // color map x11.colormap = XCreateColormap(x11.display, @@ -514,7 +514,7 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i &wa); if(!x11.window) - fatal("FATAL ERROR: Unable to create X window"); + logFatal("FATAL ERROR: Unable to create X window"); // create input context (to have better key input handling) if(XSupportsLocale()) { @@ -526,14 +526,14 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i XIMPreeditNothing | XIMStatusNothing, XNClientWindow, x11.window, NULL); if(!x11.xic) - error("ERROR: Unable to create the input context"); + logError("ERROR: Unable to create the input context"); } else - error("ERROR: Failed to open an input method"); + logError("ERROR: Failed to open an input method"); } else - error("ERROR: X11 does not support the current locale"); + logError("ERROR: X11 does not support the current locale"); if(!x11.xic) - warning("Input of special keys maybe messed up because we couldn't create an input context"); + logWarning("Input of special keys maybe messed up because we couldn't create an input context"); // set window minimum size @@ -815,6 +815,6 @@ std::string Platform::getAppUserDir() std::stringstream sdir; sdir << PHYSFS_getUserDir() << "." << x11.appName; if((mkdir(sdir.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) && (errno != EEXIST)) - error("ERROR: Couldn't create directory for saving configuration file. (",sdir.str(),")"); + logError("ERROR: Couldn't create directory for saving configuration file. (",sdir.str(),")"); return sdir.str(); } diff --git a/src/framework/script/luafunctions.h b/src/framework/script/luafunctions.h deleted file mode 100644 index a13d7647..00000000 --- a/src/framework/script/luafunctions.h +++ /dev/null @@ -1,75 +0,0 @@ -/* The MIT License - * - * Copyright (c) 2010 OTClient, https://github.com/edubart/otclient - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef LUAFUNCTIONS_H -#define LUAFUNCTIONS_H - -#include -#include