mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-23 12:10:06 +02:00
Julius: add recipe
This commit is contained in:
69
games-strategy/julius/additional-files/JuliusLauncher.sh
Executable file
69
games-strategy/julius/additional-files/JuliusLauncher.sh
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
|
||||
about="Julius is an open source re-implementation of Caesar III.
|
||||
|
||||
The aim of this project is to create an open-source version of Caesar 3, \
|
||||
with the same logic as the original, but with some UI enhancements, that \
|
||||
is able to be played on multiple platforms. The same logic means that the\
|
||||
saved games are 100% compatible, and any gameplay bugs present in the or\
|
||||
iginal Caesar 3 game will also be present in Julius.
|
||||
|
||||
Julius requires the original assets (graphics, sounds, etc) from Caesar 3\
|
||||
to run.
|
||||
|
||||
"
|
||||
|
||||
configFile="/boot/home/config/settings/julius.ini"
|
||||
testFile="c3.inf"
|
||||
|
||||
dataFolder=$(cat "$configFile")
|
||||
scriptFile=$(realpath "$0")
|
||||
workFolder=$(dirname "$scriptFile")
|
||||
|
||||
while true
|
||||
do
|
||||
if [[ "$dataFolder" == "" ]]; then
|
||||
idx=`alert --empty "$about Data folder: not selected" \
|
||||
"Select game data folder" "Exit"`
|
||||
else
|
||||
if [ -f "$dataFolder/$testFile" ]; then
|
||||
valid="[OK]"
|
||||
else
|
||||
valid="[ERROR]"
|
||||
fi
|
||||
idx=`alert --empty "$about Data folder: $dataFolder $valid" \
|
||||
"Select game data folder" "Exit" "Play game"`
|
||||
fi
|
||||
|
||||
if [[ "$idx" == "Select game data folder" ]]; then
|
||||
selected=`filepanel -l -k d --single -t "Select game data folder"`
|
||||
if [ -d $selected ]; then
|
||||
dataFolder="$selected"
|
||||
echo "$dataFolder" > "$configFile"
|
||||
continue
|
||||
else
|
||||
dataFolder=""
|
||||
fi
|
||||
if [ -f $selected ]; then
|
||||
dataFolder=`dirname "$selected"`
|
||||
echo "$dataFolder" > "$configFile"
|
||||
continue
|
||||
else
|
||||
dataFolder=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$idx" == "Play game" ]]; then
|
||||
if [ -f "$dataFolder/$testFile" ]; then
|
||||
$workFolder/Julius "$dataFolder" &
|
||||
else
|
||||
alert "Game files not found!"
|
||||
continue
|
||||
fi
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ "$idx" == "Exit" ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
77
games-strategy/julius/additional-files/julius.rdef.in
Normal file
77
games-strategy/julius/additional-files/julius.rdef.in
Normal file
@@ -0,0 +1,77 @@
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
resource app_version {
|
||||
major = @MAJOR@,
|
||||
middle = @MIDDLE@,
|
||||
minor = @MINOR@,
|
||||
|
||||
variety = B_APPV_FINAL,
|
||||
internal = 0,
|
||||
|
||||
short_info = "Julius",
|
||||
long_info = "@LONG_INFO@"
|
||||
};
|
||||
|
||||
resource app_signature "@APP_SIGNATURE@";
|
||||
|
||||
resource vector_icon array {
|
||||
$"6E636966040200060232430A3BFF32BC1FA83267544B03394A535000FFAA00FF"
|
||||
$"7F4C000200060238CA003C1580BC5A5539261E4B102947ADEF00FFE0A5FFE8C0"
|
||||
$"0605010400540F020FBD73B54CBB82B628BE3BB4F4BFECB4ADBF11B4B8C100B4"
|
||||
$"A3C303B577C212B4F3C265B5D1C167B6D5C1D8B647C150B68AC10DB5FBC131B6"
|
||||
$"41C070B63BBF5EB704BFDBB691BF1DB73EBEACB7C3BEE5B781BE97B7A1BE6EB7"
|
||||
$"5A3DB773BD56B7C6BBCAB992BC66B892BBACB931BB42B884BB7EB8D6BA83B8EF"
|
||||
$"B95BBA34B9D7B97EB92CBA75B8E1BB03B908BABDB8BEBAC3B869BA4BB895BA85"
|
||||
$"B84ABA61B80EBA8CB82DBA77B83DBA26B8B8B969B87AB9C7B9E6B7A90207C537"
|
||||
$"B69AC4DAB6E7C5C3B627C71AB5ABC669B5D1C70CB60BC6C0B6BFC6E7B666C682"
|
||||
$"B744C5CBB82CC636B7C6C597B85BC50DB87FC556B889C4D9B877C47AB849C4A4"
|
||||
$"B869C450B828C45EB7BBC44EB7EBC483B7460206C1ABB814C182B867C217B744"
|
||||
$"C39728C2C9B69DC39CB6E5C342B844C37DB79AC31DB8A4C2A4B94CC2F2B906C2"
|
||||
$"78B974C202B976C23AB97AC1CBB976C178B927C189B961C160B8C90208BFBCB7"
|
||||
$"EEBF68B84BBFFBB7AE42B743C03DB76EC0A1B7C5C08BB8CEC09CB84BC079B946"
|
||||
$"C021BA2AC05EB9C0C002BA62BF91BAA3BFD3BA98BF59BAACBEE6BA96BF19BAB5"
|
||||
$"BEC1BA80BED9BA31BED9BA53BEE9B9D9BEECB926BEE1B97EBF1BB8B10206BC6D"
|
||||
$"BA4ABC38BAB3BCCAB99EBDF6B89CBD50B905BE0EB948BDDDBAA4BE02B9F9BDC4"
|
||||
$"BB0A3ABBC5BDA3BB74BD27BC05BC7EBC03BCCBBC0BBC4CBBFDBC1FBBA1BC26BB"
|
||||
$"D2BC0BBB2A0207C55FB961C51DB96DC5D4B94EC68AB8B3C637B904C725B8CCC8"
|
||||
$"48B945C7BFB8F7C7ACB9BBC62FBA24C6F0BA07C609BA2FC5CBBA01C5EABA13C5"
|
||||
$"81B9D1C4E2B985C533B9A8C4C8B97AC49BB959C4B0B96BC4DCB95B0207BA08BA"
|
||||
$"D4B9AFBB5FBA48BA77BAEAB9D9BA8FBA1CBB12BA6DBB14BBA0BB1CBB08BB0CBC"
|
||||
$"07BAD3BCCFBAFCBC70BABCBD04BA5FBD4DBA98BD39BA28BD60B9B1BD5BB9E9BD"
|
||||
$"6EB96EBD3BB962BCA4B963BCE6B967BBFD0207C2FCBA23C2C2BA4AC31BBA13C3"
|
||||
$"5DB9FAC337B9F1C3DABA0DC4C2BA72C451BA3AC51EBAA0C5C6BB1AC579BAD4C4"
|
||||
$"F8BB7EC328BB7FC40ABBA2C2C7BB6EC222BAF9C25EBB4CC200BAC7C23ABA60C2"
|
||||
$"21BA8DC27DBA560227C6E1BAF0C6F7BB11C71BBADDC78DBAB7C754BACBC7AFBB"
|
||||
$"B3C77FBDADC793BCB1C779BDD6C7BEBE05C7A6BDEAC8BEBEE7C9A8C16EC95AC0"
|
||||
$"25C90AC1A4C7BCC1AFC861C1A8C7FFC296C84CC472C844C380C852C512C7E9C6"
|
||||
$"45C839C5B8C7C351C72EC6A1C772C696C681C6B4C524C6B1C5D2C6A9C4EDC6B5"
|
||||
$"C47FC6AFC4B5C6B6C31551C042C634C1A4C691BF8FC606BE61C525BEDDC5B3BE"
|
||||
$"13C4CD3847BCAEC2F937483648BC0DC2DBBBFAC3BF3D51BDE1C602BF68C72FC1"
|
||||
$"38C74EC02BC729C1C3C760C2DBC775C24EC76DC24FC819C178C991C1C5C8C6C1"
|
||||
$"46CA13C136CB29C133CA9FBF24CB5EBB0BCA84BD06CB2ABA41CA42B8C0C98DB9"
|
||||
$"7DC9EFB8DEC947B926C8C1B904C905B999C7E1BA80C622BA0DC702B9C4C506B8"
|
||||
$"7EC2B0B916C3E0B814C1D6B76BC010B7AFC0F9B7F4C0AFB974C15EB8ADC11FBA"
|
||||
$"50C1A9BC21C18BBB3EC1AFBC15C11ABBBFC049BBF6C0ACBC55C06ABD89C064BC"
|
||||
$"F0C075BDEDC059BEAEC025BE4EC03FBEA1BFC9BE56BF1EBE80BF71BF46BF4BC1"
|
||||
$"29BEEFC041BF3EC114BE85C0B7BDC4C0EFBE20C13FBDCCC24EBDADC1C9BDCAC2"
|
||||
$"D8BD94C3D8BD20C35A3AC3C1BCE5C388BC74C3A4BCACC427BC79C560BC3AC4C8"
|
||||
$"BC6AC604BC0CC721BB55C697BBB5C70DBB320207BFDDBB7CBF97BB8FC010BB6F"
|
||||
$"C06BBB38C03EBB53C13BBB87C28DBCB0C1F8BC0AC1B7BCEDBFF9BCB1C0CFBCF0"
|
||||
$"BFB8BCA1BF5DBC41BF8EBC6ABF3BBC23BEF3BBEBBF13BC0BBEE8BBCABF06BB8C"
|
||||
$"BEFCBBAABF4EBB8D0207B781BCB9B748BD36B7ADBC5CB829BBB8B7E1BC02B84F"
|
||||
$"BC29B864BD17B85EBCA0B868BD80B843BE51B864BDECB833BE80B7EABEC6B81A"
|
||||
$"BEB2B7C1BED6B767BED9B792BEECB737BEBAB728BE48B72FBE7CB71FBDBE0206"
|
||||
$"BE00BC68BDD4BC8FBE7BBCA7BF45BD65BEE6BD02BF86BDAABFF2BE49BFC6BDF3"
|
||||
$"BF08BE61BD46BDC0BE13BE36BCF7BD8ABC88BCE9BC9FBD4CBCD6BCE8BD6FBCCA"
|
||||
$"BD26BCE7BDA6BCB40206BAF0BE05BAB0BE2CBB23BDE7BB71BD90BB49BDB9BC12"
|
||||
$"BDDEBD0CBEDFBC98BE59BD37BF10BD7DBF7FBD5DBF46BCA8BF90BB0CBF15BBCE"
|
||||
$"BF71BAABBEE7BA1BBE44BA4EBEA6BA64BE390205B83EBFA0B867BFCF2EBF76B9"
|
||||
$"05BEDCB8D8BF30B986BF0FBA4CBFD4B9EFBF6FBA89C01BBAEEC0B7BAC6C063BA"
|
||||
$"2FC0AEB8CDC016B972C077B898BFF60205B4EFC05FB516C09FB57AC004B694BF"
|
||||
$"52B607BFABB6BFBF7CB729BFB2B6F0BF9EB742BFB9B754BFE6B74ABFD1B6AFC0"
|
||||
$"4DB568C11EB60FC0BAB540C0DE110A030F000102030405060708090A0B0C0D0E"
|
||||
$"124000000000000000004008714200003FDADC01178400040A020F0001020304"
|
||||
$"05060708090A0B0C0D0E1001178400040A000100000A010101000A010102000A"
|
||||
$"010103000A010104000A010105000A010106000A010107000A000108000A0101"
|
||||
$"09000A01010A000A01010B000A01010C000A01010D000A01010E00"
|
||||
};
|
||||
95
games-strategy/julius/julius-1.1.0.recipe
Normal file
95
games-strategy/julius/julius-1.1.0.recipe
Normal file
@@ -0,0 +1,95 @@
|
||||
SUMMARY="An open source re-implementation of Caesar III"
|
||||
DESCRIPTION="Julius is an open source re-implementation of Caesar III.
|
||||
|
||||
The aim of this project is to create an open-source version of Caesar 3, \
|
||||
with the same logic as the original, but with some UI enhancements, that \
|
||||
is able to be played on multiple platforms. The same logic means that the \
|
||||
saved games are 100% compatible, and any gameplay bugs present in the \
|
||||
original Caesar 3 game will also be present in Julius.
|
||||
|
||||
Julius requires the original assets (graphics, sounds, etc) from Caesar 3 to run."
|
||||
HOMEPAGE="https://github.com/bvschaik/julius/"
|
||||
COPYRIGHT="Bianca van Schaik"
|
||||
LICENSE="GNU GPL v3"
|
||||
REVISION="1"
|
||||
SOURCE_URI="https://github.com/bvschaik/julius/archive/v$portVersion.tar.gz"
|
||||
CHECKSUM_SHA256="d558a13645508bf3a1055698a201d7d089a78b150362d861e57a07686cb82a9a"
|
||||
PATCHES="julius-$portVersion.patchset"
|
||||
ADDITIONAL_FILES="
|
||||
julius.rdef.in
|
||||
JuliusLauncher.sh
|
||||
"
|
||||
|
||||
ARCHITECTURES="!x86_gcc2 x86_64"
|
||||
SECONDARY_ARCHITECTURES="x86"
|
||||
|
||||
PROVIDES="
|
||||
julius$secondaryArchSuffix = $portVersion
|
||||
app:Julius$secondaryArchSuffix = $portVersion
|
||||
"
|
||||
REQUIRES="
|
||||
haiku$secondaryArchSuffix
|
||||
lib:libgl$secondaryArchSuffix
|
||||
lib:libintl$secondaryArchSuffix
|
||||
lib:libsdl2_2.0$secondaryArchSuffix
|
||||
lib:libsdl2_mixer_2.0$secondaryArchSuffix
|
||||
lib:libz$secondaryArchSuffix
|
||||
"
|
||||
|
||||
BUILD_REQUIRES="
|
||||
haiku${secondaryArchSuffix}_devel
|
||||
devel:libgl$secondaryArchSuffix
|
||||
devel:libintl$secondaryArchSuffix
|
||||
devel:libsdl2_2.0$secondaryArchSuffix
|
||||
devel:libsdl2_mixer_2.0$secondaryArchSuffix
|
||||
devel:libz$secondaryArchSuffix
|
||||
"
|
||||
BUILD_PREREQUIRES="
|
||||
cmd:cmake
|
||||
cmd:gcc$secondaryArchSuffix
|
||||
cmd:ld$secondaryArchSuffix
|
||||
cmd:make
|
||||
cmd:pkg_config$secondaryArchSuffix
|
||||
"
|
||||
|
||||
BUILD()
|
||||
{
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$appsDir/Julius \
|
||||
-DSDL2_INCLUDE_DIR=/system/$relativeIncludeDir/SDL2 \
|
||||
-DSDL2_MIXER_INCLUDE_DIR=/system/$relativeIncludeDir/SDL2 \
|
||||
-DHAIKU_BUILD=ON
|
||||
make $jobArgs
|
||||
}
|
||||
|
||||
INSTALL()
|
||||
{
|
||||
cd build
|
||||
|
||||
mkdir -p $appsDir/Julius
|
||||
|
||||
cp julius $appsDir/Julius/Julius
|
||||
cp $portDir/additional-files/JuliusLauncher.sh "$appsDir/Julius/Julius Launcher"
|
||||
|
||||
local APP_SIGNATURE="application/x-vnd.julius"
|
||||
local MAJOR="`echo "$portVersion" | cut -d. -f1`"
|
||||
local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
|
||||
local MINOR="`echo "$portVersion" | cut -d. -f3`"
|
||||
local LONG_INFO="$SUMMARY"
|
||||
sed \
|
||||
-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
|
||||
-e "s|@MAJOR@|$MAJOR|" \
|
||||
-e "s|@MIDDLE@|$MIDDLE|" \
|
||||
-e "s|@MINOR@|$MINOR|" \
|
||||
-e "s|@LONG_INFO@|$LONG_INFO|" \
|
||||
$portDir/additional-files/julius.rdef.in > $sourceDir/build/julius.rdef
|
||||
|
||||
rc julius.rdef
|
||||
resattr -o "$appsDir/Julius/Julius Launcher" julius.rsrc
|
||||
addResourcesToBinaries $sourceDir/build/julius.rdef $appsDir/Julius/Julius
|
||||
|
||||
addAppDeskbarSymlink "$appsDir/Julius/Julius Launcher" "Julius"
|
||||
}
|
||||
363
games-strategy/julius/patches/julius-1.1.0.patchset
Normal file
363
games-strategy/julius/patches/julius-1.1.0.patchset
Normal file
@@ -0,0 +1,363 @@
|
||||
From 8dd8b22cb2a887d4ca90d3a3cfb8d6fcb35a30ad Mon Sep 17 00:00:00 2001
|
||||
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
Date: Sun, 27 Oct 2019 20:49:35 +1000
|
||||
Subject: Add Haiku support
|
||||
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index b18a3e2..fa06267 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -174,6 +174,12 @@ elseif (SWITCH_BUILD)
|
||||
${PROJECT_SOURCE_DIR}/src/platform/switch/switch_touch.c
|
||||
${PROJECT_SOURCE_DIR}/src/platform/switch/switch_keyboard.c
|
||||
)
|
||||
+elseif (HAIKU_BUILD)
|
||||
+ set(PLATFORM_FILES
|
||||
+ ${PLATFORM_FILES}
|
||||
+ ${PROJECT_SOURCE_DIR}/src/platform/haiku/cursor.c
|
||||
+ ${PROJECT_SOURCE_DIR}/src/platform/haiku/screen.c
|
||||
+ )
|
||||
else()
|
||||
set(PLATFORM_FILES
|
||||
${PLATFORM_FILES}
|
||||
diff --git a/src/game/settings.c b/src/game/settings.c
|
||||
index 3bcaebb..1016cad 100644
|
||||
--- a/src/game/settings.c
|
||||
+++ b/src/game/settings.c
|
||||
@@ -39,7 +39,7 @@ static struct {
|
||||
|
||||
static void load_default_settings(void)
|
||||
{
|
||||
- data.fullscreen = 1;
|
||||
+ data.fullscreen = 0;
|
||||
data.window_width = 800;
|
||||
data.window_height = 600;
|
||||
|
||||
@@ -68,7 +68,7 @@ static void load_default_settings(void)
|
||||
static void load_settings(buffer *buf)
|
||||
{
|
||||
buffer_skip(buf, 4);
|
||||
- data.fullscreen = buffer_read_i32(buf);
|
||||
+ data.fullscreen = 0;
|
||||
buffer_skip(buf, 3);
|
||||
data.sound_effects.enabled = buffer_read_u8(buf);
|
||||
data.sound_music.enabled = buffer_read_u8(buf);
|
||||
@@ -118,7 +118,7 @@ void settings_load(void)
|
||||
buffer_init(&buf, data.inf_file, size);
|
||||
load_settings(&buf);
|
||||
|
||||
- if (data.window_width + data.window_height < 500) {
|
||||
+ if (data.window_width < 800 || data.window_height < 600) {
|
||||
// most likely migration from Caesar 3
|
||||
data.window_width = 800;
|
||||
data.window_height = 600;
|
||||
diff --git a/src/platform/haiku/cursor.c b/src/platform/haiku/cursor.c
|
||||
new file mode 100644
|
||||
index 0000000..befff8f
|
||||
--- /dev/null
|
||||
+++ b/src/platform/haiku/cursor.c
|
||||
@@ -0,0 +1,56 @@
|
||||
+#include "graphics/color.h"
|
||||
+#include "game/system.h"
|
||||
+#include "input/cursor.h"
|
||||
+
|
||||
+#include "SDL.h"
|
||||
+
|
||||
+static SDL_Texture *cursors[CURSOR_MAX];
|
||||
+SDL_Texture *current_cursor;
|
||||
+
|
||||
+extern struct {
|
||||
+ SDL_Window *window;
|
||||
+ SDL_Renderer *renderer;
|
||||
+ SDL_Texture *texture;
|
||||
+} SDL;
|
||||
+
|
||||
+static SDL_Texture *init_cursor(const cursor *c)
|
||||
+{
|
||||
+
|
||||
+ SDL_Texture *tex = SDL_CreateTexture(SDL.renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 32, 32);
|
||||
+
|
||||
+ uint32_t pixels[32 * 32];
|
||||
+
|
||||
+ for (int i = 0; i < 32; i++) {
|
||||
+ for (int j = 0; j < 32; j++) {
|
||||
+ switch (c->data[i * 32 + j]) {
|
||||
+ case 'X':
|
||||
+ pixels[i * 32 + j] = 0xFF000000; //black
|
||||
+ break;
|
||||
+ case '.':
|
||||
+ pixels[i * 32 + j] = 0xFFFFFFFF; //white
|
||||
+ break;
|
||||
+ case ' ':
|
||||
+ pixels[i * 32 + j] = 0x00000000; //transparent
|
||||
+ break; // Transparent is 0x00000000 which is the default value of the buffer
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ SDL_UpdateTexture(tex, NULL, pixels, 32 * 4);
|
||||
+ SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
|
||||
+
|
||||
+ return tex;
|
||||
+}
|
||||
+
|
||||
+void system_init_cursors(void)
|
||||
+{
|
||||
+ for (int i = 0; i < CURSOR_MAX; i++) {
|
||||
+ cursors[i] = init_cursor(input_cursor_data(i));
|
||||
+ }
|
||||
+ system_set_cursor(CURSOR_ARROW);
|
||||
+}
|
||||
+
|
||||
+void system_set_cursor(int cursor_id)
|
||||
+{
|
||||
+ current_cursor = cursors[cursor_id];
|
||||
+}
|
||||
diff --git a/src/platform/haiku/screen.c b/src/platform/haiku/screen.c
|
||||
new file mode 100644
|
||||
index 0000000..80fd5de
|
||||
--- /dev/null
|
||||
+++ b/src/platform/haiku/screen.c
|
||||
@@ -0,0 +1,180 @@
|
||||
+#include "platform/screen.h"
|
||||
+
|
||||
+#include "SDL.h"
|
||||
+
|
||||
+#include "game/settings.h"
|
||||
+#include "graphics/graphics.h"
|
||||
+#include "graphics/screen.h"
|
||||
+
|
||||
+extern SDL_Texture *current_cursor;
|
||||
+#include "input/mouse.h"
|
||||
+
|
||||
+struct {
|
||||
+ SDL_Window *window;
|
||||
+ SDL_Renderer *renderer;
|
||||
+ SDL_Texture *texture;
|
||||
+} SDL = {0, 0, 0};
|
||||
+
|
||||
+static struct {
|
||||
+ int x;
|
||||
+ int y;
|
||||
+ int centered;
|
||||
+} window_pos = { 0, 0, 1 };
|
||||
+
|
||||
+static struct {
|
||||
+ const int WIDTH;
|
||||
+ const int HEIGHT;
|
||||
+} MINIMUM = { 640, 480 };
|
||||
+
|
||||
+int platform_screen_create(const char *title)
|
||||
+{
|
||||
+ int width, height;
|
||||
+ int fullscreen = setting_fullscreen();
|
||||
+ if (fullscreen) {
|
||||
+ SDL_DisplayMode mode;
|
||||
+ SDL_GetDesktopDisplayMode(0, &mode);
|
||||
+ width = mode.w;
|
||||
+ height = mode.h;
|
||||
+ } else {
|
||||
+ setting_window(&width, &height);
|
||||
+ }
|
||||
+
|
||||
+ platform_screen_destroy();
|
||||
+
|
||||
+ SDL_Log("Creating screen %d x %d, fullscreen? %d\n", width, height, fullscreen);
|
||||
+ Uint32 flags = SDL_WINDOW_RESIZABLE;
|
||||
+ if (fullscreen) {
|
||||
+ flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
+ }
|
||||
+ SDL.window = SDL_CreateWindow(title,
|
||||
+ SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
+ width, height, flags);
|
||||
+
|
||||
+ if (!SDL.window) {
|
||||
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create window: %s", SDL_GetError());
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ SDL.renderer = SDL_CreateRenderer(SDL.window, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||
+ if (!SDL.renderer) {
|
||||
+ SDL_Log("Unable to create renderer, trying software renderer: %s", SDL_GetError());
|
||||
+ SDL.renderer = SDL_CreateRenderer(SDL.window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_SOFTWARE);
|
||||
+ if (!SDL.renderer) {
|
||||
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create renderer: %s", SDL_GetError());
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+ if (fullscreen && SDL_GetNumVideoDisplays() > 1) {
|
||||
+ SDL_SetWindowGrab(SDL.window, SDL_TRUE);
|
||||
+ }
|
||||
+
|
||||
+ SDL_ShowCursor(SDL_DISABLE);
|
||||
+
|
||||
+ SDL_SetWindowMinimumSize(SDL.window, MINIMUM.WIDTH, MINIMUM.HEIGHT);
|
||||
+ return platform_screen_resize(width, height);
|
||||
+}
|
||||
+
|
||||
+void platform_screen_destroy(void)
|
||||
+{
|
||||
+ if (SDL.texture) {
|
||||
+ SDL_DestroyTexture(SDL.texture);
|
||||
+ SDL.texture = 0;
|
||||
+ }
|
||||
+ if (SDL.renderer) {
|
||||
+ SDL_DestroyRenderer(SDL.renderer);
|
||||
+ SDL.renderer = 0;
|
||||
+ }
|
||||
+ if (SDL.window) {
|
||||
+ SDL_DestroyWindow(SDL.window);
|
||||
+ SDL.window = 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int platform_screen_resize(int width, int height)
|
||||
+{
|
||||
+ if (SDL.texture) {
|
||||
+ SDL_DestroyTexture(SDL.texture);
|
||||
+ SDL.texture = 0;
|
||||
+ }
|
||||
+
|
||||
+ setting_set_display(setting_fullscreen(), width, height);
|
||||
+ SDL.texture = SDL_CreateTexture(SDL.renderer,
|
||||
+ SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING,
|
||||
+ width, height);
|
||||
+ if (SDL.texture) {
|
||||
+ SDL_Log("Texture created (%d x %d)", width, height);
|
||||
+ screen_set_resolution(width, height);
|
||||
+ return 1;
|
||||
+ } else {
|
||||
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create texture: %s", SDL_GetError());
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void platform_screen_move(int x, int y)
|
||||
+{
|
||||
+ if (!setting_fullscreen()) {
|
||||
+ window_pos.x = x;
|
||||
+ window_pos.y = y;
|
||||
+ window_pos.centered = 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void platform_screen_set_fullscreen(void)
|
||||
+{
|
||||
+ SDL_GetWindowPosition(SDL.window, &window_pos.x, &window_pos.y);
|
||||
+ int orig_w, orig_h;
|
||||
+ SDL_GetWindowSize(SDL.window, &orig_w, &orig_h);
|
||||
+ SDL_DisplayMode mode;
|
||||
+ SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(SDL.window), &mode);
|
||||
+ SDL_Log("User to fullscreen %d x %d\n", mode.w, mode.h);
|
||||
+ if (0 != SDL_SetWindowFullscreen(SDL.window, SDL_WINDOW_FULLSCREEN_DESKTOP)) {
|
||||
+ SDL_Log("Unable to enter fullscreen: %s\n", SDL_GetError());
|
||||
+ return;
|
||||
+ }
|
||||
+ SDL_SetWindowDisplayMode(SDL.window, &mode);
|
||||
+ setting_set_display(1, mode.w, mode.h);
|
||||
+}
|
||||
+
|
||||
+void platform_screen_set_windowed(void)
|
||||
+{
|
||||
+ int width, height;
|
||||
+ setting_window(&width, &height);
|
||||
+ SDL_Log("User to windowed %d x %d\n", width, height);
|
||||
+ SDL_SetWindowFullscreen(SDL.window, 0);
|
||||
+ SDL_SetWindowSize(SDL.window, width, height);
|
||||
+ SDL_SetWindowPosition(SDL.window, window_pos.x, window_pos.y);
|
||||
+ setting_set_display(0, width, height);
|
||||
+}
|
||||
+
|
||||
+void platform_screen_set_window_size(int width, int height)
|
||||
+{
|
||||
+ if (setting_fullscreen()) {
|
||||
+ SDL_SetWindowFullscreen(SDL.window, 0);
|
||||
+ }
|
||||
+ SDL_SetWindowSize(SDL.window, width, height);
|
||||
+ SDL_SetWindowPosition(SDL.window, window_pos.x, window_pos.y);
|
||||
+ SDL_Log("User resize to %d x %d\n", width, height);
|
||||
+ setting_set_display(0, width, height);
|
||||
+}
|
||||
+
|
||||
+void platform_screen_center_window(void)
|
||||
+{
|
||||
+ SDL_SetWindowPosition(SDL.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
+}
|
||||
+
|
||||
+void platform_screen_render(void)
|
||||
+{
|
||||
+ SDL_UpdateTexture(SDL.texture, NULL, graphics_canvas(), screen_width() * 4);
|
||||
+ SDL_RenderCopy(SDL.renderer, SDL.texture, NULL, NULL);
|
||||
+
|
||||
+ const mouse *mouse = mouse_get();
|
||||
+ SDL_Rect dst;
|
||||
+ dst.x = mouse->x;
|
||||
+ dst.y = mouse->y;
|
||||
+ dst.w = 32;
|
||||
+ dst.h = 32;
|
||||
+ SDL_RenderCopy(SDL.renderer, current_cursor, NULL, &dst);
|
||||
+
|
||||
+ SDL_RenderPresent(SDL.renderer);
|
||||
+}
|
||||
diff --git a/src/platform/julius.c b/src/platform/julius.c
|
||||
index 99d8a66..64ae8a0 100644
|
||||
--- a/src/platform/julius.c
|
||||
+++ b/src/platform/julius.c
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
-#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__vita__) && !defined(__SWITCH__)
|
||||
+#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__vita__) && !defined(__SWITCH__) && !defined(__HAIKU__)
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
diff --git a/test/sav/run.c b/test/sav/run.c
|
||||
index 1093269..84d7977 100644
|
||||
--- a/test/sav/run.c
|
||||
+++ b/test/sav/run.c
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "game/game.h"
|
||||
#include "game/settings.h"
|
||||
|
||||
-#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__)
|
||||
+#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__HAIKU__)
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
static void handler(int sig)
|
||||
{
|
||||
-#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__)
|
||||
+#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__HAIKU__)
|
||||
void *array[100];
|
||||
size_t size;
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
|
||||
From 57c9d2ff4da9463fb563b9b8cad101c66844a7c6 Mon Sep 17 00:00:00 2001
|
||||
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
Date: Sun, 27 Oct 2019 20:58:50 +1000
|
||||
Subject: Disable backtrace for Haiku
|
||||
|
||||
|
||||
diff --git a/src/platform/julius.c b/src/platform/julius.c
|
||||
index 64ae8a0..963b9a4 100644
|
||||
--- a/src/platform/julius.c
|
||||
+++ b/src/platform/julius.c
|
||||
@@ -69,7 +69,7 @@ enum {
|
||||
};
|
||||
|
||||
static void handler(int sig) {
|
||||
-#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__vita__) && !defined(__SWITCH__)
|
||||
+#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OpenBSD__) && !defined(__vita__) && !defined(__SWITCH__) && !defined(__HAIKU__)
|
||||
void *array[100];
|
||||
size_t size;
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
Reference in New Issue
Block a user