From bb9e9511381570bb1b9cb55efc63fcd9bf853a65 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 2 Nov 2024 12:58:52 +0100 Subject: [PATCH] some guards to make it compile on Android --- basegraph.cpp | 6 ++++++ config.cpp | 10 ++++++++++ graph.cpp | 2 ++ 3 files changed, 18 insertions(+) diff --git a/basegraph.cpp b/basegraph.cpp index 842d05cb..a5902965 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -475,7 +475,9 @@ EX fontdata* font_by_name(string fname) { fd.use_fontconfig = true; #endif for(int i=0; i<=max_glfont_size; i++) fd.glfont[i] = nullptr; + #if CAP_SDLTTF for(int i=0; i<=max_font_size; i++) fd.font[i] = nullptr; + #endif fd.finf = nullptr; } return &fd; @@ -1479,6 +1481,7 @@ EX int SDL_Init1(Uint32 flags) { } #endif +#if CAP_SDLTTF EX void set_cfont() { int f = font_id; int fch = f; @@ -1487,6 +1490,7 @@ EX void set_cfont() { cfont = font_by_name(font_filenames[last_font_id = f]); cfont_chinese = font_by_name(font_filenames[fch]); } +#endif EX void init_font() { #if CAP_SDLTTF @@ -1515,7 +1519,9 @@ fontdata::~fontdata() { EX void close_font() { fontdatas.clear(); +#if CAP_SDLTTF TTF_Quit(); +#endif } EX void init_graph() { diff --git a/config.cpp b/config.cpp index 39789751..593840a9 100644 --- a/config.cpp +++ b/config.cpp @@ -1053,6 +1053,7 @@ EX purehookset hooks_configfile; EX ld mapfontscale = 100; +#if CAP_SDLTTF EX void font_reaction() { if(among(font_id, 5, 6)) { int fid = font_id; @@ -1062,6 +1063,7 @@ EX void font_reaction() { }); } } +#endif EX void initConfig() { @@ -1153,11 +1155,13 @@ EX void initConfig() { initcs(vid.cs); paramset(vid.cs, "single"); param_b(vid.samegender, "princess choice", false); param_i(vid.language, "language", -1); + #if CAP_SDLTTF param_enum(font_id, "font_id", 0) ->editable(font_names, "select font", 'f') ->manual_reaction = font_reaction; param_str(font_filenames[5], "ttf_font"); param_str(font_filenames[6], "otf_font"); + #endif param_b(vid.drawmousecircle, "mouse circle", ISMOBILE || ISPANDORA); param_b(vid.revcontrol, "reverse control", false); #if CAP_AUDIO @@ -1405,6 +1409,7 @@ EX void initConfig() { -> help("Background particle effects, e.g., in the Blizzard."); // control + #if CAP_SDL param_enum(joy_init, "joyinit", jiFast) ->editable({{"off", "do not use joysticks"}, {"fast", "do not wait until the joysticks are initialized"}, {"wait", "wait until the joysticks are initialized"}}, "joystick initialization", 'j'); param_i(vid.joyvalue, "vid.joyvalue", 4800); @@ -1413,6 +1418,7 @@ EX void initConfig() { param_i(vid.joypanthreshold, "vid.joypanthreshold", 2500); param_f(vid.joypanspeed, "vid.joypanspeed", ISPANDORA ? 0.0001 : 0); param_b(autojoy, "autojoy"); + #endif vid.killreduction = 0; @@ -2493,7 +2499,9 @@ EX void configureInterface() { dialog::add_action_push(selectLanguageScreen); #endif + #if CAP_SDLTTF add_edit(font_id); + #endif dialog::addSelItem(XLAT("player character"), numplayers() > 1 ? "" : csname(vid.cs), 'g'); dialog::add_action_push(showCustomizeChar); @@ -4365,6 +4373,7 @@ EX int read_config_args() { else return 1; return 0; } +#endif EX void set_char_by_name(charstyle& cs, const string& s) { if(s == "dodek") { @@ -4418,6 +4427,7 @@ EX void set_char_by_name(charstyle& cs, const string& s) { } } +#if CAP_COMMANDLINE EX int read_param_args() { const string& s = arg::args(); auto pos = s.find("="); diff --git a/graph.cpp b/graph.cpp index 36fbf3d9..1c5d319a 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5655,7 +5655,9 @@ EX void calcparam() { ld fov = vid.fov * degree / 2; cd->tanfov = sin(fov) / (cos(fov) + get_stereo_param()); + #if CAP_SDLTTF set_cfont(); + #endif callhooks(hooks_calcparam); reset_projection(); }