Skip to content

Commit

Permalink
Allow for FLTK < 1.4; do not build FLTK on nix platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Nov 22, 2024
1 parent 3eba035 commit 3424fdf
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ if(UNIX)
)
find_package(Fontconfig REQUIRED)
endif()
if (NOT CONSOLE_ONLY)
find_package(FLTK REQUIRED)
endif()
endif()

add_subdirectory(libraries)
Expand Down
2 changes: 1 addition & 1 deletion libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_subdirectory(fastPRNG)
if(NOT CONSOLE_ONLY)
if(WIN32 AND NOT CONSOLE_ONLY)
add_subdirectory(fltk)
endif()
add_subdirectory(minilua)
Expand Down
2 changes: 1 addition & 1 deletion source/lib_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#ifndef _WIN32
#include <dirent.h>
#include <ftw.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Expand All @@ -32,6 +31,7 @@
#include <sys/stat.h>
#endif

#include <stdarg.h>
#include <stdint.h>

#include <algorithm>
Expand Down
22 changes: 19 additions & 3 deletions source/m_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <FL/fl_ask.H>
#include <FL/fl_utf8.h>

#include <stdarg.h>

#include <limits>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -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<size_t>(user_buf.size())};
try
Expand Down
22 changes: 22 additions & 0 deletions source/m_theme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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+");
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions source/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions source/sys_assert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "main.h"
#include "sys_macro.h"

#include <stdarg.h>

//----------------------------------------------------------------------------

void AssertFail(const char *msg, ...)
Expand Down
1 change: 1 addition & 0 deletions source/sys_debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "sys_debug.h"

#include <stdarg.h>
#include <time.h>

#include "lib_util.h"
Expand Down

0 comments on commit 3424fdf

Please sign in to comment.