From e3298d561c1274b257c47ec4d059248f4b3ec7c6 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 13 Jul 2012 22:10:24 -0300 Subject: [PATCH] Rework application class and framework Make otclient's framework flexible enough to run console apps like servers, so this mean is possible to build otclient versions without graphical interface and use it's framework to code servers --- CMakeLists.txt | 47 +- modules/game_bugreport/bugreport.otui | 1 - modules/game_minimap/zoomin.png | Bin 0 -> 836 bytes modules/game_minimap/zoomout.png | Bin 0 -> 819 bytes src/framework/CMakeLists.txt | 696 +++++++++--------- src/framework/core/application.cpp | 143 ++++ src/framework/{ => core}/application.h | 49 +- .../core/consoleapplication.cpp} | 45 +- .../core/consoleapplication.h} | 24 +- src/framework/core/event.h | 2 +- src/framework/core/filestream.cpp | 4 +- src/framework/core/filestream.h | 2 +- .../graphicalapplication.cpp} | 163 +--- src/framework/core/graphicalapplication.h | 72 ++ src/framework/core/logger.cpp | 5 +- src/framework/core/module.cpp | 2 +- src/framework/core/module.h | 2 +- src/framework/core/modulemanager.cpp | 2 +- src/framework/core/resourcemanager.cpp | 4 +- .../{thirdparty => graphics}/apngloader.cpp | 0 .../{thirdparty => graphics}/apngloader.h | 0 src/framework/graphics/framebuffer.cpp | 4 +- src/framework/graphics/hardwarebuffer.cpp | 4 +- src/framework/graphics/image.cpp | 2 +- src/framework/graphics/particleeffect.h | 2 +- src/framework/graphics/shader.cpp | 4 +- src/framework/graphics/shaderprogram.cpp | 4 +- src/framework/graphics/shaderprogram.h | 2 +- src/framework/graphics/texture.cpp | 4 +- src/framework/graphics/texturemanager.cpp | 2 +- .../{luascript => luaengine}/declarations.h | 0 .../lbitlib.cpp} | 0 .../lbitlib.h} | 0 .../{luascript => luaengine}/luabinder.h | 0 .../{luascript => luaengine}/luaexception.cpp | 0 .../{luascript => luaengine}/luaexception.h | 0 .../{luascript => luaengine}/luainterface.cpp | 2 +- .../{luascript => luaengine}/luainterface.h | 0 .../{luascript => luaengine}/luaobject.cpp | 4 +- .../{luascript => luaengine}/luaobject.h | 0 .../luavaluecasts.cpp | 0 .../{luascript => luaengine}/luavaluecasts.h | 0 src/framework/luafunctions.cpp | 390 +++++----- src/framework/net/connection.cpp | 4 +- src/framework/net/inputmessage.h | 2 +- src/framework/net/outputmessage.h | 2 +- src/framework/net/protocol.cpp | 4 +- src/framework/net/protocol.h | 2 +- src/framework/pch.h | 1 + src/framework/platform/unixcrashhandler.cpp | 2 +- src/framework/platform/win32crashhandler.cpp | 2 +- src/framework/platform/win32window.cpp | 4 +- src/framework/platform/x11window.cpp | 2 +- src/framework/ui/uilayout.h | 2 +- src/framework/ui/uimanager.cpp | 2 +- src/framework/ui/uitextedit.cpp | 2 +- src/framework/ui/uiwidget.cpp | 4 +- src/framework/ui/uiwidget.h | 2 +- src/framework/ui/uiwidgettext.cpp | 2 +- src/framework/{thirdparty => xml}/tinystr.cpp | 0 src/framework/{thirdparty => xml}/tinystr.h | 0 src/framework/{thirdparty => xml}/tinyxml.cpp | 0 src/framework/{thirdparty => xml}/tinyxml.h | 148 ++-- .../{thirdparty => xml}/tinyxmlerror.cpp | 0 .../{thirdparty => xml}/tinyxmlparser.cpp | 0 src/main.cpp | 10 +- src/otclient/CMakeLists.txt | 160 ++-- src/otclient/{core => }/animatedtext.cpp | 0 src/otclient/{core => }/animatedtext.h | 0 src/otclient/{core => }/container.cpp | 0 src/otclient/{core => }/container.h | 2 +- src/otclient/{core => }/creature.cpp | 0 src/otclient/{core => }/creature.h | 0 src/otclient/{core => }/declarations.h | 27 +- src/otclient/{core => }/effect.cpp | 0 src/otclient/{core => }/effect.h | 0 src/otclient/{core => }/game.cpp | 6 +- src/otclient/{core => }/game.h | 5 +- src/otclient/global.h | 2 +- src/otclient/{core => }/item.cpp | 0 src/otclient/{core => }/item.h | 0 src/otclient/{core => }/localplayer.cpp | 0 src/otclient/{core => }/localplayer.h | 0 src/otclient/luafunctions.cpp | 46 +- .../{luascript => }/luavaluecasts.cpp | 2 +- src/otclient/{luascript => }/luavaluecasts.h | 6 +- src/otclient/{core => }/map.cpp | 0 src/otclient/{core => }/map.h | 0 src/otclient/{core => }/mapview.cpp | 4 +- src/otclient/{core => }/mapview.h | 2 +- src/otclient/{core => }/minimap.cpp | 0 src/otclient/{core => }/minimap.h | 2 +- src/otclient/{core => }/missile.cpp | 0 src/otclient/{core => }/missile.h | 0 src/otclient/otclient.cpp | 8 +- src/otclient/otclient.h | 2 +- src/otclient/{core => }/outfit.cpp | 0 src/otclient/{core => }/outfit.h | 2 +- src/otclient/{core => }/player.cpp | 0 src/otclient/{core => }/player.h | 0 src/otclient/{util => }/position.h | 2 +- src/otclient/{net => }/protocolcodes.h | 2 +- src/otclient/{net => }/protocolgame.cpp | 10 +- src/otclient/{net => }/protocolgame.h | 4 +- src/otclient/{net => }/protocolgameparse.cpp | 18 +- src/otclient/{net => }/protocolgamesend.cpp | 2 +- src/otclient/{core => }/shadermanager.cpp | 0 src/otclient/{core => }/shadermanager.h | 0 src/otclient/{core => }/spritemanager.cpp | 0 src/otclient/{core => }/spritemanager.h | 0 src/otclient/{core => }/statictext.cpp | 0 src/otclient/{core => }/statictext.h | 0 src/otclient/{core => }/thing.cpp | 0 src/otclient/{core => }/thing.h | 2 +- src/otclient/{core => }/thingstype.h | 0 src/otclient/{core => }/thingtypedat.cpp | 0 src/otclient/{core => }/thingtypedat.h | 2 +- src/otclient/{core => }/thingtypemanager.cpp | 4 +- src/otclient/{core => }/thingtypemanager.h | 0 src/otclient/{core => }/thingtypeotb.cpp | 0 src/otclient/{core => }/thingtypeotb.h | 2 +- src/otclient/{core => }/tile.cpp | 2 +- src/otclient/{core => }/tile.h | 2 +- src/otclient/{ui => }/uicreature.cpp | 0 src/otclient/{ui => }/uicreature.h | 2 +- src/otclient/{ui => }/uiitem.cpp | 0 src/otclient/{ui => }/uiitem.h | 2 +- src/otclient/{ui => }/uimap.cpp | 10 +- src/otclient/{ui => }/uimap.h | 4 +- src/otclient/{ui => }/uiprogressrect.cpp | 0 src/otclient/{ui => }/uiprogressrect.h | 2 +- 131 files changed, 1222 insertions(+), 1010 deletions(-) create mode 100644 modules/game_minimap/zoomin.png create mode 100644 modules/game_minimap/zoomout.png create mode 100644 src/framework/core/application.cpp rename src/framework/{ => core}/application.h (64%) rename src/{otclient/ui/declarations.h => framework/core/consoleapplication.cpp} (65%) rename src/{otclient/net/declarations.h => framework/core/consoleapplication.h} (78%) rename src/framework/{application.cpp => core/graphicalapplication.cpp} (66%) create mode 100644 src/framework/core/graphicalapplication.h rename src/framework/{thirdparty => graphics}/apngloader.cpp (100%) rename src/framework/{thirdparty => graphics}/apngloader.h (100%) rename src/framework/{luascript => luaengine}/declarations.h (100%) rename src/framework/{thirdparty/lbitlib-5.2.0-backport4.cpp => luaengine/lbitlib.cpp} (100%) rename src/framework/{thirdparty/lbitlib-5.2.0-backport4.h => luaengine/lbitlib.h} (100%) rename src/framework/{luascript => luaengine}/luabinder.h (100%) rename src/framework/{luascript => luaengine}/luaexception.cpp (100%) rename src/framework/{luascript => luaengine}/luaexception.h (100%) rename src/framework/{luascript => luaengine}/luainterface.cpp (99%) rename src/framework/{luascript => luaengine}/luainterface.h (100%) rename src/framework/{luascript => luaengine}/luaobject.cpp (97%) rename src/framework/{luascript => luaengine}/luaobject.h (100%) rename src/framework/{luascript => luaengine}/luavaluecasts.cpp (100%) rename src/framework/{luascript => luaengine}/luavaluecasts.h (100%) rename src/framework/{thirdparty => xml}/tinystr.cpp (100%) rename src/framework/{thirdparty => xml}/tinystr.h (100%) rename src/framework/{thirdparty => xml}/tinyxml.cpp (100%) rename src/framework/{thirdparty => xml}/tinyxml.h (97%) rename src/framework/{thirdparty => xml}/tinyxmlerror.cpp (100%) rename src/framework/{thirdparty => xml}/tinyxmlparser.cpp (100%) rename src/otclient/{core => }/animatedtext.cpp (100%) rename src/otclient/{core => }/animatedtext.h (100%) rename src/otclient/{core => }/container.cpp (100%) rename src/otclient/{core => }/container.h (98%) rename src/otclient/{core => }/creature.cpp (100%) rename src/otclient/{core => }/creature.h (100%) rename src/otclient/{core => }/declarations.h (79%) rename src/otclient/{core => }/effect.cpp (100%) rename src/otclient/{core => }/effect.h (100%) rename src/otclient/{core => }/game.cpp (99%) rename src/otclient/{core => }/game.h (99%) rename src/otclient/{core => }/item.cpp (100%) rename src/otclient/{core => }/item.h (100%) rename src/otclient/{core => }/localplayer.cpp (100%) rename src/otclient/{core => }/localplayer.h (100%) rename src/otclient/{luascript => }/luavaluecasts.cpp (98%) rename src/otclient/{luascript => }/luavaluecasts.h (92%) rename src/otclient/{core => }/map.cpp (100%) rename src/otclient/{core => }/map.h (100%) rename src/otclient/{core => }/mapview.cpp (99%) rename src/otclient/{core => }/mapview.h (99%) rename src/otclient/{core => }/minimap.cpp (100%) rename src/otclient/{core => }/minimap.h (98%) rename src/otclient/{core => }/missile.cpp (100%) rename src/otclient/{core => }/missile.h (100%) rename src/otclient/{core => }/outfit.cpp (100%) rename src/otclient/{core => }/outfit.h (98%) rename src/otclient/{core => }/player.cpp (100%) rename src/otclient/{core => }/player.h (100%) rename src/otclient/{util => }/position.h (99%) rename src/otclient/{net => }/protocolcodes.h (99%) rename src/otclient/{net => }/protocolgame.cpp (92%) rename src/otclient/{net => }/protocolgame.h (99%) rename src/otclient/{net => }/protocolgameparse.cpp (99%) rename src/otclient/{net => }/protocolgamesend.cpp (99%) rename src/otclient/{core => }/shadermanager.cpp (100%) rename src/otclient/{core => }/shadermanager.h (100%) rename src/otclient/{core => }/spritemanager.cpp (100%) rename src/otclient/{core => }/spritemanager.h (100%) rename src/otclient/{core => }/statictext.cpp (100%) rename src/otclient/{core => }/statictext.h (100%) rename src/otclient/{core => }/thing.cpp (100%) rename src/otclient/{core => }/thing.h (99%) rename src/otclient/{core => }/thingstype.h (100%) rename src/otclient/{core => }/thingtypedat.cpp (100%) rename src/otclient/{core => }/thingtypedat.h (99%) rename src/otclient/{core => }/thingtypemanager.cpp (99%) rename src/otclient/{core => }/thingtypemanager.h (100%) rename src/otclient/{core => }/thingtypeotb.cpp (100%) rename src/otclient/{core => }/thingtypeotb.h (98%) rename src/otclient/{core => }/tile.cpp (99%) rename src/otclient/{core => }/tile.h (98%) rename src/otclient/{ui => }/uicreature.cpp (100%) rename src/otclient/{ui => }/uicreature.h (98%) rename src/otclient/{ui => }/uiitem.cpp (100%) rename src/otclient/{ui => }/uiitem.h (98%) rename src/otclient/{ui => }/uimap.cpp (97%) rename src/otclient/{ui => }/uimap.h (98%) rename src/otclient/{ui => }/uiprogressrect.cpp (100%) rename src/otclient/{ui => }/uiprogressrect.h (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b022c2e..8ae8892b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,46 +1,49 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(otclient) +cmake_minimum_required(VERSION 2.6) +project(otclient) -ADD_DEFINITIONS(-DFW_WINDOW) - -INCLUDE(src/framework/CMakeLists.txt) -INCLUDE(src/otclient/CMakeLists.txt) +set(FRAMEWORK_SOUND ON) +set(FRAMEWORK_GRAPHICS ON) +set(FRAMEWORK_XML ON) +set(FRAMEWORK_NET ON) +include(src/framework/CMakeLists.txt) +include(src/otclient/CMakeLists.txt) # functions map for reading backtraces -SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-Map=otclient.map") +set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-Map=otclient.map") -OPTION(USE_PCH "Use precompiled header (speed up compile)" OFF) +option(USE_PCH "Use precompiled header (speed up compile)" OFF) -SET(executable_SOURCES +set(executable_SOURCES src/main.cpp ) # add executable icon for win32 platforms -IF(WIN32) - ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o +if(WIN32) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o COMMAND ${CMAKE_RC_COMPILER} -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) -ENDIF(WIN32) +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) +if(USE_PCH) include(cotire) cotire(otclient) - MESSAGE(STATUS "Use precompiled header: ON") -ELSE() - MESSAGE(STATUS "Use precompiled header: OFF") -ENDIF() + message(STATUS "Use precompiled header: ON") +else() + message(STATUS "Use precompiled header: OFF") +endif() # installation -SET(DATA_INSTALL_DIR share/otclient) -INSTALL(TARGETS otclient RUNTIME DESTINATION bin) -INSTALL(DIRECTORY modules DESTINATION ${DATA_INSTALL_DIR} +set(DATA_INSTALL_DIR share/otclient) +install(TARGETS otclient RUNTIME DESTINATION bin) +install(FILES README.md BUGS LICENSE AUTHORS init.lua DESTINATION ${DATA_INSTALL_DIR}) +install(DIRECTORY modules DESTINATION ${DATA_INSTALL_DIR} PATTERN ".git" EXCLUDE) diff --git a/modules/game_bugreport/bugreport.otui b/modules/game_bugreport/bugreport.otui index f61fbede..0f2f45c9 100644 --- a/modules/game_bugreport/bugreport.otui +++ b/modules/game_bugreport/bugreport.otui @@ -1,7 +1,6 @@ BugReportWindow < MainWindow !text: tr('Report Bug') size: 280 250 - &onEnter: BugReport.doReport @onEscape: self:hide() Label diff --git a/modules/game_minimap/zoomin.png b/modules/game_minimap/zoomin.png new file mode 100644 index 0000000000000000000000000000000000000000..cca4c635c0325115178291f84885812723f2a3b7 GIT binary patch literal 836 zcmV-K1H1f*P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L02U;N(TQ-*45CfGJ_>#6n zuM%DCf3O!zPz1eQLLCDI_{2c?NU?o`1U;WoGxlM zOCt7rbmgFXQMev{$laMFJMfk2i2-ef1WPGz|Ka zlbACO0`RzWVvF;^vFPn?pO`SyyJkalx7X!I$XiwQI}86xD~4WK6a_q7?Rmy<>J6*P z7V*dUG$1H1TWY)*db;_}ot{&b>();LXi8{%qp?H~&EU_sSxV-6Y3m%Ir(C&mZ}C-*NORiHb0r%8STt2tdmnEZf1HviX)~ zEC*eiTbBsE|8?4|49#JtZ}bpEi`?_ZX}y@sJ!HwS}^~KRZy)Z-bBS{qjR;q$sh($I$pR z4K*?L9J>xcLv1-qDWVHpIJU);zPnSe#>Y?236jrWcx6-FR!?4D9;vj$gp~`DMsb0L zZOzcxahd#l!|uIxd&)F3o7*m2ygfV0Rhn*Gh_7B743~stf!7VddvlVJDm=y8=L$vfs9>u2d>@dTeZLuyjeOuOQ&# z$CYu;wVWON0`NWU-qTPCT#rP;zU9lyxpAZ8-Twl7f~*0~2q6{%zkUEEqbENdxR%5K O0000Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L02U~0nfp%gY76No0UscTu882 zt{@e)h!_43C141M^)e7r=&j;~sG&&dRgE=Da?yMgs-i~Gx>3=rH6Ny;t9z1|bM{Ox z(ruzqN}rnkT94_z{qAcj{ z>B=HhZ+%lbR+~(y>bMQS%=01-ALYIKw=Wma-oeg}!~LrS-925cRycNUYuheMnI>cT zd7MQb0ayWprVlH?cNre+o11eA`&LSfP&g1psG-*E-pVHh&G=K7s+dJ(I7q|_pp?PA z>DPduc|(KwVEm7rqocnb&urQH8bE3x+v}UsaiqzgFG|#`4HF3|tbl=O2&53iZIcJH zE=ZI5rgTgTd8m8>rG?s7n@p%{6Ap>BHmCY-AO!dtvq<2Hr+&lvb+j316BTo@7-8e-#`M>ejykp}m28{_&@&h6eS_DUr>r zM@oTQAy|43&88ZQySbbvv^ThX1?_*IyZQTb-&-WT&L$dCL_>;5$Rui+OKV86IT^83B5G&p5?m@k{a6 zXNpQ`v>T?m&G)<(07I!U&vgeTCnrx#O-<$M*45dOn9au@r8s@&RPGJIf3g3-*BRhK xZEezSY;5M@#r~K7OYo26GvK5U;sfBDzX2Ps9TYPxDvSUC002ovPDHLkV1kK8dCmX; literal 0 HcmV?d00001 diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 7f06cdb8..81696bee 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -1,173 +1,54 @@ +# framework flags +# FRAMEWORK_SOUND +# FRAMEWORK_GRAPHICS +# FRAMEWORK_NET +# FRAMEWORK_XML + # CMAKE_CURRENT_LIST_DIR cmake 2.6 compatiblity -IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) - GET_FILENAME_COMPONENT(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) +if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) + get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +endif(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) # add framework cmake modules -SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}") - -ADD_DEFINITIONS(-DFRAMEWORK) -OPTION(CRASH_HANDLER "Generate crash reports" ON) -OPTION(LUAJIT "Use lua jit" OFF) -OPTION(USE_STATIC_LIBS "Don't use shared libraries (dlls)" ON) - -SET(OPENGLES "OFF" CACHE "Use OpenGL ES 1.0 or 2.0 (for mobiles devices)" STRING) -SET(BUILD_COMMIT "custom" CACHE "Git commit string (intended for releases)" STRING) -SET(BUILD_REVISION "0" CACHE "Git revision string (intended for releases)" STRING) - -IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "RelWithDebInfo") -ENDIF() - -##IF(CMAKE_SIZEOF_VOID_P EQUAL 8) -## SET(ARCH_FLAGS "-m64 -march=x86-64 -mtune=generic") -##ELSE() -## SET(ARCH_FLAGS "-m32 -march=i686 -mtune=generic") -##ENDIF() - -SET(WARNS_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNS_FLAGS} ${ARCH_FLAGS} -std=gnu++0x -pipe") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -ggdb -fno-omit-frame-pointer") -SET(CMAKE_CXX_FLAGS_RELEASE "-O2") -SET(CMAKE_CXX_FLAGS_PERFORMANCE "-Ofast -mmxx -msee -msee2") -SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") - -IF(USE_STATIC_LIBS) - SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++") - MESSAGE(STATUS "Link to static libraries: ON") -ELSE() - MESSAGE(STATUS "Link to static libraries: OFF") -ENDIF() - -MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) -ADD_DEFINITIONS(-D"BUILD_TYPE=\\\"${CMAKE_BUILD_TYPE}\\\"") - -MESSAGE(STATUS "Build commit: ${BUILD_COMMIT}") -ADD_DEFINITIONS(-D"BUILD_COMMIT=\\\"${BUILD_COMMIT}\\\"") - -MESSAGE(STATUS "Build revision: ${BUILD_REVISION}") -ADD_DEFINITIONS(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"") - -# find needed libraries -IF(WIN32) - SET(Boost_THREADAPI win32) -ENDIF() -SET(Boost_USE_MULTITHREADED ON) -SET(Boost_USE_STATIC_LIBS ON) -FIND_PACKAGE(Boost COMPONENTS system REQUIRED) - -IF(OPENGLES STREQUAL "2.0") - FIND_PACKAGE(OpenGLES2 REQUIRED) - FIND_PACKAGE(EGL REQUIRED) - ADD_DEFINITIONS(-DOPENGL_ES=2) - SET(OPENGL_INCLUDE_DIR ${EGL_INCLUDE_DIR} ${OPENGLES2_INCLUDE_DIR}) - SET(OPENGL_LIBRARIES ${EGL_LIBRARY} ${OPENGLES2_LIBRARY}) -ELSEIF(OPENGLES STREQUAL "1.0") - FIND_PACKAGE(OpenGLES1 REQUIRED) - FIND_PACKAGE(EGL REQUIRED) - ADD_DEFINITIONS(-DOPENGL_ES=1) - SET(OPENGL_INCLUDE_DIR ${EGL_INCLUDE_DIR} ${OPENGLES1_INCLUDE_DIR}) - SET(OPENGL_LIBRARIES ${EGL_LIBRARY} ${OPENGLES1_LIBRARY}) -ELSE() - FIND_PACKAGE(OpenGL REQUIRED) - FIND_PACKAGE(GLEW REQUIRED) - SET(OPENGL_LIBRARIES ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) -ENDIF() -MESSAGE(STATUS "OpenGL ES: " ${OPENGLES}) - -IF(LUAJIT) - FIND_PACKAGE(LuaJIT REQUIRED) - SET(LUA_INCLUDE_DIR ${LUAJIT_INCLUDE_DIR}) - SET(LUA_LIBRARY ${LUAJIT_LIBRARY}) -ELSE() - FIND_PACKAGE(Lua REQUIRED) -ENDIF() -MESSAGE(STATUS "LuaJIT: " ${LUAJIT}) - -FIND_PACKAGE(PhysFS REQUIRED) -FIND_PACKAGE(GMP REQUIRED) -FIND_PACKAGE(ZLIB REQUIRED) -FIND_PACKAGE(OpenAL REQUIRED) -FIND_PACKAGE(VorbisFile REQUIRED) -FIND_PACKAGE(Vorbis REQUIRED) -FIND_PACKAGE(Ogg REQUIRED) - -IF(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - MESSAGE(STATUS "Debug information: ON") - ADD_DEFINITIONS(-DDEBUG) -ELSE() - MESSAGE(STATUS "Debug information: OFF") - - # NDEBUG disable asserts - ADD_DEFINITIONS(-DNDEBUG) - - # strip all debug information - SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--as-needed -Wl,-s") -ENDIF() - -IF(CRASH_HANDLER) - ADD_DEFINITIONS(-DCRASH_HANDLER) - MESSAGE(STATUS "Crash handler: ON") -ELSE() - MESSAGE(STATUS "Crash handler: OFF") -ENDIF() - -IF(WIN32) - OPTION(WINDOWS_CONSOLE "Enables console window on Windows platform" OFF) - - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads") - ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501) - SET(ADDITIONAL_LIBRARIES ws2_32 mswsock imagehlp winmm) - - # fix boost thread linkage - ADD_DEFINITIONS(-DBOOST_THREAD_USE_LIB) - - IF(WINDOWS_CONSOLE) - MESSAGE(STATUS "Windows console: ON") - ELSE() - SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -mwindows") - MESSAGE(STATUS "Windows console: OFF") - ENDIF() -ELSE() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") - SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic") - SET(ADDITIONAL_LIBRARIES X11 dl rt) -ENDIF() - - -INCLUDE_DIRECTORIES( - ${Boost_INCLUDE_DIRS} - ${OPENGL_INCLUDE_DIR} - ${OPENAL_INCLUDE_DIR} ${VORBISFILE_INCLUDE_DIR} - ${LUA_INCLUDE_DIR} - ${PHYSFS_INCLUDE_DIR} - ${GMP_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR} - "${CMAKE_CURRENT_LIST_DIR}/.." -) - -SET(framework_LIBRARIES - ${Boost_LIBRARIES} - ${LUA_LIBRARY} - ${PHYSFS_LIBRARY} - ${GMP_LIBRARY} - ${ZLIB_LIBRARY} - ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY} - ${OPENGL_LIBRARIES} - ${OPENAL_LIBRARY} - ${ADDITIONAL_LIBRARIES} -) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}") -SET(framework_SOURCES ${framework_SOURCES} - ${CMAKE_CURRENT_LIST_DIR}/application.cpp - ${CMAKE_CURRENT_LIST_DIR}/application.h +set(framework_LIBRARIES "") +set(framework_DEFINITIONS "") +set(framework_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/..") +set(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/const.h ${CMAKE_CURRENT_LIST_DIR}/global.h ${CMAKE_CURRENT_LIST_DIR}/pch.h ${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp + ${CMAKE_CURRENT_LIST_DIR}/util/boolean.h + ${CMAKE_CURRENT_LIST_DIR}/util/color.cpp + ${CMAKE_CURRENT_LIST_DIR}/util/color.h + ${CMAKE_CURRENT_LIST_DIR}/util/crypt.cpp + ${CMAKE_CURRENT_LIST_DIR}/util/crypt.h + ${CMAKE_CURRENT_LIST_DIR}/util/databuffer.h + ${CMAKE_CURRENT_LIST_DIR}/util/matrix.h + ${CMAKE_CURRENT_LIST_DIR}/util/point.h + ${CMAKE_CURRENT_LIST_DIR}/util/rect.h + ${CMAKE_CURRENT_LIST_DIR}/util/rsa.cpp + ${CMAKE_CURRENT_LIST_DIR}/util/rsa.h + ${CMAKE_CURRENT_LIST_DIR}/util/size.h + + # stdext + ${CMAKE_CURRENT_LIST_DIR}/stdext/cast.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/compiler.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/demangle.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/dumper.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/exception.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/math.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/stdext.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/string.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/time.h + ${CMAKE_CURRENT_LIST_DIR}/stdext/types.h + # core + ${CMAKE_CURRENT_LIST_DIR}/core/application.cpp + ${CMAKE_CURRENT_LIST_DIR}/core/application.h ${CMAKE_CURRENT_LIST_DIR}/core/adaptativeframecounter.cpp ${CMAKE_CURRENT_LIST_DIR}/core/adaptativeframecounter.h ${CMAKE_CURRENT_LIST_DIR}/core/binarytree.cpp @@ -197,84 +78,19 @@ SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/core/timer.cpp ${CMAKE_CURRENT_LIST_DIR}/core/timer.h - # graphics - ${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/cachedtext.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/cachedtext.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/coordsbuffer.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/coordsbuffer.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/bitmapfont.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/bitmapfont.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/fontmanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/fontmanager.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffer.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffer.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffermanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffermanager.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/glutil.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/graphics.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/graphics.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/hardwarebuffer.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/hardwarebuffer.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/image.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/image.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/painter.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/painter.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl1.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl1.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl2.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl2.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl2_shadersources.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/paintershaderprogram.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/paintershaderprogram.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/particleaffector.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/particleaffector.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/particle.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/particleemitter.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/particleemitter.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/particleeffect.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/particleeffect.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/particle.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/particlemanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/particlemanager.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/particlesystem.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/particlesystem.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/shader.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/shader.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/shaderprogram.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/shaderprogram.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/texture.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/texture.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.h - ${CMAKE_CURRENT_LIST_DIR}/graphics/vertexarray.h - - # luascript - ${CMAKE_CURRENT_LIST_DIR}/luascript/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/luascript/luabinder.h - ${CMAKE_CURRENT_LIST_DIR}/luascript/luaexception.cpp - ${CMAKE_CURRENT_LIST_DIR}/luascript/luaexception.h - ${CMAKE_CURRENT_LIST_DIR}/luascript/luainterface.cpp - ${CMAKE_CURRENT_LIST_DIR}/luascript/luainterface.h - ${CMAKE_CURRENT_LIST_DIR}/luascript/luaobject.cpp - ${CMAKE_CURRENT_LIST_DIR}/luascript/luaobject.h - ${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.cpp - ${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.h - - # net - ${CMAKE_CURRENT_LIST_DIR}/net/connection.cpp - ${CMAKE_CURRENT_LIST_DIR}/net/connection.h - ${CMAKE_CURRENT_LIST_DIR}/net/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/net/inputmessage.cpp - ${CMAKE_CURRENT_LIST_DIR}/net/inputmessage.h - ${CMAKE_CURRENT_LIST_DIR}/net/outputmessage.cpp - ${CMAKE_CURRENT_LIST_DIR}/net/outputmessage.h - ${CMAKE_CURRENT_LIST_DIR}/net/protocol.cpp - ${CMAKE_CURRENT_LIST_DIR}/net/protocol.h - ${CMAKE_CURRENT_LIST_DIR}/net/server.cpp - ${CMAKE_CURRENT_LIST_DIR}/net/server.h + # luaengine + ${CMAKE_CURRENT_LIST_DIR}/luaengine/declarations.h + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luabinder.h + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luaexception.cpp + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luaexception.h + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luainterface.cpp + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luainterface.h + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luaobject.cpp + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luaobject.h + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luavaluecasts.cpp + ${CMAKE_CURRENT_LIST_DIR}/luaengine/luavaluecasts.h + ${CMAKE_CURRENT_LIST_DIR}/luaengine/lbitlib.cpp + ${CMAKE_CURRENT_LIST_DIR}/luaengine/lbitlib.h # otml ${CMAKE_CURRENT_LIST_DIR}/otml/declarations.h @@ -290,100 +106,322 @@ SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/otml/otmlparser.cpp ${CMAKE_CURRENT_LIST_DIR}/otml/otmlparser.h - # platform + # crash handler ${CMAKE_CURRENT_LIST_DIR}/platform/crashhandler.h - ${CMAKE_CURRENT_LIST_DIR}/platform/platformwindow.cpp - ${CMAKE_CURRENT_LIST_DIR}/platform/platformwindow.h ${CMAKE_CURRENT_LIST_DIR}/platform/unixcrashhandler.cpp ${CMAKE_CURRENT_LIST_DIR}/platform/win32crashhandler.cpp - ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp - ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.h - ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp - ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.h - - # sound - ${CMAKE_CURRENT_LIST_DIR}/sound/combinedsoundsource.cpp - ${CMAKE_CURRENT_LIST_DIR}/sound/combinedsoundsource.h - ${CMAKE_CURRENT_LIST_DIR}/sound/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/sound/oggsoundfile.cpp - ${CMAKE_CURRENT_LIST_DIR}/sound/oggsoundfile.h - ${CMAKE_CURRENT_LIST_DIR}/sound/soundbuffer.cpp - ${CMAKE_CURRENT_LIST_DIR}/sound/soundbuffer.h - ${CMAKE_CURRENT_LIST_DIR}/sound/soundfile.cpp - ${CMAKE_CURRENT_LIST_DIR}/sound/soundfile.h - ${CMAKE_CURRENT_LIST_DIR}/sound/soundmanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/sound/soundmanager.h - ${CMAKE_CURRENT_LIST_DIR}/sound/soundsource.cpp - ${CMAKE_CURRENT_LIST_DIR}/sound/soundsource.h - ${CMAKE_CURRENT_LIST_DIR}/sound/streamsoundsource.cpp - ${CMAKE_CURRENT_LIST_DIR}/sound/streamsoundsource.h +) - # stdext - ${CMAKE_CURRENT_LIST_DIR}/stdext/cast.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/compiler.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/demangle.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/dumper.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/exception.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/math.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/stdext.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/string.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/time.h - ${CMAKE_CURRENT_LIST_DIR}/stdext/types.h +# some build options +option(CRASH_HANDLER "Generate crash reports" ON) +option(LUAJIT "Use lua jit" OFF) +option(USE_STATIC_LIBS "Don't use shared libraries (dlls)" ON) +set(BUILD_COMMIT "custom" CACHE "Git commit string (intended for releases)" STRING) +set(BUILD_REVISION "0" CACHE "Git revision string (intended for releases)" STRING) + +# default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "RelWithDebInfo") +endif() + +# gcc compile flags +set(WARNS_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNS_FLAGS} ${ARCH_FLAGS} -std=gnu++0x -pipe") +set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -ggdb -fno-omit-frame-pointer") +set(CMAKE_CXX_FLAGS_RELEASE "-O2") +set(CMAKE_CXX_FLAGS_PERFORMANCE "-Ofast -mmxx -msee -msee2") +set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") + +# process options +if(USE_STATIC_LIBS) + set(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++") + message(STATUS "Link to static libraries: ON") +else() + message(STATUS "Link to static libraries: OFF") +endif() + +message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) +add_definitions(-D"BUILD_TYPE=\\\"${CMAKE_BUILD_TYPE}\\\"") +message(STATUS "Build commit: ${BUILD_COMMIT}") +add_definitions(-D"BUILD_COMMIT=\\\"${BUILD_COMMIT}\\\"") +message(STATUS "Build revision: ${BUILD_REVISION}") +add_definitions(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"") + +# find boost +if(WIN32) + set(Boost_THREADAPI win32) +endif() +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_LIBS ON) +find_package(Boost COMPONENTS system REQUIRED) + +#find lua +if(LUAJIT) + find_package(LuaJIT REQUIRED) + set(LUA_INCLUDE_DIR ${LUAJIT_INCLUDE_DIR}) + set(LUA_LIBRARY ${LUAJIT_LIBRARY}) +else() + find_package(Lua REQUIRED) +endif() +message(STATUS "LuaJIT: " ${LUAJIT}) + +find_package(PhysFS REQUIRED) +find_package(GMP REQUIRED) +find_package(ZLIB REQUIRED) + +set(framework_LIBRARIES ${framework_LIBRARIES} + ${Boost_LIBRARIES} + ${LUA_LIBRARY} + ${PHYSFS_LIBRARY} + ${GMP_LIBRARY} + ${ZLIB_LIBRARY} +) - # third party - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/apngloader.cpp - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/apngloader.h - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/lbitlib-5.2.0-backport4.cpp - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/lbitlib-5.2.0-backport4.h - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/tinyxml.cpp - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/tinyxml.h - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/tinystr.cpp - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/tinystr.h - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/tinyxmlerror.cpp - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/tinyxmlparser.cpp - - # ui - ${CMAKE_CURRENT_LIST_DIR}/ui/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uianchorlayout.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uianchorlayout.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uiboxlayout.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiboxlayout.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uigridlayout.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uigridlayout.h - ${CMAKE_CURRENT_LIST_DIR}/ui/ui.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uihorizontallayout.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uihorizontallayout.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uilayout.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uilayout.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uimanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uimanager.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uiparticles.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiparticles.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uirichtext.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uirichtext.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uitextedit.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uitextedit.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uitranslator.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uitranslator.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uiverticallayout.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiverticallayout.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetbasestyle.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidget.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidget.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetimage.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgettext.cpp - - # util - ${CMAKE_CURRENT_LIST_DIR}/util/boolean.h - ${CMAKE_CURRENT_LIST_DIR}/util/color.cpp - ${CMAKE_CURRENT_LIST_DIR}/util/color.h - ${CMAKE_CURRENT_LIST_DIR}/util/crypt.cpp - ${CMAKE_CURRENT_LIST_DIR}/util/crypt.h - ${CMAKE_CURRENT_LIST_DIR}/util/databuffer.h - ${CMAKE_CURRENT_LIST_DIR}/util/matrix.h - ${CMAKE_CURRENT_LIST_DIR}/util/point.h - ${CMAKE_CURRENT_LIST_DIR}/util/rect.h - ${CMAKE_CURRENT_LIST_DIR}/util/rsa.cpp - ${CMAKE_CURRENT_LIST_DIR}/util/rsa.h - ${CMAKE_CURRENT_LIST_DIR}/util/size.h +set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${OPENGL_INCLUDE_DIR} + ${LUA_INCLUDE_DIR} + ${PHYSFS_INCLUDE_DIR} + ${GMP_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIR} ) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + message(STATUS "Debug information: ON") + add_definitions(-DDEBUG) +else() + message(STATUS "Debug information: OFF") + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DNDEBUG) # NDEBUG disable asserts + set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--as-needed -Wl,-s") # strip all debug information +endif() + +if(CRASH_HANDLER) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DCRASH_HANDLER) + message(STATUS "Crash handler: ON") + if(WIN32) + set(framework_LIBRARIES ${framework_LIBRARIES} imagehlp) + endif() +else() + message(STATUS "Crash handler: OFF") +endif() + +if(WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads") + set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_WIN32_WINNT=0x0501) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DBOOST_THREAD_USE_LIB) # fix boost thread linkage +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic") + set(framework_LIBRARIES ${framework_LIBRARIES} dl) +endif() + +if(FRAMEWORK_GRAPHICS) + set(OPENGLES "OFF" CACHE "Use OpenGL ES 1.0 or 2.0 (for mobiles devices)" STRING) + if(OPENGLES STREQUAL "2.0") + find_package(OpenGLES2 REQUIRED) + find_package(EGL REQUIRED) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DOPENGL_ES=2) + set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} ${EGL_INCLUDE_DIR} ${OPENGLES2_INCLUDE_DIR}) + set(framework_LIBRARIES ${framework_LIBRARIES} ${EGL_LIBRARY} ${OPENGLES2_LIBRARY}) + ELSEif(OPENGLES STREQUAL "1.0") + find_package(OpenGLES1 REQUIRED) + find_package(EGL REQUIRED) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DOPENGL_ES=1) + set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} ${EGL_INCLUDE_DIR} ${OPENGLES1_INCLUDE_DIR}) + set(framework_LIBRARIES ${framework_LIBRARIES} ${EGL_LIBRARY} ${OPENGLES1_LIBRARY}) + else() + find_package(OpenGL REQUIRED) + find_package(GLEW REQUIRED) + set(framework_LIBRARIES ${framework_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) + endif() + message(STATUS "OpenGL ES: " ${OPENGLES}) + + if(WIN32) + option(WINDOWS_CONSOLE "Enables console window on Windows platform" OFF) + if(WINDOWS_CONSOLE) + message(STATUS "Windows console: ON") + else() + set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -mwindows") + message(STATUS "Windows console: OFF") + endif() + else() + set(framework_LIBRARIES ${framework_LIBRARIES} X11) + endif() + + set(framework_SOURCES ${framework_SOURCES} + ${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/cachedtext.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/cachedtext.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/coordsbuffer.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/coordsbuffer.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/declarations.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/bitmapfont.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/bitmapfont.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/fontmanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/fontmanager.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffer.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffer.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffermanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffermanager.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/glutil.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/graphics.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/graphics.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/hardwarebuffer.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/hardwarebuffer.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/image.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/image.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/painter.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/painter.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl1.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl1.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl2.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl2.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/painterogl2_shadersources.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/paintershaderprogram.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/paintershaderprogram.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/particleaffector.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/particleaffector.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/particle.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/particleemitter.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/particleemitter.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/particleeffect.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/particleeffect.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/particle.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/particlemanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/particlemanager.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/particlesystem.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/particlesystem.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/shader.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/shader.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/shaderprogram.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/shaderprogram.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/texture.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/texture.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/vertexarray.h + ${CMAKE_CURRENT_LIST_DIR}/graphics/apngloader.cpp + ${CMAKE_CURRENT_LIST_DIR}/graphics/apngloader.h + + # ui + ${CMAKE_CURRENT_LIST_DIR}/ui/declarations.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uianchorlayout.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uianchorlayout.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uiboxlayout.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uiboxlayout.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uigridlayout.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uigridlayout.h + ${CMAKE_CURRENT_LIST_DIR}/ui/ui.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uihorizontallayout.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uihorizontallayout.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uilayout.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uilayout.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uimanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uimanager.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uiparticles.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uiparticles.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uirichtext.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uirichtext.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uitextedit.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uitextedit.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uitranslator.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uitranslator.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uiverticallayout.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uiverticallayout.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetbasestyle.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidget.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidget.h + ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetimage.cpp + ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgettext.cpp + + # platform window + ${CMAKE_CURRENT_LIST_DIR}/platform/platformwindow.cpp + ${CMAKE_CURRENT_LIST_DIR}/platform/platformwindow.h + ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp + ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.h + ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp + ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.h + + + ${CMAKE_CURRENT_LIST_DIR}/core/graphicalapplication.cpp + ${CMAKE_CURRENT_LIST_DIR}/core/graphicalapplication.h + ) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DFW_GRAPHICS) +else() + set(framework_SOURCES ${framework_SOURCES} + ${CMAKE_CURRENT_LIST_DIR}/core/consoleapplication.cpp + ${CMAKE_CURRENT_LIST_DIR}/core/consoleapplication.h + ) +endif() + +if(FRAMEWORK_SOUND) + find_package(OpenAL REQUIRED) + find_package(VorbisFile REQUIRED) + find_package(Vorbis REQUIRED) + find_package(Ogg REQUIRED) + + set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIR} ${VORBISFILE_INCLUDE_DIR}) + set(framework_LIBRARIES ${framework_LIBRARIES} ${OPENAL_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) + + if(WIN32) + set(framework_LIBRARIES ${framework_LIBRARIES} winmm) + else() + set(framework_LIBRARIES ${framework_LIBRARIES} rt) + endif() + + set(framework_SOURCES ${framework_SOURCES} + ${CMAKE_CURRENT_LIST_DIR}/sound/combinedsoundsource.cpp + ${CMAKE_CURRENT_LIST_DIR}/sound/combinedsoundsource.h + ${CMAKE_CURRENT_LIST_DIR}/sound/declarations.h + ${CMAKE_CURRENT_LIST_DIR}/sound/oggsoundfile.cpp + ${CMAKE_CURRENT_LIST_DIR}/sound/oggsoundfile.h + ${CMAKE_CURRENT_LIST_DIR}/sound/soundbuffer.cpp + ${CMAKE_CURRENT_LIST_DIR}/sound/soundbuffer.h + ${CMAKE_CURRENT_LIST_DIR}/sound/soundfile.cpp + ${CMAKE_CURRENT_LIST_DIR}/sound/soundfile.h + ${CMAKE_CURRENT_LIST_DIR}/sound/soundmanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/sound/soundmanager.h + ${CMAKE_CURRENT_LIST_DIR}/sound/soundsource.cpp + ${CMAKE_CURRENT_LIST_DIR}/sound/soundsource.h + ${CMAKE_CURRENT_LIST_DIR}/sound/streamsoundsource.cpp + ${CMAKE_CURRENT_LIST_DIR}/sound/streamsoundsource.h + ) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DFW_SOUND) +endif() + +if(FRAMEWORK_NET) + if(WIN32) + set(framework_LIBRARIES ${framework_LIBRARIES} ws2_32 mswsock) + endif() + set(framework_SOURCES ${framework_SOURCES} + ${CMAKE_CURRENT_LIST_DIR}/net/connection.cpp + ${CMAKE_CURRENT_LIST_DIR}/net/connection.h + ${CMAKE_CURRENT_LIST_DIR}/net/declarations.h + ${CMAKE_CURRENT_LIST_DIR}/net/inputmessage.cpp + ${CMAKE_CURRENT_LIST_DIR}/net/inputmessage.h + ${CMAKE_CURRENT_LIST_DIR}/net/outputmessage.cpp + ${CMAKE_CURRENT_LIST_DIR}/net/outputmessage.h + ${CMAKE_CURRENT_LIST_DIR}/net/protocol.cpp + ${CMAKE_CURRENT_LIST_DIR}/net/protocol.h + ${CMAKE_CURRENT_LIST_DIR}/net/server.cpp + ${CMAKE_CURRENT_LIST_DIR}/net/server.h + ) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DFW_NET) +endif() + +if(FRAMEWORK_XML) + set(framework_SOURCES ${framework_SOURCES} + ${CMAKE_CURRENT_LIST_DIR}/xml/tinyxml.cpp + ${CMAKE_CURRENT_LIST_DIR}/xml/tinyxml.h + ${CMAKE_CURRENT_LIST_DIR}/xml/tinystr.cpp + ${CMAKE_CURRENT_LIST_DIR}/xml/tinystr.h + ${CMAKE_CURRENT_LIST_DIR}/xml/tinyxmlerror.cpp + ${CMAKE_CURRENT_LIST_DIR}/xml/tinyxmlparser.cpp + ) + set(framework_DEFINITIONS ${framework_DEFINITIONS} -DFW_XML) +endif() + +include_directories(${framework_INCLUDE_DIRS}) +add_definitions(${framework_DEFINITIONS}) diff --git a/src/framework/core/application.cpp b/src/framework/core/application.cpp new file mode 100644 index 00000000..420f1408 --- /dev/null +++ b/src/framework/core/application.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2010-2012 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 "application.h" +#include +#include +#include +#include +#include +#include +#include + +#ifdef FW_NET +#include +#endif + +void exitSignalHandler(int sig) +{ + static bool signaled = false; + switch(sig) { + case SIGTERM: + case SIGINT: + if(!signaled) { + signaled = true; + g_dispatcher.addEvent(std::bind(&Application::close, &g_app)); + } + break; + } +} + +Application::Application() +{ + m_appName = "application"; + m_appCompactName = "app"; + m_appVersion = "none"; + m_stopping = false; +} + +void Application::init(const std::vector& args) +{ + // capture exit signals + signal(SIGTERM, exitSignalHandler); + signal(SIGINT, exitSignalHandler); + +#ifdef CRASH_HANDLER + installCrashHandler(); +#endif + + std::string startupOptions; + for(uint i=1;i 0) + g_logger.info(stdext::format("Startup options: %s", startupOptions)); + + m_startupOptions = startupOptions; + + // initialize resources + g_resources.init(args[0].c_str()); + + // initialize lua + g_lua.init(); + registerLuaFunctions(); +} + +void Application::deinit() +{ + g_lua.callGlobalField("g_app", "onTerminate"); + + // run modules unload events + g_modules.unloadModules(); + g_modules.clear(); + + // release remaining lua object references + g_lua.collectGarbage(); + + // poll remaining events + poll(); +} + +void Application::terminate() +{ +#ifdef FW_NET + // terminate network + Connection::terminate(); +#endif + + // save configurations + g_configs.save(); + + // release resources + g_resources.terminate(); + + // terminate script environment + g_lua.terminate(); + + // flush remaining dispatcher events + g_dispatcher.flush(); + + m_terminated = true; +} + +void Application::poll() +{ +#ifdef FW_NET + Connection::poll(); +#endif + + g_dispatcher.poll(); +} + +void Application::exit() +{ + g_logger.info("Exiting application.."); + m_stopping = true; +} + +void Application::close() +{ + if(!g_lua.callGlobalField("g_app", "onClose")) + exit(); +} diff --git a/src/framework/application.h b/src/framework/core/application.h similarity index 64% rename from src/framework/application.h rename to src/framework/core/application.h index d74909c0..082ced81 100644 --- a/src/framework/application.h +++ b/src/framework/core/application.h @@ -23,49 +23,35 @@ #ifndef APPLICATION_H #define APPLICATION_H -#include +#include #include -#include //@bindsingleton g_app class Application { - enum { - POLL_CYCLE_DELAY = 10 - }; - public: Application(); + virtual ~Application() {} - void init(const std::string& compactName, const std::vector& args); - void deinit(); - void terminate(); - void run(); - void exit(); - void poll(); - void close(); - - bool willRepaint() { return m_mustRepaint; } - void repaint() { m_mustRepaint = true; } + virtual void init(const std::vector& args); + virtual void deinit(); + virtual void terminate(); + virtual void run() = 0; + virtual void poll(); + virtual void exit(); + virtual void close(); - void setForegroundPaneMaxFps(int maxFps) { m_foregroundFrameCounter.setMaxFps(maxFps); } - void setBackgroundPaneMaxFps(int maxFps) { m_backgroundFrameCounter.setMaxFps(maxFps); } void setName(const std::string& name) { m_appName = name; } void setCompactName(const std::string& compactName) { m_appCompactName = compactName; } void setVersion(const std::string& version) { m_appVersion = version; } bool isRunning() { return m_running; } bool isStopping() { return m_stopping; } - bool isTermianted() { return m_terminated; } - bool isOnInputEvent() { return m_onInputEvent; } + bool isTerminated() { return m_terminated; } const std::string& getName() { return m_appName; } const std::string& getCompactName() { return m_appCompactName; } const std::string& getVersion() { return m_appVersion; } - int getForegroundPaneFps() { return m_foregroundFrameCounter.getLastFps(); } - int getBackgroundPaneFps() { return m_backgroundFrameCounter.getLastFps(); } - int getForegroundPaneMaxFps() { return m_foregroundFrameCounter.getMaxFps(); } - int getBackgroundPaneMaxFps() { return m_backgroundFrameCounter.getMaxFps(); } std::string getBuildCompiler() { return BUILD_COMPILER; } std::string getBuildDate() { return BUILD_DATE; } std::string getBuildRevision() { return BUILD_REVISION; } @@ -74,26 +60,21 @@ public: std::string getStartupOptions() { return m_startupOptions; } protected: - void resize(const Size& size); - void inputEvent(const InputEvent& event); void registerLuaFunctions(); std::string m_appName; std::string m_appCompactName; std::string m_appVersion; std::string m_startupOptions; - Boolean m_initialized; Boolean m_running; Boolean m_stopping; Boolean m_terminated; - Boolean m_onInputEvent; - Boolean m_mustRepaint; - AdaptativeFrameCounter m_backgroundFrameCounter; - AdaptativeFrameCounter m_foregroundFrameCounter; - TexturePtr m_foreground; }; -extern Application g_app; - +#ifdef FW_GRAPHICS +#include "graphicalapplication.h" +#else +#include "consoleapplication.h" #endif +#endif diff --git a/src/otclient/ui/declarations.h b/src/framework/core/consoleapplication.cpp similarity index 65% rename from src/otclient/ui/declarations.h rename to src/framework/core/consoleapplication.cpp index 342fb9b7..5e6c62d6 100644 --- a/src/otclient/ui/declarations.h +++ b/src/framework/core/consoleapplication.cpp @@ -20,20 +20,41 @@ * THE SOFTWARE. */ -#ifndef OTCLIENT_UI_DECLARATIONS_H -#define OTCLIENT_UI_DECLARATIONS_H -#include -#include +#include "consoleapplication.h" +#include +#include -class UIItem; -class UICreature; -class UIMap; -class UIProgressRect; +#ifdef FW_NET +#include +#endif + +ConsoleApplication g_app; + +void ConsoleApplication::run() +{ + m_running = true; + + // run the first poll + poll(); -typedef std::shared_ptr UIItemPtr; -typedef std::shared_ptr UICreaturePtr; -typedef std::shared_ptr UIMapPtr; -typedef std::shared_ptr UIProgressRectPtr; + // first clock update + g_clock.update(); + g_lua.callGlobalField("g_app", "onRun"); + + while(!m_stopping) { + poll(); + +#ifdef FW_NET + Connection::poll(); #endif + + stdext::millisleep(1); + g_clock.update(); + m_frameCounter.update(); + } + + m_stopping = false; + m_running = false; +} diff --git a/src/otclient/net/declarations.h b/src/framework/core/consoleapplication.h similarity index 78% rename from src/otclient/net/declarations.h rename to src/framework/core/consoleapplication.h index 1e7498f4..fee7c4c4 100644 --- a/src/otclient/net/declarations.h +++ b/src/framework/core/consoleapplication.h @@ -20,17 +20,23 @@ * THE SOFTWARE. */ -#ifndef OTCLIENT_NET_DECLARATIONS_H -#define OTCLIENT_NET_DECLARATIONS_H -#include -#include -#include "protocolcodes.h" +#ifndef CONSOLEAPPLICATION_H +#define CONSOLEAPPLICATION_H -class ProtocolLogin; -class ProtocolGame; +#include "application.h" -typedef std::shared_ptr ProtocolGamePtr; -typedef std::shared_ptr ProtocolLoginPtr; +class ConsoleApplication : public Application +{ +public: + void run(); + + int getFps() { return m_frameCounter.getLastFps(); } + +protected: + AdaptativeFrameCounter m_frameCounter; +}; + +extern ConsoleApplication g_app; #endif diff --git a/src/framework/core/event.h b/src/framework/core/event.h index 906274ba..18438b1f 100644 --- a/src/framework/core/event.h +++ b/src/framework/core/event.h @@ -23,7 +23,7 @@ #ifndef EVENT_H #define EVENT_H -#include +#include // @bindclass class Event : public LuaObject diff --git a/src/framework/core/filestream.cpp b/src/framework/core/filestream.cpp index 0d286e14..3e671405 100644 --- a/src/framework/core/filestream.cpp +++ b/src/framework/core/filestream.cpp @@ -22,7 +22,7 @@ #include "filestream.h" #include "binarytree.h" -#include +#include #include @@ -37,7 +37,7 @@ FileStream::FileStream(const std::string& name, PHYSFS_File *fileHandle, bool wr FileStream::~FileStream() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); close(); } diff --git a/src/framework/core/filestream.h b/src/framework/core/filestream.h index b55426f8..b4488c6d 100644 --- a/src/framework/core/filestream.h +++ b/src/framework/core/filestream.h @@ -24,7 +24,7 @@ #define FILESTREAM_H #include "declarations.h" -#include +#include #include struct PHYSFS_File; diff --git a/src/framework/application.cpp b/src/framework/core/graphicalapplication.cpp similarity index 66% rename from src/framework/application.cpp rename to src/framework/core/graphicalapplication.cpp index 0ae07a57..bb9f7500 100644 --- a/src/framework/application.cpp +++ b/src/framework/core/graphicalapplication.cpp @@ -20,174 +20,97 @@ * THE SOFTWARE. */ -#include "application.h" + +#include "graphicalapplication.h" #include -#include -#include #include -#include -#include #include #include -#include #include #include #include -#include -#include -#include - -Application g_app; - -void exitSignalHandler(int sig) -{ - static bool signaled = false; - switch(sig) { - case SIGTERM: - case SIGINT: - if(!signaled) { - signaled = true; - g_dispatcher.addEvent(std::bind(&Application::close, &g_app)); - } - break; - } -} - -Application::Application() -{ - m_appName = "application"; - m_appCompactName = "app"; - m_appVersion = "none"; - m_foregroundFrameCounter.setMaxFps(60); - m_stopping = false; -} - -void Application::init(const std::string& compactName, const std::vector& args) -{ - // capture exit signals - signal(SIGTERM, exitSignalHandler); - signal(SIGINT, exitSignalHandler); -#ifdef CRASH_HANDLER - installCrashHandler(); +#ifdef FW_SOUND +#include #endif - m_appCompactName = compactName; - - std::string startupOptions; - for(uint i=1;i 0) - g_logger.info(stdext::format("Startup options: %s", startupOptions)); - - m_startupOptions = startupOptions; +GraphicalApplication g_app; - // initialize resources - g_resources.init(args[0].c_str()); - - // initialize lua - g_lua.init(); - registerLuaFunctions(); - - // initialize ui - g_ui.init(); +void GraphicalApplication::init(const std::vector& args) +{ + Application::init(args); // setup platform window g_window.init(); g_window.hide(); - g_window.setOnResize(std::bind(&Application::resize, this, std::placeholders::_1)); - g_window.setOnInputEvent(std::bind(&Application::inputEvent, this, std::placeholders::_1)); - g_window.setOnClose(std::bind(&Application::close, this)); + g_window.setOnResize(std::bind(&GraphicalApplication::resize, this, std::placeholders::_1)); + g_window.setOnInputEvent(std::bind(&GraphicalApplication::inputEvent, this, std::placeholders::_1)); + g_window.setOnClose(std::bind(&GraphicalApplication::close, this)); + + // initialize ui + g_ui.init(); // initialize graphics g_graphics.init(); - // initialize sound - g_sounds.init(); - // fire first resize event resize(g_window.getSize()); - m_initialized = true; +#ifdef FW_SOUND + // initialize sound + g_sounds.init(); +#endif } -void Application::deinit() +void GraphicalApplication::deinit() { // hide the window because there is no render anymore g_window.hide(); - g_lua.callGlobalField("g_app", "onTerminate"); - - // run modules unload events - g_modules.unloadModules(); - g_modules.clear(); - - // release remaining lua object references - g_lua.collectGarbage(); - - // poll remaining events - poll(); + Application::deinit(); } -void Application::terminate() +void GraphicalApplication::terminate() { - assert(m_initialized); - // destroy particles g_particles.terminate(); // destroy any remaining widget g_ui.terminate(); - // terminate network - Connection::terminate(); - +#ifdef FW_SOUND // terminate sound g_sounds.terminate(); +#endif - // save configurations - g_configs.save(); - - // release resources - g_resources.terminate(); - - // terminate script environment - g_lua.terminate(); - - // flush remaining dispatcher events - g_dispatcher.flush(); + Application::terminate(); + m_terminated = false; // terminate graphics m_foreground = nullptr; g_graphics.terminate(); g_window.terminate(); - g_logger.debug("Application ended successfully."); m_terminated = true; } -void Application::run() +void GraphicalApplication::run() { - assert(m_initialized); - m_running = true; + // first clock update + g_clock.update(); + // run the first poll poll(); + g_clock.update(); g_lua.callGlobalField("g_app", "onRun"); - // first clock update - g_clock.update(); - // show the application only after we draw some frames g_dispatcher.scheduleEvent([] { g_window.show(); }, 10); - while(!m_stopping) { // poll all events before rendering poll(); @@ -269,33 +192,27 @@ void Application::run() m_running = false; } -void Application::exit() -{ - g_logger.info("Exiting application.."); - m_stopping = true; -} - -void Application::poll() +void GraphicalApplication::poll() { +#ifdef FW_SOUND g_sounds.poll(); +#endif - // poll input events + // poll window input events g_window.poll(); - //g_particles.update(); + g_particles.update(); - Connection::poll(); - g_dispatcher.poll(); + Application::poll(); } -void Application::close() +void GraphicalApplication::close() { m_onInputEvent = true; - if(!g_lua.callGlobalField("g_app", "onClose")) - exit(); + Application::close(); m_onInputEvent = false; } -void Application::resize(const Size& size) +void GraphicalApplication::resize(const Size& size) { m_onInputEvent = true; g_graphics.resize(size); @@ -309,7 +226,7 @@ void Application::resize(const Size& size) m_mustRepaint = true; } -void Application::inputEvent(const InputEvent& event) +void GraphicalApplication::inputEvent(const InputEvent& event) { m_onInputEvent = true; g_ui.inputEvent(event); diff --git a/src/framework/core/graphicalapplication.h b/src/framework/core/graphicalapplication.h new file mode 100644 index 00000000..683e7001 --- /dev/null +++ b/src/framework/core/graphicalapplication.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2010-2012 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 GRAPHICALAPPLICATION_H +#define GRAPHICALAPPLICATION_H + +#include "application.h" +#include +#include + +class GraphicalApplication : public Application +{ + enum { + POLL_CYCLE_DELAY = 10 + }; + +public: + void init(const std::vector< std::string >& args); + void deinit(); + void terminate(); + void run(); + void poll(); + void close(); + + bool willRepaint() { return m_mustRepaint; } + void repaint() { m_mustRepaint = true; } + + void setForegroundPaneMaxFps(int maxFps) { m_foregroundFrameCounter.setMaxFps(maxFps); } + void setBackgroundPaneMaxFps(int maxFps) { m_backgroundFrameCounter.setMaxFps(maxFps); } + + int getForegroundPaneFps() { return m_foregroundFrameCounter.getLastFps(); } + int getBackgroundPaneFps() { return m_backgroundFrameCounter.getLastFps(); } + int getForegroundPaneMaxFps() { return m_foregroundFrameCounter.getMaxFps(); } + int getBackgroundPaneMaxFps() { return m_backgroundFrameCounter.getMaxFps(); } + + bool isOnInputEvent() { return m_onInputEvent; } + +protected: + void resize(const Size& size); + void inputEvent(const InputEvent& event); + +private: + Boolean m_onInputEvent; + Boolean m_mustRepaint; + AdaptativeFrameCounter m_backgroundFrameCounter; + AdaptativeFrameCounter m_foregroundFrameCounter; + TexturePtr m_foreground; +}; + +extern GraphicalApplication g_app; + +#endif diff --git a/src/framework/core/logger.cpp b/src/framework/core/logger.cpp index 02e9b806..77f30422 100644 --- a/src/framework/core/logger.cpp +++ b/src/framework/core/logger.cpp @@ -22,7 +22,10 @@ #include "logger.h" #include "eventdispatcher.h" + +#ifdef FW_GRAPHICS #include +#endif Logger g_logger; @@ -61,7 +64,7 @@ void Logger::log(Fw::LogLevel level, const std::string& message) } if(level == Fw::LogFatal) { -#ifdef FW_WINDOW +#ifdef FW_GRAPHICS g_window.displayFatalError(message); #endif ignoreLogs = true; diff --git a/src/framework/core/module.cpp b/src/framework/core/module.cpp index d9126226..fb4f1a09 100644 --- a/src/framework/core/module.cpp +++ b/src/framework/core/module.cpp @@ -24,7 +24,7 @@ #include "modulemanager.h" #include -#include +#include Module::Module(const std::string& name) { diff --git a/src/framework/core/module.h b/src/framework/core/module.h index 0fdc1b30..6d6cf27c 100644 --- a/src/framework/core/module.h +++ b/src/framework/core/module.h @@ -26,7 +26,7 @@ #include "declarations.h" #include -#include +#include // @bindclass class Module : public LuaObject diff --git a/src/framework/core/modulemanager.cpp b/src/framework/core/modulemanager.cpp index df30c45d..c07ebbf8 100644 --- a/src/framework/core/modulemanager.cpp +++ b/src/framework/core/modulemanager.cpp @@ -24,7 +24,7 @@ #include "resourcemanager.h" #include -#include +#include ModuleManager g_modules; diff --git a/src/framework/core/resourcemanager.cpp b/src/framework/core/resourcemanager.cpp index ad508824..a17e46ef 100644 --- a/src/framework/core/resourcemanager.cpp +++ b/src/framework/core/resourcemanager.cpp @@ -23,8 +23,8 @@ #include "resourcemanager.h" #include "filestream.h" -#include -#include +#include +#include #include diff --git a/src/framework/thirdparty/apngloader.cpp b/src/framework/graphics/apngloader.cpp similarity index 100% rename from src/framework/thirdparty/apngloader.cpp rename to src/framework/graphics/apngloader.cpp diff --git a/src/framework/thirdparty/apngloader.h b/src/framework/graphics/apngloader.h similarity index 100% rename from src/framework/thirdparty/apngloader.h rename to src/framework/graphics/apngloader.h diff --git a/src/framework/graphics/framebuffer.cpp b/src/framework/graphics/framebuffer.cpp index 745b9e66..5fdb09bc 100644 --- a/src/framework/graphics/framebuffer.cpp +++ b/src/framework/graphics/framebuffer.cpp @@ -25,7 +25,7 @@ #include "texture.h" #include -#include +#include uint FrameBuffer::boundFbo = 0; @@ -47,7 +47,7 @@ void FrameBuffer::internalCreate() FrameBuffer::~FrameBuffer() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); if(g_graphics.ok() && m_fbo != 0) glDeleteFramebuffers(1, &m_fbo); } diff --git a/src/framework/graphics/hardwarebuffer.cpp b/src/framework/graphics/hardwarebuffer.cpp index 9c10d12a..15004654 100644 --- a/src/framework/graphics/hardwarebuffer.cpp +++ b/src/framework/graphics/hardwarebuffer.cpp @@ -23,7 +23,7 @@ #include "hardwarebuffer.h" #include "graphics.h" -#include +#include #include HardwareBuffer::HardwareBuffer(Type type) @@ -37,7 +37,7 @@ HardwareBuffer::HardwareBuffer(Type type) HardwareBuffer::~HardwareBuffer() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); if(g_graphics.ok()) glDeleteBuffers(1, &m_id); } diff --git a/src/framework/graphics/image.cpp b/src/framework/graphics/image.cpp index 5a95781c..dd9f3e1d 100644 --- a/src/framework/graphics/image.cpp +++ b/src/framework/graphics/image.cpp @@ -24,7 +24,7 @@ #include "image.h" #include -#include +#include Image::Image(const Size& size, int bpp, uint8 *pixels) { diff --git a/src/framework/graphics/particleeffect.h b/src/framework/graphics/particleeffect.h index 6d00434e..fbb4f796 100644 --- a/src/framework/graphics/particleeffect.h +++ b/src/framework/graphics/particleeffect.h @@ -25,7 +25,7 @@ #include "declarations.h" #include "particlesystem.h" -#include +#include #include class ParticleEffectType : public LuaObject diff --git a/src/framework/graphics/shader.cpp b/src/framework/graphics/shader.cpp index 00554296..7a0742f3 100644 --- a/src/framework/graphics/shader.cpp +++ b/src/framework/graphics/shader.cpp @@ -23,7 +23,7 @@ #include "shader.h" #include "graphics.h" -#include +#include #include Shader::Shader(Shader::ShaderType shaderType) @@ -44,7 +44,7 @@ Shader::Shader(Shader::ShaderType shaderType) Shader::~Shader() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); if(g_graphics.ok()) glDeleteShader(m_shaderId); } diff --git a/src/framework/graphics/shaderprogram.cpp b/src/framework/graphics/shaderprogram.cpp index f9841d70..9394632e 100644 --- a/src/framework/graphics/shaderprogram.cpp +++ b/src/framework/graphics/shaderprogram.cpp @@ -23,7 +23,7 @@ #include "shaderprogram.h" #include "graphics.h" -#include +#include uint ShaderProgram::m_currentProgram = 0; @@ -38,7 +38,7 @@ ShaderProgram::ShaderProgram() ShaderProgram::~ShaderProgram() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); if(g_graphics.ok()) glDeleteProgram(m_programId); } diff --git a/src/framework/graphics/shaderprogram.h b/src/framework/graphics/shaderprogram.h index ac875549..47521d1d 100644 --- a/src/framework/graphics/shaderprogram.h +++ b/src/framework/graphics/shaderprogram.h @@ -24,7 +24,7 @@ #define SHADERPROGRAM_H #include "shader.h" -#include +#include // @bindclass class ShaderProgram : public LuaObject diff --git a/src/framework/graphics/texture.cpp b/src/framework/graphics/texture.cpp index c1b33d39..edfe711f 100644 --- a/src/framework/graphics/texture.cpp +++ b/src/framework/graphics/texture.cpp @@ -25,7 +25,7 @@ #include "framebuffer.h" #include "image.h" -#include +#include Texture::Texture() { @@ -79,7 +79,7 @@ Texture::Texture(const ImagePtr& image, bool buildMipmaps) Texture::~Texture() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); // free texture from gl memory if(g_graphics.ok() && m_id != 0) glDeleteTextures(1, &m_id); diff --git a/src/framework/graphics/texturemanager.cpp b/src/framework/graphics/texturemanager.cpp index d48b6c75..13bc7c9b 100644 --- a/src/framework/graphics/texturemanager.cpp +++ b/src/framework/graphics/texturemanager.cpp @@ -26,7 +26,7 @@ #include "image.h" #include -#include +#include TextureManager g_textures; diff --git a/src/framework/luascript/declarations.h b/src/framework/luaengine/declarations.h similarity index 100% rename from src/framework/luascript/declarations.h rename to src/framework/luaengine/declarations.h diff --git a/src/framework/thirdparty/lbitlib-5.2.0-backport4.cpp b/src/framework/luaengine/lbitlib.cpp similarity index 100% rename from src/framework/thirdparty/lbitlib-5.2.0-backport4.cpp rename to src/framework/luaengine/lbitlib.cpp diff --git a/src/framework/thirdparty/lbitlib-5.2.0-backport4.h b/src/framework/luaengine/lbitlib.h similarity index 100% rename from src/framework/thirdparty/lbitlib-5.2.0-backport4.h rename to src/framework/luaengine/lbitlib.h diff --git a/src/framework/luascript/luabinder.h b/src/framework/luaengine/luabinder.h similarity index 100% rename from src/framework/luascript/luabinder.h rename to src/framework/luaengine/luabinder.h diff --git a/src/framework/luascript/luaexception.cpp b/src/framework/luaengine/luaexception.cpp similarity index 100% rename from src/framework/luascript/luaexception.cpp rename to src/framework/luaengine/luaexception.cpp diff --git a/src/framework/luascript/luaexception.h b/src/framework/luaengine/luaexception.h similarity index 100% rename from src/framework/luascript/luaexception.h rename to src/framework/luaengine/luaexception.h diff --git a/src/framework/luascript/luainterface.cpp b/src/framework/luaengine/luainterface.cpp similarity index 99% rename from src/framework/luascript/luainterface.cpp rename to src/framework/luaengine/luainterface.cpp index f5539383..e91079e5 100644 --- a/src/framework/luascript/luainterface.cpp +++ b/src/framework/luaengine/luainterface.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include "lbitlib.h" LuaInterface g_lua; diff --git a/src/framework/luascript/luainterface.h b/src/framework/luaengine/luainterface.h similarity index 100% rename from src/framework/luascript/luainterface.h rename to src/framework/luaengine/luainterface.h diff --git a/src/framework/luascript/luaobject.cpp b/src/framework/luaengine/luaobject.cpp similarity index 97% rename from src/framework/luascript/luaobject.cpp rename to src/framework/luaengine/luaobject.cpp index 0ea34fe4..c43190a9 100644 --- a/src/framework/luascript/luaobject.cpp +++ b/src/framework/luaengine/luaobject.cpp @@ -23,7 +23,7 @@ #include "luaobject.h" #include "luainterface.h" -#include +#include LuaObject::LuaObject() : m_fieldsTableRef(-1), @@ -33,7 +33,7 @@ LuaObject::LuaObject() : LuaObject::~LuaObject() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); releaseLuaFieldsTable(); if(m_metatableRef != -1) { diff --git a/src/framework/luascript/luaobject.h b/src/framework/luaengine/luaobject.h similarity index 100% rename from src/framework/luascript/luaobject.h rename to src/framework/luaengine/luaobject.h diff --git a/src/framework/luascript/luavaluecasts.cpp b/src/framework/luaengine/luavaluecasts.cpp similarity index 100% rename from src/framework/luascript/luavaluecasts.cpp rename to src/framework/luaengine/luavaluecasts.cpp diff --git a/src/framework/luascript/luavaluecasts.h b/src/framework/luaengine/luavaluecasts.h similarity index 100% rename from src/framework/luascript/luavaluecasts.h rename to src/framework/luaengine/luavaluecasts.h diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index a425c78f..22ca9763 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -20,8 +20,8 @@ * THE SOFTWARE. */ -#include "application.h" -#include +#include +#include #include #include #include @@ -50,15 +50,103 @@ void Application::registerLuaFunctions() g_lua.bindGlobalFunction("sizetostring", [](const Size& v) { return stdext::to_string(v); }); g_lua.bindGlobalFunction("iptostring", [](int v) { return stdext::ip_to_string(v); }); + // Application + g_lua.registerSingletonClass("g_app"); + g_lua.bindSingletonFunction("g_app", "setName", &Application::setName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "setCompactName", &Application::setCompactName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "setVersion", &Application::setVersion, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "isRunning", &Application::isRunning, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "isStopping", &Application::isStopping, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getName", &Application::getName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getCompactName", &Application::getCompactName, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getVersion", &Application::getVersion, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildCompiler", &Application::getBuildCompiler, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildDate", &Application::getBuildDate, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildRevision", &Application::getBuildRevision, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildCommit", &Application::getBuildCommit, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "getBuildType", &Application::getBuildType, static_cast(&g_app)); + g_lua.bindSingletonFunction("g_app", "exit", &Application::exit, static_cast(&g_app)); + + // Crypt g_lua.registerSingletonClass("g_crypt"); g_lua.bindClassStaticFunction("g_crypt", "encrypt", Crypt::encrypt); g_lua.bindClassStaticFunction("g_crypt", "decrypt", Crypt::decrypt); + // Clock g_lua.registerSingletonClass("g_clock"); g_lua.bindSingletonFunction("g_clock", "micros", &Clock::micros, &g_clock); g_lua.bindSingletonFunction("g_clock", "millis", &Clock::millis, &g_clock); g_lua.bindSingletonFunction("g_clock", "seconds", &Clock::seconds, &g_clock); + // ConfigManager + g_lua.registerSingletonClass("g_configs"); + g_lua.bindSingletonFunction("g_configs", "load", &ConfigManager::load, &g_configs); + g_lua.bindSingletonFunction("g_configs", "save", &ConfigManager::save, &g_configs); + g_lua.bindSingletonFunction("g_configs", "set", &ConfigManager::set, &g_configs); + g_lua.bindSingletonFunction("g_configs", "setList", &ConfigManager::setList, &g_configs); + g_lua.bindSingletonFunction("g_configs", "get", &ConfigManager::get, &g_configs); + g_lua.bindSingletonFunction("g_configs", "getList", &ConfigManager::getList, &g_configs); + g_lua.bindSingletonFunction("g_configs", "exists", &ConfigManager::exists, &g_configs); + g_lua.bindSingletonFunction("g_configs", "remove", &ConfigManager::remove, &g_configs); + g_lua.bindSingletonFunction("g_configs", "setNode", &ConfigManager::setNode, &g_configs); + g_lua.bindSingletonFunction("g_configs", "mergeNode", &ConfigManager::mergeNode, &g_configs); + g_lua.bindSingletonFunction("g_configs", "getNode", &ConfigManager::getNode, &g_configs); + + // Logger + g_lua.registerSingletonClass("g_logger"); + g_lua.bindSingletonFunction("g_logger", "log", &Logger::log, &g_logger); + g_lua.bindSingletonFunction("g_logger", "fireOldMessages", &Logger::fireOldMessages, &g_logger); + g_lua.bindSingletonFunction("g_logger", "setLogFile", &Logger::setLogFile, &g_logger); + g_lua.bindSingletonFunction("g_logger", "setOnLog", &Logger::setOnLog, &g_logger); + g_lua.bindSingletonFunction("g_logger", "debug", &Logger::debug, &g_logger); + g_lua.bindSingletonFunction("g_logger", "info", &Logger::info, &g_logger); + g_lua.bindSingletonFunction("g_logger", "warning", &Logger::warning, &g_logger); + g_lua.bindSingletonFunction("g_logger", "error", &Logger::error, &g_logger); + g_lua.bindSingletonFunction("g_logger", "fatal", &Logger::fatal, &g_logger); + + // ModuleManager + g_lua.registerSingletonClass("g_modules"); + g_lua.bindSingletonFunction("g_modules", "discoverModules", &ModuleManager::discoverModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "autoLoadModules", &ModuleManager::autoLoadModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "discoverModule", &ModuleManager::discoverModule, &g_modules); + g_lua.bindSingletonFunction("g_modules", "ensureModuleLoaded", &ModuleManager::ensureModuleLoaded, &g_modules); + g_lua.bindSingletonFunction("g_modules", "unloadModules", &ModuleManager::unloadModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "reloadModules", &ModuleManager::reloadModules, &g_modules); + g_lua.bindSingletonFunction("g_modules", "getModule", &ModuleManager::getModule, &g_modules); + g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules); + + // EventDispatcher + g_lua.registerSingletonClass("g_dispatcher"); + g_lua.bindSingletonFunction("g_dispatcher", "addEvent", &EventDispatcher::addEvent, &g_dispatcher); + g_lua.bindSingletonFunction("g_dispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_dispatcher); + g_lua.bindSingletonFunction("g_dispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_dispatcher); + + // ResourceManager + g_lua.registerSingletonClass("g_resources"); + g_lua.bindSingletonFunction("g_resources", "addToSearchPath", &ResourceManager::addToSearchPath, &g_resources); + g_lua.bindSingletonFunction("g_resources", "setupWriteDir", &ResourceManager::setupWriteDir, &g_resources); + g_lua.bindSingletonFunction("g_resources", "removeFromSearchPath", &ResourceManager::removeFromSearchPath, &g_resources); + g_lua.bindSingletonFunction("g_resources", "fileExists", &ResourceManager::fileExists, &g_resources); + g_lua.bindSingletonFunction("g_resources", "getRealDir", &ResourceManager::getRealDir, &g_resources); + g_lua.bindSingletonFunction("g_resources", "getWorkDir", &ResourceManager::getWorkDir, &g_resources); + + // Module + g_lua.registerClass(); + g_lua.bindClassMemberFunction("load", &Module::load); + g_lua.bindClassMemberFunction("unload", &Module::unload); + g_lua.bindClassMemberFunction("reload", &Module::reload); + g_lua.bindClassMemberFunction("canReload", &Module::canReload); + g_lua.bindClassMemberFunction("canUnload", &Module::canUnload); + g_lua.bindClassMemberFunction("isLoaded", &Module::isLoaded); + g_lua.bindClassMemberFunction("isReloadble", &Module::isReloadable); + g_lua.bindClassMemberFunction("getDescription", &Module::getDescription); + g_lua.bindClassMemberFunction("getName", &Module::getName); + g_lua.bindClassMemberFunction("getAuthor", &Module::getAuthor); + g_lua.bindClassMemberFunction("getWebsite", &Module::getWebsite); + g_lua.bindClassMemberFunction("getVersion", &Module::getVersion); + g_lua.bindClassMemberFunction("isAutoLoad", &Module::isAutoLoad); + g_lua.bindClassMemberFunction("getAutoLoadPriority", &Module::getAutoLoadPriority); + // Event g_lua.registerClass(); g_lua.bindClassMemberFunction("cancel", &Event::cancel); @@ -75,6 +163,95 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("cyclesExecuted", &ScheduledEvent::cyclesExecuted); g_lua.bindClassMemberFunction("maxCycles", &ScheduledEvent::maxCycles); +#ifdef FW_GRAPHICS + // GraphicalApplication + g_lua.bindSingletonFunction("g_app", "setForegroundPaneMaxFps", &GraphicalApplication::setForegroundPaneMaxFps, &g_app); + g_lua.bindSingletonFunction("g_app", "setBackgroundPaneMaxFps", &GraphicalApplication::setBackgroundPaneMaxFps, &g_app); + g_lua.bindSingletonFunction("g_app", "isOnInputEvent", &GraphicalApplication::isOnInputEvent, &g_app); + g_lua.bindSingletonFunction("g_app", "getForegroundPaneFps", &GraphicalApplication::getForegroundPaneFps, &g_app); + g_lua.bindSingletonFunction("g_app", "getBackgroundPaneFps", &GraphicalApplication::getBackgroundPaneFps, &g_app); + g_lua.bindSingletonFunction("g_app", "getForegroundPaneMaxFps", &GraphicalApplication::getForegroundPaneMaxFps, &g_app); + g_lua.bindSingletonFunction("g_app", "getBackgroundPaneMaxFps", &GraphicalApplication::getBackgroundPaneMaxFps, &g_app); + + // PlatformWindow + g_lua.registerSingletonClass("g_window"); + g_lua.bindSingletonFunction("g_window", "move", &PlatformWindow::move, &g_window); + g_lua.bindSingletonFunction("g_window", "resize", &PlatformWindow::resize, &g_window); + g_lua.bindSingletonFunction("g_window", "show", &PlatformWindow::show, &g_window); + g_lua.bindSingletonFunction("g_window", "hide", &PlatformWindow::hide, &g_window); + g_lua.bindSingletonFunction("g_window", "maximize", &PlatformWindow::maximize, &g_window); + g_lua.bindSingletonFunction("g_window", "restoreMouseCursor", &PlatformWindow::restoreMouseCursor, &g_window); + g_lua.bindSingletonFunction("g_window", "showMouse", &PlatformWindow::showMouse, &g_window); + g_lua.bindSingletonFunction("g_window", "hideMouse", &PlatformWindow::hideMouse, &g_window); + g_lua.bindSingletonFunction("g_window", "setTitle", &PlatformWindow::setTitle, &g_window); + g_lua.bindSingletonFunction("g_window", "setMouseCursor", &PlatformWindow::setMouseCursor, &g_window); + g_lua.bindSingletonFunction("g_window", "setMinimumSize", &PlatformWindow::setMinimumSize, &g_window); + g_lua.bindSingletonFunction("g_window", "setFullscreen", &PlatformWindow::setFullscreen, &g_window); + g_lua.bindSingletonFunction("g_window", "setVerticalSync", &PlatformWindow::setVerticalSync, &g_window); + g_lua.bindSingletonFunction("g_window", "setIcon", &PlatformWindow::setIcon, &g_window); + g_lua.bindSingletonFunction("g_window", "setClipboardText", &PlatformWindow::setClipboardText, &g_window); + g_lua.bindSingletonFunction("g_window", "getDisplaySize", &PlatformWindow::getDisplaySize, &g_window); + g_lua.bindSingletonFunction("g_window", "getClipboardText", &PlatformWindow::getClipboardText, &g_window); + g_lua.bindSingletonFunction("g_window", "getPlatformType", &PlatformWindow::getPlatformType, &g_window); + g_lua.bindSingletonFunction("g_window", "getDisplayWidth", &PlatformWindow::getDisplayWidth, &g_window); + g_lua.bindSingletonFunction("g_window", "getDisplayHeight", &PlatformWindow::getDisplayHeight, &g_window); + g_lua.bindSingletonFunction("g_window", "getUnmaximizedSize", &PlatformWindow::getUnmaximizedSize, &g_window); + g_lua.bindSingletonFunction("g_window", "getSize", &PlatformWindow::getSize, &g_window); + g_lua.bindSingletonFunction("g_window", "getWidth", &PlatformWindow::getWidth, &g_window); + g_lua.bindSingletonFunction("g_window", "getHeight", &PlatformWindow::getHeight, &g_window); + g_lua.bindSingletonFunction("g_window", "getUnmaximizedPos", &PlatformWindow::getUnmaximizedPos, &g_window); + g_lua.bindSingletonFunction("g_window", "getPosition", &PlatformWindow::getPosition, &g_window); + g_lua.bindSingletonFunction("g_window", "getX", &PlatformWindow::getX, &g_window); + g_lua.bindSingletonFunction("g_window", "getY", &PlatformWindow::getY, &g_window); + g_lua.bindSingletonFunction("g_window", "getMousePosition", &PlatformWindow::getMousePosition, &g_window); + g_lua.bindSingletonFunction("g_window", "getKeyboardModifiers", &PlatformWindow::getKeyboardModifiers, &g_window); + g_lua.bindSingletonFunction("g_window", "isKeyPressed", &PlatformWindow::isKeyPressed, &g_window); + g_lua.bindSingletonFunction("g_window", "isMouseButtonPressed", &PlatformWindow::isMouseButtonPressed, &g_window); + g_lua.bindSingletonFunction("g_window", "isVisible", &PlatformWindow::isVisible, &g_window); + g_lua.bindSingletonFunction("g_window", "isFullscreen", &PlatformWindow::isFullscreen, &g_window); + g_lua.bindSingletonFunction("g_window", "isMaximized", &PlatformWindow::isMaximized, &g_window); + g_lua.bindSingletonFunction("g_window", "hasFocus", &PlatformWindow::hasFocus, &g_window); + + // Graphics + g_lua.registerSingletonClass("g_graphics"); + g_lua.bindSingletonFunction("g_graphics", "isPainterEngineAvailable", &Graphics::isPainterEngineAvailable, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "selectPainterEngine", &Graphics::selectPainterEngine, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "canCacheBackbuffer", &Graphics::canCacheBackbuffer, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "canUseShaders", &Graphics::canUseShaders, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getPainterEngine", &Graphics::getPainterEngine, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getViewportSize", &Graphics::getViewportSize, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getVendor", &Graphics::getVendor, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getRenderer", &Graphics::getRenderer, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "getVersion", &Graphics::getVersion, &g_graphics); + + // UI + g_lua.registerSingletonClass("g_ui"); + g_lua.bindSingletonFunction("g_ui", "clearStyles", &UIManager::clearStyles, &g_ui); + g_lua.bindSingletonFunction("g_ui", "importStyle", &UIManager::importStyle, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getStyle", &UIManager::getStyle, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getStyleClass", &UIManager::getStyleClass, &g_ui); + g_lua.bindSingletonFunction("g_ui", "loadUI", &UIManager::loadUI, &g_ui); + g_lua.bindSingletonFunction("g_ui", "displayUI", &UIManager::displayUI, &g_ui); + g_lua.bindSingletonFunction("g_ui", "createWidget", &UIManager::createWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "createWidgetFromOTML", &UIManager::createWidgetFromOTML, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getRootWidget", &UIManager::getRootWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getDraggingWidget", &UIManager::getDraggingWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "getPressedWidget", &UIManager::getPressedWidget, &g_ui); + g_lua.bindSingletonFunction("g_ui", "setDebugBoxesDrawing", &UIManager::setDebugBoxesDrawing, &g_ui); + g_lua.bindSingletonFunction("g_ui", "isDrawingDebugBoxes", &UIManager::setDebugBoxesDrawing, &g_ui); + + // FontManager + g_lua.registerSingletonClass("g_fonts"); + g_lua.bindSingletonFunction("g_fonts", "clearFonts", &FontManager::clearFonts, &g_fonts); + g_lua.bindSingletonFunction("g_fonts", "importFont", &FontManager::importFont, &g_fonts); + g_lua.bindSingletonFunction("g_fonts", "fontExists", &FontManager::fontExists, &g_fonts); + g_lua.bindSingletonFunction("g_fonts", "setDefaultFont", &FontManager::setDefaultFont, &g_fonts); + + // ParticleManager + g_lua.registerSingletonClass("g_particles"); + g_lua.bindSingletonFunction("g_particles", "importParticle", &ParticleManager::importParticle, &g_particles); + g_lua.bindSingletonFunction("g_particles", "getEffectsTypes", &ParticleManager::getEffectsTypes, &g_particles); + // UIWidget g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIWidgetPtr(new UIWidget); }); @@ -412,6 +589,24 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("isShiftNavigation", &UITextEdit::isShiftNavigation); g_lua.bindClassMemberFunction("isMultiline", &UITextEdit::isMultiline); + g_lua.registerClass(); + g_lua.registerClass(); + g_lua.bindClassMemberFunction("addMultiTexture", &PainterShaderProgram::addMultiTexture); + + // ParticleEffect + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return ParticleEffectTypePtr(new ParticleEffectType); }); + g_lua.bindClassMemberFunction("getName", &ParticleEffectType::getName); + g_lua.bindClassMemberFunction("getFile", &ParticleEffectType::getFile); + g_lua.bindClassMemberFunction("getDescription", &ParticleEffectType::getDescription); + + // UIParticles + g_lua.registerClass(); + g_lua.bindClassStaticFunction("create", []{ return UIParticlesPtr(new UIParticles); } ); + g_lua.bindClassMemberFunction("addEffect", &UIParticles::addEffect); +#endif + +#ifdef FW_NET // Protocol g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return ProtocolPtr(new Protocol); }); @@ -426,23 +621,6 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("enableXteaEncryption", &Protocol::enableXteaEncryption); g_lua.bindClassMemberFunction("enableChecksum", &Protocol::enableChecksum); - // Module - g_lua.registerClass(); - g_lua.bindClassMemberFunction("load", &Module::load); - g_lua.bindClassMemberFunction("unload", &Module::unload); - g_lua.bindClassMemberFunction("reload", &Module::reload); - g_lua.bindClassMemberFunction("canReload", &Module::canReload); - g_lua.bindClassMemberFunction("canUnload", &Module::canUnload); - g_lua.bindClassMemberFunction("isLoaded", &Module::isLoaded); - g_lua.bindClassMemberFunction("isReloadble", &Module::isReloadable); - g_lua.bindClassMemberFunction("getDescription", &Module::getDescription); - g_lua.bindClassMemberFunction("getName", &Module::getName); - g_lua.bindClassMemberFunction("getAuthor", &Module::getAuthor); - g_lua.bindClassMemberFunction("getWebsite", &Module::getWebsite); - g_lua.bindClassMemberFunction("getVersion", &Module::getVersion); - g_lua.bindClassMemberFunction("isAutoLoad", &Module::isAutoLoad); - g_lua.bindClassMemberFunction("getAutoLoadPriority", &Module::getAutoLoadPriority); - // InputMessage g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return InputMessagePtr(new InputMessage); }); @@ -476,146 +654,9 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("addPaddingBytes", &OutputMessage::addPaddingBytes); g_lua.bindClassMemberFunction("encryptRSA", &OutputMessage::encryptRSA); g_lua.bindClassMemberFunction("getMessageSize", &OutputMessage::getMessageSize); +#endif - g_lua.registerClass(); - g_lua.registerClass(); - g_lua.bindClassMemberFunction("addMultiTexture", &PainterShaderProgram::addMultiTexture); - - // Application - g_lua.registerSingletonClass("g_app"); - g_lua.bindSingletonFunction("g_app", "setForegroundPaneMaxFps", &Application::setForegroundPaneMaxFps, &g_app); - g_lua.bindSingletonFunction("g_app", "setBackgroundPaneMaxFps", &Application::setBackgroundPaneMaxFps, &g_app); - g_lua.bindSingletonFunction("g_app", "setName", &Application::setName, &g_app); - g_lua.bindSingletonFunction("g_app", "setCompactName", &Application::setCompactName, &g_app); - g_lua.bindSingletonFunction("g_app", "setVersion", &Application::setVersion, &g_app); - g_lua.bindSingletonFunction("g_app", "isRunning", &Application::isRunning, &g_app); - g_lua.bindSingletonFunction("g_app", "isStopping", &Application::isStopping, &g_app); - g_lua.bindSingletonFunction("g_app", "isOnInputEvent", &Application::isOnInputEvent, &g_app); - g_lua.bindSingletonFunction("g_app", "getName", &Application::getName, &g_app); - g_lua.bindSingletonFunction("g_app", "getCompactName", &Application::getCompactName, &g_app); - g_lua.bindSingletonFunction("g_app", "getVersion", &Application::getVersion, &g_app); - g_lua.bindSingletonFunction("g_app", "getForegroundPaneFps", &Application::getForegroundPaneFps, &g_app); - g_lua.bindSingletonFunction("g_app", "getBackgroundPaneFps", &Application::getBackgroundPaneFps, &g_app); - g_lua.bindSingletonFunction("g_app", "getForegroundPaneMaxFps", &Application::getForegroundPaneMaxFps, &g_app); - g_lua.bindSingletonFunction("g_app", "getBackgroundPaneMaxFps", &Application::getBackgroundPaneMaxFps, &g_app); - g_lua.bindSingletonFunction("g_app", "getBuildCompiler", &Application::getBuildCompiler, &g_app); - g_lua.bindSingletonFunction("g_app", "getBuildDate", &Application::getBuildDate, &g_app); - g_lua.bindSingletonFunction("g_app", "getBuildRevision", &Application::getBuildRevision, &g_app); - g_lua.bindSingletonFunction("g_app", "getBuildCommit", &Application::getBuildCommit, &g_app); - g_lua.bindSingletonFunction("g_app", "getBuildType", &Application::getBuildType, &g_app); - g_lua.bindSingletonFunction("g_app", "exit", &Application::exit, &g_app); - - // ConfigManager - g_lua.registerSingletonClass("g_configs"); - g_lua.bindSingletonFunction("g_configs", "load", &ConfigManager::load, &g_configs); - g_lua.bindSingletonFunction("g_configs", "save", &ConfigManager::save, &g_configs); - g_lua.bindSingletonFunction("g_configs", "set", &ConfigManager::set, &g_configs); - g_lua.bindSingletonFunction("g_configs", "setList", &ConfigManager::setList, &g_configs); - g_lua.bindSingletonFunction("g_configs", "get", &ConfigManager::get, &g_configs); - g_lua.bindSingletonFunction("g_configs", "getList", &ConfigManager::getList, &g_configs); - g_lua.bindSingletonFunction("g_configs", "exists", &ConfigManager::exists, &g_configs); - g_lua.bindSingletonFunction("g_configs", "remove", &ConfigManager::remove, &g_configs); - g_lua.bindSingletonFunction("g_configs", "setNode", &ConfigManager::setNode, &g_configs); - g_lua.bindSingletonFunction("g_configs", "mergeNode", &ConfigManager::mergeNode, &g_configs); - g_lua.bindSingletonFunction("g_configs", "getNode", &ConfigManager::getNode, &g_configs); - - // PlatformWindow - g_lua.registerSingletonClass("g_window"); - g_lua.bindSingletonFunction("g_window", "move", &PlatformWindow::move, &g_window); - g_lua.bindSingletonFunction("g_window", "resize", &PlatformWindow::resize, &g_window); - g_lua.bindSingletonFunction("g_window", "show", &PlatformWindow::show, &g_window); - g_lua.bindSingletonFunction("g_window", "hide", &PlatformWindow::hide, &g_window); - g_lua.bindSingletonFunction("g_window", "maximize", &PlatformWindow::maximize, &g_window); - g_lua.bindSingletonFunction("g_window", "restoreMouseCursor", &PlatformWindow::restoreMouseCursor, &g_window); - g_lua.bindSingletonFunction("g_window", "showMouse", &PlatformWindow::showMouse, &g_window); - g_lua.bindSingletonFunction("g_window", "hideMouse", &PlatformWindow::hideMouse, &g_window); - g_lua.bindSingletonFunction("g_window", "setTitle", &PlatformWindow::setTitle, &g_window); - g_lua.bindSingletonFunction("g_window", "setMouseCursor", &PlatformWindow::setMouseCursor, &g_window); - g_lua.bindSingletonFunction("g_window", "setMinimumSize", &PlatformWindow::setMinimumSize, &g_window); - g_lua.bindSingletonFunction("g_window", "setFullscreen", &PlatformWindow::setFullscreen, &g_window); - g_lua.bindSingletonFunction("g_window", "setVerticalSync", &PlatformWindow::setVerticalSync, &g_window); - g_lua.bindSingletonFunction("g_window", "setIcon", &PlatformWindow::setIcon, &g_window); - g_lua.bindSingletonFunction("g_window", "setClipboardText", &PlatformWindow::setClipboardText, &g_window); - g_lua.bindSingletonFunction("g_window", "getDisplaySize", &PlatformWindow::getDisplaySize, &g_window); - g_lua.bindSingletonFunction("g_window", "getClipboardText", &PlatformWindow::getClipboardText, &g_window); - g_lua.bindSingletonFunction("g_window", "getPlatformType", &PlatformWindow::getPlatformType, &g_window); - g_lua.bindSingletonFunction("g_window", "getDisplayWidth", &PlatformWindow::getDisplayWidth, &g_window); - g_lua.bindSingletonFunction("g_window", "getDisplayHeight", &PlatformWindow::getDisplayHeight, &g_window); - g_lua.bindSingletonFunction("g_window", "getUnmaximizedSize", &PlatformWindow::getUnmaximizedSize, &g_window); - g_lua.bindSingletonFunction("g_window", "getSize", &PlatformWindow::getSize, &g_window); - g_lua.bindSingletonFunction("g_window", "getWidth", &PlatformWindow::getWidth, &g_window); - g_lua.bindSingletonFunction("g_window", "getHeight", &PlatformWindow::getHeight, &g_window); - g_lua.bindSingletonFunction("g_window", "getUnmaximizedPos", &PlatformWindow::getUnmaximizedPos, &g_window); - g_lua.bindSingletonFunction("g_window", "getPosition", &PlatformWindow::getPosition, &g_window); - g_lua.bindSingletonFunction("g_window", "getX", &PlatformWindow::getX, &g_window); - g_lua.bindSingletonFunction("g_window", "getY", &PlatformWindow::getY, &g_window); - g_lua.bindSingletonFunction("g_window", "getMousePosition", &PlatformWindow::getMousePosition, &g_window); - g_lua.bindSingletonFunction("g_window", "getKeyboardModifiers", &PlatformWindow::getKeyboardModifiers, &g_window); - g_lua.bindSingletonFunction("g_window", "isKeyPressed", &PlatformWindow::isKeyPressed, &g_window); - g_lua.bindSingletonFunction("g_window", "isMouseButtonPressed", &PlatformWindow::isMouseButtonPressed, &g_window); - g_lua.bindSingletonFunction("g_window", "isVisible", &PlatformWindow::isVisible, &g_window); - g_lua.bindSingletonFunction("g_window", "isFullscreen", &PlatformWindow::isFullscreen, &g_window); - g_lua.bindSingletonFunction("g_window", "isMaximized", &PlatformWindow::isMaximized, &g_window); - g_lua.bindSingletonFunction("g_window", "hasFocus", &PlatformWindow::hasFocus, &g_window); - - // Graphics - g_lua.registerSingletonClass("g_graphics"); - g_lua.bindSingletonFunction("g_graphics", "isPainterEngineAvailable", &Graphics::isPainterEngineAvailable, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "selectPainterEngine", &Graphics::selectPainterEngine, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "canCacheBackbuffer", &Graphics::canCacheBackbuffer, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "canUseShaders", &Graphics::canUseShaders, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "getPainterEngine", &Graphics::getPainterEngine, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "getViewportSize", &Graphics::getViewportSize, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "getVendor", &Graphics::getVendor, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "getRenderer", &Graphics::getRenderer, &g_graphics); - g_lua.bindSingletonFunction("g_graphics", "getVersion", &Graphics::getVersion, &g_graphics); - - // Logger - g_lua.registerSingletonClass("g_logger"); - g_lua.bindSingletonFunction("g_logger", "log", &Logger::log, &g_logger); - g_lua.bindSingletonFunction("g_logger", "fireOldMessages", &Logger::fireOldMessages, &g_logger); - g_lua.bindSingletonFunction("g_logger", "setLogFile", &Logger::setLogFile, &g_logger); - g_lua.bindSingletonFunction("g_logger", "setOnLog", &Logger::setOnLog, &g_logger); - g_lua.bindSingletonFunction("g_logger", "debug", &Logger::debug, &g_logger); - g_lua.bindSingletonFunction("g_logger", "info", &Logger::info, &g_logger); - g_lua.bindSingletonFunction("g_logger", "warning", &Logger::warning, &g_logger); - g_lua.bindSingletonFunction("g_logger", "error", &Logger::error, &g_logger); - g_lua.bindSingletonFunction("g_logger", "fatal", &Logger::fatal, &g_logger); - - // UI - g_lua.registerSingletonClass("g_ui"); - g_lua.bindSingletonFunction("g_ui", "clearStyles", &UIManager::clearStyles, &g_ui); - g_lua.bindSingletonFunction("g_ui", "importStyle", &UIManager::importStyle, &g_ui); - g_lua.bindSingletonFunction("g_ui", "getStyle", &UIManager::getStyle, &g_ui); - g_lua.bindSingletonFunction("g_ui", "getStyleClass", &UIManager::getStyleClass, &g_ui); - g_lua.bindSingletonFunction("g_ui", "loadUI", &UIManager::loadUI, &g_ui); - g_lua.bindSingletonFunction("g_ui", "displayUI", &UIManager::displayUI, &g_ui); - g_lua.bindSingletonFunction("g_ui", "createWidget", &UIManager::createWidget, &g_ui); - g_lua.bindSingletonFunction("g_ui", "createWidgetFromOTML", &UIManager::createWidgetFromOTML, &g_ui); - g_lua.bindSingletonFunction("g_ui", "getRootWidget", &UIManager::getRootWidget, &g_ui); - g_lua.bindSingletonFunction("g_ui", "getDraggingWidget", &UIManager::getDraggingWidget, &g_ui); - g_lua.bindSingletonFunction("g_ui", "getPressedWidget", &UIManager::getPressedWidget, &g_ui); - g_lua.bindSingletonFunction("g_ui", "setDebugBoxesDrawing", &UIManager::setDebugBoxesDrawing, &g_ui); - g_lua.bindSingletonFunction("g_ui", "isDrawingDebugBoxes", &UIManager::setDebugBoxesDrawing, &g_ui); - - // ModuleManager - g_lua.registerSingletonClass("g_modules"); - g_lua.bindSingletonFunction("g_modules", "discoverModules", &ModuleManager::discoverModules, &g_modules); - g_lua.bindSingletonFunction("g_modules", "autoLoadModules", &ModuleManager::autoLoadModules, &g_modules); - g_lua.bindSingletonFunction("g_modules", "discoverModule", &ModuleManager::discoverModule, &g_modules); - g_lua.bindSingletonFunction("g_modules", "ensureModuleLoaded", &ModuleManager::ensureModuleLoaded, &g_modules); - g_lua.bindSingletonFunction("g_modules", "unloadModules", &ModuleManager::unloadModules, &g_modules); - g_lua.bindSingletonFunction("g_modules", "reloadModules", &ModuleManager::reloadModules, &g_modules); - g_lua.bindSingletonFunction("g_modules", "getModule", &ModuleManager::getModule, &g_modules); - g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules); - - // FontManager - g_lua.registerSingletonClass("g_fonts"); - g_lua.bindSingletonFunction("g_fonts", "clearFonts", &FontManager::clearFonts, &g_fonts); - g_lua.bindSingletonFunction("g_fonts", "importFont", &FontManager::importFont, &g_fonts); - g_lua.bindSingletonFunction("g_fonts", "fontExists", &FontManager::fontExists, &g_fonts); - g_lua.bindSingletonFunction("g_fonts", "setDefaultFont", &FontManager::setDefaultFont, &g_fonts); - +#ifdef FW_SOUND // SoundManager g_lua.registerSingletonClass("g_sounds"); g_lua.bindSingletonFunction("g_sounds", "preload", &SoundManager::preload, &g_sounds); @@ -628,36 +669,5 @@ void Application::registerLuaFunctions() g_lua.bindSingletonFunction("g_sounds", "isSoundEnabled", &SoundManager::isSoundEnabled, &g_sounds); g_lua.bindSingletonFunction("g_sounds", "isAudioEnabled", &SoundManager::isAudioEnabled, &g_sounds); g_lua.bindSingletonFunction("g_sounds", "getCurrentMusic", &SoundManager::getCurrentMusic, &g_sounds); - - // EventDispatcher - g_lua.registerSingletonClass("g_dispatcher"); - g_lua.bindSingletonFunction("g_dispatcher", "addEvent", &EventDispatcher::addEvent, &g_dispatcher); - g_lua.bindSingletonFunction("g_dispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_dispatcher); - g_lua.bindSingletonFunction("g_dispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_dispatcher); - - // ResourceManager - g_lua.registerSingletonClass("g_resources"); - g_lua.bindSingletonFunction("g_resources", "addToSearchPath", &ResourceManager::addToSearchPath, &g_resources); - g_lua.bindSingletonFunction("g_resources", "setupWriteDir", &ResourceManager::setupWriteDir, &g_resources); - g_lua.bindSingletonFunction("g_resources", "removeFromSearchPath", &ResourceManager::removeFromSearchPath, &g_resources); - g_lua.bindSingletonFunction("g_resources", "fileExists", &ResourceManager::fileExists, &g_resources); - g_lua.bindSingletonFunction("g_resources", "getRealDir", &ResourceManager::getRealDir, &g_resources); - g_lua.bindSingletonFunction("g_resources", "getWorkDir", &ResourceManager::getWorkDir, &g_resources); - - // ParticleManager - g_lua.registerSingletonClass("g_particles"); - g_lua.bindSingletonFunction("g_particles", "importParticle", &ParticleManager::importParticle, &g_particles); - g_lua.bindSingletonFunction("g_particles", "getEffectsTypes", &ParticleManager::getEffectsTypes, &g_particles); - - // ParticleEffect - g_lua.registerClass(); - g_lua.bindClassStaticFunction("create", []{ return ParticleEffectTypePtr(new ParticleEffectType); }); - g_lua.bindClassMemberFunction("getName", &ParticleEffectType::getName); - g_lua.bindClassMemberFunction("getFile", &ParticleEffectType::getFile); - g_lua.bindClassMemberFunction("getDescription", &ParticleEffectType::getDescription); - - // UIParticles - g_lua.registerClass(); - g_lua.bindClassStaticFunction("create", []{ return UIParticlesPtr(new UIParticles); } ); - g_lua.bindClassMemberFunction("addEffect", &UIParticles::addEffect); +#endif } diff --git a/src/framework/net/connection.cpp b/src/framework/net/connection.cpp index 79ff509a..0bd08a5b 100644 --- a/src/framework/net/connection.cpp +++ b/src/framework/net/connection.cpp @@ -22,7 +22,7 @@ #include "connection.h" -#include +#include #include #include @@ -41,7 +41,7 @@ Connection::Connection() : Connection::~Connection() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); close(); } diff --git a/src/framework/net/inputmessage.h b/src/framework/net/inputmessage.h index 0269ae04..c55a951b 100644 --- a/src/framework/net/inputmessage.h +++ b/src/framework/net/inputmessage.h @@ -24,7 +24,7 @@ #define INPUTMESSAGE_H #include "declarations.h" -#include +#include // @bindclass class InputMessage : public LuaObject diff --git a/src/framework/net/outputmessage.h b/src/framework/net/outputmessage.h index a8095c96..f3ba04aa 100644 --- a/src/framework/net/outputmessage.h +++ b/src/framework/net/outputmessage.h @@ -24,7 +24,7 @@ #define OUTPUTMESSAGE_H #include "declarations.h" -#include +#include // @bindclass class OutputMessage : public LuaObject diff --git a/src/framework/net/protocol.cpp b/src/framework/net/protocol.cpp index 441c543c..42d9ea23 100644 --- a/src/framework/net/protocol.cpp +++ b/src/framework/net/protocol.cpp @@ -22,7 +22,7 @@ #include "protocol.h" #include "connection.h" -#include +#include Protocol::Protocol() { @@ -33,7 +33,7 @@ Protocol::Protocol() Protocol::~Protocol() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); disconnect(); } diff --git a/src/framework/net/protocol.h b/src/framework/net/protocol.h index e90e23b4..90c04d81 100644 --- a/src/framework/net/protocol.h +++ b/src/framework/net/protocol.h @@ -27,7 +27,7 @@ #include "inputmessage.h" #include "outputmessage.h" -#include +#include // @bindclass class Protocol : public LuaObject diff --git a/src/framework/pch.h b/src/framework/pch.h index e167b528..3c408a6b 100644 --- a/src/framework/pch.h +++ b/src/framework/pch.h @@ -59,6 +59,7 @@ #include #include #include +#include // boost utilities #include diff --git a/src/framework/platform/unixcrashhandler.cpp b/src/framework/platform/unixcrashhandler.cpp index 95aa4d39..e51f0453 100644 --- a/src/framework/platform/unixcrashhandler.cpp +++ b/src/framework/platform/unixcrashhandler.cpp @@ -24,7 +24,7 @@ #include "crashhandler.h" #include -#include +#include #ifndef __USE_GNU #define __USE_GNU diff --git a/src/framework/platform/win32crashhandler.cpp b/src/framework/platform/win32crashhandler.cpp index a6ffe77c..bab406e4 100644 --- a/src/framework/platform/win32crashhandler.cpp +++ b/src/framework/platform/win32crashhandler.cpp @@ -24,7 +24,7 @@ #include "crashhandler.h" #include -#include +#include #include #include diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index cd8df5ae..970b8f86 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -24,8 +24,8 @@ #include "win32window.h" -#include -#include +#include +#include #include #define HSB_BIT_SET(p, n) (p[(n)/8] |= (128 >>((n)%8))) diff --git a/src/framework/platform/x11window.cpp b/src/framework/platform/x11window.cpp index ad9812bf..546d8b80 100644 --- a/src/framework/platform/x11window.cpp +++ b/src/framework/platform/x11window.cpp @@ -24,7 +24,7 @@ #include "x11window.h" #include -#include +#include #define LSB_BIT_SET(p, n) (p[(n)/8] |= (1 <<((n)%8))) diff --git a/src/framework/ui/uilayout.h b/src/framework/ui/uilayout.h index 909c92a4..3925a5cd 100644 --- a/src/framework/ui/uilayout.h +++ b/src/framework/ui/uilayout.h @@ -24,7 +24,7 @@ #define UILAYOUT_H #include "declarations.h" -#include +#include #include // @bindclass diff --git a/src/framework/ui/uimanager.cpp b/src/framework/ui/uimanager.cpp index 287d0eb4..a11b22eb 100644 --- a/src/framework/ui/uimanager.cpp +++ b/src/framework/ui/uimanager.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include UIManager g_ui; diff --git a/src/framework/ui/uitextedit.cpp b/src/framework/ui/uitextedit.cpp index f0ffd0ef..9fd82ee2 100644 --- a/src/framework/ui/uitextedit.cpp +++ b/src/framework/ui/uitextedit.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include UITextEdit::UITextEdit() { diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index f32e296b..3f98cefa 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include UIWidget::UIWidget() { @@ -46,7 +46,7 @@ UIWidget::UIWidget() UIWidget::~UIWidget() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); #ifdef DEBUG if(!m_destroyed) g_logger.warning(stdext::format("widget '%s' was not explicitly destroyed", m_id)); diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index 90aa2bad..fe7889ce 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -24,7 +24,7 @@ #define UIWIDGET_H #include "declarations.h" -#include +#include #include #include #include diff --git a/src/framework/ui/uiwidgettext.cpp b/src/framework/ui/uiwidgettext.cpp index 10f1bffd..9d013495 100644 --- a/src/framework/ui/uiwidgettext.cpp +++ b/src/framework/ui/uiwidgettext.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include void UIWidget::initText() { diff --git a/src/framework/thirdparty/tinystr.cpp b/src/framework/xml/tinystr.cpp similarity index 100% rename from src/framework/thirdparty/tinystr.cpp rename to src/framework/xml/tinystr.cpp diff --git a/src/framework/thirdparty/tinystr.h b/src/framework/xml/tinystr.h similarity index 100% rename from src/framework/thirdparty/tinystr.h rename to src/framework/xml/tinystr.h diff --git a/src/framework/thirdparty/tinyxml.cpp b/src/framework/xml/tinyxml.cpp similarity index 100% rename from src/framework/thirdparty/tinyxml.cpp rename to src/framework/xml/tinyxml.cpp diff --git a/src/framework/thirdparty/tinyxml.h b/src/framework/xml/tinyxml.h similarity index 97% rename from src/framework/thirdparty/tinyxml.h rename to src/framework/xml/tinyxml.h index b1f4ae1b..1fea277e 100644 --- a/src/framework/thirdparty/tinyxml.h +++ b/src/framework/xml/tinyxml.h @@ -26,6 +26,8 @@ distribution. #ifndef TINYXML_INCLUDED #define TINYXML_INCLUDED +#define TIXML_USE_STL // use STL strings instead + #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable : 4530 ) @@ -78,7 +80,7 @@ distribution. #define TIXML_SNPRINTF snprintf #define TIXML_SSCANF sscanf #endif -#endif +#endif class TiXmlDocument; class TiXmlElement; @@ -93,7 +95,7 @@ const int TIXML_MAJOR_VERSION = 2; const int TIXML_MINOR_VERSION = 6; const int TIXML_PATCH_VERSION = 2; -/* Internal structure for tracking location of items +/* Internal structure for tracking location of items in the XML file. */ struct TiXmlCursor @@ -116,7 +118,7 @@ struct TiXmlCursor If you return 'true' from a Visit method, recursive parsing will continue. If you return false, no children of this node or its sibilings will be Visited. - All flavors of Visit methods have a default implementation that returns 'true' (continue + All flavors of Visit methods have a default implementation that returns 'true' (continue visiting). You need to only override methods that are interesting to you. Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. @@ -151,8 +153,8 @@ public: }; // Only used by Attribute::Query functions -enum -{ +enum +{ TIXML_SUCCESS, TIXML_NO_ATTRIBUTE, TIXML_WRONG_TYPE @@ -204,10 +206,10 @@ public: /** All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.) Either or both cfile and str can be null. - - This is a formatted print, and will insert + + This is a formatted print, and will insert tabs and newlines. - + (For an unformatted stream, use the << operator.) */ virtual void Print( FILE* cfile, int depth ) const = 0; @@ -252,11 +254,11 @@ public: // in the UTF-8 sequence. static const int utf8ByteTable[256]; - virtual const char* Parse( const char* p, - TiXmlParsingData* data, + virtual const char* Parse( const char* p, + TiXmlParsingData* data, TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; - /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, or they will be transformed into entities! */ static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); @@ -287,9 +289,9 @@ protected: static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); - inline static bool IsWhiteSpace( char c ) - { - return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); + inline static bool IsWhiteSpace( char c ) + { + return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); } inline static bool IsWhiteSpace( int c ) { @@ -374,7 +376,7 @@ protected: /// Field containing a generic user pointer void* userData; - + // None of these methods are reliable for any language except English. // Good for approximation, not great for accuracy. static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); @@ -426,7 +428,7 @@ class TiXmlNode : public TiXmlBase friend class TiXmlElement; public: - #ifdef TIXML_USE_STL + #ifdef TIXML_USE_STL /** An input stream operator, for every class. Tolerant of newlines and formatting, but doesn't expect them. @@ -440,7 +442,7 @@ public: The operator<< and operator>> are not completely symmetric. Writing a node to a stream is very well defined. You'll get a nice stream of output, without any extra whitespace or newlines. - + But reading is not as well defined. (As it always is.) If you create a TiXmlElement (for example) and read that from an input stream, the text needs to define an element or junk will result. This is @@ -448,7 +450,7 @@ public: A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element. - */ + */ friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); /// Appends the XML node or attribute to a std::string. @@ -530,7 +532,7 @@ public: } const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. TiXmlNode* LastChild() { return lastChild; } - + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. TiXmlNode* LastChild( const char * _value ) { return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); @@ -709,11 +711,11 @@ public: virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. /** Create an exact duplicate of this node and return it. The memory must be deleted - by the caller. + by the caller. */ virtual TiXmlNode* Clone() const = 0; - /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface. @@ -724,7 +726,7 @@ public: The interface has been based on ideas from: - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern Which are both good references for "visiting". @@ -821,7 +823,7 @@ public: /** QueryIntValue examines the value string. It is an alternative to the IntValue() method with richer error checking. - If the value is an integer, it is stored in 'value' and + If the value is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. @@ -840,21 +842,21 @@ public: #ifdef TIXML_USE_STL /// STL std::string form. - void SetName( const std::string& _name ) { name = _name; } - /// STL std::string form. + void SetName( const std::string& _name ) { name = _name; } + /// STL std::string form. void SetValue( const std::string& _value ) { value = _value; } #endif /// Get the next sibling attribute in the DOM. Returns null at end. const TiXmlAttribute* Next() const; TiXmlAttribute* Next() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); } /// Get the previous sibling attribute in the DOM. Returns null at beginning. const TiXmlAttribute* Previous() const; TiXmlAttribute* Previous() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); } bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } @@ -890,7 +892,7 @@ private: /* A class used to manage a group of attributes. It is only used internally, both by the ELEMENT and the DECLARATION. - + The set can be changed transparent to the Element and Declaration classes that use it, but NOT transparent to the Attribute which has to implement a next() and previous() method. Which makes @@ -977,15 +979,15 @@ public: /** QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking. - If the attribute is an integer, it is stored in 'value' and + If the attribute is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned. - */ + */ int QueryIntAttribute( const char* name, int* _value ) const; /// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute(). int QueryUnsignedAttribute( const char* name, unsigned* _value ) const; - /** QueryBoolAttribute examines the attribute - see QueryIntAttribute(). + /** QueryBoolAttribute examines the attribute - see QueryIntAttribute(). Note that '1', 'true', or 'yes' are considered true, while '0', 'false' and 'no' are considered false. */ @@ -1016,7 +1018,7 @@ public: /** Template form of the attribute query which will try to read the attribute into the specified type. Very easy, very powerful, but be careful to make sure to call this with the correct type. - + NOTE: This method doesn't work correctly for 'string' types that contain spaces. @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE @@ -1089,7 +1091,7 @@ public: /** Convenience function for easy access to the text inside an element. Although easy and concise, GetText() is limited compared to getting the TiXmlText child and accessing it directly. - + If the first child of 'this' is a TiXmlText, the GetText() returns the character string of the Text node, else null is returned. @@ -1099,23 +1101,23 @@ public: const char* str = fooElement->GetText(); @endverbatim - 'str' will be a pointer to "This is text". - + 'str' will be a pointer to "This is text". + Note that this function can be misleading. If the element foo was created from this XML: @verbatim - This is text + This is text @endverbatim then the value of str would be null. The first child node isn't a text node, it is another element. From this XML: @verbatim - This is text + This is text @endverbatim GetText() will return "This is ". - WARNING: GetText() accesses a child node - don't become confused with the - similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are safe type casts on the referenced node. */ const char* GetText() const; @@ -1133,7 +1135,7 @@ public: virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - /** Walk the XML tree visiting this node and all of its children. + /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; @@ -1186,7 +1188,7 @@ public: virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - /** Walk the XML tree visiting this node and all of its children. + /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; @@ -1204,16 +1206,16 @@ private: }; -/** XML text. A text node can have 2 ways to output the next. "normal" output +/** XML text. A text node can have 2 ways to output the next. "normal" output and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with + you generally want to leave it alone, but you can change the output mode with SetCDATA() and query it with CDATA(). */ class TiXmlText : public TiXmlNode { friend class TiXmlElement; public: - /** Constructor for text element. By default, it is treated as + /** Constructor for text element. By default, it is treated as normal, encoded text. If you want it be output as a CDATA text element, set the parameter _cdata to 'true' */ @@ -1249,7 +1251,7 @@ public: virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - /** Walk the XML tree visiting this node and all of its children. + /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; @@ -1325,7 +1327,7 @@ public: virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - /** Walk the XML tree visiting this node and all of its children. + /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; @@ -1370,7 +1372,7 @@ public: virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - /** Walk the XML tree visiting this node and all of its children. + /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; @@ -1456,7 +1458,7 @@ public: - The ErrorId() will contain the integer identifier of the error (not generally useful) - The ErrorDesc() method will return the name of the error. (very useful) - The ErrorRow() and ErrorCol() will return the location of the error (if known) - */ + */ bool Error() const { return error; } /// Contains a textual (english) description of the error if one occurs. @@ -1467,7 +1469,7 @@ public: */ int ErrorId() const { return errorId; } - /** Returns the location (if known) of the error. The first column is column 1, + /** Returns the location (if known) of the error. The first column is column 1, and the first row is row 1. A value of 0 means the row and column wasn't applicable (memory errors, for example, have no row/column) or the parser lost the error. (An error in the error reporting, in that case.) @@ -1480,7 +1482,7 @@ public: /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column. It does not change the output or input in any way. - + By calling this method, with a tab size greater than 0, the row and column of each node and attribute is stored when the file is loaded. Very useful for tracking the DOM back in to @@ -1508,11 +1510,11 @@ public: /** If you have handled the error, it can be reset with this call. The error state is automatically cleared if you Parse a new XML block. */ - void ClearError() { error = false; - errorId = 0; - errorDesc = ""; - errorLocation.row = errorLocation.col = 0; - //errorLocation.last = 0; + void ClearError() { error = false; + errorId = 0; + errorDesc = ""; + errorLocation.row = errorLocation.col = 0; + //errorLocation.last = 0; } /** Write the document to standard out using formatted printing ("pretty print"). */ @@ -1522,7 +1524,7 @@ public: will allocate a character array (new char[]) and return it as a pointer. The calling code pust call delete[] on the return char* to avoid a memory leak. */ - //char* PrintToMemory() const; + //char* PrintToMemory() const; /// Print this Document to a FILE stream. virtual void Print( FILE* cfile, int depth = 0 ) const; @@ -1532,7 +1534,7 @@ public: virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - /** Walk the XML tree visiting this node and all of its children. + /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; @@ -1570,7 +1572,7 @@ private: @endverbatim - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very easy to write a *lot* of code that looks like: @verbatim @@ -1590,7 +1592,7 @@ private: @endverbatim And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity - of such code. A TiXmlHandle checks for null pointers so it is perfectly safe + of such code. A TiXmlHandle checks for null pointers so it is perfectly safe and correct to use: @verbatim @@ -1611,7 +1613,7 @@ private: What they should not be used for is iteration: @verbatim - int i=0; + int i=0; while ( true ) { TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); @@ -1622,8 +1624,8 @@ private: } @endverbatim - It seems reasonable, but it is in fact two embedded while loops. The Child method is - a linear walk to find the element, so this code would iterate much more than it needs + It seems reasonable, but it is in fact two embedded while loops. The Child method is + a linear walk to find the element, so this code would iterate much more than it needs to. Instead, prefer: @verbatim @@ -1653,20 +1655,20 @@ public: /// Return a handle to the first child element with the given name. TiXmlHandle FirstChildElement( const char * value ) const; - /** Return a handle to the "index" child with the given name. + /** Return a handle to the "index" child with the given name. The first child is 0, the second 1, etc. */ TiXmlHandle Child( const char* value, int index ) const; - /** Return a handle to the "index" child. + /** Return a handle to the "index" child. The first child is 0, the second 1, etc. */ TiXmlHandle Child( int index ) const; - /** Return a handle to the "index" child element with the given name. + /** Return a handle to the "index" child element with the given name. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ TiXmlHandle ChildElement( const char* value, int index ) const; - /** Return a handle to the "index" child element. + /** Return a handle to the "index" child element. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ @@ -1682,7 +1684,7 @@ public: /** Return the handle as a TiXmlNode. This may return null. */ - TiXmlNode* ToNode() const { return node; } + TiXmlNode* ToNode() const { return node; } /** Return the handle as a TiXmlElement. This may return null. */ TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } @@ -1693,11 +1695,11 @@ public: */ TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } - /** @deprecated use ToNode. + /** @deprecated use ToNode. Return the handle as a TiXmlNode. This may return null. */ - TiXmlNode* Node() const { return ToNode(); } - /** @deprecated use ToElement. + TiXmlNode* Node() const { return ToNode(); } + /** @deprecated use ToElement. Return the handle as a TiXmlElement. This may return null. */ TiXmlElement* Element() const { return ToElement(); } @@ -1757,7 +1759,7 @@ public: void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } /// Query the indention string. const char* Indent() { return indent.c_str(); } - /** Set the line breaking string. By default set to newline (\n). + /** Set the line breaking string. By default set to newline (\n). Some operating systems prefer other characters, or can be set to the null/empty string for no indenation. */ @@ -1765,12 +1767,12 @@ public: /// Query the current line breaking string. const char* LineBreak() { return lineBreak.c_str(); } - /** Switch over to "stream printing" which is the most dense formatting without + /** Switch over to "stream printing" which is the most dense formatting without linebreaks. Common when the XML is needed for network transmission. */ void SetStreamPrinting() { indent = ""; lineBreak = ""; - } + } /// Return the result. const char* CStr() { return buffer.c_str(); } /// Return the length of the result string. diff --git a/src/framework/thirdparty/tinyxmlerror.cpp b/src/framework/xml/tinyxmlerror.cpp similarity index 100% rename from src/framework/thirdparty/tinyxmlerror.cpp rename to src/framework/xml/tinyxmlerror.cpp diff --git a/src/framework/thirdparty/tinyxmlparser.cpp b/src/framework/xml/tinyxmlparser.cpp similarity index 100% rename from src/framework/thirdparty/tinyxmlparser.cpp rename to src/framework/xml/tinyxmlparser.cpp diff --git a/src/main.cpp b/src/main.cpp index 562a76bf..c3162f42 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,10 +20,10 @@ * THE SOFTWARE. */ -#include "framework/application.h" -#include "framework/luascript/luainterface.h" -#include "framework/core/resourcemanager.h" -#include "otclient/otclient.h" +#include +#include +#include +#include int main(int argc, const char* argv[]) { @@ -35,7 +35,7 @@ int main(int argc, const char* argv[]) g_app.setVersion("0.5.0_dev"); // initialize application framework and otclient - g_app.init("otclient", args); + g_app.init(args); g_otclient.init(args); // find script init.lua and run it diff --git a/src/otclient/CMakeLists.txt b/src/otclient/CMakeLists.txt index 9ed9fb32..d7aabe94 100644 --- a/src/otclient/CMakeLists.txt +++ b/src/otclient/CMakeLists.txt @@ -1,31 +1,31 @@ # CMAKE_CURRENT_LIST_DIR cmake 2.6 compatiblity -IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) - GET_FILENAME_COMPONENT(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) +if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) + get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +endif(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) # otclient options -ADD_DEFINITIONS(-DOTCLIENT) -OPTION(BOT_PROTECTION "Enable bot protection" ON) -SET(PROTOCOL 860 CACHE "Protocol version" STRING) -OPTION(CIPSOFT_RSA "Use cipsoft RSA to login into original tibia" OFF) -ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL}) -MESSAGE(STATUS "Protocol: " ${PROTOCOL}) +add_definitions(-DOTCLIENT) +option(BOT_PROTECTION "Enable bot protection" ON) +set(PROTOCOL 860 CACHE "Protocol version" STRING) +option(CIPSOFT_RSA "Use cipsoft RSA to login into original tibia" OFF) +add_definitions(-DPROTOCOL=${PROTOCOL}) +message(STATUS "Protocol: " ${PROTOCOL}) -IF(CIPSOFT_RSA) - ADD_DEFINITIONS(-DCIPSOFT_RSA -DOSTYPE=2) - MESSAGE(STATUS "RSA: CipSoft") -ELSE() - MESSAGE(STATUS "RSA: OTServ") -ENDIF() +if(CIPSOFT_RSA) + add_definitions(-DCIPSOFT_RSA -DOSTYPE=2) + message(STATUS "RSA: CipSoft") +else() + message(STATUS "RSA: OTServ") +endif() -IF(BOT_PROTECTION) - ADD_DEFINITIONS(-DBOT_PROTECTION) - MESSAGE(STATUS "Bot protection: ON") -ELSE(BOT_PROTECTION) - MESSAGE(STATUS "Bot protection: OFF") -ENDIF(BOT_PROTECTION) +if(BOT_PROTECTION) + add_definitions(-DBOT_PROTECTION) + message(STATUS "Bot protection: ON") +else(BOT_PROTECTION) + message(STATUS "Bot protection: OFF") +endif(BOT_PROTECTION) -SET(otclient_SOURCES ${otclient_SOURCES} +set(otclient_SOURCES ${otclient_SOURCES} # otclient ${CMAKE_CURRENT_LIST_DIR}/const.h ${CMAKE_CURRENT_LIST_DIR}/global.h @@ -34,71 +34,69 @@ SET(otclient_SOURCES ${otclient_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/otclient.h # core - ${CMAKE_CURRENT_LIST_DIR}/core/animatedtext.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/animatedtext.h - ${CMAKE_CURRENT_LIST_DIR}/core/container.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/container.h - ${CMAKE_CURRENT_LIST_DIR}/core/creature.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/creature.h - ${CMAKE_CURRENT_LIST_DIR}/core/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/core/effect.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/effect.h - ${CMAKE_CURRENT_LIST_DIR}/core/game.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/game.h - ${CMAKE_CURRENT_LIST_DIR}/core/shadermanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/shadermanager.h - ${CMAKE_CURRENT_LIST_DIR}/core/item.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/item.h - ${CMAKE_CURRENT_LIST_DIR}/core/localplayer.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/localplayer.h - ${CMAKE_CURRENT_LIST_DIR}/core/map.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/map.h - ${CMAKE_CURRENT_LIST_DIR}/core/mapview.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/mapview.h - ${CMAKE_CURRENT_LIST_DIR}/core/missile.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/missile.h - ${CMAKE_CURRENT_LIST_DIR}/core/outfit.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/outfit.h - ${CMAKE_CURRENT_LIST_DIR}/core/player.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/player.h - ${CMAKE_CURRENT_LIST_DIR}/core/spritemanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/spritemanager.h - ${CMAKE_CURRENT_LIST_DIR}/core/statictext.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/statictext.h - ${CMAKE_CURRENT_LIST_DIR}/core/thing.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/thing.h - ${CMAKE_CURRENT_LIST_DIR}/core/thingtypemanager.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/thingtypemanager.h - ${CMAKE_CURRENT_LIST_DIR}/core/thingtypedat.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/thingtypedat.h - ${CMAKE_CURRENT_LIST_DIR}/core/thingtypeotb.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/thingtypeotb.h - ${CMAKE_CURRENT_LIST_DIR}/core/tile.cpp - ${CMAKE_CURRENT_LIST_DIR}/core/tile.h + ${CMAKE_CURRENT_LIST_DIR}/animatedtext.cpp + ${CMAKE_CURRENT_LIST_DIR}/animatedtext.h + ${CMAKE_CURRENT_LIST_DIR}/container.cpp + ${CMAKE_CURRENT_LIST_DIR}/container.h + ${CMAKE_CURRENT_LIST_DIR}/creature.cpp + ${CMAKE_CURRENT_LIST_DIR}/creature.h + ${CMAKE_CURRENT_LIST_DIR}/declarations.h + ${CMAKE_CURRENT_LIST_DIR}/effect.cpp + ${CMAKE_CURRENT_LIST_DIR}/effect.h + ${CMAKE_CURRENT_LIST_DIR}/game.cpp + ${CMAKE_CURRENT_LIST_DIR}/game.h + ${CMAKE_CURRENT_LIST_DIR}/shadermanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/shadermanager.h + ${CMAKE_CURRENT_LIST_DIR}/item.cpp + ${CMAKE_CURRENT_LIST_DIR}/item.h + ${CMAKE_CURRENT_LIST_DIR}/localplayer.cpp + ${CMAKE_CURRENT_LIST_DIR}/localplayer.h + ${CMAKE_CURRENT_LIST_DIR}/map.cpp + ${CMAKE_CURRENT_LIST_DIR}/map.h + ${CMAKE_CURRENT_LIST_DIR}/mapview.cpp + ${CMAKE_CURRENT_LIST_DIR}/mapview.h + ${CMAKE_CURRENT_LIST_DIR}/missile.cpp + ${CMAKE_CURRENT_LIST_DIR}/missile.h + ${CMAKE_CURRENT_LIST_DIR}/outfit.cpp + ${CMAKE_CURRENT_LIST_DIR}/outfit.h + ${CMAKE_CURRENT_LIST_DIR}/player.cpp + ${CMAKE_CURRENT_LIST_DIR}/player.h + ${CMAKE_CURRENT_LIST_DIR}/spritemanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/spritemanager.h + ${CMAKE_CURRENT_LIST_DIR}/statictext.cpp + ${CMAKE_CURRENT_LIST_DIR}/statictext.h + ${CMAKE_CURRENT_LIST_DIR}/thing.cpp + ${CMAKE_CURRENT_LIST_DIR}/thing.h + ${CMAKE_CURRENT_LIST_DIR}/thingtypemanager.cpp + ${CMAKE_CURRENT_LIST_DIR}/thingtypemanager.h + ${CMAKE_CURRENT_LIST_DIR}/thingtypedat.cpp + ${CMAKE_CURRENT_LIST_DIR}/thingtypedat.h + ${CMAKE_CURRENT_LIST_DIR}/thingtypeotb.cpp + ${CMAKE_CURRENT_LIST_DIR}/thingtypeotb.h + ${CMAKE_CURRENT_LIST_DIR}/tile.cpp + ${CMAKE_CURRENT_LIST_DIR}/tile.h # lua - ${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.cpp - ${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.h + ${CMAKE_CURRENT_LIST_DIR}/luavaluecasts.cpp + ${CMAKE_CURRENT_LIST_DIR}/luavaluecasts.h # net - ${CMAKE_CURRENT_LIST_DIR}/net/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/net/protocolcodes.h - ${CMAKE_CURRENT_LIST_DIR}/net/protocolgame.cpp - ${CMAKE_CURRENT_LIST_DIR}/net/protocolgame.h - ${CMAKE_CURRENT_LIST_DIR}/net/protocolgameparse.cpp - ${CMAKE_CURRENT_LIST_DIR}/net/protocolgamesend.cpp + ${CMAKE_CURRENT_LIST_DIR}/protocolcodes.h + ${CMAKE_CURRENT_LIST_DIR}/protocolgame.cpp + ${CMAKE_CURRENT_LIST_DIR}/protocolgame.h + ${CMAKE_CURRENT_LIST_DIR}/protocolgameparse.cpp + ${CMAKE_CURRENT_LIST_DIR}/protocolgamesend.cpp # ui - ${CMAKE_CURRENT_LIST_DIR}/ui/declarations.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uicreature.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uicreature.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uiitem.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiitem.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uimap.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uimap.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uiprogressrect.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uiprogressrect.h + ${CMAKE_CURRENT_LIST_DIR}/uicreature.cpp + ${CMAKE_CURRENT_LIST_DIR}/uicreature.h + ${CMAKE_CURRENT_LIST_DIR}/uiitem.cpp + ${CMAKE_CURRENT_LIST_DIR}/uiitem.h + ${CMAKE_CURRENT_LIST_DIR}/uimap.cpp + ${CMAKE_CURRENT_LIST_DIR}/uimap.h + ${CMAKE_CURRENT_LIST_DIR}/uiprogressrect.cpp + ${CMAKE_CURRENT_LIST_DIR}/uiprogressrect.h # util - ${CMAKE_CURRENT_LIST_DIR}/util/position.h + ${CMAKE_CURRENT_LIST_DIR}/position.h ) diff --git a/src/otclient/core/animatedtext.cpp b/src/otclient/animatedtext.cpp similarity index 100% rename from src/otclient/core/animatedtext.cpp rename to src/otclient/animatedtext.cpp diff --git a/src/otclient/core/animatedtext.h b/src/otclient/animatedtext.h similarity index 100% rename from src/otclient/core/animatedtext.h rename to src/otclient/animatedtext.h diff --git a/src/otclient/core/container.cpp b/src/otclient/container.cpp similarity index 100% rename from src/otclient/core/container.cpp rename to src/otclient/container.cpp diff --git a/src/otclient/core/container.h b/src/otclient/container.h similarity index 98% rename from src/otclient/core/container.h rename to src/otclient/container.h index a679605c..30b6bdf3 100644 --- a/src/otclient/core/container.h +++ b/src/otclient/container.h @@ -25,7 +25,7 @@ #include "declarations.h" -#include +#include // @bindclass class Container : public LuaObject diff --git a/src/otclient/core/creature.cpp b/src/otclient/creature.cpp similarity index 100% rename from src/otclient/core/creature.cpp rename to src/otclient/creature.cpp diff --git a/src/otclient/core/creature.h b/src/otclient/creature.h similarity index 100% rename from src/otclient/core/creature.h rename to src/otclient/creature.h diff --git a/src/otclient/core/declarations.h b/src/otclient/declarations.h similarity index 79% rename from src/otclient/core/declarations.h rename to src/otclient/declarations.h index 78dd4ccb..d98b7e44 100644 --- a/src/otclient/core/declarations.h +++ b/src/otclient/declarations.h @@ -20,11 +20,14 @@ * THE SOFTWARE. */ -#ifndef OTCLIENT_CORE_DECLARATIONS_H -#define OTCLIENT_CORE_DECLARATIONS_H +#ifndef OTCLIENT_DECLARATIONS_H +#define OTCLIENT_DECLARATIONS_H -#include +#include "global.h" +#include +#include +// core class Map; class Game; class MapView; @@ -65,4 +68,22 @@ typedef std::vector ThingList; typedef std::vector ThingTypeDatList; typedef std::vector ThingTypeOtbList; +// net +class ProtocolLogin; +class ProtocolGame; + +typedef std::shared_ptr ProtocolGamePtr; +typedef std::shared_ptr ProtocolLoginPtr; + +// ui +class UIItem; +class UICreature; +class UIMap; +class UIProgressRect; + +typedef std::shared_ptr UIItemPtr; +typedef std::shared_ptr UICreaturePtr; +typedef std::shared_ptr UIMapPtr; +typedef std::shared_ptr UIProgressRectPtr; + #endif diff --git a/src/otclient/core/effect.cpp b/src/otclient/effect.cpp similarity index 100% rename from src/otclient/core/effect.cpp rename to src/otclient/effect.cpp diff --git a/src/otclient/core/effect.h b/src/otclient/effect.h similarity index 100% rename from src/otclient/core/effect.h rename to src/otclient/effect.h diff --git a/src/otclient/core/game.cpp b/src/otclient/game.cpp similarity index 99% rename from src/otclient/core/game.cpp rename to src/otclient/game.cpp index 2594d399..0be8bb58 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/game.cpp @@ -29,9 +29,9 @@ #include "statictext.h" #include #include -#include -#include -#include +#include +#include "luavaluecasts.h" +#include "protocolgame.h" Game g_game; diff --git a/src/otclient/core/game.h b/src/otclient/game.h similarity index 99% rename from src/otclient/core/game.h rename to src/otclient/game.h index 10bfe3df..b8c90175 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/game.h @@ -24,9 +24,8 @@ #define GAME_H #include "declarations.h" -#include -#include -#include +#include "item.h" +#include "outfit.h" #include typedef std::tuple Vip; diff --git a/src/otclient/global.h b/src/otclient/global.h index 6f3947ef..aee9243e 100644 --- a/src/otclient/global.h +++ b/src/otclient/global.h @@ -27,6 +27,6 @@ // widely used headers #include "const.h" -#include "util/position.h" +#include "position.h" #endif diff --git a/src/otclient/core/item.cpp b/src/otclient/item.cpp similarity index 100% rename from src/otclient/core/item.cpp rename to src/otclient/item.cpp diff --git a/src/otclient/core/item.h b/src/otclient/item.h similarity index 100% rename from src/otclient/core/item.h rename to src/otclient/item.h diff --git a/src/otclient/core/localplayer.cpp b/src/otclient/localplayer.cpp similarity index 100% rename from src/otclient/core/localplayer.cpp rename to src/otclient/localplayer.cpp diff --git a/src/otclient/core/localplayer.h b/src/otclient/localplayer.h similarity index 100% rename from src/otclient/core/localplayer.h rename to src/otclient/localplayer.h diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index 4387fd62..73e7d7df 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -21,29 +21,29 @@ */ #include "otclient.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include "luavaluecasts.h" +#include "game.h" +#include "tile.h" +#include "container.h" +#include "item.h" +#include "effect.h" +#include "missile.h" +#include "statictext.h" +#include "animatedtext.h" +#include "creature.h" +#include "player.h" +#include "localplayer.h" +#include "map.h" +#include "thingtypemanager.h" +#include "spritemanager.h" +#include "shadermanager.h" +#include "protocolgame.h" +#include "uiitem.h" +#include "uicreature.h" +#include "uimap.h" +#include "uiprogressrect.h" +#include "outfit.h" void OTClient::registerLuaFunctions() { diff --git a/src/otclient/luascript/luavaluecasts.cpp b/src/otclient/luavaluecasts.cpp similarity index 98% rename from src/otclient/luascript/luavaluecasts.cpp rename to src/otclient/luavaluecasts.cpp index 4ed5bf0c..6bf8a6fa 100644 --- a/src/otclient/luascript/luavaluecasts.cpp +++ b/src/otclient/luavaluecasts.cpp @@ -21,7 +21,7 @@ */ #include "luavaluecasts.h" -#include +#include int push_luavalue(const Outfit& outfit) { diff --git a/src/otclient/luascript/luavaluecasts.h b/src/otclient/luavaluecasts.h similarity index 92% rename from src/otclient/luascript/luavaluecasts.h rename to src/otclient/luavaluecasts.h index dfeb02d4..5b42e091 100644 --- a/src/otclient/luascript/luavaluecasts.h +++ b/src/otclient/luavaluecasts.h @@ -23,9 +23,9 @@ #ifndef OTCLIENT_LUAVALUECASTS_H #define OTCLIENT_LUAVALUECASTS_H -#include -#include -#include +#include "global.h" +#include +#include "outfit.h" // outfit int push_luavalue(const Outfit& outfit); diff --git a/src/otclient/core/map.cpp b/src/otclient/map.cpp similarity index 100% rename from src/otclient/core/map.cpp rename to src/otclient/map.cpp diff --git a/src/otclient/core/map.h b/src/otclient/map.h similarity index 100% rename from src/otclient/core/map.h rename to src/otclient/map.h diff --git a/src/otclient/core/mapview.cpp b/src/otclient/mapview.cpp similarity index 99% rename from src/otclient/core/mapview.cpp rename to src/otclient/mapview.cpp index 47cfc313..43091974 100644 --- a/src/otclient/core/mapview.cpp +++ b/src/otclient/mapview.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include MapView::MapView() { @@ -51,7 +51,7 @@ MapView::MapView() MapView::~MapView() { - assert(!g_app.isTermianted()); + assert(!g_app.isTerminated()); } void MapView::draw(const Rect& rect) diff --git a/src/otclient/core/mapview.h b/src/otclient/mapview.h similarity index 99% rename from src/otclient/core/mapview.h rename to src/otclient/mapview.h index a71dbbce..51fff750 100644 --- a/src/otclient/core/mapview.h +++ b/src/otclient/mapview.h @@ -25,7 +25,7 @@ #include "declarations.h" #include -#include +#include #include // @bindclass diff --git a/src/otclient/core/minimap.cpp b/src/otclient/minimap.cpp similarity index 100% rename from src/otclient/core/minimap.cpp rename to src/otclient/minimap.cpp diff --git a/src/otclient/core/minimap.h b/src/otclient/minimap.h similarity index 98% rename from src/otclient/core/minimap.h rename to src/otclient/minimap.h index ce4c6908..0fd09e06 100644 --- a/src/otclient/core/minimap.h +++ b/src/otclient/minimap.h @@ -24,7 +24,7 @@ #ifndef MINIMAP_H #define MINIMAP_H -#include +#include "global.h" #include /* enum { diff --git a/src/otclient/core/missile.cpp b/src/otclient/missile.cpp similarity index 100% rename from src/otclient/core/missile.cpp rename to src/otclient/missile.cpp diff --git a/src/otclient/core/missile.h b/src/otclient/missile.h similarity index 100% rename from src/otclient/core/missile.h rename to src/otclient/missile.h diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index 50965ac9..2b04d1c3 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -24,10 +24,10 @@ #include #include #include -#include -#include -#include -#include "core/spritemanager.h" +#include "game.h" +#include "map.h" +#include "shadermanager.h" +#include "spritemanager.h" #include OTClient g_otclient; diff --git a/src/otclient/otclient.h b/src/otclient/otclient.h index 355af86f..1b5e470e 100644 --- a/src/otclient/otclient.h +++ b/src/otclient/otclient.h @@ -23,7 +23,7 @@ #ifndef OTCLIENT_H #define OTCLIENT_H -#include +#include "global.h" class OTClient { diff --git a/src/otclient/core/outfit.cpp b/src/otclient/outfit.cpp similarity index 100% rename from src/otclient/core/outfit.cpp rename to src/otclient/outfit.cpp diff --git a/src/otclient/core/outfit.h b/src/otclient/outfit.h similarity index 98% rename from src/otclient/core/outfit.h rename to src/otclient/outfit.h index 797e1248..70caf8c9 100644 --- a/src/otclient/core/outfit.h +++ b/src/otclient/outfit.h @@ -24,7 +24,7 @@ #define OUTFIT_H #include -#include +#include "thingtypemanager.h" class Outfit { diff --git a/src/otclient/core/player.cpp b/src/otclient/player.cpp similarity index 100% rename from src/otclient/core/player.cpp rename to src/otclient/player.cpp diff --git a/src/otclient/core/player.h b/src/otclient/player.h similarity index 100% rename from src/otclient/core/player.h rename to src/otclient/player.h diff --git a/src/otclient/util/position.h b/src/otclient/position.h similarity index 99% rename from src/otclient/util/position.h rename to src/otclient/position.h index 4a82bac1..3a39c38f 100644 --- a/src/otclient/util/position.h +++ b/src/otclient/position.h @@ -23,7 +23,7 @@ #ifndef POSITION_H #define POSITION_H -#include +#include "const.h" #include #include diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/protocolcodes.h similarity index 99% rename from src/otclient/net/protocolcodes.h rename to src/otclient/protocolcodes.h index f6d04f7e..86f3ee05 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/protocolcodes.h @@ -23,7 +23,7 @@ #ifndef PROTOCOLCODES_H #define PROTOCOLCODES_H -#include +#include "global.h" #if !(PROTOCOL == 810) && \ !(PROTOCOL == 854) && \ diff --git a/src/otclient/net/protocolgame.cpp b/src/otclient/protocolgame.cpp similarity index 92% rename from src/otclient/net/protocolgame.cpp rename to src/otclient/protocolgame.cpp index c4d8c5e7..306ede37 100644 --- a/src/otclient/net/protocolgame.cpp +++ b/src/otclient/protocolgame.cpp @@ -20,11 +20,11 @@ * THE SOFTWARE. */ -#include -#include -#include -#include -#include +#include "protocolgame.h" +#include "game.h" +#include "player.h" +#include "item.h" +#include "localplayer.h" void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName) { diff --git a/src/otclient/net/protocolgame.h b/src/otclient/protocolgame.h similarity index 99% rename from src/otclient/net/protocolgame.h rename to src/otclient/protocolgame.h index 9ba96e1f..c8372d00 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/protocolgame.h @@ -24,9 +24,9 @@ #define PROTOCOLGAME_H #include "declarations.h" -#include +#include "protocolcodes.h" #include -#include +#include "creature.h" class ProtocolGame : public Protocol { diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp similarity index 99% rename from src/otclient/net/protocolgameparse.cpp rename to src/otclient/protocolgameparse.cpp index 6d5fd20a..c8e27e9d 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -22,15 +22,15 @@ #include "protocolgame.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "localplayer.h" +#include "thingtypemanager.h" +#include "game.h" +#include "map.h" +#include "item.h" +#include "effect.h" +#include "missile.h" +#include "tile.h" +#include "luavaluecasts.h" #include void ProtocolGame::parseMessage(const InputMessagePtr& msg) diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/protocolgamesend.cpp similarity index 99% rename from src/otclient/net/protocolgamesend.cpp rename to src/otclient/protocolgamesend.cpp index dcc1324e..dc5b5a70 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/protocolgamesend.cpp @@ -21,7 +21,7 @@ */ #include "protocolgame.h" -#include +#include "game.h" void ProtocolGame::safeSend(const OutputMessagePtr& outputMessage) { diff --git a/src/otclient/core/shadermanager.cpp b/src/otclient/shadermanager.cpp similarity index 100% rename from src/otclient/core/shadermanager.cpp rename to src/otclient/shadermanager.cpp diff --git a/src/otclient/core/shadermanager.h b/src/otclient/shadermanager.h similarity index 100% rename from src/otclient/core/shadermanager.h rename to src/otclient/shadermanager.h diff --git a/src/otclient/core/spritemanager.cpp b/src/otclient/spritemanager.cpp similarity index 100% rename from src/otclient/core/spritemanager.cpp rename to src/otclient/spritemanager.cpp diff --git a/src/otclient/core/spritemanager.h b/src/otclient/spritemanager.h similarity index 100% rename from src/otclient/core/spritemanager.h rename to src/otclient/spritemanager.h diff --git a/src/otclient/core/statictext.cpp b/src/otclient/statictext.cpp similarity index 100% rename from src/otclient/core/statictext.cpp rename to src/otclient/statictext.cpp diff --git a/src/otclient/core/statictext.h b/src/otclient/statictext.h similarity index 100% rename from src/otclient/core/statictext.h rename to src/otclient/statictext.h diff --git a/src/otclient/core/thing.cpp b/src/otclient/thing.cpp similarity index 100% rename from src/otclient/core/thing.cpp rename to src/otclient/thing.cpp diff --git a/src/otclient/core/thing.h b/src/otclient/thing.h similarity index 99% rename from src/otclient/core/thing.h rename to src/otclient/thing.h index c85284de..7dc4a514 100644 --- a/src/otclient/core/thing.h +++ b/src/otclient/thing.h @@ -25,7 +25,7 @@ #include "declarations.h" #include "thingtypedat.h" -#include +#include struct Light { diff --git a/src/otclient/core/thingstype.h b/src/otclient/thingstype.h similarity index 100% rename from src/otclient/core/thingstype.h rename to src/otclient/thingstype.h diff --git a/src/otclient/core/thingtypedat.cpp b/src/otclient/thingtypedat.cpp similarity index 100% rename from src/otclient/core/thingtypedat.cpp rename to src/otclient/thingtypedat.cpp diff --git a/src/otclient/core/thingtypedat.h b/src/otclient/thingtypedat.h similarity index 99% rename from src/otclient/core/thingtypedat.h rename to src/otclient/thingtypedat.h index ef61ab11..1d5e7f27 100644 --- a/src/otclient/core/thingtypedat.h +++ b/src/otclient/thingtypedat.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include enum DatCategory { diff --git a/src/otclient/core/thingtypemanager.cpp b/src/otclient/thingtypemanager.cpp similarity index 99% rename from src/otclient/core/thingtypemanager.cpp rename to src/otclient/thingtypemanager.cpp index 1ea9ad8f..b20bf410 100644 --- a/src/otclient/core/thingtypemanager.cpp +++ b/src/otclient/thingtypemanager.cpp @@ -29,9 +29,7 @@ #include #include #include - -#define TIXML_USE_STL // use STL strings instead. -#include +#include ThingTypeManager g_things; diff --git a/src/otclient/core/thingtypemanager.h b/src/otclient/thingtypemanager.h similarity index 100% rename from src/otclient/core/thingtypemanager.h rename to src/otclient/thingtypemanager.h diff --git a/src/otclient/core/thingtypeotb.cpp b/src/otclient/thingtypeotb.cpp similarity index 100% rename from src/otclient/core/thingtypeotb.cpp rename to src/otclient/thingtypeotb.cpp diff --git a/src/otclient/core/thingtypeotb.h b/src/otclient/thingtypeotb.h similarity index 98% rename from src/otclient/core/thingtypeotb.h rename to src/otclient/thingtypeotb.h index f99360bf..32a2e086 100644 --- a/src/otclient/core/thingtypeotb.h +++ b/src/otclient/thingtypeotb.h @@ -25,7 +25,7 @@ #define THINGTYPEOTB_H #include -#include +#include enum OtbCategory { OtbInvalidCateogry = 0, diff --git a/src/otclient/core/tile.cpp b/src/otclient/tile.cpp similarity index 99% rename from src/otclient/core/tile.cpp rename to src/otclient/tile.cpp index 7346d44c..85aa0871 100644 --- a/src/otclient/core/tile.cpp +++ b/src/otclient/tile.cpp @@ -27,7 +27,7 @@ #include "game.h" #include "localplayer.h" #include "effect.h" -#include +#include "protocolgame.h" #include Tile::Tile(const Position& position) : diff --git a/src/otclient/core/tile.h b/src/otclient/tile.h similarity index 98% rename from src/otclient/core/tile.h rename to src/otclient/tile.h index 586502d2..aa9d3773 100644 --- a/src/otclient/core/tile.h +++ b/src/otclient/tile.h @@ -24,7 +24,7 @@ #define TILE_H #include "declarations.h" -#include +#include enum tileflags_t { diff --git a/src/otclient/ui/uicreature.cpp b/src/otclient/uicreature.cpp similarity index 100% rename from src/otclient/ui/uicreature.cpp rename to src/otclient/uicreature.cpp diff --git a/src/otclient/ui/uicreature.h b/src/otclient/uicreature.h similarity index 98% rename from src/otclient/ui/uicreature.h rename to src/otclient/uicreature.h index 34ba739a..feded127 100644 --- a/src/otclient/ui/uicreature.h +++ b/src/otclient/uicreature.h @@ -25,7 +25,7 @@ #include "declarations.h" #include -#include +#include "creature.h" class UICreature : public UIWidget { diff --git a/src/otclient/ui/uiitem.cpp b/src/otclient/uiitem.cpp similarity index 100% rename from src/otclient/ui/uiitem.cpp rename to src/otclient/uiitem.cpp diff --git a/src/otclient/ui/uiitem.h b/src/otclient/uiitem.h similarity index 98% rename from src/otclient/ui/uiitem.h rename to src/otclient/uiitem.h index ed709eb1..df58dbdf 100644 --- a/src/otclient/ui/uiitem.h +++ b/src/otclient/uiitem.h @@ -25,7 +25,7 @@ #include "declarations.h" #include -#include +#include "item.h" class UIItem : public UIWidget { diff --git a/src/otclient/ui/uimap.cpp b/src/otclient/uimap.cpp similarity index 97% rename from src/otclient/ui/uimap.cpp rename to src/otclient/uimap.cpp index fcda0d7a..f2efde01 100644 --- a/src/otclient/ui/uimap.cpp +++ b/src/otclient/uimap.cpp @@ -21,12 +21,12 @@ */ #include "uimap.h" -#include -#include -#include +#include "game.h" +#include "map.h" +#include "mapview.h" #include #include -#include +#include "localplayer.h" UIMap::UIMap() { @@ -120,7 +120,7 @@ TilePtr UIMap::getTile(const Point& mousePos) { /* * Known Issue: If you move a container widget into the map rect - * if you move an item onto itself it will allow this to execute + * if you move an item onto itself it will allow this to execute * still dropping the item on the ground. */ if(!m_mapRect.contains(mousePos)) diff --git a/src/otclient/ui/uimap.h b/src/otclient/uimap.h similarity index 98% rename from src/otclient/ui/uimap.h rename to src/otclient/uimap.h index 7505d80f..51f8404f 100644 --- a/src/otclient/ui/uimap.h +++ b/src/otclient/uimap.h @@ -25,9 +25,9 @@ #include "declarations.h" #include -#include +#include "tile.h" -#include +#include "mapview.h" class UIMap : public UIWidget { diff --git a/src/otclient/ui/uiprogressrect.cpp b/src/otclient/uiprogressrect.cpp similarity index 100% rename from src/otclient/ui/uiprogressrect.cpp rename to src/otclient/uiprogressrect.cpp diff --git a/src/otclient/ui/uiprogressrect.h b/src/otclient/uiprogressrect.h similarity index 98% rename from src/otclient/ui/uiprogressrect.h rename to src/otclient/uiprogressrect.h index 91c6615c..104a6672 100644 --- a/src/otclient/ui/uiprogressrect.h +++ b/src/otclient/uiprogressrect.h @@ -25,7 +25,7 @@ #include "declarations.h" #include -#include +#include "item.h" class UIProgressRect : public UIWidget {