Files
haikuports/games-action/extreme_tuxracer/patches/extreme_tuxracer-0.6.patchset
2020-05-31 18:18:44 +10:00

115 lines
3.4 KiB
Plaintext

From 0b0d7fc17b2e861aedcdb84cbddd73fd2e8ab68d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 31 May 2020 14:24:42 +1000
Subject: Fixes for Haiku
diff --git a/bh.h b/bh.h
index 4c366ac..498d3a8 100644
--- a/bh.h
+++ b/bh.h
@@ -33,7 +33,9 @@ GNU General Public License for more details.
#define HAVE_GL_GLX_H
//#define HAVE_GL_GLES1
#define HAVE_SYS_TIME_H
+#ifndef __HAIKU__
#define USE_STENCIL_BUFFER
+#endif
// --------------------------------------------------------------------
// includes
diff --git a/game_config.cpp b/game_config.cpp
index edad5ba..7696dc4 100644
--- a/game_config.cpp
+++ b/game_config.cpp
@@ -47,6 +47,12 @@ Then edit the below functions:
#include "course.h"
#include "game_ctrl.h"
+#ifdef __HAIKU__
+#include <libgen.h>
+#include <Path.h>
+#include <FindDirectory.h>
+#endif
+
TParam param;
@@ -92,8 +98,13 @@ void LoadConfigFile () {
}
void SetConfigDefaults () {
+#ifdef __HAIKU__
+ param.fullscreen = false;
+ param.res_type = 1;
+#else
param.fullscreen = true;
param.res_type = 0; // 0=auto / 1=800x600 / 2=1024x768 ...
+#endif
param.perf_level = 3; // detail level
param.language = 0;
param.sound_volume = 100;
@@ -293,6 +304,19 @@ void InitConfig (char *arg0) {
param.config_dir = "config";
param.data_dir = "data";
param.configfile = param.config_dir + SEP + "options.txt";
+#elif defined(__HAIKU__)
+ BPath settings_dir;
+ if (!find_directory(B_USER_SETTINGS_DIRECTORY, &settings_dir, true, NULL))
+ settings_dir.SetTo("/boot/home/config/settings/");
+ settings_dir.Append("ExtremeTuxRacer");
+ param.prog_dir = dirname(realpath(arg0, NULL));
+
+ param.config_dir = settings_dir.Path();
+ if (!DirExists (param.config_dir.c_str()))
+ mkdir (param.config_dir.c_str(), 0775);
+
+ param.data_dir = param.prog_dir + SEP + "data";
+ param.configfile = param.config_dir + SEP + "options";
#else
char buff[256];
if (strcmp (arg0, "./etr") == 0) { // start from work directory
diff --git a/winsys.cpp b/winsys.cpp
index ab60089..60d8696 100644
--- a/winsys.cpp
+++ b/winsys.cpp
@@ -135,22 +135,31 @@ void CWinsys::SetupVideoMode (TScreenRes resolution) {
#if !defined(HAVE_GL_GLES1)
window_flags |= SDL_WINDOW_OPENGL;
#endif
+#ifdef __HAIKU__
+ window_flags |= SDL_WINDOW_SHOWN;
+ if (window !=NULL) {
+ SaveConfigFile ();
+ string appname = param.prog_dir + SEP + "ExtremeTuxRacer &";
+ system(appname.c_str());
+ Quit();
+ }
+#endif
- window = SDL_CreateWindow(WINDOW_TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, resolution.width, resolution.height, window_flags);
+ window = SDL_CreateWindow(WINDOW_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, resolution.width, resolution.height, window_flags);
if (NULL == window) {
Message ("couldn't initialize video", SDL_GetError());
Message ("set to 800 x 600");
- window = SDL_CreateWindow (WINDOW_TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, window_flags);
+ window = SDL_CreateWindow (WINDOW_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, window_flags);
param.res_type = 1;
SaveConfigFile ();
}
-
+#ifndef __HAIKU__
renderer = SDL_CreateRenderer(window, -1, 0);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
-
+#endif
SDL_GetWindowSize(window, &param.x_resolution, &param.y_resolution);
if (resolution.width == 0 && resolution.height == 0) {
auto_x_resolution = param.x_resolution;
--
2.26.0