From cf0aab6d4dad81182e918b6c5d3a344e1b225a90 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 5 Dec 2011 16:27:07 -0200 Subject: [PATCH] reorganize modules --- .gitmodules | 4 +- CMakeLists.txt | 8 ++-- TODO | 1 + .../{console => addon_console}/console.lua | 0 .../{console => addon_console}/console.otmod | 4 ++ .../{console => addon_console}/console.otui | 0 modules/addon_playground/playground.lua | 1 + .../playground.otmod | 3 -- .../otclient.lua => client/client.lua} | 8 ++-- modules/client/client.otmod | 22 ++++++++++ .../otcicon.png => client/clienticon.png} | Bin modules/{about => client_about}/about.lua | 8 ++-- modules/{about => client_about}/about.otmod | 4 +- modules/{about => client_about}/about.otui | 0 .../background.lua | 0 .../background.otmod | 4 +- .../background.otui | 2 +- .../background.png | Bin .../characterlist.lua | 0 .../characterlist.otui | 0 .../entergame.lua | 0 .../entergame.otmod | 3 +- .../entergame.otui | 0 .../{options => client_options}/options.lua | 0 .../{options => client_options}/options.otmod | 3 +- .../{options => client_options}/options.otui | 0 modules/client_tibiafiles | 1 + .../{topmenu => client_topmenu}/topmenu.lua | 2 +- .../{topmenu => client_topmenu}/topmenu.otmod | 8 +--- .../{topmenu => client_topmenu}/topmenu.otui | 0 modules/core/core.otmod | 18 +++----- modules/core_fonts/sans-11px-antialised.png | Bin 9954 -> 0 bytes modules/{core => core_scripts}/constants.lua | 0 modules/core_scripts/core_scripts.otmod | 16 +++++++ modules/{core => core_scripts}/dispatcher.lua | 0 modules/{core => core_scripts}/ext/color.lua | 0 modules/{core => core_scripts}/ext/point.lua | 0 modules/{core => core_scripts}/ext/rect.lua | 0 modules/{core => core_scripts}/ext/size.lua | 0 modules/{core => core_scripts}/ext/string.lua | 0 modules/{core => core_scripts}/ext/table.lua | 0 modules/{core => core_scripts}/gfx.lua | 0 modules/{core => core_scripts}/ui.lua | 0 modules/{core => core_scripts}/util.lua | 8 +++- modules/{core => core_scripts}/widget.lua | 0 modules/core_styles/core_styles.otmod | 4 +- modules/core_widgets/core_widgets.otmod | 10 +++++ .../messagebox/messagebox.lua | 0 .../messagebox/messagebox.otui | 0 .../{ => core_widgets}/tooltip/tooltip.lua | 0 .../{ => core_widgets}/tooltip/tooltip.otui | 0 modules/game/game.lua | 6 +-- modules/game/game.otmod | 12 +++++- modules/{chat => game_chat}/chat.lua | 0 modules/{chat => game_chat}/chat.otmod | 2 +- modules/{chat => game_chat}/chat.otui | 0 .../healthbar.lua} | 12 +++--- .../healthbar.otmod} | 4 +- .../healthbar.otui} | 0 .../inventory.lua | 0 .../inventory.otmod | 2 +- .../inventory.otui | 0 .../itempopupmenu.otui | 0 modules/{outfit => game_outfit}/outfit.lua | 0 modules/{outfit => game_outfit}/outfit.otmod | 2 +- modules/{outfit => game_outfit}/outfit.otui | 0 modules/{skills => game_skills}/skills.lua | 0 modules/{skills => game_skills}/skills.otmod | 2 +- modules/{skills => game_skills}/skills.otui | 0 .../textmessage.lua | 2 +- .../textmessage.otmod | 2 +- .../textmessage.otui | 0 modules/{viplist => game_viplist}/viplist.lua | 0 .../{viplist => game_viplist}/viplist.otmod | 2 +- .../{viplist => game_viplist}/viplist.otui | 0 modules/messagebox/messagebox.otmod | 12 ------ modules/otclient/otclient.otmod | 27 ------------ modules/playground/playground.lua | 24 ----------- modules/tibiafiles | 1 - modules/tooltip/tooltip.otmod | 13 ------ src/framework/CMakeLists.txt | 8 ++-- src/framework/application.cpp | 27 ++---------- src/framework/application.h | 1 - src/framework/core/modulemanager.cpp | 40 ++++++++++++++++-- src/framework/core/modulemanager.h | 6 ++- src/framework/graphics/font.cpp | 2 +- src/framework/graphics/fontmanager.cpp | 5 +++ src/framework/graphics/fontmanager.h | 2 + src/otclient/CMakeLists.txt | 2 +- src/otclient/otclient.cpp | 7 +++ 90 files changed, 186 insertions(+), 181 deletions(-) rename modules/{console => addon_console}/console.lua (100%) rename modules/{console => addon_console}/console.otmod (82%) rename modules/{console => addon_console}/console.otui (100%) create mode 100644 modules/addon_playground/playground.lua rename modules/{playground => addon_playground}/playground.otmod (77%) rename modules/{otclient/otclient.lua => client/client.lua} (62%) create mode 100644 modules/client/client.otmod rename modules/{otclient/otcicon.png => client/clienticon.png} (100%) rename modules/{about => client_about}/about.lua (61%) rename modules/{about => client_about}/about.otmod (80%) rename modules/{about => client_about}/about.otui (100%) rename modules/{background => client_background}/background.lua (100%) rename modules/{background => client_background}/background.otmod (84%) rename modules/{background => client_background}/background.otui (83%) rename modules/{background => client_background}/background.png (100%) rename modules/{entergame => client_entergame}/characterlist.lua (100%) rename modules/{entergame => client_entergame}/characterlist.otui (100%) rename modules/{entergame => client_entergame}/entergame.lua (100%) rename modules/{entergame => client_entergame}/entergame.otmod (91%) rename modules/{entergame => client_entergame}/entergame.otui (100%) rename modules/{options => client_options}/options.lua (100%) rename modules/{options => client_options}/options.otmod (87%) rename modules/{options => client_options}/options.otui (100%) create mode 160000 modules/client_tibiafiles rename modules/{topmenu => client_topmenu}/topmenu.lua (98%) rename modules/{topmenu => client_topmenu}/topmenu.otmod (72%) rename modules/{topmenu => client_topmenu}/topmenu.otui (100%) delete mode 100644 modules/core_fonts/sans-11px-antialised.png rename modules/{core => core_scripts}/constants.lua (100%) create mode 100644 modules/core_scripts/core_scripts.otmod rename modules/{core => core_scripts}/dispatcher.lua (100%) rename modules/{core => core_scripts}/ext/color.lua (100%) rename modules/{core => core_scripts}/ext/point.lua (100%) rename modules/{core => core_scripts}/ext/rect.lua (100%) rename modules/{core => core_scripts}/ext/size.lua (100%) rename modules/{core => core_scripts}/ext/string.lua (100%) rename modules/{core => core_scripts}/ext/table.lua (100%) rename modules/{core => core_scripts}/gfx.lua (100%) rename modules/{core => core_scripts}/ui.lua (100%) rename modules/{core => core_scripts}/util.lua (84%) rename modules/{core => core_scripts}/widget.lua (100%) create mode 100644 modules/core_widgets/core_widgets.otmod rename modules/{ => core_widgets}/messagebox/messagebox.lua (100%) rename modules/{ => core_widgets}/messagebox/messagebox.otui (100%) rename modules/{ => core_widgets}/tooltip/tooltip.lua (100%) rename modules/{ => core_widgets}/tooltip/tooltip.otui (100%) rename modules/{chat => game_chat}/chat.lua (100%) rename modules/{chat => game_chat}/chat.otmod (89%) rename modules/{chat => game_chat}/chat.otui (100%) rename modules/{health_mana/health_mana.lua => game_healthbar/healthbar.lua} (85%) rename modules/{health_mana/health_mana.otmod => game_healthbar/healthbar.otmod} (76%) rename modules/{health_mana/health_mana.otui => game_healthbar/healthbar.otui} (100%) rename modules/{inventory => game_inventory}/inventory.lua (100%) rename modules/{inventory => game_inventory}/inventory.otmod (88%) rename modules/{inventory => game_inventory}/inventory.otui (100%) rename modules/{inventory => game_inventory}/itempopupmenu.otui (100%) rename modules/{outfit => game_outfit}/outfit.lua (100%) rename modules/{outfit => game_outfit}/outfit.otmod (89%) rename modules/{outfit => game_outfit}/outfit.otui (100%) rename modules/{skills => game_skills}/skills.lua (100%) rename modules/{skills => game_skills}/skills.otmod (89%) rename modules/{skills => game_skills}/skills.otui (100%) rename modules/{textmessage => game_textmessage}/textmessage.lua (96%) rename modules/{textmessage => game_textmessage}/textmessage.otmod (87%) rename modules/{textmessage => game_textmessage}/textmessage.otui (100%) rename modules/{viplist => game_viplist}/viplist.lua (100%) rename modules/{viplist => game_viplist}/viplist.otmod (88%) rename modules/{viplist => game_viplist}/viplist.otui (100%) delete mode 100644 modules/messagebox/messagebox.otmod delete mode 100644 modules/otclient/otclient.otmod delete mode 100644 modules/playground/playground.lua delete mode 160000 modules/tibiafiles delete mode 100644 modules/tooltip/tooltip.otmod diff --git a/.gitmodules b/.gitmodules index 55bc079e..524ca5c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "modules/tibiafiles"] - path = modules/tibiafiles +[submodule "modules/client_tibiafiles"] + path = modules/client_tibiafiles url = git://github.com/Baxnie/otclient-tibiafiles.git diff --git a/CMakeLists.txt b/CMakeLists.txt index dfa45666..1561590c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ INCLUDE(src/otclient/CMakeLists.txt) OPTION(USE_PCH "Use precompiled header (speed up compile)" ON) -SET(EXECUTABLE_SOURCES src/main.cpp) +SET(executable_SOURCES src/main.cpp) # add executable icon for win32 platforms IF(WIN32) @@ -15,14 +15,14 @@ IF(WIN32) -I${CMAKE_CURRENT_SOURCE_DIR}/src -i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc -o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o) - SET(${EXECUTABLE_SOURCES} ${EXECUTABLE_SOURCES} otcicon.o) + SET(executable_SOURCES ${executable_SOURCES} otcicon.o) ENDIF(WIN32) # add otclient executable -ADD_EXECUTABLE(otclient ${FRAMEWORK_SOURCES} ${OTCLIENT_SOURCES} ${EXECUTABLE_SOURCES}) +ADD_EXECUTABLE(otclient ${framework_SOURCES} ${otclient_SOURCES} ${executable_SOURCES}) # target link libraries -TARGET_LINK_LIBRARIES(otclient ${FRAMEWORK_LIBRARIES}) +TARGET_LINK_LIBRARIES(otclient ${framework_LIBRARIES}) IF(USE_PCH) FIND_PACKAGE(PCHSupport REQUIRED) diff --git a/TODO b/TODO index 0398e081..e78600a8 100644 --- a/TODO +++ b/TODO @@ -29,3 +29,4 @@ bind every global lua function in a static class use metatable for Point,Rect,Color,Size lua classes lua binder generator restore win32 platform +set special types for g_configs like lists/point/size \ No newline at end of file diff --git a/modules/console/console.lua b/modules/addon_console/console.lua similarity index 100% rename from modules/console/console.lua rename to modules/addon_console/console.lua diff --git a/modules/console/console.otmod b/modules/addon_console/console.otmod similarity index 82% rename from modules/console/console.otmod rename to modules/addon_console/console.otmod index 5f38397d..bc6972b1 100644 --- a/modules/console/console.otmod +++ b/modules/addon_console/console.otmod @@ -3,7 +3,11 @@ Module description: Console for executing lua functions author: OTClient team website: https://github.com/edubart/otclient + + // console can be loaded after core autoLoad: true + autoLoadPriority: 20 + dependencies: - core diff --git a/modules/console/console.otui b/modules/addon_console/console.otui similarity index 100% rename from modules/console/console.otui rename to modules/addon_console/console.otui diff --git a/modules/addon_playground/playground.lua b/modules/addon_playground/playground.lua new file mode 100644 index 00000000..805983c3 --- /dev/null +++ b/modules/addon_playground/playground.lua @@ -0,0 +1 @@ +-- place any code for testing purposes here \ No newline at end of file diff --git a/modules/playground/playground.otmod b/modules/addon_playground/playground.otmod similarity index 77% rename from modules/playground/playground.otmod rename to modules/addon_playground/playground.otmod index 5e95db40..1ef3d48f 100644 --- a/modules/playground/playground.otmod +++ b/modules/addon_playground/playground.otmod @@ -1,9 +1,6 @@ Module name: playground autoLoad: true - dependencies: - - core - onLoad: | require 'playground' return true diff --git a/modules/otclient/otclient.lua b/modules/client/client.lua similarity index 62% rename from modules/otclient/otclient.lua rename to modules/client/client.lua index ac801b10..99ae68a5 100644 --- a/modules/otclient/otclient.lua +++ b/modules/client/client.lua @@ -1,13 +1,13 @@ -OTClient = { } +Client = { } -- TODO: load and save configurations -function OTClient.init() +function Client.init() g_window.move({ x=220, y=220 }) g_window.resize({ width=800, height=600 }) g_window.setTitle('OTClient') - g_window.setIcon('otcicon.png') + g_window.setIcon('clienticon.png') return true end -function OTClient.terminate() +function Client.terminate() end diff --git a/modules/client/client.otmod b/modules/client/client.otmod new file mode 100644 index 00000000..1c6c7ef0 --- /dev/null +++ b/modules/client/client.otmod @@ -0,0 +1,22 @@ +Module + name: client + description: Load all other otclient dependecies + author: OTClient team + website: https://github.com/edubart/otclient + + // NOTE: order does matter + dependencies: + - client_background + - client_topmenu + - client_tibiafiles + - client_about + - client_options + - client_entergame + - game + + onLoad: | + require 'client' + return Client.init() + + onUnload: | + Client.terminate() diff --git a/modules/otclient/otcicon.png b/modules/client/clienticon.png similarity index 100% rename from modules/otclient/otcicon.png rename to modules/client/clienticon.png diff --git a/modules/about/about.lua b/modules/client_about/about.lua similarity index 61% rename from modules/about/about.lua rename to modules/client_about/about.lua index 8e6032d5..64b92909 100644 --- a/modules/about/about.lua +++ b/modules/client_about/about.lua @@ -1,16 +1,16 @@ About = {} -- private variables -local about +local aboutWindow -- public functions function About.create() - about = UI.display('about.otui', { locked = true }) + aboutWindow = UI.display('about.otui', { locked = true }) end function About.destroy() - about:destroy() - about = nil + aboutWindow:destroy() + aboutWindow = nil end function About.openWebpage() diff --git a/modules/about/about.otmod b/modules/client_about/about.otmod similarity index 80% rename from modules/about/about.otmod rename to modules/client_about/about.otmod index 353895a8..5dd5c9db 100644 --- a/modules/about/about.otmod +++ b/modules/client_about/about.otmod @@ -1,10 +1,8 @@ Module - name: about + name: client_about description: Create the about window author: OTClient team website: https://github.com/edubart/otclient - dependencies: - - core onLoad: | require 'about' diff --git a/modules/about/about.otui b/modules/client_about/about.otui similarity index 100% rename from modules/about/about.otui rename to modules/client_about/about.otui diff --git a/modules/background/background.lua b/modules/client_background/background.lua similarity index 100% rename from modules/background/background.lua rename to modules/client_background/background.lua diff --git a/modules/background/background.otmod b/modules/client_background/background.otmod similarity index 84% rename from modules/background/background.otmod rename to modules/client_background/background.otmod index 750d33a5..4b3dc707 100644 --- a/modules/background/background.otmod +++ b/modules/client_background/background.otmod @@ -1,10 +1,8 @@ Module - name: background + name: client_background description: Handles the background of the login screen author: OTClient team website: https://github.com/edubart/otclient - dependencies: - - core onLoad: | require 'background' diff --git a/modules/background/background.otui b/modules/client_background/background.otui similarity index 83% rename from modules/background/background.otui rename to modules/client_background/background.otui index a2d9dadd..c88b9b87 100644 --- a/modules/background/background.otui +++ b/modules/client_background/background.otui @@ -1,7 +1,7 @@ Panel id: background image: - source: /background/background.png + source: /client_background/background.png smooth: true fixed ratio: true anchors.top: topMenu.bottom diff --git a/modules/background/background.png b/modules/client_background/background.png similarity index 100% rename from modules/background/background.png rename to modules/client_background/background.png diff --git a/modules/entergame/characterlist.lua b/modules/client_entergame/characterlist.lua similarity index 100% rename from modules/entergame/characterlist.lua rename to modules/client_entergame/characterlist.lua diff --git a/modules/entergame/characterlist.otui b/modules/client_entergame/characterlist.otui similarity index 100% rename from modules/entergame/characterlist.otui rename to modules/client_entergame/characterlist.otui diff --git a/modules/entergame/entergame.lua b/modules/client_entergame/entergame.lua similarity index 100% rename from modules/entergame/entergame.lua rename to modules/client_entergame/entergame.lua diff --git a/modules/entergame/entergame.otmod b/modules/client_entergame/entergame.otmod similarity index 91% rename from modules/entergame/entergame.otmod rename to modules/client_entergame/entergame.otmod index 7b9bfa7d..e1241bcf 100644 --- a/modules/entergame/entergame.otmod +++ b/modules/client_entergame/entergame.otmod @@ -1,8 +1,9 @@ Module - name: entergame + name: client_entergame description: Manages enter game and character list windows author: OTClient team website: https://github.com/edubart/otclient + onLoad: | require 'entergame' require 'characterlist' diff --git a/modules/entergame/entergame.otui b/modules/client_entergame/entergame.otui similarity index 100% rename from modules/entergame/entergame.otui rename to modules/client_entergame/entergame.otui diff --git a/modules/options/options.lua b/modules/client_options/options.lua similarity index 100% rename from modules/options/options.lua rename to modules/client_options/options.lua diff --git a/modules/options/options.otmod b/modules/client_options/options.otmod similarity index 87% rename from modules/options/options.otmod rename to modules/client_options/options.otmod index 97d72044..4722e368 100644 --- a/modules/options/options.otmod +++ b/modules/client_options/options.otmod @@ -1,8 +1,9 @@ Module - name: options + name: client_options description: Create the options window author: OTClient team website: https://github.com/edubart/otclient + onLoad: | require 'options' return true diff --git a/modules/options/options.otui b/modules/client_options/options.otui similarity index 100% rename from modules/options/options.otui rename to modules/client_options/options.otui diff --git a/modules/client_tibiafiles b/modules/client_tibiafiles new file mode 160000 index 00000000..e76fa278 --- /dev/null +++ b/modules/client_tibiafiles @@ -0,0 +1 @@ +Subproject commit e76fa2786e2a194375a110b700b7e2daa769f960 diff --git a/modules/topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua similarity index 98% rename from modules/topmenu/topmenu.lua rename to modules/client_topmenu/topmenu.lua index 28874b2a..fb1662c1 100644 --- a/modules/topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -15,4 +15,4 @@ end function TopMenu.getButton(id) return topMenu:getChildById(id) -end \ No newline at end of file +end diff --git a/modules/topmenu/topmenu.otmod b/modules/client_topmenu/topmenu.otmod similarity index 72% rename from modules/topmenu/topmenu.otmod rename to modules/client_topmenu/topmenu.otmod index 84bcca62..4a102ac2 100644 --- a/modules/topmenu/topmenu.otmod +++ b/modules/client_topmenu/topmenu.otmod @@ -1,13 +1,8 @@ Module - name: topmenu + name: client_topmenu description: Create the top menu author: OTClient team website: https://github.com/edubart/otclient - dependencies: - - core - - entergame - - options - - about onLoad: | require 'topmenu' @@ -16,4 +11,3 @@ Module onUnload: | TopMenu.destroy() - diff --git a/modules/topmenu/topmenu.otui b/modules/client_topmenu/topmenu.otui similarity index 100% rename from modules/topmenu/topmenu.otui rename to modules/client_topmenu/topmenu.otui diff --git a/modules/core/core.otmod b/modules/core/core.otmod index b4886d92..88849485 100644 --- a/modules/core/core.otmod +++ b/modules/core/core.otmod @@ -3,19 +3,15 @@ Module description: Contains lua classes, functions and constants used by other modules author: OTClient team website: https://github.com/edubart/otclient + + // core must be loaded before other modules autoLoad: true + autoLoadPriority: 10 + + // NOTE: order does matter dependencies: - core_fonts - core_styles - - onLoad: | - require 'ext/table' - require 'ext/string' - require 'constants' - require 'util' - require 'dispatcher' - require 'widget' - require 'ui' - require 'gfx' - return true + - core_scripts + - core_widgets diff --git a/modules/core_fonts/sans-11px-antialised.png b/modules/core_fonts/sans-11px-antialised.png deleted file mode 100644 index 2178d6841253d99e53adf780c25c4bba0cb30f28..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9954 zcmZvi2T&7F`1daf9RU@Q-m4&rR0V-hLqIx86Nr=m3WD^W!~!Tk=^#BIMY>23k(Q`{ zl+b&RO7GGMB`?2u=RfoNzw_SA-LrQyyLWrL&+d0W`@A+Wf-y00F#rI-1lQ9x0|3x@ z5+KphoL|>8>P*fJ$kz;}2~_s*ET7-dI2ypT&+Ykfq}6~rH}u|m*1iD1$olUI0y45V z&L7hH!3}k2CmBKDYaBN>f2;z4007t4un3x1&kk64P+8nL%0ylEe5_MHf?@6R8x)+Sq7lbY=2!4lM{b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l9aFHmwOn;7!=EreV-VyKHac*{ElLOMxt6A z09<}G5CO8HBbpwag10$xtaV!swTk7Nw)GB-V&m3v=RlE_KzQF7D1Qf?oz3|5aFji* znBDcj3S{!&=sboXV%vZ8B>Tde9jUtF(ft1s*;c22@pz4}6}qX-k$ F{|EHbSG)iK diff --git a/modules/core/constants.lua b/modules/core_scripts/constants.lua similarity index 100% rename from modules/core/constants.lua rename to modules/core_scripts/constants.lua diff --git a/modules/core_scripts/core_scripts.otmod b/modules/core_scripts/core_scripts.otmod new file mode 100644 index 00000000..8c52ba30 --- /dev/null +++ b/modules/core_scripts/core_scripts.otmod @@ -0,0 +1,16 @@ +Module + name: core_scripts + description: Contains core lua classes, functions and constants used by other modules + author: OTClient team + website: https://github.com/edubart/otclient + + onLoad: | + require 'ext/table' + require 'ext/string' + require 'constants' + require 'util' + require 'dispatcher' + require 'widget' + require 'ui' + require 'gfx' + return true diff --git a/modules/core/dispatcher.lua b/modules/core_scripts/dispatcher.lua similarity index 100% rename from modules/core/dispatcher.lua rename to modules/core_scripts/dispatcher.lua diff --git a/modules/core/ext/color.lua b/modules/core_scripts/ext/color.lua similarity index 100% rename from modules/core/ext/color.lua rename to modules/core_scripts/ext/color.lua diff --git a/modules/core/ext/point.lua b/modules/core_scripts/ext/point.lua similarity index 100% rename from modules/core/ext/point.lua rename to modules/core_scripts/ext/point.lua diff --git a/modules/core/ext/rect.lua b/modules/core_scripts/ext/rect.lua similarity index 100% rename from modules/core/ext/rect.lua rename to modules/core_scripts/ext/rect.lua diff --git a/modules/core/ext/size.lua b/modules/core_scripts/ext/size.lua similarity index 100% rename from modules/core/ext/size.lua rename to modules/core_scripts/ext/size.lua diff --git a/modules/core/ext/string.lua b/modules/core_scripts/ext/string.lua similarity index 100% rename from modules/core/ext/string.lua rename to modules/core_scripts/ext/string.lua diff --git a/modules/core/ext/table.lua b/modules/core_scripts/ext/table.lua similarity index 100% rename from modules/core/ext/table.lua rename to modules/core_scripts/ext/table.lua diff --git a/modules/core/gfx.lua b/modules/core_scripts/gfx.lua similarity index 100% rename from modules/core/gfx.lua rename to modules/core_scripts/gfx.lua diff --git a/modules/core/ui.lua b/modules/core_scripts/ui.lua similarity index 100% rename from modules/core/ui.lua rename to modules/core_scripts/ui.lua diff --git a/modules/core/util.lua b/modules/core_scripts/util.lua similarity index 84% rename from modules/core/util.lua rename to modules/core_scripts/util.lua index ac26a4ae..9bf33688 100644 --- a/modules/core/util.lua +++ b/modules/core_scripts/util.lua @@ -12,14 +12,18 @@ function createEnvironment() return env end -function connect(object, signalsAndSlots) +function connect(object, signalsAndSlots, pushFront) for signal,slot in pairs(signalsAndSlots) do if not object[signal] then object[signal] = slot elseif type(object[signal]) == 'function' then object[signal] = { object[signal], slot } elseif type(object[signal]) == 'table' then - table.insert(object[signal], #object[signal]+1, slot) + if pushFront then + table.insert(object[signal], 1, slot) + else + table.insert(object[signal], #object[signal]+1, slot) + end end end end diff --git a/modules/core/widget.lua b/modules/core_scripts/widget.lua similarity index 100% rename from modules/core/widget.lua rename to modules/core_scripts/widget.lua diff --git a/modules/core_styles/core_styles.otmod b/modules/core_styles/core_styles.otmod index 93ce19d8..cdf885e1 100644 --- a/modules/core_styles/core_styles.otmod +++ b/modules/core_styles/core_styles.otmod @@ -3,8 +3,7 @@ Module description: Contains ui styles used by other modules author: OTClient team website: https://github.com/edubart/otclient - dependencies: - - core_fonts + onLoad: | importStyles 'styles/buttons.otui' importStyles 'styles/labels.otui' @@ -17,4 +16,3 @@ Module importStyles 'styles/items.otui' importStyles 'styles/creatures.otui' return true - diff --git a/modules/core_widgets/core_widgets.otmod b/modules/core_widgets/core_widgets.otmod new file mode 100644 index 00000000..6b228a62 --- /dev/null +++ b/modules/core_widgets/core_widgets.otmod @@ -0,0 +1,10 @@ +Module + name: core_widgets + description: Contains widgets used by other modules + author: OTClient team + website: https://github.com/edubart/otclient + + onLoad: | + require 'tooltip/tooltip' + require 'messagebox/messagebox' + return true \ No newline at end of file diff --git a/modules/messagebox/messagebox.lua b/modules/core_widgets/messagebox/messagebox.lua similarity index 100% rename from modules/messagebox/messagebox.lua rename to modules/core_widgets/messagebox/messagebox.lua diff --git a/modules/messagebox/messagebox.otui b/modules/core_widgets/messagebox/messagebox.otui similarity index 100% rename from modules/messagebox/messagebox.otui rename to modules/core_widgets/messagebox/messagebox.otui diff --git a/modules/tooltip/tooltip.lua b/modules/core_widgets/tooltip/tooltip.lua similarity index 100% rename from modules/tooltip/tooltip.lua rename to modules/core_widgets/tooltip/tooltip.lua diff --git a/modules/tooltip/tooltip.otui b/modules/core_widgets/tooltip/tooltip.otui similarity index 100% rename from modules/tooltip/tooltip.otui rename to modules/core_widgets/tooltip/tooltip.otui diff --git a/modules/game/game.lua b/modules/game/game.lua index b389bb1b..81b8d6ab 100644 --- a/modules/game/game.lua +++ b/modules/game/game.lua @@ -16,7 +16,7 @@ end function Game.createInterface() Background.hide() CharacterList.destroyLoadBox() - Game.gameUi = UI.display('/game/game.otui') + Game.gameUi = UI.display('game.otui') UI.root:moveChildToIndex(Game.gameUi, 1) Game.gameMapPanel = Game.gameUi:getChildById('mapPanel') Game.gameRightPanel = Game.gameUi:getChildById('rightPanel') @@ -56,5 +56,5 @@ function Game.onConnectionError(message) errorBox.onOk = CharacterList.show end -connect(Game, { onLogin = Game.createInterface, - onLogout = Game.destroyInterface }) +connect(Game, { onLogin = Game.createInterface }, true) +connect(Game, { onLogout = Game.destroyInterface }) diff --git a/modules/game/game.otmod b/modules/game/game.otmod index 4f941688..240e67da 100644 --- a/modules/game/game.otmod +++ b/modules/game/game.otmod @@ -3,6 +3,16 @@ Module description: Create the game interface, where the ingame stuff starts author: OTClient team website: https://github.com/edubart/otclient + + dependencies: + - game_healthbar + - game_inventory + - game_skills + - game_textmessage + - game_viplist + - game_chat + - game_outfit + onLoad: | require 'game' - return true + return true \ No newline at end of file diff --git a/modules/chat/chat.lua b/modules/game_chat/chat.lua similarity index 100% rename from modules/chat/chat.lua rename to modules/game_chat/chat.lua diff --git a/modules/chat/chat.otmod b/modules/game_chat/chat.otmod similarity index 89% rename from modules/chat/chat.otmod rename to modules/game_chat/chat.otmod index 6ce771d6..549c8d32 100644 --- a/modules/chat/chat.otmod +++ b/modules/game_chat/chat.otmod @@ -1,5 +1,5 @@ Module - name: chat + name: game_chat description: Manage chat window author: OTClient team website: https://github.com/edubart/otclient diff --git a/modules/chat/chat.otui b/modules/game_chat/chat.otui similarity index 100% rename from modules/chat/chat.otui rename to modules/game_chat/chat.otui diff --git a/modules/health_mana/health_mana.lua b/modules/game_healthbar/healthbar.lua similarity index 85% rename from modules/health_mana/health_mana.lua rename to modules/game_healthbar/healthbar.lua index e8fe8f1a..237296b4 100644 --- a/modules/health_mana/health_mana.lua +++ b/modules/game_healthbar/healthbar.lua @@ -1,11 +1,11 @@ -HealthMana = {} +HealthBar = {} -- private variables local healthManaPanel = nil -- public functions -function HealthMana.create() - healthManaPanel = UI.display('health_mana.otui', { parent = Game.gameRightPanel }) +function HealthBar.create() + healthManaPanel = UI.display('healthbar.otui', { parent = Game.gameRightPanel }) local healthBar = UIProgressBar.create() healthManaPanel:addChild(healthBar) @@ -32,7 +32,7 @@ function HealthMana.create() healthManaPanel:setHeight(healthBar:getHeight() + manaBar:getHeight() + 4) end -function HealthMana.destroy() +function HealthBar.destroy() healthManaPanel:destroy() healthManaPanel = nil end @@ -61,5 +61,5 @@ function Game.onManaChange(mana, maxMana) manaBar:setPercent(percent) end -connect(Game, { onLogin = HealthMana.create, - onLogout = HealthMana.destroy }) +connect(Game, { onLogin = HealthBar.create, + onLogout = HealthBar.destroy }) diff --git a/modules/health_mana/health_mana.otmod b/modules/game_healthbar/healthbar.otmod similarity index 76% rename from modules/health_mana/health_mana.otmod rename to modules/game_healthbar/healthbar.otmod index c62bf9b3..4dee07e3 100644 --- a/modules/health_mana/health_mana.otmod +++ b/modules/game_healthbar/healthbar.otmod @@ -1,10 +1,10 @@ Module - name: health_mana + name: game_healthbar description: Displays health and mana points author: OTClient team website: https://github.com/edubart/otclient onLoad: | - require 'health_mana' + require 'healthbar' return true diff --git a/modules/health_mana/health_mana.otui b/modules/game_healthbar/healthbar.otui similarity index 100% rename from modules/health_mana/health_mana.otui rename to modules/game_healthbar/healthbar.otui diff --git a/modules/inventory/inventory.lua b/modules/game_inventory/inventory.lua similarity index 100% rename from modules/inventory/inventory.lua rename to modules/game_inventory/inventory.lua diff --git a/modules/inventory/inventory.otmod b/modules/game_inventory/inventory.otmod similarity index 88% rename from modules/inventory/inventory.otmod rename to modules/game_inventory/inventory.otmod index 1ce10ed3..2d44fa1d 100644 --- a/modules/inventory/inventory.otmod +++ b/modules/game_inventory/inventory.otmod @@ -1,5 +1,5 @@ Module - name: inventory + name: game_inventory description: View local player equipments window author: OTClient team website: https://github.com/edubart/otclient diff --git a/modules/inventory/inventory.otui b/modules/game_inventory/inventory.otui similarity index 100% rename from modules/inventory/inventory.otui rename to modules/game_inventory/inventory.otui diff --git a/modules/inventory/itempopupmenu.otui b/modules/game_inventory/itempopupmenu.otui similarity index 100% rename from modules/inventory/itempopupmenu.otui rename to modules/game_inventory/itempopupmenu.otui diff --git a/modules/outfit/outfit.lua b/modules/game_outfit/outfit.lua similarity index 100% rename from modules/outfit/outfit.lua rename to modules/game_outfit/outfit.lua diff --git a/modules/outfit/outfit.otmod b/modules/game_outfit/outfit.otmod similarity index 89% rename from modules/outfit/outfit.otmod rename to modules/game_outfit/outfit.otmod index e43042e5..e31feea7 100644 --- a/modules/outfit/outfit.otmod +++ b/modules/game_outfit/outfit.otmod @@ -1,5 +1,5 @@ Module - name: outfit + name: game_outfit description: Change local player outfit author: OTClient team website: https://github.com/edubart/otclient diff --git a/modules/outfit/outfit.otui b/modules/game_outfit/outfit.otui similarity index 100% rename from modules/outfit/outfit.otui rename to modules/game_outfit/outfit.otui diff --git a/modules/skills/skills.lua b/modules/game_skills/skills.lua similarity index 100% rename from modules/skills/skills.lua rename to modules/game_skills/skills.lua diff --git a/modules/skills/skills.otmod b/modules/game_skills/skills.otmod similarity index 89% rename from modules/skills/skills.otmod rename to modules/game_skills/skills.otmod index b895f8a2..1b6f7c99 100644 --- a/modules/skills/skills.otmod +++ b/modules/game_skills/skills.otmod @@ -1,5 +1,5 @@ Module - name: skills + name: game_skills description: Manage skills window author: OTClient team website: https://github.com/edubart/otclient diff --git a/modules/skills/skills.otui b/modules/game_skills/skills.otui similarity index 100% rename from modules/skills/skills.otui rename to modules/game_skills/skills.otui diff --git a/modules/textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua similarity index 96% rename from modules/textmessage/textmessage.lua rename to modules/game_textmessage/textmessage.lua index 748e7b3b..81a46d9c 100644 --- a/modules/textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -1,7 +1,7 @@ TextMessage = {} -- require styles -importStyles '/textmessage/textmessage.otui' +importStyles 'textmessage.otui' -- private variables local bottomLabelWidget, centerLabelWidget diff --git a/modules/textmessage/textmessage.otmod b/modules/game_textmessage/textmessage.otmod similarity index 87% rename from modules/textmessage/textmessage.otmod rename to modules/game_textmessage/textmessage.otmod index 534a2fe0..cdb15547 100644 --- a/modules/textmessage/textmessage.otmod +++ b/modules/game_textmessage/textmessage.otmod @@ -1,5 +1,5 @@ Module - name: textmessage + name: game_textmessage description: Manage game text messages author: OTClient team website: https://github.com/edubart/otclient diff --git a/modules/textmessage/textmessage.otui b/modules/game_textmessage/textmessage.otui similarity index 100% rename from modules/textmessage/textmessage.otui rename to modules/game_textmessage/textmessage.otui diff --git a/modules/viplist/viplist.lua b/modules/game_viplist/viplist.lua similarity index 100% rename from modules/viplist/viplist.lua rename to modules/game_viplist/viplist.lua diff --git a/modules/viplist/viplist.otmod b/modules/game_viplist/viplist.otmod similarity index 88% rename from modules/viplist/viplist.otmod rename to modules/game_viplist/viplist.otmod index 40b14260..8ff16013 100644 --- a/modules/viplist/viplist.otmod +++ b/modules/game_viplist/viplist.otmod @@ -1,5 +1,5 @@ Module - name: viplist + name: game_viplist description: Manage vip list window author: OTClient team website: https://github.com/edubart/otclient diff --git a/modules/viplist/viplist.otui b/modules/game_viplist/viplist.otui similarity index 100% rename from modules/viplist/viplist.otui rename to modules/game_viplist/viplist.otui diff --git a/modules/messagebox/messagebox.otmod b/modules/messagebox/messagebox.otmod deleted file mode 100644 index 23da5c55..00000000 --- a/modules/messagebox/messagebox.otmod +++ /dev/null @@ -1,12 +0,0 @@ -Module - name: messagebox - description: Manages message boxes - author: OTClient team - website: https://github.com/edubart/otclient - autoLoad: true - dependencies: - - core - - onLoad: | - require 'messagebox' - return true diff --git a/modules/otclient/otclient.otmod b/modules/otclient/otclient.otmod deleted file mode 100644 index c041c1c5..00000000 --- a/modules/otclient/otclient.otmod +++ /dev/null @@ -1,27 +0,0 @@ -Module - name: otclient - description: Load all other otclient modules - author: OTClient team - website: https://github.com/edubart/otclient - autoLoad: true - autoLoadPriority: 10 - dependencies: - - core - - background - - topmenu - - game - - health_mana - - inventory - - skills - - viplist - - textmessage - - chat - - outfit - - tibiafiles - - onLoad: | - require 'otclient' - return OTClient.init() - - onUnload: | - OTClient.terminate() diff --git a/modules/playground/playground.lua b/modules/playground/playground.lua deleted file mode 100644 index 2f3d65e1..00000000 --- a/modules/playground/playground.lua +++ /dev/null @@ -1,24 +0,0 @@ --- place any code for testing purposes here - -function UIItem.onMouseRelease(self, mousePos, mouseButton) - if mouseButton ~= MouseRightButton then return end - local top = self:getY() - local bottom = self:getY() + self:getHeight() - local left = self:getX() - local right = self:getX() + self:getWidth() - if not (mousePos.y >= top and mousePos.y <= bottom and mousePos.x >= left and mousePos.x <= right) then return end - - local menuFile = self:getStyle()['popup menu'] - if not menuFile then return end - - local popupMenu = UI.display(menuFile) - if not popupMenu then return end - - popupMenu:moveTo(mousePos) - popupMenu.onMouseRelease = function(self) self:destroy() end -end - -local function init() -end - -addEvent(init) \ No newline at end of file diff --git a/modules/tibiafiles b/modules/tibiafiles deleted file mode 160000 index 8bb3b7d6..00000000 --- a/modules/tibiafiles +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8bb3b7d6d86e561be4622fbe7dbef208446a0319 diff --git a/modules/tooltip/tooltip.otmod b/modules/tooltip/tooltip.otmod deleted file mode 100644 index 6c3b3efa..00000000 --- a/modules/tooltip/tooltip.otmod +++ /dev/null @@ -1,13 +0,0 @@ -Module - name: tooltip - description: Enable tooltips on any button - author: OTClient team - website: https://github.com/edubart/otclient - autoLoad: true - autoLoadPriority: 2 - dependencies: - - core - - onLoad: | - require 'tooltip' - return true diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index ebcecc15..659fc10a 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -62,7 +62,7 @@ ENDIF(HANDLE_EXCEPTIONS) IF(WIN32) - SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp) + SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp) SET(ADDITIONAL_LIBRARIES ws2_32 mswsock) IF(CMAKE_COMPILER_IS_GNUCXX) @@ -80,7 +80,7 @@ IF(WIN32) ELSE(WIN32) SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic") SET(ADDITIONAL_LIBRARIES pthread) - SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp) + SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp) ENDIF(WIN32) @@ -94,7 +94,7 @@ INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_LIST_DIR}/.." ) -SET(FRAMEWORK_LIBRARIES +SET(framework_LIBRARIES ${Boost_LIBRARIES} ${OPENGL_LIBRARIES} ${LUA_LIBRARIES} @@ -105,7 +105,7 @@ SET(FRAMEWORK_LIBRARIES ) -SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} +SET(framework_SOURCES ${framework_SOURCES} # framework ${CMAKE_CURRENT_LIST_DIR}/application.cpp ${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp diff --git a/src/framework/application.cpp b/src/framework/application.cpp index ad2fde85..25542cc3 100644 --- a/src/framework/application.cpp +++ b/src/framework/application.cpp @@ -103,33 +103,12 @@ void Application::init(const std::vector& args, int appFlags) resize(g_window.getSize()); } - if(m_appFlags & Fw::AppEnableModules) { - // search for modules directory - std::string baseDir = g_resources.getBaseDir(); - std::string possibleDirs[] = { "modules", - baseDir + "modules", - baseDir + "../modules", - baseDir + "../share/" + m_appName + "/modules", - "" }; - bool found = false; - for(const std::string& dir : possibleDirs) { - // try to add module directory - if(g_resources.addToSearchPath(dir)) { - logInfo("Using modules directory '", dir.c_str(), "'"); - found = true; - break; - } - } - - if(!found) - logFatal("Could not find modules directory"); - - g_modules.discoverAndLoadModules(); - } - // finally show the window if(m_appFlags & Fw::AppEnableGraphics) g_window.show(); + + if(m_appFlags & Fw::AppEnableModules) + g_modules.discoverModulesPath(); } diff --git a/src/framework/application.h b/src/framework/application.h index b456765f..b09f2942 100644 --- a/src/framework/application.h +++ b/src/framework/application.h @@ -54,7 +54,6 @@ protected: virtual void resize(const Size& size); virtual void inputEvent(const InputEvent& event); -private: std::string m_appName; int m_appFlags; int m_pollCycleDelay; diff --git a/src/framework/core/modulemanager.cpp b/src/framework/core/modulemanager.cpp index d74ebb19..817016be 100644 --- a/src/framework/core/modulemanager.cpp +++ b/src/framework/core/modulemanager.cpp @@ -24,13 +24,12 @@ #include "resourcemanager.h" #include +#include ModuleManager g_modules; -void ModuleManager::discoverAndLoadModules() +void ModuleManager::discoverModules() { - std::multimap m_autoLoadModules; - auto moduleDirs = g_resources.listDirectoryFiles("/"); for(const std::string& moduleDir : moduleDirs) { auto moduleFiles = g_resources.listDirectoryFiles("/" + moduleDir); @@ -42,14 +41,42 @@ void ModuleManager::discoverAndLoadModules() } } } +} +void ModuleManager::autoLoadModules(int maxPriority) +{ for(auto& pair : m_autoLoadModules) { + int priority = pair.first; + if(priority > maxPriority) + break; ModulePtr module = pair.second; if(!module->isLoaded() && !module->load()) logFatal("A required module has failed to load, cannot continue to run."); } } +void ModuleManager::discoverModulesPath() +{ + // search for modules directory + std::string possibleDirs[] = { "modules", + g_resources.getBaseDir() + "modules", + g_resources.getBaseDir() + "../modules", + g_resources.getBaseDir() + "../share/" + g_app->getAppName() + "/modules", + "" }; + bool found = false; + for(const std::string& dir : possibleDirs) { + // try to add module directory + if(g_resources.addToSearchPath(dir)) { + logInfo("Using modules directory '", dir.c_str(), "'"); + found = true; + break; + } + } + + if(!found) + logFatal("Could not find modules directory"); +} + ModulePtr ModuleManager::discoverModule(const std::string& moduleFile) { ModulePtr module; @@ -70,6 +97,13 @@ ModulePtr ModuleManager::discoverModule(const std::string& moduleFile) return module; } +void ModuleManager::ensureModuleLoaded(const std::string& moduleName) +{ + ModulePtr module = g_modules.getModule(moduleName); + if(!module || !module->load()) + logFatal("Unable to load '", moduleName, "' module"); +} + void ModuleManager::unloadModules() { for(const ModulePtr& module : m_modules) diff --git a/src/framework/core/modulemanager.h b/src/framework/core/modulemanager.h index 9ce06bcd..3d49106d 100644 --- a/src/framework/core/modulemanager.h +++ b/src/framework/core/modulemanager.h @@ -28,14 +28,18 @@ class ModuleManager { public: - void discoverAndLoadModules(); + void discoverModulesPath(); + void discoverModules(); + void autoLoadModules(int maxPriority); ModulePtr discoverModule(const std::string& moduleFile); + void ensureModuleLoaded(const std::string& moduleName); void unloadModules(); ModulePtr getModule(const std::string& moduleName); private: std::vector m_modules; + std::multimap m_autoLoadModules; }; extern ModuleManager g_modules; diff --git a/src/framework/graphics/font.cpp b/src/framework/graphics/font.cpp index 20d2fa20..29a4246c 100644 --- a/src/framework/graphics/font.cpp +++ b/src/framework/graphics/font.cpp @@ -76,7 +76,7 @@ void Font::renderText(const std::string& text, const Color& color) { // prevent glitches from invalid rects - if(!screenCoords.isValid()) + if(!screenCoords.isValid() || !m_texture) return; int textLenght = text.length(); diff --git a/src/framework/graphics/fontmanager.cpp b/src/framework/graphics/fontmanager.cpp index 9137b2c6..c15a6721 100644 --- a/src/framework/graphics/fontmanager.cpp +++ b/src/framework/graphics/fontmanager.cpp @@ -27,6 +27,11 @@ FontManager g_fonts; +FontManager::FontManager() +{ + m_defaultFont = FontPtr(new Font("emptyfont")); +} + void FontManager::releaseFonts() { m_defaultFont.reset(); diff --git a/src/framework/graphics/fontmanager.h b/src/framework/graphics/fontmanager.h index 0444f672..586a79bd 100644 --- a/src/framework/graphics/fontmanager.h +++ b/src/framework/graphics/fontmanager.h @@ -28,6 +28,8 @@ class FontManager { public: + FontManager(); + /// Release fonts references, thus making possible to destruct them void releaseFonts(); diff --git a/src/otclient/CMakeLists.txt b/src/otclient/CMakeLists.txt index 242787f2..738a489b 100644 --- a/src/otclient/CMakeLists.txt +++ b/src/otclient/CMakeLists.txt @@ -8,7 +8,7 @@ ELSE(FORBIDDEN_FUNCTIONS) MESSAGE(STATUS "Lua forbidden functions: OFF") ENDIF(FORBIDDEN_FUNCTIONS) -SET(OTCLIENT_SOURCES ${OTCLIENT_SOURCES} +SET(otclient_SOURCES ${otclient_SOURCES} # otclient ${CMAKE_CURRENT_LIST_DIR}/otclient.cpp ${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index 314d7c50..ef2c282a 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -21,6 +21,7 @@ */ #include "otclient.h" +#include OTClient::OTClient() : Application(Otc::AppCompactName) { @@ -31,4 +32,10 @@ void OTClient::init(const std::vector& args) { logInfo(Otc::AppName, " ", Otc::AppVersion); Application::init(args, Fw::AppEnableAll); + + g_modules.discoverModules(); + g_modules.autoLoadModules(100); + g_modules.ensureModuleLoaded("client"); + g_modules.ensureModuleLoaded("game"); + g_modules.autoLoadModules(1000); }