summaryrefslogtreecommitdiff
path: root/games-roguelike/dwarf-fortress/files/dwarf-fortress-0.47.05-nogtk.patch
blob: 7702362b4a69aa0b86d59411b9039ac77a991d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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();