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
This commit is contained in:
Eduardo Bart 2012-07-13 22:10:24 -03:00
parent 099716fe03
commit e3298d561c
131 changed files with 1228 additions and 1016 deletions

View File

@ -1,46 +1,49 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
PROJECT(otclient) project(otclient)
ADD_DEFINITIONS(-DFW_WINDOW) set(FRAMEWORK_SOUND ON)
set(FRAMEWORK_GRAPHICS ON)
INCLUDE(src/framework/CMakeLists.txt) set(FRAMEWORK_XML ON)
INCLUDE(src/otclient/CMakeLists.txt) set(FRAMEWORK_NET ON)
include(src/framework/CMakeLists.txt)
include(src/otclient/CMakeLists.txt)
# functions map for reading backtraces # 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 src/main.cpp
) )
# add executable icon for win32 platforms # add executable icon for win32 platforms
IF(WIN32) if(WIN32)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o
COMMAND ${CMAKE_RC_COMPILER} COMMAND ${CMAKE_RC_COMPILER}
-I${CMAKE_CURRENT_SOURCE_DIR}/src -I${CMAKE_CURRENT_SOURCE_DIR}/src
-i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc -i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc
-o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o) -o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o)
SET(executable_SOURCES ${executable_SOURCES} otcicon.o) SET(executable_SOURCES ${executable_SOURCES} otcicon.o)
ENDIF(WIN32) endif(WIN32)
# add otclient executable # 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
TARGET_LINK_LIBRARIES(otclient ${framework_LIBRARIES}) target_link_libraries(otclient ${framework_LIBRARIES})
IF(USE_PCH) if(USE_PCH)
include(cotire) include(cotire)
cotire(otclient) cotire(otclient)
MESSAGE(STATUS "Use precompiled header: ON") message(STATUS "Use precompiled header: ON")
ELSE() else()
MESSAGE(STATUS "Use precompiled header: OFF") message(STATUS "Use precompiled header: OFF")
ENDIF() endif()
# installation # installation
SET(DATA_INSTALL_DIR share/otclient) set(DATA_INSTALL_DIR share/otclient)
INSTALL(TARGETS otclient RUNTIME DESTINATION bin) install(TARGETS otclient RUNTIME DESTINATION bin)
INSTALL(DIRECTORY modules DESTINATION ${DATA_INSTALL_DIR} install(FILES README.md BUGS LICENSE AUTHORS init.lua DESTINATION ${DATA_INSTALL_DIR})
install(DIRECTORY modules DESTINATION ${DATA_INSTALL_DIR}
PATTERN ".git" EXCLUDE) PATTERN ".git" EXCLUDE)

View File

@ -1,7 +1,6 @@
BugReportWindow < MainWindow BugReportWindow < MainWindow
!text: tr('Report Bug') !text: tr('Report Bug')
size: 280 250 size: 280 250
&onEnter: BugReport.doReport
@onEscape: self:hide() @onEscape: self:hide()
Label Label

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

View File

