mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
make framework more flexible, split cmake files
This commit is contained in:
176
src/framework/CMakeLists.txt
Normal file
176
src/framework/CMakeLists.txt
Normal file
@@ -0,0 +1,176 @@
|
||||
# add framework cmake modules
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}")
|
||||
MESSAGE(STATUS ${CMAKE_MODULE_PATH})
|
||||
|
||||
# framework options
|
||||
OPTION(NO_CONSOLE "Disables console window on Windows platform" OFF)
|
||||
OPTION(HANDLE_EXCEPTIONS "Generate crash reports" OFF)
|
||||
OPTION(USE_OPENGL_ES2 "Use OpenGL ES 2.0 (for mobiles devices)" OFF)
|
||||
|
||||
# set debug as default build type
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE Debug)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
# find needed libraries
|
||||
SET(Boost_USE_STATIC_LIBS ON)
|
||||
SET(Boost_USE_MULTITHREADED OFF)
|
||||
FIND_PACKAGE(Boost COMPONENTS system REQUIRED)
|
||||
|
||||
IF(USE_OPENGL_ES2)
|
||||
FIND_PACKAGE(OpenGLES2 REQUIRED)
|
||||
FIND_PACKAGE(EGL REQUIRED)
|
||||
SET(OPENGL_INCLUDE_DIR ${OPENGLES_INCLUDE_DIR} ${EGL_INCLUDE_DIR})
|
||||
SET(OPENGL_LIBRARIES ${OPENGLES_LIBRARY} ${EGL_LIBRARY})
|
||||
ADD_DEFINITIONS(-DOPENGL_ES2)
|
||||
ELSE(USE_OPENGL_ES2)
|
||||
FIND_PACKAGE(OpenGL REQUIRED)
|
||||
ENDIF(USE_OPENGL_ES2)
|
||||
|
||||
FIND_PACKAGE(Lua REQUIRED)
|
||||
FIND_PACKAGE(PhysFS REQUIRED)
|
||||
FIND_PACKAGE(GMP REQUIRED)
|
||||
FIND_PACKAGE(ZLIB REQUIRED)
|
||||
|
||||
# setup compiler options
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(CXX_WARNS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable -Wno-switch -Wno-missing-field-initializers")
|
||||
SET(CMAKE_CXX_FLAGS "-std=gnu++0x -pipe ${CXX_WARNS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb -fno-inline")
|
||||
SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++ -Wl,--as-needed")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
ADD_DEFINITIONS(-D_DEBUG)
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
||||
IF(USE_OPENGL_ES2)
|
||||
MESSAGE(STATUS "Renderer: OpenGL ES 2")
|
||||
ELSE(USE_OPENGL_ES2)
|
||||
MESSAGE(STATUS "Renderer: OpenGL")
|
||||
ENDIF(USE_OPENGL_ES2)
|
||||
|
||||
IF(HANDLE_EXCEPTIONS)
|
||||
ADD_DEFINITIONS(-DHANDLE_EXCEPTIONS)
|
||||
MESSAGE(STATUS "Generate crash reports: ON")
|
||||
ELSE(HANDLE_EXCEPTIONS)
|
||||
MESSAGE(STATUS "Generate crash reports: OFF")
|
||||
ENDIF(HANDLE_EXCEPTIONS)
|
||||
|
||||
|
||||
IF(WIN32)
|
||||
SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/win32window.cpp)
|
||||
SET(ADDITIONAL_LIBRARIES ws2_32 mswsock)
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501)
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
IF(NO_CONSOLE)
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -mwindows")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
MESSAGE(STATUS "Disable windows console: ON")
|
||||
ELSE(NO_CONSOLE)
|
||||
MESSAGE(STATUS "Disable windows console: OFF")
|
||||
ENDIF(NO_CONSOLE)
|
||||
ELSE(WIN32)
|
||||
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic")
|
||||
SET(ADDITIONAL_LIBRARIES pthread)
|
||||
SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp)
|
||||
ENDIF(WIN32)
|
||||
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${LUA_INCLUDE_DIR}
|
||||
${PHYSFS_INCLUDE_DIR}
|
||||
${GMP_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
"${CMAKE_CURRENT_LIST_DIR}/.."
|
||||
)
|
||||
|
||||
SET(FRAMEWORK_LIBRARIES
|
||||
${Boost_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${LUA_LIBRARIES}
|
||||
${PHYSFS_LIBRARY}
|
||||
${GMP_LIBRARY}
|
||||
${ZLIB_LIBRARY}
|
||||
${ADDITIONAL_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
SET(FRAMEWORK_SOURCES ${FRAMEWORK_SOURCES}
|
||||
# framework
|
||||
${CMAKE_CURRENT_LIST_DIR}/application.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp
|
||||
|
||||
# framework core
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/logger.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/clock.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/configmanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/resourcemanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/eventdispatcher.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/modulemanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/module.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/clock.cpp
|
||||
|
||||
# framework net
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/connection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/inputmessage.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/outputmessage.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/protocol.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/rsa.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/server.cpp
|
||||
|
||||
# framework platform
|
||||
${CMAKE_CURRENT_LIST_DIR}/platform/platformwindow.cpp
|
||||
|
||||
# framework graphics
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/font.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/fontmanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/graphics.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/texture.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffer.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffer.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/borderimage.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/graphics/image.cpp
|
||||
|
||||
# framework otml
|
||||
${CMAKE_CURRENT_LIST_DIR}/otml/otmldocument.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/otml/otmlemitter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/otml/otmlnode.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/otml/otmlparser.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/otml/otmlexception.cpp
|
||||
|
||||
# framework luascript
|
||||
${CMAKE_CURRENT_LIST_DIR}/luascript/luainterface.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/luascript/luaobject.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/luascript/luaexception.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.cpp
|
||||
|
||||
# framework ui
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uimanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uiwidget.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uilabel.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uibutton.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uilineedit.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uiwindow.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uianchorlayout.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uiverticallayout.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uilayout.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uiprogressbar.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uicheckbox.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uiframecounter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uitranslator.cpp
|
||||
|
||||
# framework third party
|
||||
${CMAKE_CURRENT_LIST_DIR}/thirdparty/apngloader.cpp
|
||||
)
|
@@ -33,6 +33,8 @@
|
||||
#include <framework/graphics/graphics.h>
|
||||
#include <framework/luascript/luainterface.h>
|
||||
|
||||
Application *g_app = nullptr;
|
||||
|
||||
void exitSignalHandler(int sig)
|
||||
{
|
||||
static bool signaled = false;
|
||||
@@ -41,18 +43,28 @@ void exitSignalHandler(int sig)
|
||||
case SIGINT:
|
||||
if(!signaled) {
|
||||
signaled = true;
|
||||
g_dispatcher.addEvent(std::bind(&Application::close, &g_app));
|
||||
g_dispatcher.addEvent(std::bind(&Application::close, g_app));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::init(const std::string& appName, const std::vector<std::string>& args)
|
||||
Application::Application(const std::string& appName)
|
||||
{
|
||||
logInfo("Starting application...");
|
||||
|
||||
m_pollCycleDelay = POLL_CYCLE_DELAY;
|
||||
g_app = this;
|
||||
m_appName = appName;
|
||||
m_pollCycleDelay = POLL_CYCLE_DELAY;
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
g_app = nullptr;
|
||||
}
|
||||
|
||||
void Application::init(const std::vector<std::string>& args, int appFlags)
|
||||
{
|
||||
m_appFlags = appFlags;
|
||||
logInfo("Starting application...");
|
||||
|
||||
// capture exit signals
|
||||
signal(SIGTERM, exitSignalHandler);
|
||||
@@ -65,37 +77,71 @@ void Application::init(const std::string& appName, const std::vector<std::string
|
||||
// initialize resources
|
||||
g_resources.init(args[0].c_str());
|
||||
|
||||
// loads user configuration
|
||||
if(!g_configs.load("config.otml"))
|
||||
logInfo("Using default configurations.");
|
||||
if(m_appFlags & Fw::AppEnableConfigs) {
|
||||
// setup configs write directory
|
||||
if(!g_resources.setupWriteDir(m_appName))
|
||||
logError("Could not setup write directory");
|
||||
|
||||
// initialize the ui
|
||||
g_ui.init();
|
||||
// load configs
|
||||
if(!g_configs.load("config.otml"))
|
||||
logInfo("Using default configurations.");
|
||||
}
|
||||
|
||||
// setup platform window
|
||||
g_window.init();
|
||||
g_window.setOnResize(std::bind(&Application::resize, this, _1));
|
||||
g_window.setOnInputEvent(std::bind(&Application::inputEvent, this, _1));
|
||||
g_window.setOnClose(std::bind(&Application::close, this));
|
||||
if(m_appFlags & Fw::AppEnableGraphics) {
|
||||
g_ui.init();
|
||||
|
||||
// initialize graphics
|
||||
g_graphics.init();
|
||||
g_window.init();
|
||||
g_window.setOnResize(std::bind(&Application::resize, this, _1));
|
||||
g_window.setOnInputEvent(std::bind(&Application::inputEvent, this, _1));
|
||||
g_window.setOnClose(std::bind(&Application::close, this));
|
||||
|
||||
// fire first resize
|
||||
resize(g_window.getSize());
|
||||
// initialize graphics
|
||||
g_graphics.init();
|
||||
|
||||
// auto load lua modules
|
||||
g_modules.discoverAndLoadModules();
|
||||
// fire first resize
|
||||
resize(g_window.getSize());
|
||||
}
|
||||
|
||||
if(m_appFlags & Fw::AppEnableModules) {
|
||||
// search for modules directory
|
||||
std::string baseDir = g_resources.getBaseDir();
|
||||
std::string possibleDirs[] = { "modules",
|
||||
baseDir + "modules",
|
||||
baseDir + "../modules",
|
||||
baseDir + "../share/" + m_appName + "/modules",
|
||||
"" };
|
||||
bool found = false;
|
||||
for(const std::string& dir : possibleDirs) {
|
||||
// try to add module directory
|
||||
if(g_resources.addToSearchPath(dir)) {
|
||||
logInfo("Using modules directory '", dir.c_str(), "'");
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
logFatal("Could not find modules directory");
|
||||
|
||||
g_modules.discoverAndLoadModules();
|
||||
}
|
||||
|
||||
// finally show the window
|
||||
if(m_appFlags & Fw::AppEnableGraphics)
|
||||
g_window.show();
|
||||
}
|
||||
|
||||
|
||||
void Application::terminate()
|
||||
{
|
||||
// hide the window because there is no render anymore
|
||||
g_window.hide();
|
||||
if(m_appFlags & Fw::AppEnableGraphics)
|
||||
g_window.hide();
|
||||
|
||||
// run modules unload events
|
||||
g_modules.unloadModules();
|
||||
if(m_appFlags & Fw::AppEnableModules)
|
||||
g_modules.unloadModules();
|
||||
|
||||
// release remaining lua object references
|
||||
g_lua.collectGarbage();
|
||||
@@ -103,20 +149,22 @@ void Application::terminate()
|
||||
// poll remaining events
|
||||
poll();
|
||||
|
||||
// terminate ui
|
||||
g_ui.terminate();
|
||||
|
||||
// terminate network
|
||||
Connection::terminate();
|
||||
|
||||
// terminate graphics
|
||||
if(m_appFlags & Fw::AppEnableGraphics) {
|
||||
g_ui.terminate();
|
||||
g_graphics.terminate();
|
||||
g_window.terminate();
|
||||
}
|
||||
|
||||
// flush remaining dispatcher events
|
||||
g_dispatcher.flush();
|
||||
|
||||
// terminate graphics
|
||||
g_graphics.terminate();
|
||||
|
||||
// save configurations
|
||||
g_configs.save();
|
||||
if(m_appFlags & Fw::AppEnableConfigs)
|
||||
g_configs.save();
|
||||
|
||||
// release resources
|
||||
g_resources.terminate();
|
||||
@@ -124,9 +172,6 @@ void Application::terminate()
|
||||
// terminate script environment
|
||||
g_lua.terminate();
|
||||
|
||||
// release platform window
|
||||
g_window.terminate();
|
||||
|
||||
logInfo("Application ended successfully.");
|
||||
}
|
||||
|
||||
@@ -139,11 +184,6 @@ void Application::run()
|
||||
// run the first poll
|
||||
poll();
|
||||
|
||||
if(g_ui.getRootWidget()->getChildCount() == 0) {
|
||||
logError("There is no root widgets to display, the app will close");
|
||||
m_stopping = true;
|
||||
}
|
||||
|
||||
while(!m_stopping) {
|
||||
g_clock.updateTicks();
|
||||
|
||||
@@ -154,7 +194,7 @@ void Application::run()
|
||||
lastPollTicks = g_clock.ticks();
|
||||
}
|
||||
|
||||
if(g_window.isVisible()) {
|
||||
if(m_appFlags & Fw::AppEnableGraphics && g_window.isVisible()) {
|
||||
g_graphics.beginRender();
|
||||
render();
|
||||
g_graphics.endRender();
|
||||
@@ -180,7 +220,8 @@ void Application::exit()
|
||||
void Application::poll()
|
||||
{
|
||||
// poll input events
|
||||
g_window.poll();
|
||||
if(m_appFlags & Fw::AppEnableGraphics)
|
||||
g_window.poll();
|
||||
|
||||
// poll network events
|
||||
Connection::poll();
|
||||
|
@@ -32,7 +32,10 @@ class Application
|
||||
};
|
||||
|
||||
public:
|
||||
virtual void init(const std::string& appName, const std::vector<std::string>& args);
|
||||
Application(const std::string& appName);
|
||||
~Application();
|
||||
|
||||
virtual void init(const std::vector<std::string>& args, int appFlags);
|
||||
virtual void registerLuaFunctions();
|
||||
virtual void terminate();
|
||||
virtual void run();
|
||||
@@ -53,12 +56,13 @@ protected:
|
||||
|
||||
private:
|
||||
std::string m_appName;
|
||||
int m_appFlags;
|
||||
int m_pollCycleDelay;
|
||||
Boolean<false> m_running;
|
||||
Boolean<false> m_stopping;
|
||||
};
|
||||
|
||||
extern Application& g_app;
|
||||
extern Application *g_app;
|
||||
|
||||
#endif
|
||||
|
||||
|
10
src/framework/cmake/FindEGL.cmake
Normal file
10
src/framework/cmake/FindEGL.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
# Try to find the EGL librairy
|
||||
# EGL_FOUND - system has EGL
|
||||
# EGL_INCLUDE_DIR - the EGL include directory
|
||||
# EGL_LIBRARY - the EGL library
|
||||
|
||||
FIND_PATH(EGL_INCLUDE_DIR egl.h PATH_SUFFIXES EGL)
|
||||
FIND_LIBRARY(EGL_LIBRARY NAMES EGL)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(EGL_LIBRARY EGL_INCLUDE_DIR)
|
10
src/framework/cmake/FindGMP.cmake
Normal file
10
src/framework/cmake/FindGMP.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
# Try to find the GMP librairy
|
||||
# GMP_FOUND - system has GMP
|
||||
# GMP_INCLUDE_DIR - the GMP include directory
|
||||
# GMP_LIBRARY - the GMP library
|
||||
|
||||
FIND_PATH(GMP_INCLUDE_DIR NAMES gmp.h)
|
||||
FIND_LIBRARY(GMP_LIBRARY NAMES libgmp.a gmp)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG GMP_LIBRARY GMP_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(GMP_LIBRARY GMP_INCLUDE_DIR)
|
22
src/framework/cmake/FindLua.cmake
Normal file
22
src/framework/cmake/FindLua.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
# Try to find the lua librairy
|
||||
# LUA_FOUND - system has lua
|
||||
# LUA_INCLUDE_DIR - the lua include directory
|
||||
# LUA_LIBRARY - the lua library
|
||||
# LUA_LIBRARIES - the lua library and it's dependencies
|
||||
|
||||
FIND_PATH(LUA_INCLUDE_DIR NAMES lua.h PATH_SUFFIXES lua51 lua5.1)
|
||||
FIND_LIBRARY(LUA_LIBRARY NAMES liblua51.a liblua5.1.a liblua-5.1.a liblua.a lua51 lua5.1 lua-5.1 lua)
|
||||
|
||||
IF(LUA_LIBRARY)
|
||||
IF(UNIX AND NOT APPLE)
|
||||
FIND_LIBRARY(LUA_MATH_LIBRARY m)
|
||||
SET(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
|
||||
ELSE(UNIX AND NOT APPLE)
|
||||
SET(LUA_LIBRARIES "${LUA_LIBRARY}")
|
||||
ENDIF(UNIX AND NOT APPLE)
|
||||
ENDIF(LUA_LIBRARY)
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
||||
|
10
src/framework/cmake/FindOpenGLES2.cmake
Normal file
10
src/framework/cmake/FindOpenGLES2.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
# Try to find the OpenGLES librairy
|
||||
# OPENGLES_FOUND - system has OpenGLES
|
||||
# OPENGLES_INCLUDE_DIR - the OpenGLES include directory
|
||||
# OPENGLES_LIBRARY - the OpenGLES library
|
||||
|
||||
FIND_PATH(OPENGLES_INCLUDE_DIR gl2.h PATH_SUFFIXES GLES2)
|
||||
FIND_LIBRARY(OPENGLES_LIBRARY NAMES GLESv2)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGLES DEFAULT_MSG OPENGLES_LIBRARY OPENGLES_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(OPENGLES_LIBRARY OPENGLES_INCLUDE_DIR)
|
315
src/framework/cmake/FindPCHSupport.cmake
Normal file
315
src/framework/cmake/FindPCHSupport.cmake
Normal file
@@ -0,0 +1,315 @@
|
||||
# - Try to find precompiled headers support for GCC 3.4 and 4.x (and MSVC)
|
||||
# Once done this will define:
|
||||
#
|
||||
# Variable:
|
||||
# PCHSupport_FOUND
|
||||
#
|
||||
# Macro:
|
||||
# ADD_PRECOMPILED_HEADER _targetName _input _dowarn
|
||||
# ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use _dowarn
|
||||
# ADD_NATIVE_PRECOMPILED_HEADER _targetName _input _dowarn
|
||||
# GET_NATIVE_PRECOMPILED_HEADER _targetName _input
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
EXEC_PROGRAM(
|
||||
${CMAKE_CXX_COMPILER}
|
||||
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
|
||||
OUTPUT_VARIABLE gcc_compiler_version
|
||||
)
|
||||
#MESSAGE("GCC Version: ${gcc_compiler_version}")
|
||||
IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
|
||||
SET(PCHSupport_FOUND TRUE)
|
||||
ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
|
||||
IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
|
||||
SET(PCHSupport_FOUND TRUE)
|
||||
ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
|
||||
ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
|
||||
|
||||
SET(_PCH_include_prefix "-I")
|
||||
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
IF(WIN32)
|
||||
SET(PCHSupport_FOUND TRUE) # for experimental msvc support
|
||||
SET(_PCH_include_prefix "/I")
|
||||
ELSE(WIN32)
|
||||
SET(PCHSupport_FOUND FALSE)
|
||||
ENDIF(WIN32)
|
||||
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||
|
||||
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
||||
SET(${_out_compile_flags} ${${_flags_var_name}} )
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
||||
IF(${_targetType} STREQUAL SHARED_LIBRARY AND NOT WIN32)
|
||||
LIST(APPEND ${_out_compile_flags} -fPIC)
|
||||
ENDIF()
|
||||
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
## TODO ... ? or does it work out of the box
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
|
||||
FOREACH(item ${DIRINC})
|
||||
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}${item}")
|
||||
ENDFOREACH(item)
|
||||
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
|
||||
GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
|
||||
#MESSAGE("_directory_flags ${_directory_flags} ${_global_definitions}" )
|
||||
LIST(APPEND ${_out_compile_flags} ${_directory_flags})
|
||||
LIST(APPEND ${_out_compile_flags} ${_global_definitions})
|
||||
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS} )
|
||||
|
||||
SEPARATE_ARGUMENTS(${_out_compile_flags})
|
||||
|
||||
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
|
||||
|
||||
MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
|
||||
|
||||
SET(${_dephelp} ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch_dephelp.cxx)
|
||||
FILE(WRITE ${${_dephelp}}
|
||||
"#include \"${_include_file}\"
|
||||
int testfunction()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
)
|
||||
|
||||
ENDMACRO(_PCH_WRITE_PCHDEP_CXX )
|
||||
|
||||
MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
|
||||
|
||||
FILE(TO_NATIVE_PATH ${_input} _native_input)
|
||||
FILE(TO_NATIVE_PATH ${_output} _native_output)
|
||||
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
IF(CMAKE_CXX_COMPILER_ARG1)
|
||||
# remove leading space in compiler argument
|
||||
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
|
||||
|
||||
SET(${out_command}
|
||||
${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
|
||||
)
|
||||
ELSE(CMAKE_CXX_COMPILER_ARG1)
|
||||
SET(${out_command}
|
||||
${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
|
||||
)
|
||||
ENDIF(CMAKE_CXX_COMPILER_ARG1)
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
SET(_dummy_str "#include <${_input}>")
|
||||
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pch_dummy.cpp ${_dummy_str})
|
||||
|
||||
SET(${out_command}
|
||||
${CMAKE_CXX_COMPILER} ${_compile_FLAGS} /c /Fp${_native_output} /Yc${_native_input} pch_dummy.cpp
|
||||
)
|
||||
#/out:${_output}
|
||||
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
ENDMACRO(_PCH_GET_COMPILE_COMMAND )
|
||||
|
||||
|
||||
|
||||
MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn )
|
||||
|
||||
FILE(TO_NATIVE_PATH ${_pch_path} _native_pch_path)
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible
|
||||
# on all remote machines set
|
||||
# PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
|
||||
# if you want warnings for invalid header files (which is very inconvenient
|
||||
# if you have different versions of the headers for different build types
|
||||
# you may set _pch_dowarn
|
||||
IF (_dowarn)
|
||||
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include ${CMAKE_CURRENT_BINARY_DIR}/${_header_name} -Winvalid-pch " )
|
||||
ELSE (_dowarn)
|
||||
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include ${CMAKE_CURRENT_BINARY_DIR}/${_header_name} " )
|
||||
ENDIF (_dowarn)
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
set(${_cflags} "/Fp${_native_pch_path} /Yu${_header_name}" )
|
||||
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
ENDMACRO(_PCH_GET_TARGET_COMPILE_FLAGS )
|
||||
|
||||
MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
|
||||
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
||||
GET_FILENAME_COMPONENT(_path ${_input} PATH)
|
||||
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch/${_targetName}_${CMAKE_BUILD_TYPE}.gch")
|
||||
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
|
||||
|
||||
|
||||
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
|
||||
|
||||
# to do: test whether compiler flags match between target _targetName
|
||||
# and _pch_output_to_use
|
||||
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
||||
|
||||
IF( "${ARGN}" STREQUAL "0")
|
||||
SET(_dowarn 0)
|
||||
ELSE( "${ARGN}" STREQUAL "0")
|
||||
SET(_dowarn 1)
|
||||
ENDIF("${ARGN}" STREQUAL "0")
|
||||
|
||||
|
||||
_PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn})
|
||||
# MESSAGE("Add flags ${_target_cflags} to ${_targetName} " )
|
||||
SET_TARGET_PROPERTIES(${_targetName}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS ${_target_cflags}
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(pch_Generate_${_targetName}
|
||||
DEPENDS ${_pch_output_to_use}
|
||||
)
|
||||
|
||||
ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName} )
|
||||
|
||||
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
|
||||
|
||||
MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
|
||||
|
||||
SET(_PCH_current_target ${_targetName})
|
||||
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"This is the ADD_PRECOMPILED_HEADER macro. "
|
||||
"You must set CMAKE_BUILD_TYPE!"
|
||||
)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
IF( "${ARGN}" STREQUAL "0")
|
||||
SET(_dowarn 0)
|
||||
ELSE( "${ARGN}" STREQUAL "0")
|
||||
SET(_dowarn 1)
|
||||
ENDIF("${ARGN}" STREQUAL "0")
|
||||
|
||||
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
||||
GET_FILENAME_COMPONENT(_path ${_input} PATH)
|
||||
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_input} _output)
|
||||
|
||||
GET_FILENAME_COMPONENT(_outdir ${_output} PATH )
|
||||
|
||||
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
||||
_PCH_WRITE_PCHDEP_CXX(${_targetName} ${_input} _pch_dephelp_cxx)
|
||||
|
||||
IF(${_targetType} STREQUAL SHARED_LIBRARY)
|
||||
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_pch_dephelp_cxx} )
|
||||
ELSE(${_targetType} STREQUAL SHARED_LIBRARY)
|
||||
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_pch_dephelp_cxx})
|
||||
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY)
|
||||
|
||||
FILE(MAKE_DIRECTORY ${_outdir})
|
||||
|
||||
_PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
|
||||
|
||||
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
|
||||
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
|
||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${_name} PROPERTIES GENERATED 1)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${_input} ${CMAKE_CURRENT_BINARY_DIR}/${_name} # ensure same directory! Required by gcc
|
||||
DEPENDS ${_input}
|
||||
)
|
||||
|
||||
#message("_command ${_input} ${_output}")
|
||||
_PCH_GET_COMPILE_COMMAND(_command ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_output} )
|
||||
|
||||
#message(${_input} )
|
||||
#message("_output ${_output}")
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${_output}
|
||||
COMMAND ${_command}
|
||||
DEPENDS ${_input} ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_targetName}_pch_dephelp
|
||||
)
|
||||
|
||||
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_input} ${_output} ${_dowarn})
|
||||
ENDMACRO(ADD_PRECOMPILED_HEADER)
|
||||
|
||||
# Generates the use of precompiled in a target,
|
||||
# without using depency targets (2 extra for each target)
|
||||
# Using Visual, must also add ${_targetName}_pch to sources
|
||||
# Not needed by Xcode
|
||||
|
||||
MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES Visual*)
|
||||
|
||||
SET(_dummy_str "#include \"${_input}\"\n"
|
||||
"// This is required to suppress LNK4221. Very annoying.\n"
|
||||
"void *g_${_targetName}Dummy = 0\;\n")
|
||||
|
||||
# Use of cxx extension for generated files (as Qt does)
|
||||
SET(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cxx)
|
||||
if(EXISTS ${${_targetName}_pch})
|
||||
# Check if contents is the same, if not rewrite
|
||||
# todo
|
||||
else(EXISTS ${${_targetName}_pch})
|
||||
FILE(WRITE ${${_targetName}_pch} ${_dummy_str})
|
||||
endif(EXISTS ${${_targetName}_pch})
|
||||
endif(CMAKE_GENERATOR MATCHES Visual*)
|
||||
|
||||
ENDMACRO(GET_NATIVE_PRECOMPILED_HEADER)
|
||||
|
||||
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
|
||||
|
||||
IF( "${ARGN}" STREQUAL "0")
|
||||
SET(_dowarn 0)
|
||||
ELSE( "${ARGN}" STREQUAL "0")
|
||||
SET(_dowarn 1)
|
||||
ENDIF("${ARGN}" STREQUAL "0")
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES Visual*)
|
||||
# Auto include the precompile (useful for moc processing, since the use of
|
||||
# precompiled is specified at the target level
|
||||
# and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
|
||||
|
||||
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
|
||||
if (${oldProps} MATCHES NOTFOUND)
|
||||
SET(oldProps "")
|
||||
endif(${oldProps} MATCHES NOTFOUND)
|
||||
|
||||
SET(newProperties "${oldProps} /Yu\"${_input}.h\" /FI\"${_input}.h\"")
|
||||
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
|
||||
|
||||
#also inlude ${oldProps} to have the same compile options
|
||||
SET_SOURCE_FILES_PROPERTIES(${_input}.cpp PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_input}.h\"")
|
||||
|
||||
else(CMAKE_GENERATOR MATCHES Visual*)
|
||||
|
||||
if (CMAKE_GENERATOR MATCHES Xcode)
|
||||
# For Xcode, cmake needs my patch to process
|
||||
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
|
||||
|
||||
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
|
||||
if (${oldProps} MATCHES NOTFOUND)
|
||||
SET(oldProps "")
|
||||
endif(${oldProps} MATCHES NOTFOUND)
|
||||
|
||||
# When buiding out of the tree, precompiled may not be located
|
||||
# Use full path instead.
|
||||
GET_FILENAME_COMPONENT(fullPath ${_input} ABSOLUTE)
|
||||
|
||||
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
|
||||
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
|
||||
|
||||
else (CMAKE_GENERATOR MATCHES Xcode)
|
||||
|
||||
#Fallback to the "old" precompiled suppport
|
||||
#ADD_PRECOMPILED_HEADER(${_targetName} ${_input} ${_dowarn})
|
||||
endif(CMAKE_GENERATOR MATCHES Xcode)
|
||||
endif(CMAKE_GENERATOR MATCHES Visual*)
|
||||
|
||||
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
|
11
src/framework/cmake/FindPhysFS.cmake
Normal file
11
src/framework/cmake/FindPhysFS.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
# Try to find the physfs librairy
|
||||
# PHYSFS_FOUND - system has physfs
|
||||
# PHYSFS_INCLUDE_DIR - the physfs include directory
|
||||
# PHYSFS_LIBRARY - the physfs library
|
||||
|
||||
FIND_PATH(PHYSFS_INCLUDE_DIR physfs.h PATH_SUFFIXES physfs)
|
||||
FIND_LIBRARY(PHYSFS_LIBRARY NAMES libphysfs.a physfs)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PhysFS DEFAULT_MSG PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR)
|
||||
|
11
src/framework/cmake/FindZLIB.cmake
Normal file
11
src/framework/cmake/FindZLIB.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
# Try to find the zlib librairy
|
||||
# ZLIB_FOUND - system has zlib
|
||||
# ZLIB_INCLUDE_DIR - the zlib include directory
|
||||
# ZLIB_LIBRARY - the zlib library
|
||||
|
||||
FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h)
|
||||
FIND_LIBRARY(ZLIB_LIBRARY NAMES libz.a libzlib.a zlib1.a zlibd.a zlibd1.a z zlib zdll zlib1 zlibd zlibd1)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
|
||||
|
8
src/framework/cmake/i486-mingw32_toolchain.cmake
Normal file
8
src/framework/cmake/i486-mingw32_toolchain.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
SET(CMAKE_C_COMPILER i486-mingw32-gcc)
|
||||
SET(CMAKE_CXX_COMPILER i486-mingw32-g++)
|
||||
SET(CMAKE_RC_COMPILER i486-mingw32-windres)
|
||||
SET(CMAKE_FIND_ROOT_PATH /usr/i486-mingw32)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
8
src/framework/cmake/i586-mingw32msvc_toolchain.cmake
Normal file
8
src/framework/cmake/i586-mingw32msvc_toolchain.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
|
||||
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
|
||||
SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
|
||||
SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
@@ -271,6 +271,13 @@ namespace Fw
|
||||
//LastState,
|
||||
//AlternateState
|
||||
};
|
||||
|
||||
enum AppicationFlags {
|
||||
AppEnableModules = 1,
|
||||
AppEnableGraphics = 2,
|
||||
AppEnableConfigs = 4,
|
||||
AppEnableAll = AppEnableModules | AppEnableGraphics | AppEnableConfigs
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -32,31 +32,6 @@ ResourceManager g_resources;
|
||||
void ResourceManager::init(const char *argv0)
|
||||
{
|
||||
PHYSFS_init(argv0);
|
||||
|
||||
// setup write directory
|
||||
if(!g_resources.setupWriteDir())
|
||||
logError("Could not setup write directory");
|
||||
|
||||
// try to find modules directory, all data lives there
|
||||
//TODO: move this to Application class
|
||||
std::string baseDir = PHYSFS_getBaseDir();
|
||||
std::string possibleDirs[] = { "modules",
|
||||
baseDir + "modules",
|
||||
baseDir + "../modules",
|
||||
baseDir + "../share/" + g_app.getAppName() + "/otclient/modules",
|
||||
"" };
|
||||
|
||||
bool found = false;
|
||||
for(const std::string& dir : possibleDirs) {
|
||||
if(g_resources.addToSearchPath(dir)) {
|
||||
logInfo("Using modules directory '", dir.c_str(), "'");
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
logFatal("Could not find modules directory");
|
||||
}
|
||||
|
||||
void ResourceManager::terminate()
|
||||
@@ -64,10 +39,10 @@ void ResourceManager::terminate()
|
||||
PHYSFS_deinit();
|
||||
}
|
||||
|
||||
bool ResourceManager::setupWriteDir()
|
||||
bool ResourceManager::setupWriteDir(const std::string& appWriteDirName)
|
||||
{
|
||||
std::string userDir = PHYSFS_getUserDir();
|
||||
std::string dirName = Fw::mkstr(".", g_app.getAppName());
|
||||
std::string dirName = Fw::mkstr(".", appWriteDirName);
|
||||
std::string writeDir = userDir + dirName;
|
||||
if(!PHYSFS_setWriteDir(writeDir.c_str())) {
|
||||
if(!PHYSFS_setWriteDir(userDir.c_str()))
|
||||
@@ -196,3 +171,9 @@ std::string ResourceManager::resolvePath(const std::string& path)
|
||||
}
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
std::string ResourceManager::getBaseDir()
|
||||
{
|
||||
return PHYSFS_getBaseDir();
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
void init(const char *argv0);
|
||||
void terminate();
|
||||
|
||||
bool setupWriteDir();
|
||||
bool setupWriteDir(const std::string& appWriteDirName);
|
||||
|
||||
/// Add an package or directory to the search path
|
||||
bool addToSearchPath(const std::string& path, bool insertInFront = true);
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
std::list<std::string> listDirectoryFiles(const std::string& directoryPath = "");
|
||||
|
||||
std::string resolvePath(const std::string& path);
|
||||
std::string getAppUserPath();
|
||||
std::string getBaseDir();
|
||||
};
|
||||
|
||||
extern ResourceManager g_resources;
|
||||
|
@@ -25,8 +25,9 @@
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
std::vector<std::string> args(argv, argv + argc);
|
||||
g_otclient.init(args);
|
||||
g_otclient.run();
|
||||
g_otclient.terminate();
|
||||
OTClient otclient;
|
||||
otclient.init(args);
|
||||
otclient.run();
|
||||
otclient.terminate();
|
||||
return 0;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
1
src/otcicon.rc
Normal file
1
src/otcicon.rc
Normal file
@@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "otcicon.ico"
|
44
src/otclient/CMakeLists.txt
Normal file
44
src/otclient/CMakeLists.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
# otclient options
|
||||
OPTION(FORBIDDEN_FUNCTIONS "Enable forbidden lua functions" ON)
|
||||
|
||||
IF(FORBIDDEN_FUNCTIONS)
|
||||
ADD_DEFINITIONS(-DFORBIDDEN_FUNCTIONS)
|
||||
MESSAGE(STATUS "Lua forbidden functions: ON")
|
||||
ELSE(FORBIDDEN_FUNCTIONS)
|
||||
MESSAGE(STATUS "Lua forbidden functions: OFF")
|
||||
ENDIF(FORBIDDEN_FUNCTIONS)
|
||||
|
||||
SET(OTCLIENT_SOURCES ${OTCLIENT_SOURCES}
|
||||
# otclient
|
||||
${CMAKE_CURRENT_LIST_DIR}/otclient.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/luafunctions.cpp
|
||||
|
||||
# otclient luascript
|
||||
${CMAKE_CURRENT_LIST_DIR}/luascript/luavaluecasts.cpp
|
||||
|
||||
# otclient core
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/game.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/map.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/thingstype.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/spritemanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/item.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/tile.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/thing.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/creature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/effect.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/missile.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/localplayer.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/outfit.cpp
|
||||
|
||||
# otclient ui
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uiitem.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uicreature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uimap.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uigame.cpp
|
||||
|
||||
# otclient net
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/protocollogin.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/protocolgame.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/protocolgamesend.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/protocolgameparse.cpp
|
||||
)
|
@@ -22,7 +22,7 @@ void OTClient::registerLuaFunctions()
|
||||
{
|
||||
Application::registerLuaFunctions();
|
||||
|
||||
g_lua.bindGlobalFunction("exit", std::bind(&Application::exit, &g_app));
|
||||
g_lua.bindGlobalFunction("exit", std::bind(&Application::exit, g_app));
|
||||
g_lua.bindGlobalFunction("importDat", std::bind(&ThingsType::load, &g_thingsType, _1));
|
||||
g_lua.bindGlobalFunction("importSpr", std::bind(&SpriteManager::load, &g_sprites, _1));
|
||||
g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor);
|
||||
|
@@ -22,11 +22,13 @@
|
||||
|
||||
#include "otclient.h"
|
||||
|
||||
OTClient g_otclient;
|
||||
Application& g_app = g_otclient;
|
||||
OTClient::OTClient() : Application(Otc::AppCompactName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OTClient::init(const std::vector<std::string>& args)
|
||||
{
|
||||
logInfo(Otc::AppName, " ", Otc::AppVersion);
|
||||
Application::init(Otc::AppCompactName, args);
|
||||
Application::init(args, Fw::AppEnableAll);
|
||||
}
|
||||
|
@@ -29,10 +29,9 @@
|
||||
class OTClient : public Application
|
||||
{
|
||||
public:
|
||||
OTClient();
|
||||
void init(const std::vector<std::string>& args);
|
||||
void registerLuaFunctions();
|
||||
};
|
||||
|
||||
extern OTClient g_otclient;
|
||||
|
||||
#endif
|
||||
|
@@ -1 +0,0 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "icon.ico"
|
29
src/pch.h
29
src/pch.h
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 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 PCH_H
|
||||
#define PCH_H
|
||||
|
||||
#include "framework/global.h"
|
||||
#include "otclient/global.h"
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user