termux-packages/x11-packages/the-powder-toy/03-saves-dir-path.patch
2022-04-18 14:41:35 +05:30

125 lines
4.7 KiB
Diff

diff -uNr The-Powder-Toy-95.0/src/client/Client.cpp The-Powder-Toy-95.0.mod/src/client/Client.cpp
--- The-Powder-Toy-95.0/src/client/Client.cpp 2020-02-27 05:38:53.000000000 +0200
+++ The-Powder-Toy-95.0.mod/src/client/Client.cpp 2020-03-08 20:36:18.935572466 +0200
@@ -67,7 +67,8 @@
{
//Read config
std::ifstream configFile;
- configFile.open("powder.pref", std::ios::binary);
+ MakeDirectory("@TERMUX_HOME@/.powdertoy");
+ configFile.open("@TERMUX_HOME@/.powdertoy/powder.pref", std::ios::binary);
if (configFile)
{
try
@@ -888,7 +889,8 @@
void Client::WritePrefs()
{
std::ofstream configFile;
- configFile.open("powder.pref", std::ios::trunc);
+ MakeDirectory("@TERMUX_HOME@/.powdertoy");
+ configFile.open("@TERMUX_HOME@/.powdertoy/powder.pref", std::ios::trunc);
if (configFile)
{
@@ -1066,6 +1068,7 @@
ByteString saveID = ByteString::Build(Format::Hex(Format::Width(lastStampTime, 8)), Format::Hex(Format::Width(lastStampName, 2)));
ByteString filename = STAMPS_DIR PATH_SEP + saveID + ".stm";
+ MakeDirectory("@TERMUX_HOME@/.powdertoy");
MakeDirectory(STAMPS_DIR);
Json::Value stampInfo;
@@ -1101,6 +1104,7 @@
void Client::updateStamps()
{
+ MakeDirectory("@TERMUX_HOME@/.powdertoy");
MakeDirectory(STAMPS_DIR);
std::ofstream stampsStream;
diff -uNr The-Powder-Toy-95.0/src/Config.h The-Powder-Toy-95.0.mod/src/Config.h
--- The-Powder-Toy-95.0/src/Config.h 2020-02-27 05:38:53.000000000 +0200
+++ The-Powder-Toy-95.0.mod/src/Config.h 2020-03-08 20:36:18.935572466 +0200
@@ -61,11 +61,7 @@
#define IDENT_PLATFORM "WIN32"
#endif
#elif defined(LIN)
-#if defined(_64BIT)
-#define IDENT_PLATFORM "LIN64"
-#else
-#define IDENT_PLATFORM "LIN32"
-#endif
+#define IDENT_PLATFORM "TERMUX"
#elif defined(MACOSX)
#define IDENT_PLATFORM "MACOSX"
#else
@@ -91,11 +87,11 @@
#define STATICSERVER "static.powdertoy.co.uk"
#define ENFORCE_HTTPS
-#define LOCAL_SAVE_DIR "Saves"
+#define LOCAL_SAVE_DIR "@TERMUX_HOME@/.powdertoy/saves"
-#define STAMPS_DIR "stamps"
+#define STAMPS_DIR "@TERMUX_HOME@/.powdertoy/stamps"
-#define BRUSH_DIR "Brushes"
+#define BRUSH_DIR "@TERMUX_HOME@/.powdertoy/brushes"
#ifndef M_GRAV
#define M_GRAV 6.67300e-1
diff -uNr The-Powder-Toy-95.0/src/gui/game/GameController.cpp The-Powder-Toy-95.0.mod/src/gui/game/GameController.cpp
--- The-Powder-Toy-95.0/src/gui/game/GameController.cpp 2020-02-27 05:38:53.000000000 +0200
+++ The-Powder-Toy-95.0.mod/src/gui/game/GameController.cpp 2020-03-08 20:37:59.986378271 +0200
@@ -774,7 +774,7 @@
#if !defined(MACOSX) && !defined(NO_INSTALL_CHECK)
if (Client::Ref().IsFirstRun())
{
- Install();
+ //Install();
}
#endif
firstTick = false;
@@ -1210,6 +1210,7 @@
gameSave->authors = localSaveInfo;
gameModel->SetSaveFile(&tempSave, gameView->ShiftBehaviour());
+ Client::Ref().MakeDirectory("@TERMUX_HOME@/.powdertoy");
Client::Ref().MakeDirectory(LOCAL_SAVE_DIR);
std::vector<char> saveData = gameSave->Serialise();
if (saveData.size() == 0)
diff -uNr The-Powder-Toy-95.0/src/gui/game/GameModel.cpp The-Powder-Toy-95.0.mod/src/gui/game/GameModel.cpp
--- The-Powder-Toy-95.0/src/gui/game/GameModel.cpp 2020-02-27 05:38:53.000000000 +0200
+++ The-Powder-Toy-95.0.mod/src/gui/game/GameModel.cpp 2020-03-08 20:36:18.936572474 +0200
@@ -423,6 +423,7 @@
brushList.push_back(new TriangleBrush(ui::Point(4, 4)));
//Load more from brushes folder
+ Client::Ref().MakeDirectory("@TERMUX_HOME@/.powdertoy");
std::vector<ByteString> brushFiles = Client::Ref().DirectorySearch(BRUSH_DIR, "", ".ptb");
for (size_t i = 0; i < brushFiles.size(); i++)
{
diff -uNr The-Powder-Toy-95.0/src/gui/options/OptionsView.cpp The-Powder-Toy-95.0.mod/src/gui/options/OptionsView.cpp
--- The-Powder-Toy-95.0/src/gui/options/OptionsView.cpp 2020-02-27 05:38:53.000000000 +0200
+++ The-Powder-Toy-95.0.mod/src/gui/options/OptionsView.cpp 2020-03-08 20:38:45.213738818 +0200
@@ -300,7 +300,7 @@
const char* openCommand = "xdg-open ";
#endif
char* workingDirectory = new char[FILENAME_MAX+strlen(openCommand)];
- sprintf(workingDirectory, "%s\"%s\"", openCommand, getcwd(NULL, 0));
+ sprintf(workingDirectory, "%s\"%s\"", openCommand, "@TERMUX_HOME@/.powdertoy");
system(workingDirectory);
delete[] workingDirectory;
} });
diff -uNr The-Powder-Toy-95.0/src/gui/save/LocalSaveActivity.cpp The-Powder-Toy-95.0.mod/src/gui/save/LocalSaveActivity.cpp
--- The-Powder-Toy-95.0/src/gui/save/LocalSaveActivity.cpp 2020-02-27 05:38:53.000000000 +0200
+++ The-Powder-Toy-95.0.mod/src/gui/save/LocalSaveActivity.cpp 2020-03-08 20:36:18.937572482 +0200
@@ -104,6 +104,7 @@
void LocalSaveActivity::saveWrite(ByteString finalFilename)
{
+ Client::Ref().MakeDirectory("@TERMUX_HOME@/.powdertoy");
Client::Ref().MakeDirectory(LOCAL_SAVE_DIR);
GameSave *gameSave = save.GetGameSave();
Json::Value localSaveInfo;