@ -1,173 +1,54 @@
# framework flags
# FRAMEWORK_SOUND
# FRAMEWORK_GRAPHICS
# FRAMEWORK_NET
# FRAMEWORK_XML
# CMAKE_CURRENT_LIST_DIR cmake 2.6 compatiblity # CMAKE_CURRENT_LIST_DIR cmake 2.6 compatiblity
IF(${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) get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) endif(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
# add framework cmake modules # add framework cmake modules
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}")
ADD_DEFINITIONS(-DFRAMEWORK) set(framework_LIBRARIES "")
OPTION(CRASH_HANDLER "Generate crash reports" ON) set(framework_DEFINITIONS "")
OPTION(LUAJIT "Use lua jit" OFF) set(framework_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/..")
OPTION(USE_STATIC_LIBS "Don't use shared libraries (dlls)" ON) set(framework_SOURCES ${framework_SOURCES}
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(framework_SOURCES ${framework_SOURCES}
${CMAKE_CURRENT_LIST_DIR}/application.cpp
${CMAKE_CURRENT_LIST_DIR}/application.h
${CMAKE_CURRENT_LIST_DIR}/const.h ${CMAKE_CURRENT_LIST_DIR}/const.h
${CMAKE_CURRENT_LIST_DIR}/global.h ${CMAKE_CURRENT_LIST_DIR}/global.h
${CMAKE_CURRENT_LIST_DIR}/pch.h ${CMAKE_CURRENT_LIST_DIR}/pch.h
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp ${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 # 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.cpp
${CMAKE_CURRENT_LIST_DIR}/core/adaptativeframecounter.h ${CMAKE_CURRENT_LIST_DIR}/core/adaptativeframecounter.h
${CMAKE_CURRENT_LIST_DIR}/core/binarytree.cpp ${CMAKE_CURRENT_LIST_DIR}/core/binarytree.cpp
@ -197,7 +78,178 @@ SET(framework_SOURCES ${framework_SOURCES}
${CMAKE_CURRENT_LIST_DIR}/core/timer.cpp ${CMAKE_CURRENT_LIST_DIR}/core/timer.cpp
${CMAKE_CURRENT_LIST_DIR}/core/timer.h ${CMAKE_CURRENT_LIST_DIR}/core/timer.h
# graphics # 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
${CMAKE_CURRENT_LIST_DIR}/otml/otmldocument.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmldocument.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlemitter.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlemitter.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlexception.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlexception.h
${CMAKE_CURRENT_LIST_DIR}/otml/otml.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlnode.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlnode.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlparser.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlparser.h
# crash handler
${CMAKE_CURRENT_LIST_DIR}/platform/crashhandler.h
${CMAKE_CURRENT_LIST_DIR}/platform/unixcrashhandler.cpp
${CMAKE_CURRENT_LIST_DIR}/platform/win32crashhandler.cpp
)
# 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}
)
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.cpp
${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.h ${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.h
${CMAKE_CURRENT_LIST_DIR}/graphics/cachedtext.cpp ${CMAKE_CURRENT_LIST_DIR}/graphics/cachedtext.cpp
@ -250,97 +302,8 @@ SET(framework_SOURCES ${framework_SOURCES}
${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.cpp ${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.cpp
${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.h ${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.h
${CMAKE_CURRENT_LIST_DIR}/graphics/vertexarray.h ${CMAKE_CURRENT_LIST_DIR}/graphics/vertexarray.h
${CMAKE_CURRENT_LIST_DIR}/graphics/apngloader.cpp
# luascript ${CMAKE_CURRENT_LIST_DIR}/graphics/apngloader.h
${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
# otml
${CMAKE_CURRENT_LIST_DIR}/otml/declarations.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmldocument.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmldocument.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlemitter.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlemitter.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlexception.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlexception.h
${CMAKE_CURRENT_LIST_DIR}/otml/otml.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlnode.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlnode.h
${CMAKE_CURRENT_LIST_DIR}/otml/otmlparser.cpp
${CMAKE_CURRENT_LIST_DIR}/otml/otmlparser.h
# platform
${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
# 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 # ui
${CMAKE_CURRENT_LIST_DIR}/ui/declarations.h ${CMAKE_CURRENT_LIST_DIR}/ui/declarations.h
@ -373,17 +336,92 @@ SET(framework_SOURCES ${framework_SOURCES}
${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetimage.cpp ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetimage.cpp
${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgettext.cpp ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgettext.cpp
# util # platform window
${CMAKE_CURRENT_LIST_DIR}/util/boolean.h ${CMAKE_CURRENT_LIST_DIR}/platform/platformwindow.cpp
${CMAKE_CURRENT_LIST_DIR}/util/color.cpp ${CMAKE_CURRENT_LIST_DIR}/platform/platformwindow.h
${CMAKE_CURRENT_LIST_DIR}/util/color.h ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp
${CMAKE_CURRENT_LIST_DIR}/util/crypt.cpp ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.h
${CMAKE_CURRENT_LIST_DIR}/util/crypt.h ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp
${CMAKE_CURRENT_LIST_DIR}/util/databuffer.h ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.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}/core/graphicalapplication.cpp
${CMAKE_CURRENT_LIST_DIR}/util/rsa.cpp ${CMAKE_CURRENT_LIST_DIR}/core/graphicalapplication.h
${CMAKE_CURRENT_LIST_DIR}/util/rsa.h
${CMAKE_CURRENT_LIST_DIR}/util/size.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})

View File

@ -0,0 +1,143 @@
/*
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "application.h"
#include <framework/core/clock.h>
#include <framework/core/resourcemanager.h>
#include <framework/core/modulemanager.h>
#include <framework/core/eventdispatcher.h>
#include <framework/core/configmanager.h>
#include <framework/luaengine/luainterface.h>
#include <framework/platform/crashhandler.h>
#ifdef FW_NET
#include <framework/net/connection.h>
#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<std::string>& args)
{
// capture exit signals
signal(SIGTERM, exitSignalHandler);
signal(SIGINT, exitSignalHandler);
#ifdef CRASH_HANDLER
installCrashHandler();
#endif
std::string startupOptions;
for(uint i=1;i<args.size();++i) {
const std::string& arg = args[i];
startupOptions += " ";
startupOptions += arg;
}
if(startupOptions.length() > 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<bool>("g_app", "onClose"))
exit();
}

View File

@ -23,49 +23,35 @@
#ifndef APPLICATION_H #ifndef APPLICATION_H
#define APPLICATION_H #define APPLICATION_H
#include <framework/core/inputevent.h> #include <framework/global.h>
#include <framework/core/adaptativeframecounter.h> #include <framework/core/adaptativeframecounter.h>
#include <framework/graphics/declarations.h>
//@bindsingleton g_app //@bindsingleton g_app
class Application class Application
{ {
enum {
POLL_CYCLE_DELAY = 10
};
public: public:
Application(); Application();
virtual ~Application() {}
void init(const std::string& compactName, const std::vector<std::string>& args); virtual void init(const std::vector<std::string>& args);
void deinit(); virtual void deinit();
void terminate(); virtual void terminate();
void run(); virtual void run() = 0;
void exit(); virtual void poll();
void poll(); virtual void exit();
void close(); virtual 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); }
void setName(const std::string& name) { m_appName = name; } void setName(const std::string& name) { m_appName = name; }
void setCompactName(const std::string& compactName) { m_appCompactName = compactName; } void setCompactName(const std::string& compactName) { m_appCompactName = compactName; }
void setVersion(const std::string& version) { m_appVersion = version; } void setVersion(const std::string& version) { m_appVersion = version; }
bool isRunning() { return m_running; } bool isRunning() { return m_running; }
bool isStopping() { return m_stopping; } bool isStopping() { return m_stopping; }
bool isTermianted() { return m_terminated; } bool isTerminated() { return m_terminated; }
bool isOnInputEvent() { return m_onInputEvent; }
const std::string& getName() { return m_appName; } const std::string& getName() { return m_appName; }
const std::string& getCompactName() { return m_appCompactName; } const std::string& getCompactName() { return m_appCompactName; }
const std::string& getVersion() { return m_appVersion; } 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 getBuildCompiler() { return BUILD_COMPILER; }
std::string getBuildDate() { return BUILD_DATE; } std::string getBuildDate() { return BUILD_DATE; }
std::string getBuildRevision() { return BUILD_REVISION; } std::string getBuildRevision() { return BUILD_REVISION; }
@ -74,26 +60,21 @@ public:
std::string getStartupOptions() { return m_startupOptions; } std::string getStartupOptions() { return m_startupOptions; }
protected: protected:
void resize(const Size& size);
void inputEvent(const InputEvent& event);
void registerLuaFunctions(); void registerLuaFunctions();
std::string m_appName; std::string m_appName;
std::string m_appCompactName; std::string m_appCompactName;
std::string m_appVersion; std::string m_appVersion;
std::string m_startupOptions; std::string m_startupOptions;
Boolean<false> m_initialized;
Boolean<false> m_running; Boolean<false> m_running;
Boolean<false> m_stopping; Boolean<false> m_stopping;
Boolean<false> m_terminated; Boolean<false> m_terminated;
Boolean<false> m_onInputEvent;
Boolean<false> 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
#endif

View File

@ -20,20 +20,41 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef OTCLIENT_UI_DECLARATIONS_H
#define OTCLIENT_UI_DECLARATIONS_H
#include <otclient/global.h> #include "consoleapplication.h"
#include <framework/ui/declarations.h> #include <framework/core/clock.h>
#include <framework/luaengine/luainterface.h>
class UIItem;
class UICreature;
class UIMap;
class UIProgressRect;
typedef std::shared_ptr<UIItem> UIItemPtr;
typedef std::shared_ptr<UICreature> UICreaturePtr;
typedef std::shared_ptr<UIMap> UIMapPtr;
typedef std::shared_ptr<UIProgressRect> UIProgressRectPtr;
#ifdef FW_NET
#include <framework/net/connection.h>
#endif #endif
ConsoleApplication g_app;
void ConsoleApplication::run()
{
m_running = true;
// run the first poll
poll();
// 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;
}

View File

@ -20,17 +20,23 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef OTCLIENT_NET_DECLARATIONS_H
#define OTCLIENT_NET_DECLARATIONS_H
#include <otclient/global.h> #ifndef CONSOLEAPPLICATION_H
#include <framework/net/declarations.h> #define CONSOLEAPPLICATION_H
#include "protocolcodes.h"
class ProtocolLogin; #include "application.h"
class ProtocolGame;
typedef std::shared_ptr<ProtocolGame> ProtocolGamePtr; class ConsoleApplication : public Application
typedef std::shared_ptr<ProtocolLogin> ProtocolLoginPtr; {
public:
void run();
int getFps() { return m_frameCounter.getLastFps(); }
protected:
AdaptativeFrameCounter m_frameCounter;
};
extern ConsoleApplication g_app;
#endif #endif

View File

@ -23,7 +23,7 @@
#ifndef EVENT_H #ifndef EVENT_H
#define EVENT_H #define EVENT_H
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
// @bindclass // @bindclass
class Event : public LuaObject class Event : public LuaObject

View File

@ -22,7 +22,7 @@
#include "filestream.h" #include "filestream.h"
#include "binarytree.h" #include "binarytree.h"
#include <framework/application.h> #include <framework/core/application.h>
#include <physfs.h> #include <physfs.h>
@ -37,7 +37,7 @@ FileStream::FileStream(const std::string& name, PHYSFS_File *fileHandle, bool wr
FileStream::~FileStream() FileStream::~FileStream()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
close(); close();
} }

View File

@ -24,7 +24,7 @@
#define FILESTREAM_H #define FILESTREAM_H
#include "declarations.h" #include "declarations.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/util/databuffer.h> #include <framework/util/databuffer.h>
struct PHYSFS_File; struct PHYSFS_File;

View File

@ -20,174 +20,97 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "application.h"
#include "graphicalapplication.h"
#include <framework/core/clock.h> #include <framework/core/clock.h>
#include <framework/core/resourcemanager.h>
#include <framework/core/modulemanager.h>
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/core/configmanager.h>
#include <framework/net/connection.h>
#include <framework/platform/platformwindow.h> #include <framework/platform/platformwindow.h>
#include <framework/ui/uimanager.h> #include <framework/ui/uimanager.h>
#include <framework/ui/uiwidget.h>
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>
#include <framework/graphics/particlemanager.h> #include <framework/graphics/particlemanager.h>
#include <framework/graphics/painter.h> #include <framework/graphics/painter.h>
#ifdef FW_SOUND
#include <framework/sound/soundmanager.h> #include <framework/sound/soundmanager.h>
#include <framework/luascript/luainterface.h>
#include <framework/platform/crashhandler.h>
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<std::string>& args)
{
// capture exit signals
signal(SIGTERM, exitSignalHandler);
signal(SIGINT, exitSignalHandler);
#ifdef CRASH_HANDLER
installCrashHandler();
#endif #endif
m_appCompactName = compactName; GraphicalApplication g_app;
std::string startupOptions; void GraphicalApplication::init(const std::vector<std::string>& args)
for(uint i=1;i<args.size();++i) { {
const std::string& arg = args[i]; Application::init(args);
startupOptions += " ";
startupOptions += arg;
}
if(startupOptions.length() > 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();
// initialize ui
g_ui.init();
// setup platform window // setup platform window
g_window.init(); g_window.init();
g_window.hide(); g_window.hide();
g_window.setOnResize(std::bind(&Application::resize, this, std::placeholders::_1)); g_window.setOnResize(std::bind(&GraphicalApplication::resize, this, std::placeholders::_1));
g_window.setOnInputEvent(std::bind(&Application::inputEvent, this, std::placeholders::_1)); g_window.setOnInputEvent(std::bind(&GraphicalApplication::inputEvent, this, std::placeholders::_1));
g_window.setOnClose(std::bind(&Application::close, this)); g_window.setOnClose(std::bind(&GraphicalApplication::close, this));
// initialize ui
g_ui.init();
// initialize graphics // initialize graphics
g_graphics.init(); g_graphics.init();
// initialize sound
g_sounds.init();
// fire first resize event // fire first resize event
resize(g_window.getSize()); 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 // hide the window because there is no render anymore
g_window.hide(); g_window.hide();
g_lua.callGlobalField("g_app", "onTerminate"); Application::deinit();
// 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() void GraphicalApplication::terminate()
{ {
assert(m_initialized);
// destroy particles // destroy particles
g_particles.terminate(); g_particles.terminate();
// destroy any remaining widget // destroy any remaining widget
g_ui.terminate(); g_ui.terminate();
// terminate network #ifdef FW_SOUND
Connection::terminate();
// terminate sound // terminate sound
g_sounds.terminate(); g_sounds.terminate();
#endif
// save configurations Application::terminate();
g_configs.save(); m_terminated = false;
// release resources
g_resources.terminate();
// terminate script environment
g_lua.terminate();
// flush remaining dispatcher events
g_dispatcher.flush();
// terminate graphics // terminate graphics
m_foreground = nullptr; m_foreground = nullptr;
g_graphics.terminate(); g_graphics.terminate();
g_window.terminate(); g_window.terminate();
g_logger.debug("Application ended successfully.");
m_terminated = true; m_terminated = true;
} }
void Application::run() void GraphicalApplication::run()
{ {
assert(m_initialized);
m_running = true; m_running = true;
// run the first poll
poll();
g_lua.callGlobalField("g_app", "onRun");
// first clock update // first clock update
g_clock.update(); g_clock.update();
// run the first poll
poll();
g_clock.update();
g_lua.callGlobalField("g_app", "onRun");
// show the application only after we draw some frames // show the application only after we draw some frames
g_dispatcher.scheduleEvent([] { g_window.show(); }, 10); g_dispatcher.scheduleEvent([] { g_window.show(); }, 10);
while(!m_stopping) { while(!m_stopping) {
// poll all events before rendering // poll all events before rendering
poll(); poll();
@ -269,33 +192,27 @@ void Application::run()
m_running = false; m_running = false;
} }
void Application::exit() void GraphicalApplication::poll()
{
g_logger.info("Exiting application..");
m_stopping = true;
}
void Application::poll()
{ {
#ifdef FW_SOUND
g_sounds.poll(); g_sounds.poll();
#endif
// poll input events // poll window input events
g_window.poll(); g_window.poll();
//g_particles.update(); g_particles.update();
Connection::poll(); Application::poll();
g_dispatcher.poll();
} }
void Application::close() void GraphicalApplication::close()
{ {
m_onInputEvent = true; m_onInputEvent = true;
if(!g_lua.callGlobalField<bool>("g_app", "onClose")) Application::close();
exit();
m_onInputEvent = false; m_onInputEvent = false;
} }
void Application::resize(const Size& size) void GraphicalApplication::resize(const Size& size)
{ {
m_onInputEvent = true; m_onInputEvent = true;
g_graphics.resize(size); g_graphics.resize(size);
@ -309,7 +226,7 @@ void Application::resize(const Size& size)
m_mustRepaint = true; m_mustRepaint = true;
} }
void Application::inputEvent(const InputEvent& event) void GraphicalApplication::inputEvent(const InputEvent& event)
{ {
m_onInputEvent = true; m_onInputEvent = true;
g_ui.inputEvent(event); g_ui.inputEvent(event);

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef GRAPHICALAPPLICATION_H
#define GRAPHICALAPPLICATION_H
#include "application.h"
#include <framework/graphics/declarations.h>
#include <framework/core/inputevent.h>
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<false> m_onInputEvent;
Boolean<false> m_mustRepaint;
AdaptativeFrameCounter m_backgroundFrameCounter;
AdaptativeFrameCounter m_foregroundFrameCounter;
TexturePtr m_foreground;
};
extern GraphicalApplication g_app;
#endif

View File

@ -22,7 +22,10 @@
#include "logger.h" #include "logger.h"
#include "eventdispatcher.h" #include "eventdispatcher.h"
#ifdef FW_GRAPHICS
#include <framework/platform/platformwindow.h> #include <framework/platform/platformwindow.h>
#endif
Logger g_logger; Logger g_logger;
@ -61,7 +64,7 @@ void Logger::log(Fw::LogLevel level, const std::string& message)
} }
if(level == Fw::LogFatal) { if(level == Fw::LogFatal) {
#ifdef FW_WINDOW #ifdef FW_GRAPHICS
g_window.displayFatalError(message); g_window.displayFatalError(message);
#endif #endif
ignoreLogs = true; ignoreLogs = true;

View File

@ -24,7 +24,7 @@
#include "modulemanager.h" #include "modulemanager.h"
#include <framework/otml/otml.h> #include <framework/otml/otml.h>
#include <framework/luascript/luainterface.h> #include <framework/luaengine/luainterface.h>
Module::Module(const std::string& name) Module::Module(const std::string& name)
{ {

View File

@ -26,7 +26,7 @@
#include "declarations.h" #include "declarations.h"
#include <framework/otml/declarations.h> #include <framework/otml/declarations.h>
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
// @bindclass // @bindclass
class Module : public LuaObject class Module : public LuaObject

View File

@ -24,7 +24,7 @@
#include "resourcemanager.h" #include "resourcemanager.h"
#include <framework/otml/otml.h> #include <framework/otml/otml.h>
#include <framework/application.h> #include <framework/core/application.h>
ModuleManager g_modules; ModuleManager g_modules;

View File

@ -23,8 +23,8 @@
#include "resourcemanager.h" #include "resourcemanager.h"
#include "filestream.h" #include "filestream.h"
#include <framework/application.h> #include <framework/core/application.h>
#include <framework/luascript/luainterface.h> #include <framework/luaengine/luainterface.h>
#include <physfs.h> #include <physfs.h>

View File

@ -25,7 +25,7 @@
#include "texture.h" #include "texture.h"
#include <framework/platform/platformwindow.h> #include <framework/platform/platformwindow.h>
#include <framework/application.h> #include <framework/core/application.h>
uint FrameBuffer::boundFbo = 0; uint FrameBuffer::boundFbo = 0;
@ -47,7 +47,7 @@ void FrameBuffer::internalCreate()
FrameBuffer::~FrameBuffer() FrameBuffer::~FrameBuffer()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
if(g_graphics.ok() && m_fbo != 0) if(g_graphics.ok() && m_fbo != 0)
glDeleteFramebuffers(1, &m_fbo); glDeleteFramebuffers(1, &m_fbo);
} }

View File

@ -23,7 +23,7 @@
#include "hardwarebuffer.h" #include "hardwarebuffer.h"
#include "graphics.h" #include "graphics.h"
#include <framework/application.h> #include <framework/core/application.h>
#include <framework/core/logger.h> #include <framework/core/logger.h>
HardwareBuffer::HardwareBuffer(Type type) HardwareBuffer::HardwareBuffer(Type type)
@ -37,7 +37,7 @@ HardwareBuffer::HardwareBuffer(Type type)
HardwareBuffer::~HardwareBuffer() HardwareBuffer::~HardwareBuffer()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
if(g_graphics.ok()) if(g_graphics.ok())
glDeleteBuffers(1, &m_id); glDeleteBuffers(1, &m_id);
} }

View File

@ -24,7 +24,7 @@
#include "image.h" #include "image.h"
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <framework/thirdparty/apngloader.h> #include <framework/graphics/apngloader.h>
Image::Image(const Size& size, int bpp, uint8 *pixels) Image::Image(const Size& size, int bpp, uint8 *pixels)
{ {

View File

@ -25,7 +25,7 @@
#include "declarations.h" #include "declarations.h"
#include "particlesystem.h" #include "particlesystem.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/otml/otml.h> #include <framework/otml/otml.h>
class ParticleEffectType : public LuaObject class ParticleEffectType : public LuaObject

View File

@ -23,7 +23,7 @@
#include "shader.h" #include "shader.h"
#include "graphics.h" #include "graphics.h"
#include <framework/application.h> #include <framework/core/application.h>
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
Shader::Shader(Shader::ShaderType shaderType) Shader::Shader(Shader::ShaderType shaderType)
@ -44,7 +44,7 @@ Shader::Shader(Shader::ShaderType shaderType)
Shader::~Shader() Shader::~Shader()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
if(g_graphics.ok()) if(g_graphics.ok())
glDeleteShader(m_shaderId); glDeleteShader(m_shaderId);
} }

View File

@ -23,7 +23,7 @@
#include "shaderprogram.h" #include "shaderprogram.h"
#include "graphics.h" #include "graphics.h"
#include <framework/application.h> #include <framework/core/application.h>
uint ShaderProgram::m_currentProgram = 0; uint ShaderProgram::m_currentProgram = 0;
@ -38,7 +38,7 @@ ShaderProgram::ShaderProgram()
ShaderProgram::~ShaderProgram() ShaderProgram::~ShaderProgram()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
if(g_graphics.ok()) if(g_graphics.ok())
glDeleteProgram(m_programId); glDeleteProgram(m_programId);
} }

View File

@ -24,7 +24,7 @@
#define SHADERPROGRAM_H #define SHADERPROGRAM_H
#include "shader.h" #include "shader.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
// @bindclass // @bindclass
class ShaderProgram : public LuaObject class ShaderProgram : public LuaObject

View File

@ -25,7 +25,7 @@
#include "framebuffer.h" #include "framebuffer.h"
#include "image.h" #include "image.h"
#include <framework/application.h> #include <framework/core/application.h>
Texture::Texture() Texture::Texture()
{ {
@ -79,7 +79,7 @@ Texture::Texture(const ImagePtr& image, bool buildMipmaps)
Texture::~Texture() Texture::~Texture()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
// free texture from gl memory // free texture from gl memory
if(g_graphics.ok() && m_id != 0) if(g_graphics.ok() && m_id != 0)
glDeleteTextures(1, &m_id); glDeleteTextures(1, &m_id);

View File

@ -26,7 +26,7 @@
#include "image.h" #include "image.h"
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <framework/thirdparty/apngloader.h> #include <framework/graphics/apngloader.h>
TextureManager g_textures; TextureManager g_textures;

View File

@ -26,7 +26,7 @@
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <lua.hpp> #include <lua.hpp>
#include <framework/thirdparty/lbitlib-5.2.0-backport4.h> #include "lbitlib.h"
LuaInterface g_lua; LuaInterface g_lua;

View File

@ -23,7 +23,7 @@
#include "luaobject.h" #include "luaobject.h"
#include "luainterface.h" #include "luainterface.h"
#include <framework/application.h> #include <framework/core/application.h>
LuaObject::LuaObject() : LuaObject::LuaObject() :
m_fieldsTableRef(-1), m_fieldsTableRef(-1),
@ -33,7 +33,7 @@ LuaObject::LuaObject() :
LuaObject::~LuaObject() LuaObject::~LuaObject()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
releaseLuaFieldsTable(); releaseLuaFieldsTable();
if(m_metatableRef != -1) { if(m_metatableRef != -1) {

View File

@ -20,8 +20,8 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "application.h" #include <framework/core/application.h>
#include <framework/luascript/luainterface.h> #include <framework/luaengine/luainterface.h>
#include <framework/graphics/fontmanager.h> #include <framework/graphics/fontmanager.h>
#include <framework/ui/ui.h> #include <framework/ui/ui.h>
#include <framework/net/protocol.h> #include <framework/net/protocol.h>
@ -50,15 +50,103 @@ void Application::registerLuaFunctions()
g_lua.bindGlobalFunction("sizetostring", [](const Size& v) { return stdext::to_string(v); }); g_lua.bindGlobalFunction("sizetostring", [](const Size& v) { return stdext::to_string(v); });
g_lua.bindGlobalFunction("iptostring", [](int v) { return stdext::ip_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<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "setCompactName", &Application::setCompactName, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "setVersion", &Application::setVersion, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "isRunning", &Application::isRunning, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "isStopping", &Application::isStopping, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getName", &Application::getName, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getCompactName", &Application::getCompactName, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getVersion", &Application::getVersion, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getBuildCompiler", &Application::getBuildCompiler, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getBuildDate", &Application::getBuildDate, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getBuildRevision", &Application::getBuildRevision, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getBuildCommit", &Application::getBuildCommit, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "getBuildType", &Application::getBuildType, static_cast<Application*>(&g_app));
g_lua.bindSingletonFunction("g_app", "exit", &Application::exit, static_cast<Application*>(&g_app));
// Crypt
g_lua.registerSingletonClass("g_crypt"); g_lua.registerSingletonClass("g_crypt");
g_lua.bindClassStaticFunction("g_crypt", "encrypt", Crypt::encrypt); g_lua.bindClassStaticFunction("g_crypt", "encrypt", Crypt::encrypt);
g_lua.bindClassStaticFunction("g_crypt", "decrypt", Crypt::decrypt); g_lua.bindClassStaticFunction("g_crypt", "decrypt", Crypt::decrypt);
// Clock
g_lua.registerSingletonClass("g_clock"); g_lua.registerSingletonClass("g_clock");
g_lua.bindSingletonFunction("g_clock", "micros", &Clock::micros, &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", "millis", &Clock::millis, &g_clock);
g_lua.bindSingletonFunction("g_clock", "seconds", &Clock::seconds, &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<Module>();
g_lua.bindClassMemberFunction<Module>("load", &Module::load);
g_lua.bindClassMemberFunction<Module>("unload", &Module::unload);
g_lua.bindClassMemberFunction<Module>("reload", &Module::reload);
g_lua.bindClassMemberFunction<Module>("canReload", &Module::canReload);
g_lua.bindClassMemberFunction<Module>("canUnload", &Module::canUnload);
g_lua.bindClassMemberFunction<Module>("isLoaded", &Module::isLoaded);
g_lua.bindClassMemberFunction<Module>("isReloadble", &Module::isReloadable);
g_lua.bindClassMemberFunction<Module>("getDescription", &Module::getDescription);
g_lua.bindClassMemberFunction<Module>("getName", &Module::getName);
g_lua.bindClassMemberFunction<Module>("getAuthor", &Module::getAuthor);
g_lua.bindClassMemberFunction<Module>("getWebsite", &Module::getWebsite);
g_lua.bindClassMemberFunction<Module>("getVersion", &Module::getVersion);
g_lua.bindClassMemberFunction<Module>("isAutoLoad", &Module::isAutoLoad);
g_lua.bindClassMemberFunction<Module>("getAutoLoadPriority", &Module::getAutoLoadPriority);
// Event // Event
g_lua.registerClass<Event>(); g_lua.registerClass<Event>();
g_lua.bindClassMemberFunction<Event>("cancel", &Event::cancel); g_lua.bindClassMemberFunction<Event>("cancel", &Event::cancel);
@ -75,6 +163,95 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<ScheduledEvent>("cyclesExecuted", &ScheduledEvent::cyclesExecuted); g_lua.bindClassMemberFunction<ScheduledEvent>("cyclesExecuted", &ScheduledEvent::cyclesExecuted);
g_lua.bindClassMemberFunction<ScheduledEvent>("maxCycles", &ScheduledEvent::maxCycles); g_lua.bindClassMemberFunction<ScheduledEvent>("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 // UIWidget
g_lua.registerClass<UIWidget>(); g_lua.registerClass<UIWidget>();
g_lua.bindClassStaticFunction<UIWidget>("create", []{ return UIWidgetPtr(new UIWidget); }); g_lua.bindClassStaticFunction<UIWidget>("create", []{ return UIWidgetPtr(new UIWidget); });
@ -412,6 +589,24 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<UITextEdit>("isShiftNavigation", &UITextEdit::isShiftNavigation); g_lua.bindClassMemberFunction<UITextEdit>("isShiftNavigation", &UITextEdit::isShiftNavigation);
g_lua.bindClassMemberFunction<UITextEdit>("isMultiline", &UITextEdit::isMultiline); g_lua.bindClassMemberFunction<UITextEdit>("isMultiline", &UITextEdit::isMultiline);
g_lua.registerClass<ShaderProgram>();
g_lua.registerClass<PainterShaderProgram>();
g_lua.bindClassMemberFunction<PainterShaderProgram>("addMultiTexture", &PainterShaderProgram::addMultiTexture);
// ParticleEffect
g_lua.registerClass<ParticleEffectType>();
g_lua.bindClassStaticFunction<ParticleEffectType>("create", []{ return ParticleEffectTypePtr(new ParticleEffectType); });
g_lua.bindClassMemberFunction<ParticleEffectType>("getName", &ParticleEffectType::getName);
g_lua.bindClassMemberFunction<ParticleEffectType>("getFile", &ParticleEffectType::getFile);
g_lua.bindClassMemberFunction<ParticleEffectType>("getDescription", &ParticleEffectType::getDescription);
// UIParticles
g_lua.registerClass<UIParticles, UIWidget>();
g_lua.bindClassStaticFunction<UIParticles>("create", []{ return UIParticlesPtr(new UIParticles); } );
g_lua.bindClassMemberFunction<UIParticles>("addEffect", &UIParticles::addEffect);
#endif
#ifdef FW_NET
// Protocol // Protocol
g_lua.registerClass<Protocol>(); g_lua.registerClass<Protocol>();
g_lua.bindClassStaticFunction<Protocol>("create", []{ return ProtocolPtr(new Protocol); }); g_lua.bindClassStaticFunction<Protocol>("create", []{ return ProtocolPtr(new Protocol); });
@ -426,23 +621,6 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<Protocol>("enableXteaEncryption", &Protocol::enableXteaEncryption); g_lua.bindClassMemberFunction<Protocol>("enableXteaEncryption", &Protocol::enableXteaEncryption);
g_lua.bindClassMemberFunction<Protocol>("enableChecksum", &Protocol::enableChecksum); g_lua.bindClassMemberFunction<Protocol>("enableChecksum", &Protocol::enableChecksum);
// Module
g_lua.registerClass<Module>();
g_lua.bindClassMemberFunction<Module>("load", &Module::load);
g_lua.bindClassMemberFunction<Module>("unload", &Module::unload);
g_lua.bindClassMemberFunction<Module>("reload", &Module::reload);
g_lua.bindClassMemberFunction<Module>("canReload", &Module::canReload);
g_lua.bindClassMemberFunction<Module>("canUnload", &Module::canUnload);
g_lua.bindClassMemberFunction<Module>("isLoaded", &Module::isLoaded);
g_lua.bindClassMemberFunction<Module>("isReloadble", &Module::isReloadable);
g_lua.bindClassMemberFunction<Module>("getDescription", &Module::getDescription);
g_lua.bindClassMemberFunction<Module>("getName", &Module::getName);
g_lua.bindClassMemberFunction<Module>("getAuthor", &Module::getAuthor);
g_lua.bindClassMemberFunction<Module>("getWebsite", &Module::getWebsite);
g_lua.bindClassMemberFunction<Module>("getVersion", &Module::getVersion);
g_lua.bindClassMemberFunction<Module>("isAutoLoad", &Module::isAutoLoad);
g_lua.bindClassMemberFunction<Module>("getAutoLoadPriority", &Module::getAutoLoadPriority);
// InputMessage // InputMessage
g_lua.registerClass<InputMessage>(); g_lua.registerClass<InputMessage>();
g_lua.bindClassStaticFunction<InputMessage>("create", []{ return InputMessagePtr(new InputMessage); }); g_lua.bindClassStaticFunction<InputMessage>("create", []{ return InputMessagePtr(new InputMessage); });
@ -476,146 +654,9 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<OutputMessage>("addPaddingBytes", &OutputMessage::addPaddingBytes); g_lua.bindClassMemberFunction<OutputMessage>("addPaddingBytes", &OutputMessage::addPaddingBytes);
g_lua.bindClassMemberFunction<OutputMessage>("encryptRSA", &OutputMessage::encryptRSA); g_lua.bindClassMemberFunction<OutputMessage>("encryptRSA", &OutputMessage::encryptRSA);
g_lua.bindClassMemberFunction<OutputMessage>("getMessageSize", &OutputMessage::getMessageSize); g_lua.bindClassMemberFunction<OutputMessage>("getMessageSize", &OutputMessage::getMessageSize);
#endif
g_lua.registerClass<ShaderProgram>(); #ifdef FW_SOUND
g_lua.registerClass<PainterShaderProgram>();
g_lua.bindClassMemberFunction<PainterShaderProgram>("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);
// SoundManager // SoundManager
g_lua.registerSingletonClass("g_sounds"); g_lua.registerSingletonClass("g_sounds");
g_lua.bindSingletonFunction("g_sounds", "preload", &SoundManager::preload, &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", "isSoundEnabled", &SoundManager::isSoundEnabled, &g_sounds);
g_lua.bindSingletonFunction("g_sounds", "isAudioEnabled", &SoundManager::isAudioEnabled, &g_sounds); g_lua.bindSingletonFunction("g_sounds", "isAudioEnabled", &SoundManager::isAudioEnabled, &g_sounds);
g_lua.bindSingletonFunction("g_sounds", "getCurrentMusic", &SoundManager::getCurrentMusic, &g_sounds); g_lua.bindSingletonFunction("g_sounds", "getCurrentMusic", &SoundManager::getCurrentMusic, &g_sounds);
#endif
// 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<ParticleEffectType>();
g_lua.bindClassStaticFunction<ParticleEffectType>("create", []{ return ParticleEffectTypePtr(new ParticleEffectType); });
g_lua.bindClassMemberFunction<ParticleEffectType>("getName", &ParticleEffectType::getName);
g_lua.bindClassMemberFunction<ParticleEffectType>("getFile", &ParticleEffectType::getFile);
g_lua.bindClassMemberFunction<ParticleEffectType>("getDescription", &ParticleEffectType::getDescription);
// UIParticles
g_lua.registerClass<UIParticles, UIWidget>();
g_lua.bindClassStaticFunction<UIParticles>("create", []{ return UIParticlesPtr(new UIParticles); } );
g_lua.bindClassMemberFunction<UIParticles>("addEffect", &UIParticles::addEffect);
} }

View File

@ -22,7 +22,7 @@
#include "connection.h" #include "connection.h"
#include <framework/application.h> #include <framework/core/application.h>
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <boost/asio.hpp> #include <boost/asio.hpp>
@ -41,7 +41,7 @@ Connection::Connection() :
Connection::~Connection() Connection::~Connection()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
close(); close();
} }

View File

@ -24,7 +24,7 @@
#define INPUTMESSAGE_H #define INPUTMESSAGE_H
#include "declarations.h" #include "declarations.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
// @bindclass // @bindclass
class InputMessage : public LuaObject class InputMessage : public LuaObject

View File

@ -24,7 +24,7 @@
#define OUTPUTMESSAGE_H #define OUTPUTMESSAGE_H
#include "declarations.h" #include "declarations.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
// @bindclass // @bindclass
class OutputMessage : public LuaObject class OutputMessage : public LuaObject

View File

@ -22,7 +22,7 @@
#include "protocol.h" #include "protocol.h"
#include "connection.h" #include "connection.h"
#include <framework/application.h> #include <framework/core/application.h>
Protocol::Protocol() Protocol::Protocol()
{ {
@ -33,7 +33,7 @@ Protocol::Protocol()
Protocol::~Protocol() Protocol::~Protocol()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
disconnect(); disconnect();
} }

View File

@ -27,7 +27,7 @@
#include "inputmessage.h" #include "inputmessage.h"
#include "outputmessage.h" #include "outputmessage.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
// @bindclass // @bindclass
class Protocol : public LuaObject class Protocol : public LuaObject

View File

@ -59,6 +59,7 @@
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <atomic> #include <atomic>
#include <thread>
// boost utilities // boost utilities
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>

View File

@ -24,7 +24,7 @@
#include "crashhandler.h" #include "crashhandler.h"
#include <framework/global.h> #include <framework/global.h>
#include <framework/application.h> #include <framework/core/application.h>
#ifndef __USE_GNU #ifndef __USE_GNU
#define __USE_GNU #define __USE_GNU

View File

@ -24,7 +24,7 @@
#include "crashhandler.h" #include "crashhandler.h"
#include <framework/global.h> #include <framework/global.h>
#include <framework/application.h> #include <framework/core/application.h>
#include <windows.h> #include <windows.h>
#include <process.h> #include <process.h>

View File

@ -24,8 +24,8 @@
#include "win32window.h" #include "win32window.h"
#include <framework/application.h> #include <framework/core/application.h>
#include <framework/thirdparty/apngloader.h> #include <framework/graphics/apngloader.h>
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#define HSB_BIT_SET(p, n) (p[(n)/8] |= (128 >>((n)%8))) #define HSB_BIT_SET(p, n) (p[(n)/8] |= (128 >>((n)%8)))

View File

@ -24,7 +24,7 @@
#include "x11window.h" #include "x11window.h"
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <framework/thirdparty/apngloader.h> #include <framework/graphics/apngloader.h>
#define LSB_BIT_SET(p, n) (p[(n)/8] |= (1 <<((n)%8))) #define LSB_BIT_SET(p, n) (p[(n)/8] |= (1 <<((n)%8)))

View File

@ -24,7 +24,7 @@
#define UILAYOUT_H #define UILAYOUT_H
#include "declarations.h" #include "declarations.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/otml/otml.h> #include <framework/otml/otml.h>
// @bindclass // @bindclass

View File

@ -27,7 +27,7 @@
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>
#include <framework/platform/platformwindow.h> #include <framework/platform/platformwindow.h>
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/application.h> #include <framework/core/application.h>
UIManager g_ui; UIManager g_ui;

View File

@ -26,7 +26,7 @@
#include <framework/platform/platformwindow.h> #include <framework/platform/platformwindow.h>
#include <framework/core/clock.h> #include <framework/core/clock.h>
#include <framework/otml/otmlnode.h> #include <framework/otml/otmlnode.h>
#include <framework/application.h> #include <framework/core/application.h>
UITextEdit::UITextEdit() UITextEdit::UITextEdit()
{ {

View File

@ -30,7 +30,7 @@
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>
#include <framework/platform/platformwindow.h> #include <framework/platform/platformwindow.h>
#include <framework/graphics/texturemanager.h> #include <framework/graphics/texturemanager.h>
#include <framework/application.h> #include <framework/core/application.h>
UIWidget::UIWidget() UIWidget::UIWidget()
{ {
@ -46,7 +46,7 @@ UIWidget::UIWidget()
UIWidget::~UIWidget() UIWidget::~UIWidget()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
#ifdef DEBUG #ifdef DEBUG
if(!m_destroyed) if(!m_destroyed)
g_logger.warning(stdext::format("widget '%s' was not explicitly destroyed", m_id)); g_logger.warning(stdext::format("widget '%s' was not explicitly destroyed", m_id));

View File

@ -24,7 +24,7 @@
#define UIWIDGET_H #define UIWIDGET_H
#include "declarations.h" #include "declarations.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/graphics/declarations.h> #include <framework/graphics/declarations.h>
#include <framework/otml/otmlnode.h> #include <framework/otml/otmlnode.h>
#include <framework/graphics/bitmapfont.h> #include <framework/graphics/bitmapfont.h>

View File

@ -25,7 +25,7 @@
#include <framework/graphics/fontmanager.h> #include <framework/graphics/fontmanager.h>
#include <framework/graphics/painter.h> #include <framework/graphics/painter.h>
#include <framework/graphics/framebuffer.h> #include <framework/graphics/framebuffer.h>
#include <framework/application.h> #include <framework/core/application.h>
void UIWidget::initText() void UIWidget::initText()
{ {

View File

@ -26,6 +26,8 @@ distribution.
#ifndef TINYXML_INCLUDED #ifndef TINYXML_INCLUDED
#define TINYXML_INCLUDED #define TINYXML_INCLUDED
#define TIXML_USE_STL // use STL strings instead
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning( push ) #pragma warning( push )
#pragma warning( disable : 4530 ) #pragma warning( disable : 4530 )

View File

@ -20,10 +20,10 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "framework/application.h" #include <framework/core/application.h>
#include "framework/luascript/luainterface.h" #include <framework/core/resourcemanager.h>
#include "framework/core/resourcemanager.h" #include <framework/luaengine/luainterface.h>
#include "otclient/otclient.h" #include <otclient/otclient.h>
int main(int argc, const char* argv[]) 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"); g_app.setVersion("0.5.0_dev");
// initialize application framework and otclient // initialize application framework and otclient
g_app.init("otclient", args); g_app.init(args);
g_otclient.init(args); g_otclient.init(args);
// find script init.lua and run it // find script init.lua and run it

View File

@ -1,31 +1,31 @@
# CMAKE_CURRENT_LIST_DIR cmake 2.6 compatiblity # CMAKE_CURRENT_LIST_DIR cmake 2.6 compatiblity
IF(${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) get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) endif(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
# otclient options # otclient options
ADD_DEFINITIONS(-DOTCLIENT) add_definitions(-DOTCLIENT)
OPTION(BOT_PROTECTION "Enable bot protection" ON) option(BOT_PROTECTION "Enable bot protection" ON)
SET(PROTOCOL 860 CACHE "Protocol version" STRING) set(PROTOCOL 860 CACHE "Protocol version" STRING)
OPTION(CIPSOFT_RSA "Use cipsoft RSA to login into original tibia" OFF) option(CIPSOFT_RSA "Use cipsoft RSA to login into original tibia" OFF)
ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL}) add_definitions(-DPROTOCOL=${PROTOCOL})
MESSAGE(STATUS "Protocol: " ${PROTOCOL}) message(STATUS "Protocol: " ${PROTOCOL})
IF(CIPSOFT_RSA) if(CIPSOFT_RSA)
ADD_DEFINITIONS(-DCIPSOFT_RSA -DOSTYPE=2) add_definitions(-DCIPSOFT_RSA -DOSTYPE=2)
MESSAGE(STATUS "RSA: CipSoft") message(STATUS "RSA: CipSoft")
ELSE() else()
MESSAGE(STATUS "RSA: OTServ") message(STATUS "RSA: OTServ")
ENDIF() endif()
IF(BOT_PROTECTION) if(BOT_PROTECTION)
ADD_DEFINITIONS(-DBOT_PROTECTION) add_definitions(-DBOT_PROTECTION)
MESSAGE(STATUS "Bot protection: ON") message(STATUS "Bot protection: ON")
ELSE(BOT_PROTECTION) else(BOT_PROTECTION)
MESSAGE(STATUS "Bot protection: OFF") message(STATUS "Bot protection: OFF")
ENDIF(BOT_PROTECTION) endif(BOT_PROTECTION)
SET(otclient_SOURCES ${otclient_SOURCES} set(otclient_SOURCES ${otclient_SOURCES}
# otclient # otclient
${CMAKE_CURRENT_LIST_DIR}/const.h ${CMAKE_CURRENT_LIST_DIR}/const.h
${CMAKE_CURRENT_LIST_DIR}/global.h ${CMAKE_CURRENT_LIST_DIR}/global.h
@ -34,71 +34,69 @@ SET(otclient_SOURCES ${otclient_SOURCES}
${CMAKE_CURRENT_LIST_DIR}/otclient.h ${CMAKE_CURRENT_LIST_DIR}/otclient.h
# core # core
${CMAKE_CURRENT_LIST_DIR}/core/animatedtext.cpp ${CMAKE_CURRENT_LIST_DIR}/animatedtext.cpp
${CMAKE_CURRENT_LIST_DIR}/core/animatedtext.h ${CMAKE_CURRENT_LIST_DIR}/animatedtext.h
${CMAKE_CURRENT_LIST_DIR}/core/container.cpp ${CMAKE_CURRENT_LIST_DIR}/container.cpp
${CMAKE_CURRENT_LIST_DIR}/core/container.h ${CMAKE_CURRENT_LIST_DIR}/container.h
${CMAKE_CURRENT_LIST_DIR}/core/creature.cpp ${CMAKE_CURRENT_LIST_DIR}/creature.cpp
${CMAKE_CURRENT_LIST_DIR}/core/creature.h ${CMAKE_CURRENT_LIST_DIR}/creature.h
${CMAKE_CURRENT_LIST_DIR}/core/declarations.h ${CMAKE_CURRENT_LIST_DIR}/declarations.h
${CMAKE_CURRENT_LIST_DIR}/core/effect.cpp ${CMAKE_CURRENT_LIST_DIR}/effect.cpp
${CMAKE_CURRENT_LIST_DIR}/core/effect.h ${CMAKE_CURRENT_LIST_DIR}/effect.h
${CMAKE_CURRENT_LIST_DIR}/core/game.cpp ${CMAKE_CURRENT_LIST_DIR}/game.cpp
${CMAKE_CURRENT_LIST_DIR}/core/game.h ${CMAKE_CURRENT_LIST_DIR}/game.h
${CMAKE_CURRENT_LIST_DIR}/core/shadermanager.cpp ${CMAKE_CURRENT_LIST_DIR}/shadermanager.cpp
${CMAKE_CURRENT_LIST_DIR}/core/shadermanager.h ${CMAKE_CURRENT_LIST_DIR}/shadermanager.h
${CMAKE_CURRENT_LIST_DIR}/core/item.cpp ${CMAKE_CURRENT_LIST_DIR}/item.cpp
${CMAKE_CURRENT_LIST_DIR}/core/item.h ${CMAKE_CURRENT_LIST_DIR}/item.h
${CMAKE_CURRENT_LIST_DIR}/core/localplayer.cpp ${CMAKE_CURRENT_LIST_DIR}/localplayer.cpp
${CMAKE_CURRENT_LIST_DIR}/core/localplayer.h ${CMAKE_CURRENT_LIST_DIR}/localplayer.h
${CMAKE_CURRENT_LIST_DIR}/core/map.cpp ${CMAKE_CURRENT_LIST_DIR}/map.cpp
${CMAKE_CURRENT_LIST_DIR}/core/map.h ${CMAKE_CURRENT_LIST_DIR}/map.h
${CMAKE_CURRENT_LIST_DIR}/core/mapview.cpp ${CMAKE_CURRENT_LIST_DIR}/mapview.cpp
${CMAKE_CURRENT_LIST_DIR}/core/mapview.h ${CMAKE_CURRENT_LIST_DIR}/mapview.h
${CMAKE_CURRENT_LIST_DIR}/core/missile.cpp ${CMAKE_CURRENT_LIST_DIR}/missile.cpp
${CMAKE_CURRENT_LIST_DIR}/core/missile.h ${CMAKE_CURRENT_LIST_DIR}/missile.h
${CMAKE_CURRENT_LIST_DIR}/core/outfit.cpp ${CMAKE_CURRENT_LIST_DIR}/outfit.cpp
${CMAKE_CURRENT_LIST_DIR}/core/outfit.h ${CMAKE_CURRENT_LIST_DIR}/outfit.h
${CMAKE_CURRENT_LIST_DIR}/core/player.cpp ${CMAKE_CURRENT_LIST_DIR}/player.cpp
${CMAKE_CURRENT_LIST_DIR}/core/player.h ${CMAKE_CURRENT_LIST_DIR}/player.h
${CMAKE_CURRENT_LIST_DIR}/core/spritemanager.cpp ${CMAKE_CURRENT_LIST_DIR}/spritemanager.cpp
${CMAKE_CURRENT_LIST_DIR}/core/spritemanager.h ${CMAKE_CURRENT_LIST_DIR}/spritemanager.h
${CMAKE_CURRENT_LIST_DIR}/core/statictext.cpp ${CMAKE_CURRENT_LIST_DIR}/statictext.cpp
${CMAKE_CURRENT_LIST_DIR}/core/statictext.h ${CMAKE_CURRENT_LIST_DIR}/statictext.h
${CMAKE_CURRENT_LIST_DIR}/core/thing.cpp ${CMAKE_CURRENT_LIST_DIR}/thing.cpp
${CMAKE_CURRENT_LIST_DIR}/core/thing.h ${CMAKE_CURRENT_LIST_DIR}/thing.h
${CMAKE_CURRENT_LIST_DIR}/core/thingtypemanager.cpp ${CMAKE_CURRENT_LIST_DIR}/thingtypemanager.cpp
${CMAKE_CURRENT_LIST_DIR}/core/thingtypemanager.h ${CMAKE_CURRENT_LIST_DIR}/thingtypemanager.h
${CMAKE_CURRENT_LIST_DIR}/core/thingtypedat.cpp ${CMAKE_CURRENT_LIST_DIR}/thingtypedat.cpp
${CMAKE_CURRENT_LIST_DIR}/core/thingtypedat.h ${CMAKE_CURRENT_LIST_DIR}/thingtypedat.h
${CMAKE_CURRENT_LIST_DIR}/core/thingtypeotb.cpp ${CMAKE_CURRENT_LIST_DIR}/thingtypeotb.cpp
${CMAKE_CURRENT_LIST_DIR}/core/thingtypeotb.h ${CMAKE_CURRENT_LIST_DIR}/thingtypeotb.h
${CMAKE_CURRENT_LIST_DIR}/core/tile.cpp ${CMAKE_CURRENT_LIST_DIR}/tile.cpp
${CMAKE_CURRENT_LIST_DIR}/core/tile.h ${CMAKE_CURRENT_LIST_DIR}/tile.h
# lua # lua
${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.cpp ${CMAKE_CURRENT_LIST_DIR}/luavaluecasts.cpp
${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.h ${CMAKE_CURRENT_LIST_DIR}/luavaluecasts.h
# net # net
${CMAKE_CURRENT_LIST_DIR}/net/declarations.h ${CMAKE_CURRENT_LIST_DIR}/protocolcodes.h
${CMAKE_CURRENT_LIST_DIR}/net/protocolcodes.h ${CMAKE_CURRENT_LIST_DIR}/protocolgame.cpp
${CMAKE_CURRENT_LIST_DIR}/net/protocolgame.cpp ${CMAKE_CURRENT_LIST_DIR}/protocolgame.h
${CMAKE_CURRENT_LIST_DIR}/net/protocolgame.h ${CMAKE_CURRENT_LIST_DIR}/protocolgameparse.cpp
${CMAKE_CURRENT_LIST_DIR}/net/protocolgameparse.cpp ${CMAKE_CURRENT_LIST_DIR}/protocolgamesend.cpp
${CMAKE_CURRENT_LIST_DIR}/net/protocolgamesend.cpp
# ui # ui
${CMAKE_CURRENT_LIST_DIR}/ui/declarations.h ${CMAKE_CURRENT_LIST_DIR}/uicreature.cpp
${CMAKE_CURRENT_LIST_DIR}/ui/uicreature.cpp ${CMAKE_CURRENT_LIST_DIR}/uicreature.h
${CMAKE_CURRENT_LIST_DIR}/ui/uicreature.h ${CMAKE_CURRENT_LIST_DIR}/uiitem.cpp
${CMAKE_CURRENT_LIST_DIR}/ui/uiitem.cpp ${CMAKE_CURRENT_LIST_DIR}/uiitem.h
${CMAKE_CURRENT_LIST_DIR}/ui/uiitem.h ${CMAKE_CURRENT_LIST_DIR}/uimap.cpp
${CMAKE_CURRENT_LIST_DIR}/ui/uimap.cpp ${CMAKE_CURRENT_LIST_DIR}/uimap.h
${CMAKE_CURRENT_LIST_DIR}/ui/uimap.h ${CMAKE_CURRENT_LIST_DIR}/uiprogressrect.cpp
${CMAKE_CURRENT_LIST_DIR}/ui/uiprogressrect.cpp ${CMAKE_CURRENT_LIST_DIR}/uiprogressrect.h
${CMAKE_CURRENT_LIST_DIR}/ui/uiprogressrect.h
# util # util
${CMAKE_CURRENT_LIST_DIR}/util/position.h ${CMAKE_CURRENT_LIST_DIR}/position.h
) )

View File

@ -25,7 +25,7 @@
#include "declarations.h" #include "declarations.h"
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
// @bindclass // @bindclass
class Container : public LuaObject class Container : public LuaObject

View File

@ -20,11 +20,14 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifndef OTCLIENT_CORE_DECLARATIONS_H #ifndef OTCLIENT_DECLARATIONS_H
#define OTCLIENT_CORE_DECLARATIONS_H #define OTCLIENT_DECLARATIONS_H
#include <otclient/global.h> #include "global.h"
#include <framework/net/declarations.h>
#include <framework/ui/declarations.h>
// core
class Map; class Map;
class Game; class Game;
class MapView; class MapView;
@ -65,4 +68,22 @@ typedef std::vector<ThingPtr> ThingList;
typedef std::vector<ThingTypeDatPtr> ThingTypeDatList; typedef std::vector<ThingTypeDatPtr> ThingTypeDatList;
typedef std::vector<ThingTypeOtbPtr> ThingTypeOtbList; typedef std::vector<ThingTypeOtbPtr> ThingTypeOtbList;
// net
class ProtocolLogin;
class ProtocolGame;
typedef std::shared_ptr<ProtocolGame> ProtocolGamePtr;
typedef std::shared_ptr<ProtocolLogin> ProtocolLoginPtr;
// ui
class UIItem;
class UICreature;
class UIMap;
class UIProgressRect;
typedef std::shared_ptr<UIItem> UIItemPtr;
typedef std::shared_ptr<UICreature> UICreaturePtr;
typedef std::shared_ptr<UIMap> UIMapPtr;
typedef std::shared_ptr<UIProgressRect> UIProgressRectPtr;
#endif #endif

View File

@ -29,9 +29,9 @@
#include "statictext.h" #include "statictext.h"
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/ui/uimanager.h> #include <framework/ui/uimanager.h>
#include <framework/application.h> #include <framework/core/application.h>
#include <otclient/luascript/luavaluecasts.h> #include "luavaluecasts.h"
#include <otclient/net/protocolgame.h> #include "protocolgame.h"
Game g_game; Game g_game;

View File

@ -24,9 +24,8 @@
#define GAME_H #define GAME_H
#include "declarations.h" #include "declarations.h"
#include <otclient/net/declarations.h> #include "item.h"
#include <otclient/core/item.h> #include "outfit.h"
#include <otclient/core/outfit.h>
#include <framework/core/timer.h> #include <framework/core/timer.h>
typedef std::tuple<std::string, bool> Vip; typedef std::tuple<std::string, bool> Vip;

View File

@ -27,6 +27,6 @@
// widely used headers // widely used headers
#include "const.h" #include "const.h"
#include "util/position.h" #include "position.h"
#endif #endif

View File

@ -21,29 +21,29 @@
*/ */
#include "otclient.h" #include "otclient.h"
#include <framework/luascript/luainterface.h> #include <framework/luaengine/luainterface.h>
#include <otclient/luascript/luavaluecasts.h> #include "luavaluecasts.h"
#include <otclient/core/game.h> #include "game.h"
#include <otclient/core/tile.h> #include "tile.h"
#include <otclient/core/container.h> #include "container.h"
#include <otclient/core/item.h> #include "item.h"
#include <otclient/core/effect.h> #include "effect.h"
#include <otclient/core/missile.h> #include "missile.h"
#include <otclient/core/statictext.h> #include "statictext.h"
#include <otclient/core/animatedtext.h> #include "animatedtext.h"
#include <otclient/core/creature.h> #include "creature.h"
#include <otclient/core/player.h> #include "player.h"
#include <otclient/core/localplayer.h> #include "localplayer.h"
#include <otclient/core/map.h> #include "map.h"
#include <otclient/core/thingtypemanager.h> #include "thingtypemanager.h"
#include <otclient/core/spritemanager.h> #include "spritemanager.h"
#include <otclient/core/shadermanager.h> #include "shadermanager.h"
#include <otclient/net/protocolgame.h> #include "protocolgame.h"
#include <otclient/ui/uiitem.h> #include "uiitem.h"
#include <otclient/ui/uicreature.h> #include "uicreature.h"
#include <otclient/ui/uimap.h> #include "uimap.h"
#include <otclient/ui/uiprogressrect.h> #include "uiprogressrect.h"
#include <otclient/core/outfit.h> #include "outfit.h"
void OTClient::registerLuaFunctions() void OTClient::registerLuaFunctions()
{ {

View File

@ -21,7 +21,7 @@
*/ */
#include "luavaluecasts.h" #include "luavaluecasts.h"
#include <framework/luascript/luainterface.h> #include <framework/luaengine/luainterface.h>
int push_luavalue(const Outfit& outfit) int push_luavalue(const Outfit& outfit)
{ {

View File

@ -23,9 +23,9 @@
#ifndef OTCLIENT_LUAVALUECASTS_H #ifndef OTCLIENT_LUAVALUECASTS_H
#define OTCLIENT_LUAVALUECASTS_H #define OTCLIENT_LUAVALUECASTS_H
#include <otclient/global.h> #include "global.h"
#include <framework/luascript/declarations.h> #include <framework/luaengine/declarations.h>
#include <otclient/core/outfit.h> #include "outfit.h"
// outfit // outfit
int push_luavalue(const Outfit& outfit); int push_luavalue(const Outfit& outfit);

View File

@ -33,7 +33,7 @@
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>
#include <framework/graphics/framebuffermanager.h> #include <framework/graphics/framebuffermanager.h>
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/application.h> #include <framework/core/application.h>
MapView::MapView() MapView::MapView()
{ {
@ -51,7 +51,7 @@ MapView::MapView()
MapView::~MapView() MapView::~MapView()
{ {
assert(!g_app.isTermianted()); assert(!g_app.isTerminated());
} }
void MapView::draw(const Rect& rect) void MapView::draw(const Rect& rect)

View File

@ -25,7 +25,7 @@
#include "declarations.h" #include "declarations.h"
#include <framework/graphics/declarations.h> #include <framework/graphics/declarations.h>
#include <framework/luascript/luaobject.h> #include <framework/luaengine/luaobject.h>
#include <framework/core/declarations.h> #include <framework/core/declarations.h>
// @bindclass // @bindclass

View File

@ -24,7 +24,7 @@
#ifndef MINIMAP_H #ifndef MINIMAP_H
#define MINIMAP_H #define MINIMAP_H
#include <otclient/global.h> #include "global.h"
#include <framework/graphics/image.h> #include <framework/graphics/image.h>
/* /*
enum { enum {

View File

@ -24,10 +24,10 @@
#include <framework/core/modulemanager.h> #include <framework/core/modulemanager.h>
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>
#include <otclient/core/game.h> #include "game.h"
#include <otclient/core/map.h> #include "map.h"
#include <otclient/core/shadermanager.h> #include "shadermanager.h"
#include "core/spritemanager.h" #include "spritemanager.h"
#include <framework/core/configmanager.h> #include <framework/core/configmanager.h>
OTClient g_otclient; OTClient g_otclient;

View File

@ -23,7 +23,7 @@
#ifndef OTCLIENT_H #ifndef OTCLIENT_H
#define OTCLIENT_H #define OTCLIENT_H
#include <otclient/global.h> #include "global.h"
class OTClient class OTClient
{ {

View File

@ -24,7 +24,7 @@
#define OUTFIT_H #define OUTFIT_H
#include <framework/util/color.h> #include <framework/util/color.h>
#include <otclient/core/thingtypemanager.h> #include "thingtypemanager.h"
class Outfit class Outfit
{ {

Some files were not shown because too many files have changed in this diff Show More