DevilutionX: make script work with spawn.mpq (#12172)

Add documentation, change settings path, pack assets
* Add Diablo shareware package
This commit is contained in:
Peppersawce
2025-04-30 05:17:32 +00:00
committed by GitHub
parent a6508a35a9
commit 2d3dbca072
4 changed files with 104 additions and 63 deletions

View File

@@ -1,22 +1,37 @@
#!/bin/bash
# Global variables
PROGRAM_NAME="diasurgical/devilution"
DATA_PATH=`/bin/finddir B_USER_SETTINGS_DIRECTORY`/$PROGRAM_NAME
OLD_DATA_PATH=`finddir B_USER_SETTINGS_DIRECTORY`/diasurgical/devilution
DATA_PATH=`finddir B_USER_SETTINGS_DIRECTORY`/devilutionx
FILE=$DATA_PATH/diabdat.mpq
DEMOFILE=$DATA_PATH/spawn.mpq
SHAREFILE="$(finddir B_SYSTEM_APPS_DIRECTORY)/devilutionx/spawn.mpq"
# Migration if needed
if [ -e $OLD_DATA_PATH ] && [ ! -e $DATA_PATH ]; then
mkdir -p $DATA_PATH
mv -t $DATA_PATH $OLD_DATA_PATH/*
rm -rf `finddir B_USER_SETTINGS_DIRECTORY`/diasurgical
fi
# Check for Shareware package
if [ ! -e $SHAREFILE ]; then
SHAREFILE="$(finddir B_USER_APPS_DIRECTORY)/devilutionx/spawn.mpq"
fi
# DevilutionX has issues creating the path on its own
if [ ! -e $DATA_PATH ]; then
mkdir -p $DATA_PATH
fi
# If the file exists...
if [ -f $FILE ];
then
# ...then start the program
`/bin/finddir B_SYSTEM_APPS_DIRECTORY`/DevilutionX/devilutionx
if [ -f $FILE ] || [ -f $DEMOFILE ] || [ -f $SHAREFILE ]; then
# ...then start the program
DevilutionX $@
else
# but if it isn't exist drop a warning
if [ "$(alert --warning "Please, copy your original Diadblo 1 \"diabdat.mpq\" file to the Data Folder and rename it to lower-case." "Open Data Folder" "Cancel")" == "Open Data Folder" ]; then
# then let's create the data Dir and open it
mkdir -p $DATA_PATH
open $DATA_PATH
fi
# but if it doesn't exist drop a warning
if [ "$(alert --warning "Please copy Diablo's \"diabdat.mpq\" file or the demo's \"spawn.mpq\" to the Data Folder and rename it to lower-case." "Open Data Folder" "Cancel")" == "Open Data Folder" ]; then
# then let's open the data Dir
open $DATA_PATH
fi
fi

View File

@@ -2,12 +2,15 @@ SUMMARY="An open-source reconstruction of Diablo"
DESCRIPTION="DevilutionX is an open-source re-implementation of Blizzard's \
Diablo game from 1996.
To play, you'll need the file 'diabdat.mpq' from the original Diablo CD.
To play, you'll need the file 'diabdat.mpq' from the original Diablo CD \
or 'spawn.mpq' from its shareware version.
Starting the game from the Deskbar link will migrate the old configuration \
folder or set up a new one if needed.
Visit the homepage for more info, a FAQ, controller mappings, etc."
HOMEPAGE="https://github.com/diasurgical/devilutionX"
HOMEPAGE="https://devilutionx.com/"
COPYRIGHT="2025 DevilutionX"
LICENSE="Sustainable Use License"
REVISION="2"
REVISION="3"
SOURCE_URI="https://github.com/diasurgical/devilutionX/archive/$portVersion.zip"
CHECKSUM_SHA256="850ca8af8c0c86c9224be469f80e25f7fafdfc70bc29388ac0ab5a4c5e29da2c"
SOURCE_DIR="DevilutionX-$portVersion"
@@ -23,7 +26,7 @@ USER_SETTINGS_FILES="
PROVIDES="
devilutionx$secondaryArchSuffix = $portVersion
app:devilutionx = $portVersion
app:DevilutionX = $portVersion
"
REQUIRES="
haiku$secondaryArchSuffix
@@ -53,6 +56,7 @@ BUILD_PREREQUIRES="
cmd:gcc$secondaryArchSuffix
cmd:make
cmd:pkg_config$secondaryArchSuffix
cmd:smpq
"
BUILD()
@@ -60,25 +64,23 @@ BUILD()
export CXXFLAGS="-D_DEFAULT_SOURCE -Wall -w"
export LDFLAGS="-lbsd -lnetwork"
mkdir -p build && cd build
cmake .. $cmakeDirArgs \
cmake -Bbuild -S. $cmakeDirArgs \
-DCMAKE_BUILD_TYPE=Release \
-DDISABLE_ZERO_TIER=ON \
-DDISABLE_LTO=ON \
-DBUILD_TESTING=OFF \
-DPIE=OFF
make $jobArgs
make -C build $jobArgs
}
INSTALL()
{
cd build
# Pack docs
mkdir -p $docDir
cp -t $docDir *.md docs/*.md
# Setup pre-installed assets dir
mkdir -p $dataDir/devilutionx
cp -r assets/* $dataDir/devilutionx
cd build
# Generate the rdef
local MAJOR="`echo "$portVersion" | cut -d. -f1`"
@@ -92,17 +94,20 @@ INSTALL()
addResourcesToBinaries devilutionx.rdef devilutionx
mkdir -p $appsDir/DevilutionX
cp devilutionx $appsDir/DevilutionX
# Move binary and assets
mkdir -p $appsDir/devilutionx
cp devilutionx.mpq $appsDir/devilutionx
cp devilutionx $appsDir/devilutionx/DevilutionX
ln -s $appsDir/devilutionx/DevilutionX $appsDir/DevilutionX
# Installing start-script
cp $portDir/additional-files/devilutionx.sh $appsDir/DevilutionX
chmod +x $appsDir/DevilutionX/devilutionx.sh
# Install start-script
cp $portDir/additional-files/devilutionx.sh $appsDir/devilutionx
chmod +x $appsDir/devilutionx/devilutionx.sh
# Installing extra-attribs
# Install extra-attribs
rc devilutionx.rdef
resattr -o $appsDir/DevilutionX/devilutionx.sh \
resattr -o $appsDir/devilutionx/devilutionx.sh \
devilutionx.rsrc
addAppDeskbarSymlink $appsDir/DevilutionX/devilutionx.sh "DevilutionX"
addAppDeskbarSymlink $appsDir/devilutionx/devilutionx.sh "DevilutionX"
}

View File

@@ -1,49 +1,45 @@
From 3f57fb3eb9dcd7ecf532ddccdb78c047e7bbc411 Mon Sep 17 00:00:00 2001
From 99b4230d527066bb1297fc33c9ffe72007c6809d Mon Sep 17 00:00:00 2001
From: Peppersawce <michaelpeppers89@yahoo.it>
Date: Mon, 14 Apr 2025 23:17:00 +0200
Subject: Define Haiku assets paths (better version)
Date: Thu, 17 Apr 2025 02:55:45 +0200
Subject: Change settings path
diff --git a/Source/utils/paths.cpp b/Source/utils/paths.cpp
index 9635ac3..9ca00a9 100644
index 9635ac3..2298279 100644
--- a/Source/utils/paths.cpp
+++ b/Source/utils/paths.cpp
@@ -11,6 +11,12 @@
@@ -11,6 +11,11 @@
#include "utils/log.hpp"
#include "utils/sdl_ptrs.h"
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <fs_info.h>
+#include <dirent.h>
+#endif
+
#ifdef __IPHONEOS__
#include "platform/ios/ios_paths.h"
#endif
@@ -118,7 +123,21 @@ const std::string &ConfigPath()
const std::string &AssetsPath()
{
if (!assetsPath) {
-#if __EMSCRIPTEN__
+#if defined(__HAIKU__)
+ // Look in system first (system-wide install)
+ char buffer[B_PATH_NAME_LENGTH + 10];
+ find_directory(B_SYSTEM_DATA_DIRECTORY, dev_for_path("/boot"), false, buffer, B_PATH_NAME_LENGTH);
+ strcat(buffer, "/devilutionx/");
+ if (opendir(buffer)) {
+ assetsPath.emplace(strdup(buffer));
+ } else {
+ // Then look in user data (home-data install)
+ char homedata[B_PATH_NAME_LENGTH + 10];
+ find_directory(B_USER_DATA_DIRECTORY, dev_for_path("/boot"), false, homedata, B_PATH_NAME_LENGTH);
+ strcat(homedata, "/devilutionx/");
+ assetsPath.emplace(strdup(homedata));
+ }
+#elif __EMSCRIPTEN__
assetsPath.emplace("assets/");
@@ -84,6 +89,11 @@ const std::string &PrefPath()
prefPath = FromSDL(IOSGetPrefPath());
#elif defined(NXDK)
assetsPath.emplace("D:\\assets\\");
prefPath = NxdkGetPrefPath();
+#elif defined(__HAIKU__)
+ char cfgpath[B_PATH_NAME_LENGTH + 10];
+ find_directory(B_USER_SETTINGS_DIRECTORY, dev_for_path("/boot"), false, cfgpath, B_PATH_NAME_LENGTH);
+ strcat(cfgpath, "/devilutionx/");
+ prefPath = strdup(cfgpath);
#else
prefPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
#if !defined(__amigaos__)
@@ -103,6 +113,8 @@ const std::string &ConfigPath()
configPath = FromSDL(IOSGetPrefPath());
#elif defined(NXDK)
configPath = NxdkGetPrefPath();
+#elif defined(__HAIKU__)
+ configPath = prefPath;
#else
configPath = FromSDL(SDL_GetPrefPath("diasurgical", "devilution"));
#if !defined(__amigaos__)
--
2.48.1

View File

@@ -0,0 +1,25 @@
SUMMARY="Shareware version of Diablo, to be used with DevilutionX"
DESCRIPTION="This is the latest shareware release (v1.09) of Diablo, packed to be used with DevilutionX."
HOMEPAGE="https://devilutionx.com/"
COPYRIGHT="1996 - 2001 Blizzard Entertainment"
LICENSE="Public Domain"
REVISION="1"
SOURCE_URI="https://github.com/diasurgical/devilutionx-assets/releases/download/v2/spawn.mpq#noarchive"
CHECKSUM_SHA256="64427cd7c1ba904eaa2e0031c16a6b136d0ecef9abc888c5ff8344b459356e38"
SOURCE_FILENAME="spawn.mpq"
ARCHITECTURES="any"
DISABLE_SOURCE_PACKAGE="yes"
PROVIDES="
diablo_shareware = $portVersion
"
REQUIRES="
app:DevilutionX
"
INSTALL()
{
# Pack game data
mkdir -p $appsDir/devilutionx && cp spawn.mpq $appsDir/devilutionx
}