From 3424fdf3d5da4a2c98548878d1be3ab679d30f13 Mon Sep 17 00:00:00 2001 From: dashodanger <> Date: Thu, 21 Nov 2024 21:49:35 -0700 Subject: [PATCH] Allow for FLTK < 1.4; do not build FLTK on nix platforms --- CMakeLists.txt | 3 +++ libraries/CMakeLists.txt | 2 +- source/lib_util.cc | 2 +- source/m_dialog.cc | 22 +++++++++++++++++++--- source/m_theme.cc | 22 ++++++++++++++++++++++ source/main.cc | 10 ++++++++++ source/sys_assert.cc | 2 ++ source/sys_debug.cc | 1 + 8 files changed, 59 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54e2697ce..3ffa73cd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,9 @@ if(UNIX) ) find_package(Fontconfig REQUIRED) endif() + if (NOT CONSOLE_ONLY) + find_package(FLTK REQUIRED) + endif() endif() add_subdirectory(libraries) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 7a64cfc57..6a4114f09 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(fastPRNG) -if(NOT CONSOLE_ONLY) +if(WIN32 AND NOT CONSOLE_ONLY) add_subdirectory(fltk) endif() add_subdirectory(minilua) diff --git a/source/lib_util.cc b/source/lib_util.cc index 7a7e40389..739d697fc 100644 --- a/source/lib_util.cc +++ b/source/lib_util.cc @@ -23,7 +23,6 @@ #ifndef _WIN32 #include -#include #include #include #include @@ -32,6 +31,7 @@ #include #endif +#include #include #include diff --git a/source/m_dialog.cc b/source/m_dialog.cc index a61a914da..b7a1b76a8 100644 --- a/source/m_dialog.cc +++ b/source/m_dialog.cc @@ -24,6 +24,8 @@ #include #include +#include + #include #include #include @@ -318,19 +320,33 @@ std::string DLG_OutputFilename(const char *ext, const char *preset) void DLG_EditSeed(void) { - ; + std::string user_buf; +#if FL_MINOR_VERSION > 3 int user_response; - std::string user_buf = + user_buf = fl_input_str(user_response, 0 /* limit */, "%s", string_seed.empty() ? std::to_string(next_rand_seed).c_str() : string_seed.c_str(), _("Enter New Seed Number or Phrase:")); - // cancelled? if (user_response < 0) { return; } +#else + const char *fl_buf = + fl_input(_("Enter New Seed Number or Phrase:"), + string_seed.empty() ? std::to_string(next_rand_seed).c_str() : string_seed.c_str()); + // cancelled? + if (!fl_buf) + { + return; + } + else + { + user_buf = fl_buf; + } +#endif std::string word = {user_buf.c_str(), static_cast(user_buf.size())}; try diff --git a/source/m_theme.cc b/source/m_theme.cc index 6d68ada18..173ebd4e1 100644 --- a/source/m_theme.cc +++ b/source/m_theme.cc @@ -744,9 +744,11 @@ class UI_ThemeWin : public Fl_Window case 3: Fl::scheme("plastic"); break; +#if FL_MINOR_VERSION > 3 case 4: Fl::scheme("oxy"); break; +#endif // Shouldn't be reached, but still default: Fl::scheme("gtk+"); @@ -793,9 +795,11 @@ class UI_ThemeWin : public Fl_Window case 3: box_style = FL_PLASTIC_DOWN_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: box_style = FL_OXY_DOWN_BOX; break; +#endif default: box_style = FL_GTK_DOWN_BOX; break; @@ -816,9 +820,11 @@ class UI_ThemeWin : public Fl_Window case 3: box_style = FL_PLASTIC_THIN_UP_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: box_style = FL_OXY_THIN_UP_BOX; break; +#endif default: box_style = FL_GTK_THIN_UP_BOX; break; @@ -846,9 +852,11 @@ class UI_ThemeWin : public Fl_Window case 3: button_style = FL_PLASTIC_DOWN_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: button_style = FL_OXY_DOWN_BOX; break; +#endif default: button_style = FL_GTK_DOWN_BOX; break; @@ -869,9 +877,11 @@ class UI_ThemeWin : public Fl_Window case 3: button_style = FL_PLASTIC_UP_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: button_style = FL_OXY_UP_BOX; break; +#endif default: button_style = FL_GTK_UP_BOX; break; @@ -990,9 +1000,11 @@ class UI_ThemeWin : public Fl_Window case 3: box_style = FL_PLASTIC_DOWN_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: box_style = FL_OXY_DOWN_BOX; break; +#endif default: box_style = FL_GTK_DOWN_BOX; break; @@ -1013,9 +1025,11 @@ class UI_ThemeWin : public Fl_Window case 3: box_style = FL_PLASTIC_THIN_UP_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: box_style = FL_OXY_THIN_UP_BOX; break; +#endif default: box_style = FL_GTK_THIN_UP_BOX; break; @@ -1070,9 +1084,11 @@ class UI_ThemeWin : public Fl_Window case 3: button_style = FL_PLASTIC_DOWN_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: button_style = FL_OXY_DOWN_BOX; break; +#endif default: button_style = FL_GTK_DOWN_BOX; break; @@ -1093,9 +1109,11 @@ class UI_ThemeWin : public Fl_Window case 3: button_style = FL_PLASTIC_UP_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: button_style = FL_OXY_UP_BOX; break; +#endif default: button_style = FL_GTK_UP_BOX; break; @@ -1756,7 +1774,11 @@ UI_ThemeWin::UI_ThemeWin(int W, int H, const char *label) : Fl_Window(W, H, labe opt_widget_theme = new UI_CustomMenu(cx + W * .38, cy, listwidth, KromulentHeight(24), ""); opt_widget_theme->copy_label(_("Widget Theme: ")); opt_widget_theme->align(FL_ALIGN_LEFT); +#if FL_MINOR_VERSION > 3 opt_widget_theme->add(_("Default|Gleam|Win95|Plastic|Oxy")); +#else + opt_widget_theme->add(_("Default|Gleam|Win95|Plastic")); +#endif opt_widget_theme->callback(callback_WidgetTheme, this); opt_widget_theme->value(widget_theme); opt_widget_theme->labelfont(font_style); diff --git a/source/main.cc b/source/main.cc index b0af99063..8803fe4ed 100644 --- a/source/main.cc +++ b/source/main.cc @@ -696,9 +696,11 @@ void Main::SetupFLTK() Fl::get_color(GRADIENT_COLOR, gradient_red, gradient_green, gradient_blue); Fl::get_color(BUTTON_COLOR, button_red, button_green, button_blue); } +#if FL_MINOR_VERSION > 3 Fl::set_boxtype(FL_OXY_UP_BOX, coxy_up_box, 2, 2, 4, 4); Fl::set_boxtype(FL_OXY_THIN_UP_BOX, coxy_up_box, 1, 1, 2, 2); Fl::set_boxtype(FL_OXY_DOWN_BOX, coxy_down_box, 2, 2, 4, 4); +#endif Fl::set_boxtype(FL_GLEAM_UP_BOX, cgleam_up_box, 2, 2, 4, 4); Fl::set_boxtype(FL_GLEAM_THIN_UP_BOX, cgleam_thin_up_box, 2, 2, 4, 4); Fl::set_boxtype(FL_GLEAM_DOWN_BOX, cgleam_down_box, 2, 2, 4, 4); @@ -768,9 +770,11 @@ void Main::SetupFLTK() case 3: box_style = FL_PLASTIC_DOWN_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: box_style = FL_OXY_DOWN_BOX; break; +#endif default: box_style = FL_GTK_DOWN_BOX; break; @@ -791,9 +795,11 @@ void Main::SetupFLTK() case 3: box_style = FL_PLASTIC_THIN_UP_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: box_style = FL_OXY_THIN_UP_BOX; break; +#endif default: box_style = FL_GTK_THIN_UP_BOX; break; @@ -821,9 +827,11 @@ void Main::SetupFLTK() case 3: button_style = FL_PLASTIC_DOWN_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: button_style = FL_OXY_DOWN_BOX; break; +#endif default: button_style = FL_GTK_DOWN_BOX; break; @@ -844,9 +852,11 @@ void Main::SetupFLTK() case 3: button_style = FL_PLASTIC_UP_BOX; break; +#if FL_MINOR_VERSION > 3 case 4: button_style = FL_OXY_UP_BOX; break; +#endif default: button_style = FL_GTK_UP_BOX; break; diff --git a/source/sys_assert.cc b/source/sys_assert.cc index 9ff20c658..e60ab1160 100644 --- a/source/sys_assert.cc +++ b/source/sys_assert.cc @@ -22,6 +22,8 @@ #include "main.h" #include "sys_macro.h" +#include + //---------------------------------------------------------------------------- void AssertFail(const char *msg, ...) diff --git a/source/sys_debug.cc b/source/sys_debug.cc index a858aec36..4aeaf1037 100644 --- a/source/sys_debug.cc +++ b/source/sys_debug.cc @@ -21,6 +21,7 @@ #include "sys_debug.h" +#include #include #include "lib_util.h"