Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running without launcher #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added Build_Release/openclaw
Binary file not shown.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion OpenClaw/Engine/GameApp/BaseGameApp.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "config.h"
#include "../Resource/ResourceCache.h"
#include "../Audio/Audio.h"
#include "../Events/EventMgr.h"
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
32 changes: 30 additions & 2 deletions OpenClaw/Engine/GameApp/BaseGameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions OpenClaw/Engine/GameApp/BaseGameLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions OpenClaw/Engine/GameApp/MainLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#if !(defined(__ANDROID__) || defined(__WINDOWS__))
#include <pwd.h>
#include <unistd.h>
#include <sys/stat.h>
#endif

#ifdef __EMSCRIPTEN__
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions OpenClaw/Engine/UserInterface/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ struct ConsoleConfig
{
ConsoleConfig()
{
backgroundImagePath = "";
backgroundImagePath = "console02.tga";
stretchBackgroundImage = true;
widthRatio = 1.0;
heightRatio = 0.5;
lineSeparatorHeight = 3;
commandPromptOffsetY = 10;
consoleAnimationSpeed = 0.65;
fontColor = COLOR_WHITE;
fontPath = "";
fontHeight = 14;
fontPath = "clacon.ttf";
fontHeight = 20;
leftOffset = 5;
commandPrompt = "> ";
}
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define DEFAULT_ASSETS_FOLDER "${DEFAULT_ASSETS_FOLDER}"