Skip to content

Commit

Permalink
bump(x11/the-powder-toy): 98.2.365
Browse files Browse the repository at this point in the history
This update adds missing desktop icon and allows users to save their progress in folders other than default one.
  • Loading branch information
twaik committed Nov 9, 2024
1 parent cf41219 commit 6857418
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 113 deletions.
123 changes: 14 additions & 109 deletions x11-packages/the-powder-toy/03-saves-dir-path.patch
Original file line number Diff line number Diff line change
@@ -1,109 +1,14 @@
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -68,7 +68,8 @@
{
//Read config
std::ifstream configFile;
- configFile.open("powder.pref", std::ios::binary);
+ Platform::MakeDirectory("@TERMUX_HOME@/.powdertoy");
+ configFile.open("@TERMUX_HOME@/.powdertoy/powder.pref", std::ios::binary);
if (configFile)
{
try
@@ -777,7 +778,8 @@
void Client::WritePrefs()
{
std::ofstream configFile;
- configFile.open("powder.pref", std::ios::trunc);
+ Platform::MakeDirectory("@TERMUX_HOME@/.powdertoy");
+ configFile.open("@TERMUX_HOME@/.powdertoy/powder.pref", std::ios::trunc);

if (configFile)
{
@@ -956,6 +958,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";

+ Platform::MakeDirectory("@TERMUX_HOME@/.powdertoy");
Platform::MakeDirectory(STAMPS_DIR);

Json::Value stampInfo;
@@ -991,6 +994,7 @@

void Client::updateStamps()
{
+ Platform::MakeDirectory("@TERMUX_HOME@/.powdertoy");
Platform::MakeDirectory(STAMPS_DIR);

std::ofstream stampsStream;
--- a/src/Config.template.h
+++ b/src/Config.template.h
@@ -101,11 +97,11 @@
#define STATICSCHEME "https://"
#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
--- a/src/gui/game/GameController.cpp
+++ b/src/gui/game/GameController.cpp
@@ -741,7 +741,7 @@
#if !defined(MACOSX) && !defined(NO_INSTALL_CHECK)
if (Client::Ref().IsFirstRun())
{
- Install();
+ //Install();
}
#endif
firstTick = false;
@@ -1202,6 +1202,7 @@
gameSave->authors = localSaveInfo;

gameModel->SetSaveFile(&tempSave, gameView->ShiftBehaviour());
+ Platform::MakeDirectory("@TERMUX_HOME@/.powdertoy");
Platform::MakeDirectory(LOCAL_SAVE_DIR);
std::vector<char> saveData = gameSave->Serialise();
if (saveData.size() == 0)
--- a/src/gui/game/GameModel.cpp
+++ b/src/gui/game/GameModel.cpp
@@ -479,6 +479,7 @@
brushList.push_back(new TriangleBrush(ui::Point(4, 4)));

//Load more from brushes folder
+ Platform::MakeDirectory("@TERMUX_HOME@/.powdertoy");
std::vector<ByteString> brushFiles = Platform::DirectorySearch(BRUSH_DIR, "", { ".ptb" });
for (size_t i = 0; i < brushFiles.size(); i++)
{
--- a/src/gui/options/OptionsView.cpp
+++ b/src/gui/options/OptionsView.cpp
@@ -319,11 +319,7 @@
currentY+=20;
ui::Button * dataFolderButton = new ui::Button(ui::Point(8, currentY), ui::Point(90, 16), "Open Data Folder");
dataFolderButton->SetActionCallback({ [] {
- ByteString cwd = Platform::GetCwd();
- if (!cwd.empty())
- Platform::OpenURI(cwd);
- else
- fprintf(stderr, "cannot open data folder: Platform::GetCwd(...) failed\n");
+ Platform::OpenURI("@TERMUX_HOME@/.powdertoy");
} });
scrollPanel->AddChild(dataFolderButton);

--- a/src/gui/save/LocalSaveActivity.cpp
+++ b/src/gui/save/LocalSaveActivity.cpp
@@ -103,6 +103,7 @@

void LocalSaveActivity::saveWrite(ByteString finalFilename)
{
+ Platform::MakeDirectory("@TERMUX_HOME@/.powdertoy");
Platform::MakeDirectory(LOCAL_SAVE_DIR);
GameSave *gameSave = save.GetGameSave();
Json::Value localSaveInfo;
Not actually need that patch, just for compatibility with previous versions
+++ ./src/Config.template.h
@@ -62,9 +62,9 @@

constexpr char SCHEME[] = "https://";
constexpr char STATICSCHEME[] = "https://";
-constexpr char LOCAL_SAVE_DIR[] = "Saves";
+constexpr char LOCAL_SAVE_DIR[] = "saves";
constexpr char STAMPS_DIR[] = "stamps";
-constexpr char BRUSH_DIR[] = "Brushes";
+constexpr char BRUSH_DIR[] = "brushes";

constexpr int httpMaxConcurrentStreams = 50;
constexpr int httpConnectTimeoutS = 15;
17 changes: 13 additions & 4 deletions x11-packages/the-powder-toy/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,28 @@ TERMUX_PKG_HOMEPAGE=https://powdertoy.co.uk/
TERMUX_PKG_DESCRIPTION="The Powder Toy is a free physics sandbox game"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=97.0.352
TERMUX_PKG_REVISION=1
TERMUX_PKG_VERSION="98.2.365"
TERMUX_PKG_SRCURL=https://github.com/ThePowderToy/The-Powder-Toy/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=3ab27e1b9a84db1da7342e61232ad5be981ca1ddf001c4924fd08b61cc8d287a
TERMUX_PKG_DEPENDS="fftw, jsoncpp, libbz2, libc++, libcurl, libluajit, libpng, sdl2"
TERMUX_PKG_SHA256=21900b6b022535d0e56126b023538cc4f44b64feceafb5640492618a42a60080
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_DEPENDS="fftw, jsoncpp, libandroid-execinfo, libbz2, libc++, libcurl, libluajit, libpng, sdl2"
TERMUX_PKG_GROUPS="games"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Dworkaround_elusive_bzip2_lib_dir=$TERMUX_PREFIX/lib
-Dworkaround_elusive_bzip2_include_dir=$TERMUX_PREFIX/include
-Db_pie=true
-Dignore_updates=true
-Dapp_data=$TERMUX_ANDROID_HOME/.powdertoy
-Dcan_install=no
"

termux_step_pre_configure() {
LDFLAGS+=" -landroid-execinfo"
}

termux_step_make_install() {
install -Dm700 -t $TERMUX_PREFIX/bin powder
ln -sf powder $TERMUX_PREFIX/bin/the-powder-toy
install -Dm700 -t $TERMUX_PREFIX/share/applications resources/powder.desktop
install -Dm700 -T $TERMUX_PKG_SRCDIR/resources/generated_icons/icon_exe.png $TERMUX_PREFIX/share/pixmaps/powdertoy-powder.png
}

0 comments on commit 6857418

Please sign in to comment.