add a new folder structure redesign organized by packages
This commit is contained in:
parent
b1a881eb06
commit
ab7394f357
|
@ -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
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
rootUI = UI.getRootContainer()
|
||||
|
||||
-- AnchorPoint
|
||||
AnchorNone = 0
|
||||
AnchorTop = 1
|
||||
AnchorBottom = 2
|
||||
AnchorLeft = 3
|
||||
AnchorRight = 4
|
||||
AnchorVerticalCenter = 5
|
||||
AnchorHorizontalCenter = 6
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
require 'constants'
|
||||
require 'util'
|
||||
require 'messagebox'
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
function createEmptyFunction()
|
||||
local emptyFunction = function() end
|
||||
return emptyFunction
|
||||
end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
-- load default fonts
|
||||
App.loadFont("fonts/helvetica-11px")
|
||||
App.loadFont("fonts/helvetica-11px-bold")
|
||||
|
|
@ -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
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
|
@ -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
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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")
|
Binary file not shown.
After Width: | Height: | Size: 825 B |
Binary file not shown.
After Width: | Height: | Size: 833 B |
Binary file not shown.
After Width: | Height: | Size: 859 B |
|
@ -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()
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 <global.h>
|
||||
#include <script/scriptable.h>
|
||||
|
||||
void registerLuaFunctions();
|
||||
|
||||
// App
|
||||
int lua_App_exit();
|
||||
|
||||
// UI
|
||||
int lua_UI_load();
|
||||
int lua_UI_getRootContainer();
|
||||
|
||||
// UIElement
|
||||
int lua_UIElement_getId();
|
||||
int lua_UIElement_setId();
|
||||
int lua_UIElement_isEnabled();
|
||||
int lua_UIElement_setEnabled();
|
||||
int lua_UIElement_isVisible();
|
||||
int lua_UIElement_setVisible();
|
||||
int lua_UIElement_isFocused();
|
||||
int lua_UIElement_setFocused();
|
||||
int lua_UIElement_getParent();
|
||||
int lua_UIElement_setParent();
|
||||
int lua_UIElement_setLocked();
|
||||
int lua_UIElement_destroy();
|
||||
void lua_UIElement_onLoad();
|
||||
void lua_UIElement_onDestroy();
|
||||
|
||||
// UIContainer
|
||||
int lua_UIContainer_getChild();
|
||||
int lua_UIContainer_getChildren();
|
||||
|
||||
// UILabel
|
||||
int lua_UILabel_setText();
|
||||
int lua_UILabel_getText();
|
||||
|
||||
// UITextEdit
|
||||
int lua_UITextEdit_setText();
|
||||
int lua_UITextEdit_getText();
|
||||
|
||||
// UIButton
|
||||
void lua_UIButton_onClick();
|
||||
|
||||
// UIWindow
|
||||
int lua_UIWindow_setTitle();
|
||||
int lua_UIWindow_getTitle();
|
||||
|
||||
#endif // LUAFUNCTIONS_H
|
|
@ -12,7 +12,7 @@ void ScriptContext::init()
|
|||
{
|
||||
L = luaL_newstate();
|
||||
if(!L)
|
||||
fatal("FATAL ERROR: could not create lua context");
|
||||
logFatal("FATAL ERROR: could not create lua context");
|
||||
|
||||
// load lua standard libraries
|
||||
luaL_openlibs(L);
|
||||
|
@ -48,7 +48,7 @@ bool ScriptContext::loadFile(const std::string& fileName)
|
|||
if(g_resources.loadFile(fileName, fin))
|
||||
return loadBuffer(fin.str(), fileName);
|
||||
else
|
||||
error("ERROR: script file '", fileName, "' doesn't exist");
|
||||
logError("ERROR: script file '", fileName, "' doesn't exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ void ScriptContext::reportError(const std::string& errorDesc, const char *funcNa
|
|||
if(funcName)
|
||||
ss << " in " << funcName << "(): ";
|
||||
ss << errorDesc;
|
||||
error(ss.str());
|
||||
logError(ss.str());
|
||||
}
|
||||
|
||||
void ScriptContext::reportErrorWithTraceback(const std::string& errorDesc, const char* funcName)
|
||||
|
@ -385,7 +385,7 @@ std::string ScriptContext::getFunctionSourcePath(bool functionIsOnStack, int lev
|
|||
if(source[0] == '@' && pos != std::string::npos)
|
||||
path = source.substr(1, pos - 1);
|
||||
} else {
|
||||
error("no source");
|
||||
logError("no source");
|
||||
}
|
||||
}
|
||||
return path;
|
||||
|
|
|
@ -38,19 +38,19 @@ bool UIAnchorLayout::addAnchor(const UIElementPtr& anchoredElement, AnchorPoint
|
|||
UIElementPtr anchorLineElement = anchor.getAnchorLineElement();
|
||||
|
||||
if(!anchorLineElement) {
|
||||
error("ERROR: could not find the element to anchor on, wrong id?");
|
||||
logError("ERROR: could not find the element to anchor on, wrong id?");
|
||||
return false;
|
||||
}
|
||||
|
||||
// we can never anchor with itself
|
||||
if(anchoredElement == anchorLineElement) {
|
||||
error("ERROR: anchoring with itself is not possible");
|
||||
logError("ERROR: anchoring with itself is not possible");
|
||||
return false;
|
||||
}
|
||||
|
||||
// we must never anchor to an anchor child
|
||||
if(hasElementInAnchorTree(anchorLineElement, anchoredElement)) {
|
||||
error("ERROR: anchors is miss configurated, you must never make anchor chains in loops");
|
||||
logError("ERROR: anchors is miss configurated, you must never make anchor chains in loops");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void UIElement::destroyCheck()
|
|||
UIElementPtr me = asUIElement();
|
||||
// check for leaks, the number of references must be always 2 here
|
||||
if(me.use_count() != 2 && me != UIContainer::getRoot()) {
|
||||
warning("destroyed element with id '",getId(),"', but it still have ",(me.use_count()-2)," references left");
|
||||
logWarning("destroyed element with id '",getId(),"', but it still have ",(me.use_count()-2)," references left");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ void UIElement::addAnchor(AnchorPoint anchoredEdge, AnchorLine anchorEdge)
|
|||
{
|
||||
UIElementPtr target = backwardsGetElementById(anchorEdge.getElementId());
|
||||
if(!target)
|
||||
warning("warning: element id '", anchorEdge.getElementId(), "' doesn't exist while anchoring element '", getId(), "'");
|
||||
logWarning("warning: element id '", anchorEdge.getElementId(), "' doesn't exist while anchoring element '", getId(), "'");
|
||||
|
||||
UIAnchorLayoutPtr layout = boost::dynamic_pointer_cast<UIAnchorLayout>(getLayout());
|
||||
if(layout)
|
||||
|
|
|
@ -101,7 +101,6 @@ public:
|
|||
/// Get layout size, it always return the absolute position
|
||||
Rect getRect() const { return m_rect; }
|
||||
|
||||
// margins
|
||||
void setMargin(int top, int right, int bottom, int left) { m_marginLeft = left; m_marginRight = right; m_marginTop = top; m_marginBottom = bottom; getLayout()->recalculateElementLayout(asUIElement()); }
|
||||
void setMargin(int vertical, int horizontal) { m_marginLeft = m_marginRight = horizontal; m_marginTop = m_marginBottom = vertical; getLayout()->recalculateElementLayout(asUIElement()); }
|
||||
void setMargin(int margin) { m_marginLeft = m_marginRight = m_marginTop = m_marginBottom = margin; getLayout()->recalculateElementLayout(asUIElement()); }
|
||||
|
@ -115,7 +114,6 @@ public:
|
|||
int getMarginTop() const { return m_marginTop; }
|
||||
int getMarginBottom() const { return m_marginBottom; }
|
||||
|
||||
// layout related
|
||||
void centerIn(const std::string& targetId);
|
||||
void addAnchor(AnchorPoint anchoredEdge, AnchorLine anchorEdge);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ ImagePtr UIElementSkin::loadImage(OTMLNode* node)
|
|||
if(OTMLNode* cnode = node->at("bordered image")) {
|
||||
image = BorderedImage::loadFromOTMLNode(cnode, g_uiSkins.getDefaultTexture());
|
||||
if(!image)
|
||||
error(node->generateErrorMessage("failed to load bordered image"));
|
||||
logError(node->generateErrorMessage("failed to load bordered image"));
|
||||
} else if(OTMLNode* cnode = node->at("image")) {
|
||||
texture = g_textures.get(cnode->value());
|
||||
if(texture)
|
||||
|
@ -43,7 +43,7 @@ ImagePtr UIElementSkin::loadImage(OTMLNode* node)
|
|||
m_defaultSize = texture->getSize();
|
||||
|
||||
if(!image)
|
||||
error(cnode->generateErrorMessage("failed to load image"));
|
||||
logError(cnode->generateErrorMessage("failed to load image"));
|
||||
}
|
||||
|
||||
if(texture) {
|
||||
|
|
|
@ -67,7 +67,7 @@ UIElementPtr UILoader::loadFromFile(std::string filePath, const UIContainerPtr&
|
|||
// create element interpreting it's id
|
||||
element = createElementFromId(elementId);
|
||||
if(!element) {
|
||||
error(doc->front()->generateErrorMessage("invalid root element type"));
|
||||
logError(doc->front()->generateErrorMessage("invalid root element type"));
|
||||
return element;
|
||||
}
|
||||
parent->addChild(element);
|
||||
|
@ -82,7 +82,7 @@ UIElementPtr UILoader::loadFromFile(std::string filePath, const UIContainerPtr&
|
|||
// report onLoad events
|
||||
element->onLoad();
|
||||
} catch(OTMLException e) {
|
||||
error("ERROR: Failed to load ui ",filePath,": ", e.what());
|
||||
logError("ERROR: Failed to load ui ",filePath,": ", e.what());
|
||||
}
|
||||
|
||||
return element;
|
||||
|
@ -96,7 +96,7 @@ void UILoader::populateContainer(const UIContainerPtr& parent, OTMLNode* node)
|
|||
if(id[0] == '%') {
|
||||
UIElementPtr element = createElementFromId(id);
|
||||
if(!element) {
|
||||
error(cnode->generateErrorMessage("invalid element type"));
|
||||
logError(cnode->generateErrorMessage("invalid element type"));
|
||||
continue;
|
||||
}
|
||||
parent->addChild(element);
|
||||
|
@ -184,20 +184,20 @@ void UILoader::loadElementAnchor(const UIElementPtr& anchoredElement, AnchorPoin
|
|||
|
||||
std::string anchorDescription = node->value();
|
||||
if(anchorDescription.empty()) {
|
||||
error(node->generateErrorMessage("anchor is empty, did you forget to fill it?"));
|
||||
logError(node->generateErrorMessage("anchor is empty, did you forget to fill it?"));
|
||||
return;
|
||||
}
|
||||
|
||||
UIAnchorLayoutPtr layout = boost::dynamic_pointer_cast<UIAnchorLayout>(anchoredElement->getLayout());
|
||||
if(!layout) {
|
||||
error(node->generateErrorMessage("could not add anchor, because this element does not participate of an anchor layout"));
|
||||
logError(node->generateErrorMessage("could not add anchor, because this element does not participate of an anchor layout"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> split;
|
||||
boost::split(split, anchorDescription, boost::is_any_of(std::string(".")));
|
||||
if(split.size() != 2) {
|
||||
error(node->generateErrorMessage("invalid anchor"));
|
||||
logError(node->generateErrorMessage("invalid anchor"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -205,12 +205,12 @@ void UILoader::loadElementAnchor(const UIElementPtr& anchoredElement, AnchorPoin
|
|||
AnchorPoint anchorLineEdge = UIAnchorLayout::parseAnchorPoint(split[1]);
|
||||
|
||||
if(anchorLineEdge == AnchorNone) {
|
||||
error(node->generateErrorMessage("invalid anchor type"));
|
||||
logError(node->generateErrorMessage("invalid anchor type"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!layout->addAnchor(anchoredElement, anchoredEdge, AnchorLine(anchorLineElementId, anchorLineEdge)))
|
||||
error(node->generateErrorMessage("anchoring failed"));
|
||||
logError(node->generateErrorMessage("anchoring failed"));
|
||||
}
|
||||
|
||||
void UILoader::loadElementScriptFunction(const UIElementPtr& element, OTMLNode* node)
|
||||
|
@ -225,7 +225,7 @@ void UILoader::loadElementScriptFunction(const UIElementPtr& element, OTMLNode*
|
|||
if(g_lua.loadBufferAsFunction(node->value(), functionDesc))
|
||||
g_lua.setScriptObjectField(element, node->tag());
|
||||
else
|
||||
error(node->generateErrorMessage("failed to parse inline lua script"));
|
||||
logError(node->generateErrorMessage("failed to parse inline lua script"));
|
||||
}
|
||||
|
||||
void UILoader::loadButton(const UIButtonPtr& button, OTMLNode* node)
|
||||
|
|
|
@ -42,7 +42,7 @@ void UISkins::load(const std::string& skinName)
|
|||
|
||||
std::stringstream fin;
|
||||
if(!g_resources.loadFile(skinName + ".otml", fin))
|
||||
fatal("FATAL ERROR: Could not load skin '",skinName,"'");
|
||||
logFatal("FATAL ERROR: Could not load skin '",skinName,"'");
|
||||
|
||||
try {
|
||||
OTMLParser parser(fin, skinName);
|
||||
|
@ -50,7 +50,7 @@ void UISkins::load(const std::string& skinName)
|
|||
|
||||
m_defaultFont = g_fonts.get(doc->valueAt("default font"));
|
||||
if(!m_defaultFont)
|
||||
fatal("FATAL ERROR: Could not load skin default font");
|
||||
logFatal("FATAL ERROR: Could not load skin default font");
|
||||
|
||||
m_defaultFontColor = doc->readAt("default font color", Color::white);
|
||||
|
||||
|
@ -81,7 +81,7 @@ void UISkins::load(const std::string& skinName)
|
|||
}
|
||||
}
|
||||
} catch(OTMLException e) {
|
||||
fatal("FATAL ERROR: Malformed skin file '",skinName,"':\n ",e.what());
|
||||
logFatal("FATAL ERROR: Malformed skin file '",skinName,"':\n ",e.what());
|
||||
}
|
||||
|
||||
g_resources.popCurrentPath();
|
||||
|
@ -100,6 +100,6 @@ UIElementSkinPtr UISkins::getElementSkin(UI::ElementType elementType, const std:
|
|||
if(elementType == skin->getElementType() && name == skin->getName())
|
||||
return skin;
|
||||
}
|
||||
warning("Element skin '",name,"' not found");
|
||||
logWarning("Element skin '",name,"' not found");
|
||||
return UIElementSkinPtr();
|
||||
}
|
||||
|
|
|
@ -13,22 +13,21 @@ enum LogLevel {
|
|||
void log(LogLevel level, const std::string& message, std::string prettyFunction = "");
|
||||
|
||||
// specialized logging
|
||||
template<class... T>
|
||||
void debug(const T&... args) { log(LogInfo, make_string(args...)); }
|
||||
template<class... T>
|
||||
void info(const T&... args) { log(LogDebug, make_string(args...)); }
|
||||
template<class... T>
|
||||
void warning(const T&... args) { log(LogWarning, make_string(args...)); }
|
||||
template<class... T>
|
||||
void error(const T&... args) { log(LogError, make_string(args...)); }
|
||||
template<class... T>
|
||||
void fatal(const T&... args) { log(LogFatal, make_string(args...)); }
|
||||
#define logDebug(...) log(LogDebug, make_string(__VA_ARGS__))
|
||||
#define logInfo(...) log(LogInfo, make_string(__VA_ARGS__))
|
||||
#define logWarning(...) log(LogWarning, make_string(__VA_ARGS__))
|
||||
#define logError(...) log(LogError, make_string(__VA_ARGS__))
|
||||
#define logFatal(...) log(LogFatal, make_string(__VA_ARGS__))
|
||||
|
||||
#define trace() log(LogDebug, "", __PRETTY_FUNCTION__)
|
||||
#define traceDebug(...) log(LogDebug, make_string(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define traceInfo(...) log(LogInfo, make_string(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define traceWarning(...) log(LogWarning, make_string(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define traceError(...) log(LogError, make_string(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
|
||||
// dump utility
|
||||
struct Dump {
|
||||
~Dump() { debug(s.str().c_str()); }
|
||||
~Dump() { logDebug(s.str().c_str()); }
|
||||
template<class T>
|
||||
Dump& operator<<(const T& v) { s << v << " "; return *this; }
|
||||
std::ostringstream s;
|
||||
|
|
28
src/main.cpp
28
src/main.cpp
|
@ -1,27 +1,3 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include <global.h>
|
||||
#include <core/engine.h>
|
||||
#include <core/configs.h>
|
||||
|
@ -86,7 +62,7 @@ int main(int argc, const char *argv[])
|
|||
args.push_back(argv[i]);
|
||||
#endif
|
||||
|
||||
info("OTClient 0.2.0");
|
||||
logInfo("OTClient 0.2.0");
|
||||
|
||||
// install exit signal handler
|
||||
signal(SIGTERM, signal_handler);
|
||||
|
@ -101,7 +77,7 @@ int main(int argc, const char *argv[])
|
|||
// load configurations
|
||||
loadDefaultConfigs();
|
||||
if(!g_configs.load("config.otml"))
|
||||
info("Could not read configuration file, default configurations will be used.");
|
||||
logInfo("Could not read configuration file, default configurations will be used.");
|
||||
|
||||
// create the window
|
||||
Platform::createWindow(g_configs.get("window x"), g_configs.get("window y"),
|
||||
|
|
|
@ -1,26 +1,3 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#include "protocollogin.h"
|
||||
#include <net/outputmessage.h>
|
||||
#include <net/rsa.h>
|
||||
|
@ -124,7 +101,7 @@ void ProtocolLogin::onRecv(InputMessage *inputMessage)
|
|||
|
||||
while(!inputMessage->end()) {
|
||||
uint8 opt = inputMessage->getU8();
|
||||
debug("opt:",(uint)opt);
|
||||
logDebug("opt:",(uint)opt);
|
||||
switch(opt) {
|
||||
case 0x0A:
|
||||
parseError(inputMessage);
|
||||
|
@ -165,8 +142,8 @@ void ProtocolLogin::parseCharacterList(InputMessage *inputMessage)
|
|||
uint32 ip = inputMessage->getU32();
|
||||
uint16 port = inputMessage->getU16();
|
||||
|
||||
debug("character: ", name.c_str(), world.c_str(), ip, port);
|
||||
logDebug("character: ", name.c_str(), world.c_str(), ip, port);
|
||||
}
|
||||
uint16 premiumDays = inputMessage->getU16();
|
||||
debug("prem days: ", premiumDays);
|
||||
logDebug("prem days: ", premiumDays);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue