diff --git a/.gitignore b/.gitignore index 9c7ca5f4f4..a31cdc3613 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ ClawLauncher/bin/ ClawLauncher/obj/ Build_Release/OpenClaw_obj/ OpenClaw/Debug/ +OpenClaw/config.h OpenClaw.opensdf OpenClaw.sdf Build_Release/vim.exe.stackdump diff --git a/Build_Release/openclaw b/Build_Release/openclaw new file mode 100755 index 0000000000..5f07caec44 Binary files /dev/null and b/Build_Release/openclaw differ diff --git a/CMakeLists.txt b/CMakeLists.txt index 6be608f5ba..74cfa86cee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ option(Emscripten "Build as WASM" OFF) option(Extern_Config "Do not embed config file" ON) set(EMSCRIPTEN_PATH "CHANGE ME PLEASE!!!/emsdk") +set(DEFAULT_ASSETS_FOLDER "/usr/share/openclaw/" + CACHE STRING "AssetsFolder for auto-generated ~/.config/openclaw/config.xml") + project(OpenClaw) #if(NOT CMAKE_BUILD_TYPE) @@ -42,6 +45,10 @@ if (Emscripten) endif (Emscripten) # Directories with libs + +configure_file(config.h.in config.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + link_directories(./libwap) link_directories(./Box2D) if (WIN32) diff --git a/OpenClaw/Engine/GameApp/BaseGameApp.cpp b/OpenClaw/Engine/GameApp/BaseGameApp.cpp index f8c118cd6b..959d9e00f7 100644 --- a/OpenClaw/Engine/GameApp/BaseGameApp.cpp +++ b/OpenClaw/Engine/GameApp/BaseGameApp.cpp @@ -1,3 +1,4 @@ +#include "config.h" #include "../Resource/ResourceCache.h" #include "../Audio/Audio.h" #include "../Events/EventMgr.h" @@ -856,7 +857,7 @@ bool BaseGameApp::InitializeFont(GameOptions& gameOptions) m_pConsoleFont = TTF_OpenFont(gameOptions.consoleFontName.c_str(), gameOptions.consoleFontSize); if (m_pConsoleFont == NULL) { - LOG_ERROR("Failed to load TTF font"); + LOG_ERROR("Failed to load TTF font '" + gameOptions.consoleFontName + "'"); return false; } @@ -1400,7 +1401,9 @@ TiXmlElement* CreateDefaultAssetsConfig() { TiXmlElement* assets = new TiXmlElement("Assets"); + XML_ADD_TEXT_ELEMENT("AssetsFolder", DEFAULT_ASSETS_FOLDER, assets); XML_ADD_TEXT_ELEMENT("RezArchive", "CLAW.REZ", assets); + XML_ADD_TEXT_ELEMENT("CustomArchive", "ASSETS.ZIP", assets); XML_ADD_TEXT_ELEMENT("ResourceCacheSize", "50", assets); XML_ADD_TEXT_ELEMENT("TempDir", ".", assets); XML_ADD_TEXT_ELEMENT("SavesFile", "SAVES.XML", assets); diff --git a/OpenClaw/Engine/GameApp/BaseGameLogic.cpp b/OpenClaw/Engine/GameApp/BaseGameLogic.cpp index ae08ed5524..323b78e919 100644 --- a/OpenClaw/Engine/GameApp/BaseGameLogic.cpp +++ b/OpenClaw/Engine/GameApp/BaseGameLogic.cpp @@ -94,8 +94,8 @@ bool BaseGameLogic::Initialize() if (gameSaves.Error()) { LOG_ERROR("Error while loading " + savesFilePath - + ": " + std::string(gameSaves.ErrorDesc())); - return false; + + ": " + std::string(gameSaves.ErrorDesc()) + " - not loading saves"); + gameSaves = DefaultSaves(); } if (!m_pGameSaveMgr->Initialize(gameSaves.RootElement())) @@ -106,6 +106,34 @@ bool BaseGameLogic::Initialize() return true; } +TiXmlDocument BaseGameLogic::DefaultSaves() +{ + TiXmlDocument xmlConfig; + + //----- [GameSaves] + TiXmlElement* root = new TiXmlElement("GameSaves"); + xmlConfig.LinkEndChild(root); + + TiXmlElement* level = new TiXmlElement("Level"); + root->LinkEndChild(level); + + XML_ADD_TEXT_ELEMENT("LevelNumber", "1", level); + XML_ADD_TEXT_ELEMENT("LevelName", "La Roca", level); + + TiXmlElement* checkpoint = new TiXmlElement("Checkpoint"); + level->LinkEndChild(checkpoint); + + XML_ADD_TEXT_ELEMENT("CheckpointNumber", "0", checkpoint); + XML_ADD_TEXT_ELEMENT("Score", "0", checkpoint); + XML_ADD_TEXT_ELEMENT("Health", "100", checkpoint); + XML_ADD_TEXT_ELEMENT("Lives", "3", checkpoint); + XML_ADD_TEXT_ELEMENT("BulletCount", "10", checkpoint); + XML_ADD_TEXT_ELEMENT("MagicCount", "5", checkpoint); + XML_ADD_TEXT_ELEMENT("DynamiteCount", "3", checkpoint); + + return xmlConfig; +} + std::string BaseGameLogic::GetActorXml(uint32 actorId) { StrongActorPtr pActor = MakeStrongPtr(VGetActor(actorId)); diff --git a/OpenClaw/Engine/GameApp/BaseGameLogic.h b/OpenClaw/Engine/GameApp/BaseGameLogic.h index 1d67a1ecde..0e8f46872c 100644 --- a/OpenClaw/Engine/GameApp/BaseGameLogic.h +++ b/OpenClaw/Engine/GameApp/BaseGameLogic.h @@ -138,6 +138,8 @@ class BaseGameLogic : public IGameLogic WeakActorPtr m_pClawActor; private: + TiXmlDocument DefaultSaves(); + void ExecuteStartupCommands(const std::string& startupCommandsFile); void CreateSinglePhysicsTile(int x, int y, const TileCollisionPrototype& proto); //void LoadGameWorkerThread(const char* pXmlLevelPath, float* pProgress, bool* pRet); diff --git a/OpenClaw/Engine/GameApp/MainLoop.cpp b/OpenClaw/Engine/GameApp/MainLoop.cpp index f5c616ee0d..b6b9117850 100644 --- a/OpenClaw/Engine/GameApp/MainLoop.cpp +++ b/OpenClaw/Engine/GameApp/MainLoop.cpp @@ -5,6 +5,7 @@ #if !(defined(__ANDROID__) || defined(__WINDOWS__)) #include #include +#include #endif #ifdef __EMSCRIPTEN__ @@ -35,6 +36,7 @@ int RunGameEngine(int argc, char** argv) userDirectory = std::string(homedir) + "/.config/openclaw/"; + mkdir(userDirectory.c_str(), 0755); #endif LOG("Looking for: " + userDirectory + "config.xml"); diff --git a/OpenClaw/Engine/UserInterface/Console.h b/OpenClaw/Engine/UserInterface/Console.h index cbaee7d0a4..53347b021f 100644 --- a/OpenClaw/Engine/UserInterface/Console.h +++ b/OpenClaw/Engine/UserInterface/Console.h @@ -19,7 +19,7 @@ struct ConsoleConfig { ConsoleConfig() { - backgroundImagePath = ""; + backgroundImagePath = "console02.tga"; stretchBackgroundImage = true; widthRatio = 1.0; heightRatio = 0.5; @@ -27,8 +27,8 @@ struct ConsoleConfig commandPromptOffsetY = 10; consoleAnimationSpeed = 0.65; fontColor = COLOR_WHITE; - fontPath = ""; - fontHeight = 14; + fontPath = "clacon.ttf"; + fontHeight = 20; leftOffset = 5; commandPrompt = "> "; } diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000000..be183db568 --- /dev/null +++ b/config.h.in @@ -0,0 +1 @@ +#define DEFAULT_ASSETS_FOLDER "${DEFAULT_ASSETS_FOLDER}"