summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFinn Rayment <finn@rayment.fr>2022-08-24 14:22:13 +1000
committerJames Le Cuirot <chewi@gentoo.org>2022-10-09 13:08:35 +0100
commit1f452038d6b0f5b676e3d933d40f2fd5a797c576 (patch)
tree3c77e596b710f5305e6ea52a8f89b7a547e6e6aa /games-roguelike
parentdev-python/cairocffi: Remove ~m68k per arch team request (diff)
downloadgentoo-1f452038d6b0f5b676e3d933d40f2fd5a797c576.tar.gz
gentoo-1f452038d6b0f5b676e3d933d40f2fd5a797c576.tar.bz2
gentoo-1f452038d6b0f5b676e3d933d40f2fd5a797c576.zip
games-roguelike/dwarf-fortress: Added gui? USE flag and removed hard dep.
GTK was required for runtime but was only used for a single fullscreen dialog prompt when the config [WINDOWED:PROMPT]. Now, if libgraphics is compiled without using GTK, the game will not ask at all if run from a window manager, but instead open in windowed mode. However, if the game is run from a terminal, a simple scanf procedure will ask the user for yes/no before deciding. Signed-off-by: Finn Rayment <finn@rayment.fr> Bug: https://bugs.gentoo.org/856685 Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'games-roguelike')
-rw-r--r--games-roguelike/dwarf-fortress/dwarf-fortress-0.47.05-r1.ebuild (renamed from games-roguelike/dwarf-fortress/dwarf-fortress-0.47.05.ebuild)7
-rw-r--r--games-roguelike/dwarf-fortress/files/Makefile.native9
-rw-r--r--games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-nogtk.patch119
-rw-r--r--games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-segfault-fixes.patch16
4 files changed, 143 insertions, 8 deletions
diff --git a/games-roguelike/dwarf-fortress/dwarf-fortress-0.47.05.ebuild b/games-roguelike/dwarf-fortress/dwarf-fortress-0.47.05-r1.ebuild
index dac5c1c75c94..09f1a0c25b24 100644
--- a/games-roguelike/dwarf-fortress/dwarf-fortress-0.47.05.ebuild
+++ b/games-roguelike/dwarf-fortress/dwarf-fortress-0.47.05-r1.ebuild
@@ -18,7 +18,7 @@ S="${WORKDIR}/df_linux"
LICENSE="free-noncomm BSD BitstreamVera"
SLOT="0"
KEYWORDS="-* ~amd64 ~x86"
-IUSE="debug"
+IUSE="debug gui"
RDEPEND="
dev-libs/glib:2
@@ -29,7 +29,7 @@ RDEPEND="
media-libs/sdl-ttf
sys-libs/zlib:=
virtual/glu
- x11-libs/gtk+:2"
+ gui? ( x11-libs/gtk+:2 )"
# libsndfile, openal and ncurses are only needed at compile-time,
# optfeature through dlopen() at runtime if requested
DEPEND="
@@ -44,6 +44,7 @@ QA_PREBUILT="opt/${PN}/libs/Dwarf_Fortress"
PATCHES=(
"${FILESDIR}"/${P}-missing-cmath.patch
"${FILESDIR}"/${P}-ncurses6.patch
+ "${FILESDIR}"/${P}-nogtk.patch
"${FILESDIR}"/${P}-segfault-fixes.patch
)
@@ -60,7 +61,7 @@ src_compile() {
# -DDEBUG is recognized to give additional debug output
append-cppflags -D$(usev !debug N)DEBUG
- emake -f "${FILESDIR}"/Makefile.native
+ emake -f "${FILESDIR}"/Makefile.native HAVE_GTK=$(usex gui 1 0)
}
src_install() {
diff --git a/games-roguelike/dwarf-fortress/files/Makefile.native b/games-roguelike/dwarf-fortress/files/Makefile.native
index 85383e5e2f1d..d22fb03f4694 100644
--- a/games-roguelike/dwarf-fortress/files/Makefile.native
+++ b/games-roguelike/dwarf-fortress/files/Makefile.native
@@ -1,6 +1,8 @@
# Copyright 2014-2016 Alex Xu (Hello71)
# Distributed under the terms of the GNU General Public License v2
+HAVE_GTK ?= 1
+
SRCS := g_src/basics.cpp g_src/command_line.cpp g_src/enabler.cpp \
g_src/files.cpp g_src/find_files_posix.cpp g_src/graphics.cpp \
g_src/init.cpp g_src/interface.cpp g_src/keybindings.cpp \
@@ -11,7 +13,12 @@ SRCS := g_src/basics.cpp g_src/command_line.cpp g_src/enabler.cpp \
OBJS := $(SRCS:.cpp=.o)
BLIBS := ncursesw openal sndfile
-LIBS := glew glu gtk+-2.0 sdl SDL_image SDL_ttf zlib
+
+LIBS := glew glu sdl SDL_image SDL_ttf zlib
+ifeq ($(HAVE_GTK),1)
+LIBS += gtk+-2.0
+endif
+
CXXFLAGS ?= -O2 -pipe -Wall -Wextra
CXXFLAGS += $(shell $(PKG_CONFIG) --cflags $(BLIBS) $(LIBS)) -Dunix -Dlinux -fPIC -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0
LDLIBS := $(shell $(PKG_CONFIG) --libs $(LIBS))
diff --git a/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-nogtk.patch b/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-nogtk.patch
new file mode 100644
index 000000000000..7702362b4a69
--- /dev/null
+++ b/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-nogtk.patch
@@ -0,0 +1,119 @@
+Removes hard dependency on GTK in favour of stdin calls.
+
+--- a/g_src/KeybindingScreen.cpp
++++ b/g_src/KeybindingScreen.cpp
+@@ -1,7 +1,9 @@
+ #ifdef __APPLE__
+ # include "osx_messagebox.h"
+ #elif defined(unix)
+-# include <gtk/gtk.h>
++# ifdef HAVE_GTK
++# include <gtk/gtk.h>
++# endif
+ #endif
+
+ #include "GL/glew.h"
+--- a/g_src/enabler.cpp
++++ b/g_src/enabler.cpp
+@@ -1,7 +1,9 @@
+ #ifdef __APPLE__
+ # include "osx_messagebox.h"
+ #elif defined(unix)
+-# include <gtk/gtk.h>
++# ifdef HAVE_GTK
++# include <gtk/gtk.h>
++# endif
+ #endif
+
+ #include <cassert>
+@@ -713,7 +715,7 @@ int main (int argc, char* argv[]) {
+ #ifdef unix
+ setlocale(LC_ALL, "");
+ #endif
+-#if !defined(__APPLE__) && defined(unix)
++#if !defined(__APPLE__) && defined(unix) && defined(HAVE_GTK)
+ bool gtk_ok = false;
+ if (getenv("DISPLAY"))
+ gtk_ok = gtk_init_check(&argc, &argv);
+@@ -734,6 +736,7 @@ int main (int argc, char* argv[]) {
+ init.begin(); // Load init.txt settings
+
+ #if !defined(__APPLE__) && defined(unix)
++ #if defined(HAVE_GTK)
+ if (!gtk_ok && !init.display.flag.has_flag(INIT_DISPLAY_FLAG_TEXT)) {
+ puts("Display not found and PRINT_MODE not set to TEXT, aborting.");
+ exit(EXIT_FAILURE);
+@@ -743,6 +746,7 @@ int main (int argc, char* argv[]) {
+ puts("Graphical tiles are not compatible with text output, sorry");
+ exit(EXIT_FAILURE);
+ }
++ #endif
+ #endif
+
+ // Initialize video, if we /use/ video
+--- a/g_src/renderer_curses.cpp
++++ b/g_src/renderer_curses.cpp
+@@ -1,3 +1,7 @@
++#if defined(__APPLE__) || defined(unix)
++# include <unistd.h>
++#endif
++
+ static bool curses_initialized = false;
+
+ static void endwin_void() {
+--- a/g_src/win32_compat.cpp
++++ b/g_src/win32_compat.cpp
+@@ -13,7 +13,11 @@
+ # ifdef __APPLE__
+ # include "osx_messagebox.h"
+ # elif defined(unix)
+-# include <gtk/gtk.h>
++# ifdef HAVE_GTK
++# include <gtk/gtk.h>
++# else
++# include <unistd.h>
++# endif
+ # endif
+ #endif
+
+@@ -112,6 +116,7 @@ int MessageBox(HWND *dummy, const char *text, const char *caption, UINT type)
+ }
+ # else // GTK code
+ if (getenv("DISPLAY")) {
++ #ifdef HAVE_GTK
+ // Have X, will dialog
+ GtkWidget *dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+@@ -141,6 +146,23 @@ int MessageBox(HWND *dummy, const char *text, const char *caption, UINT type)
+ break;
+ }
+ }
++ #else
++ if (isatty(fileno(stdin))) {
++ dprintf(2, "Alert %s:\n%s\n", caption ? caption : "", text ? text : "");
++ if (type & MB_YESNO) {
++ while(ret == IDOK) {
++ dprintf(2, "please answer with 'yes' or 'no'\n");
++ char buf[16];
++ fgets(buf, sizeof buf, stdin);
++ if(!strncmp(buf, "yes", 3)) ret = IDYES;
++ else if(!strncmp(buf, "no", 2)) ret = IDNO;
++ }
++ }
++ } else {
++ /* just assume windowed if no TTY is available to ask */
++ ret = IDNO;
++ }
++ #endif /* HAVE_GTK */
+ } else {
+ // Use curses
+ init_curses();
+@@ -173,7 +195,7 @@ int MessageBox(HWND *dummy, const char *text, const char *caption, UINT type)
+ }
+ nodelay(*stdscr_p, -1);
+ }
+-# endif
++ #endif
+
+ if (toggle_screen) {
+ enabler.toggle_fullscreen();
diff --git a/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-segfault-fixes.patch b/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-segfault-fixes.patch
index 24c43be41188..11a820ac97df 100644
--- a/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-segfault-fixes.patch
+++ b/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-segfault-fixes.patch
@@ -7,32 +7,40 @@ https://bugs.gentoo.org/729002
https://www.bay12games.com/dwarves/mantisbt/view.php?id=11564
--- a/g_src/enabler.cpp
+++ b/g_src/enabler.cpp
-@@ -591,4 +591,6 @@
+@@ -592,6 +592,8 @@ int enablerst::loop(string cmdline) {
+
// Clean up graphical resources
delete renderer;
+
+ return 0;
}
+ void enablerst::override_grid_size(int x, int y) {
--- a/g_src/music_and_sound_openal.cpp
+++ b/g_src/music_and_sound_openal.cpp
-@@ -251,5 +251,4 @@
+@@ -250,7 +250,6 @@ void musicsoundst::deinitsound() {
+ alDeleteBuffers(1, &buffer);
}
// Deinit OpenAL
- alcMakeContextCurrent(NULL);
alcDestroyContext(context);
alcCloseDevice(device);
-@@ -481,5 +480,5 @@
+
+@@ -480,7 +479,7 @@ static bool init_openal() {
+
void alEnable( ALenum capability ) { _alEnable(capability); }
void alDisable( ALenum capability ) { _alDisable(capability); }
-ALboolean alIsEnabled( ALenum capability ) { _alIsEnabled(capability); }
+ALboolean alIsEnabled( ALenum capability ) { return _alIsEnabled(capability); }
const ALchar* alGetString( ALenum param ) { return _alGetString(param); }
void alGetBooleanv( ALenum param, ALboolean* data ) { _alGetBooleanv(param, data); }
-@@ -491,5 +490,5 @@
+ void alGetIntegerv( ALenum param, ALint* data ) { _alGetIntegerv(param, data); }
+@@ -490,7 +489,7 @@ ALboolean alGetBoolean( ALenum param ) { return _alGetBoolean(param); }
+ ALint alGetInteger( ALenum param ) { return _alGetInteger(param); }
ALfloat alGetFloat( ALenum param ) { return _alGetFloat(param); }
ALdouble alGetDouble( ALenum param ) { return _alGetDouble(param); }
-ALenum alGetError( void ) { _alGetError(); }
+ALenum alGetError( void ) { return _alGetError(); }
ALboolean alIsExtensionPresent( const ALchar* extname ) { return _alIsExtensionPresent(extname); }
void* alGetProcAddress( const ALchar* fname ) { return _alGetProcAddress(fname); }
+ ALenum alGetEnumValue( const ALchar* ename ) { return _alGetEnumValue(ename); }