-
Notifications
You must be signed in to change notification settings - Fork 6
/
launcher_dialog.cpp
909 lines (854 loc) · 33 KB
/
launcher_dialog.cpp
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
#include "allegro5/allegro_native_dialog.h"
#include "base/zc_alleg.h"
#include "launcher/launcher_dialog.h"
#include "base/zdefs.h"
#include "dialog/common.h"
#include "dialog/alert.h"
#include "dialog/alertfunc.h"
#include "dialog/info.h"
#include "gui/button.h"
#include "gui/tabpanel.h"
#include "launcher/theme_editor.h"
#include "launcher/launcher.h"
#include "base/process_management.h"
#include "launcher/launcher_dialog.h"
#include "gui/builder.h"
#include <cstring>
#include <fmt/format.h>
LauncherDialog::LauncherDialog(){}
#define LAUNCHER_EXIT_WARN false
static int32_t queue_revert = 0;
bool handle_close_btn_quit()
{
if(close_button_quit)
{
#if LAUNCHER_EXIT_WARN
bool r = false;
AlertDialog("Exit",
"Are you sure?",
[&](bool ret,bool)
{
r = ret;
}).show();
close_button_quit = false;
return (exiting_program = r);
#else
return (exiting_program = true);
#endif
}
return false;
}
int32_t LauncherDialog::launcher_on_tick()
{
if(handle_close_btn_quit())
return ONTICK_EXIT;
if(queue_revert > 0)
{
if(!--queue_revert)
{
AlertDialog("Theme Check",
"Would you like to revert?",
[&](bool ret,bool)
{
if(ret)
{
reset_theme();
}
else
{
set_theme(tmp_themefile);
}
}, "Revert", "Keep", 60*4, true).show();
pendDraw();
}
}
return ONTICK_CONTINUE;
}
extern char zthemepath[4096];
//{ Lists
namespace GUI::Lists
{
static const ListData snapshotFormatList
{
{ "BMP", 0 },
{ "GIF", 1 },
{ "JPEG", 2 },
{ "PNG", 3 },
{ "PCX", 4 },
{ "TGA", 5 }
};
static const ListData bottom8_list
{
{ "No Cover", 0 },
{ "Pixelated Cover", 1 },
{ "Normal Cover", 2 }
};
static const GUI::ListData invalidDataBGList
{
{ "X Out", 0 },
{ "Static" , 1 },
{ "Checkerboard", 2 }
};
static const ListData autoBackupCopiesList = ListData::numbers(false, 0, 11);
static const ListData autoSaveCopiesList = ListData::numbers(false, 1, 10);
static const ListData frameRestSuggestList = ListData::numbers(false, 0, 3);
static const ListData gfxDriverList
{
{ "Default", 0 },
{ "Direct3D", 1 },
{ "OpenGL", 2 }
};
static const ListData nameEntryList
{
{ "Keyboard", 0 },
{ "Letter Grid", 1 },
{ "Extended Letter Grid", 2 }
};
static const ListData resPresetList
{
{ "640x480", 2 },
{ "960x720", 3 },
{ "1280x960", 4 },
{ "1600x1200", 5 }
};
static const ListData quickSlotList
{
{ "Disabled", 0 },
{ "Slot 1", 1 },
{ "Slot 2", 2 },
{ "Slot 3", 3 },
{ "Slot 4", 4 },
{ "Slot 5", 5 },
{ "Slot 6", 6 },
{ "Slot 7", 7 },
{ "Slot 8", 8 },
{ "Slot 9", 9 },
{ "Slot 10", 10 },
{ "Slot 11", 11 },
{ "Slot 12", 12 },
{ "Slot 13", 13 },
{ "Slot 14", 14 },
{ "Slot 15", 15 }
};
static const ListData jitThreadsList
{
{ "All Available", -1 },
{ "1/2 Available", -2 },
{ "1/3 Available", -3 },
{ "1/4 Available", -4 },
{ "1", 1 },
{ "2", 2 },
{ "3", 3 },
{ "4", 4 },
{ "8", 8 },
{ "Disabled", 0 }
};
static const GUI::ListData snapshotScaleList
{
{ "1x", 1 },
{ "2x", 2 },
{ "3x", 3 },
{ "4x", 4 },
{ "5x", 5 }
};
}
//}
//{ Macros
//{ Checkbox
#define CONFIG_CHECKBOX(name, app, head, subhead, def) \
DummyWidget(), \
Checkbox( \
text = name, hAlign = 0.0, \
checked = zc_get_config(head,subhead,def,app)!=0, \
onToggleFunc = [&](bool state) \
{ \
zc_set_config(head,subhead,state?1:0,app); \
})
#define CONFIG_CHECKBOX_I(name, app, head, subhead, def, info) \
Button(forceFitH = true, text = "?", \
onPressFunc = [&]() \
{ \
InfoDialog("Info",info).show(); \
}), \
Checkbox( \
text = name, hAlign = 0.0, \
checked = zc_get_config(head,subhead,def,app)!=0, \
onToggleFunc = [&](bool state) \
{ \
zc_set_config(head,subhead,state?1:0,app); \
})
#define CONFIG_CHECKBOX_I_ZCL(name, head, subhead, def, info) \
Button(forceFitH = true, text = "?", \
onPressFunc = [&]() \
{ \
InfoDialog("Info",info).show(); \
}), \
Checkbox( \
text = name, hAlign = 0.0, \
checked = zc_get_config(head,subhead,def)!=0, \
onToggleFunc = [&](bool state) \
{ \
zc_set_config(head,subhead,state?1:0); \
})
//}
//{ Dropdown
//{ Standard
#define CONFIG_DROPDOWN_MINWIDTH 7_em
#define CONFIG_DROPDOWN(name, app, head, subhead, def, list) \
Label(text = name, hAlign = 1.0), \
DropDownList(data = list, \
fitParent = true, \
minwidth = CONFIG_DROPDOWN_MINWIDTH, \
selectedValue = zc_get_config(head,subhead,def,app), \
onSelectFunc = [&](int32_t val) \
{ \
zc_set_config(head,subhead,val,app); \
} \
), \
DummyWidget()
#define CONFIG_DROPDOWN_I(name, app, head, subhead, def, list, info) \
Label(text = name, hAlign = 1.0), \
DropDownList(data = list, \
fitParent = true, \
minwidth = CONFIG_DROPDOWN_MINWIDTH, \
selectedValue = zc_get_config(head,subhead,def,app), \
onSelectFunc = [&](int32_t val) \
{ \
zc_set_config(head,subhead,val,app); \
} \
), \
Button(forceFitH = true, text = "?", \
onPressFunc = [&]() \
{ \
InfoDialog("Info",info).show(); \
})
//}
//{ GFXDriver
#define GFXCARD_DROPDOWN_MINWIDTH 7_em
#define GFXCARD_DROPDOWN(name, app, head, subhead, def, list) \
Label(text = name, hAlign = 1.0), \
DropDownList(data = list, \
fitParent = true, \
minwidth = GFXCARD_DROPDOWN_MINWIDTH, \
selectedValue = getGFXDriverID(zc_get_config(head,subhead,getGFXDriverStr(def),app)), \
onSelectFunc = [&](int32_t val) \
{ \
if(val > -1) \
zc_set_config(head,subhead,getGFXDriverStr(val),app); \
} \
), \
DummyWidget()
#define GFXCARD_DROPDOWN_I(name, app, head, subhead, def, list, info) \
Label(text = name, hAlign = 1.0), \
DropDownList(data = list, \
fitParent = true, \
minwidth = GFXCARD_DROPDOWN_MINWIDTH, \
selectedValue = getGFXDriverID(zc_get_config(head,subhead,getGFXDriverStr(def),app)), \
onSelectFunc = [&](int32_t val) \
{ \
if(val > -1) \
zc_set_config(head,subhead,getGFXDriverStr(val),app); \
} \
), \
Button(forceFitH = true, text = "?", \
onPressFunc = [&]() \
{ \
InfoDialog("Info",info).show(); \
})
//}
//}
//{ TextField
#define CONFIG_TEXTFIELD_MINWIDTH 7_em
#define CONFIG_TEXTFIELD_FL(name, app, head, subhead, def, _min, _max, _places) \
Label(text = name, hAlign = 1.0), \
TextField(fitParent = true, \
minwidth = CONFIG_TEXTFIELD_MINWIDTH, \
type = GUI::TextField::type::FIXED_DECIMAL, fitParent = true, \
low = _min*int32_t(pow(10, _places)), high = _max*int32_t(pow(10, _places)), \
val = zc_get_config(head, subhead, def, app)*int32_t(pow(10, _places)), \
places = _places, \
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val) \
{ \
zc_set_config(head, subhead, val/double(pow(10, _places)), app); \
}), \
DummyWidget()
#define CONFIG_TEXTFIELD(name, app, head, subhead, def, _min, _max) \
Label(text = name, hAlign = 1.0), \
TextField(fitParent = true, \
minwidth = CONFIG_TEXTFIELD_MINWIDTH, \
type = GUI::TextField::type::INT_DECIMAL, fitParent = true, \
low = _min, high = _max, val = zc_get_config(head, subhead, def, app), \
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val) \
{ \
zc_set_config(head, subhead, val, app); \
}), \
DummyWidget()
#define L_CONFIG_TEXTFIELD(var, name, app, head, subhead, def, _min, _max) \
Label(text = name, hAlign = 1.0), \
var = TextField(fitParent = true, \
minwidth = CONFIG_TEXTFIELD_MINWIDTH, \
type = GUI::TextField::type::INT_DECIMAL, fitParent = true, \
low = _min, high = _max, val = zc_get_config(head, subhead, def, app), \
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val) \
{ \
zc_set_config(head, subhead, val, app); \
}), \
DummyWidget()
#define CONFIG_TEXTFIELD_I(name, app, head, subhead, def, _min, _max, info) \
Label(text = name, hAlign = 1.0), \
TextField(fitParent = true, \
minwidth = CONFIG_TEXTFIELD_MINWIDTH, \
type = GUI::TextField::type::INT_DECIMAL, fitParent = true, \
low = _min, high = _max, val = zc_get_config(head, subhead, def, app), \
onValChangedFunc = [&](GUI::TextField::type,std::string_view,int32_t val) \
{ \
zc_set_config(head, subhead, val, app); \
}), \
Button(forceFitH = true, text = "?", \
onPressFunc = [&]() \
{ \
InfoDialog("Info",info).show(); \
})
//{ Helpers
/* _al_stricmp:
* Case-insensitive comparison of 7-bit ASCII strings.
*/
int _al_stricmp(const char *s1, const char *s2)
{
int c1, c2;
ASSERT(s1);
ASSERT(s2);
do {
c1 = tolower(*(s1++));
c2 = tolower(*(s2++));
} while ((c1) && (c1 == c2));
return c1 - c2;
}
//{ Graphics Card
#define CMP_GFX(str, val) \
if(!_al_stricmp(str,configstr)) \
return val
#define STR_GFX(str, val) \
case val: \
strcpy(gfx_card_buf, str); \
break
int32_t getGFXDriverID(char const* configstr)
{
CMP_GFX("Default", 0);
CMP_GFX("Direct3D", 1);
CMP_GFX("OpenGL", 2);
return 0;
}
static char gfx_card_buf[10] = {0};
char const* getGFXDriverStr(int32_t id)
{
switch(id)
{
STR_GFX("Default", 0);
STR_GFX("Direct3D", 1);
STR_GFX("OpenGL", 2);
default: gfx_card_buf[0]=0; break;
}
return gfx_card_buf;
}
//}
//}
char theme_saved_filepath[4096] = {0};
static bool set_zq_theme()
{
zc_set_config("Theme","theme_filename",theme_saved_filepath, App::zquest);
return false;
}
static bool set_zc_theme()
{
zc_set_config("Theme","theme_filename",theme_saved_filepath, App::zelda);
return false;
}
static bool set_zcl_theme()
{
zc_set_config("Theme","theme_filename",theme_saved_filepath);
return false;
}
bool LauncherDialog::load_theme(char const* themefile)
{
if(themefile && fileexists(themefile))
{
load_themefile(themefile);
pendDraw();
return true;
}
return false;
}
static bool has_checked_for_updates = false;
static bool found_new_update = false;
static std::string next_version;
static std::string next_asset_url;
static bool check_for_updates()
{
if (has_checked_for_updates)
return found_new_update;
has_checked_for_updates = true;
std::string output;
bool success = run_and_get_output(ZUPDATER_FILE, {
"-headless",
"-print-next-release",
}, output);
if (!success)
return found_new_update = false;
auto output_map = parse_output_map(output);
if (!output_map.contains("tag_name"))
return found_new_update = false;
if (!output_map.contains("asset_url"))
return found_new_update = false;
next_version = output_map["tag_name"];
next_asset_url = output_map["asset_url"];
return found_new_update = next_version != getReleaseTag();
}
std::shared_ptr<GUI::Widget> LauncherDialog::view()
{
using namespace GUI::Builder;
using namespace GUI::Key;
using namespace GUI::Props;
using namespace GUI::Lists;
if (zc_get_config("ZLAUNCH", "check_for_updates", false, App::launcher))
check_for_updates();
queue_revert = 0;
int rightmost;
int bottommost;
ALLEGRO_MONITOR_INFO info;
std::shared_ptr<GUI::TabPanel> tabPanel;
al_get_monitor_info(0, &info);
rightmost = info.x2 - info.x1;
bottommost = info.y2 - info.y1;
rightmost=rightmost - 48;
bottommost=bottommost - 48;
window = Window(
title = "",
width = 0_px + zq_screen_w,
height = 0_px + zq_screen_h,
onClose = message::EXIT,
use_vsync = true,
onTick = [&](){return launcher_on_tick();},
Column(
tabPanel = TabPanel(
focused = true,
minwidth = zq_screen_w - 60_px,
minheight = zq_screen_h - 100_px,
onSwitch = [&](size_t oldind, size_t newind)
{
if (newind == 5)
{
check_for_updates();
btn_download_update->setText(found_new_update ? "Update to " + next_version : "No update found");
btn_download_update->setDisabled(!found_new_update);
btn_release_notes->setDisabled(!found_new_update);
}
if(newind < 2 || newind >= 5) //not a theme tab
{
if(oldind < 2) return; //Already not a theme tab
//Load the ZCL theme
char const* themepath = zc_get_config("Theme","theme_filename","themes/mooshmood.ztheme");
load_theme(themepath);
}
else
{
App a = App::launcher;
if(newind == 3) a = App::zquest;
else if(newind == 2) a = App::zelda;
char const* themepath = zc_get_config("Theme","theme_filename","themes/mooshmood.ztheme", a);
load_theme(themepath);
strcpy(zthemepath, themepath);
char path[4096] = {0};
relativize_path(path, zthemepath);
tf_theme[newind-2]->setText(path);
btn_save[newind-2]->setDisabled(false);
for(int q = strlen(zthemepath)-1; q > 0 && !(zthemepath[q] == '/' || zthemepath[q] == '\\'); --q)
{
zthemepath[q] = 0;
}
}
},
TabRef(name = "ZC Player", Row(framed = true,
Rows<2>(fitParent = true,
CONFIG_CHECKBOX("Fullscreen", App::zelda,"zeldadx","fullscreen",0),
CONFIG_CHECKBOX("Disable Resizing", App::zelda,"gui","disable_window_resizing",0),
CONFIG_CHECKBOX("Cap FPS", App::zelda,"zeldadx","throttlefps",1),
CONFIG_CHECKBOX("Show FPS", App::zelda,"zeldadx","showfps",0),
CONFIG_CHECKBOX("Show Game Time", App::zelda,"zeldadx","showtime",0),
CONFIG_CHECKBOX("Cont. Heart Beep", App::zelda,"zeldadx","heart_beep",0),
CONFIG_CHECKBOX("Disable Sound", App::zelda,"zeldadx","nosound",0),
CONFIG_CHECKBOX_I("Replay New Saves", App::zelda,"zeldadx","replay_new_saves",0,"Starting a new game will prompt recording to a .zplay file"),
CONFIG_CHECKBOX_I("Replay Debug", App::zelda,"zeldadx","replay_debug",1,"Record debug information when making a .zplay file")
),
Rows<2>(fitParent = true,
CONFIG_CHECKBOX("Force-reload Quest Icons", App::zelda,"zeldadx","reload_game_icons",0),
CONFIG_CHECKBOX_I("Allow Multiple Instances", App::zelda,"zeldadx","multiple_instances",0,"This can cause issues including but not limited to save file deletion."),
CONFIG_CHECKBOX("Click to Freeze", App::zelda,"zeldadx","clicktofreeze",1),
CONFIG_CHECKBOX_I("Quickload Last Quest", App::zelda,"zeldadx","quickload_last",0,"Unless 'Quickload Slot' is set, this will load the last quest played immediately upon launching."),
CONFIG_CHECKBOX_I("Autosave Window Size Changes", App::zelda,"zeldadx","save_drag_resize",0,"Makes any changes to the window size by dragging get saved for whenever you open the program next."),
CONFIG_CHECKBOX_I("Lock Aspect Ratio On Resize", App::zelda,"zeldadx","drag_aspect",1,"Makes any changes to the window size by dragging get snapped to ZC's default (4:3) aspect ratio."),
CONFIG_CHECKBOX_I("Save Window Position", App::zelda,"zeldadx","save_window_position",0,"Remembers the last position of the ZC Window."),
CONFIG_CHECKBOX_I("Force Integer Values for Scale", App::zelda,"zeldadx","scaling_force_integer",1,"Locks the screen to only scale by an integer value. Results in perfect pixel art scaling, at the expense of not using the entire availabe window space."),
CONFIG_CHECKBOX_I("Linear Scaling", App::zelda,"zeldadx","scaling_mode",0,"Use linear scaling when upscaling the window. If off, the default is nearest-neighbor scaling. If on, things will look a little blurry at most resolutions"),
CONFIG_CHECKBOX_I("Monochrome Debuggers", App::zelda,"CONSOLE","monochrome_debuggers",0,"Use non-colored debugger text."),
CONFIG_CHECKBOX_I("(EXPERIMENTAL) JIT script compilation", App::zelda,"ZSCRIPT","jit",0,"Compile scripts to machine code. Depending on the script, can be up to 10x faster. 64-bit only"),
CONFIG_CHECKBOX_I("(EXPERIMENTAL) JIT precompile", App::zelda,"ZSCRIPT","jit_precompile",0,"Do all JIT compilation upfront on quest load. Can take a couple minutes, but will avoid random pauses during play."),
CONFIG_CHECKBOX_I("Auto restart in Test Mode", App::zelda,"zeldadx","test_mode_auto_restart",0,"When a quest file is saved while in test mode, auto restarts zplayer.")
),
Rows<3>(fitParent = true,
CONFIG_TEXTFIELD_FL("Cursor Scale:", App::zelda,"zeldadx","cursor_scale_large",1.5,1.0,5.0, 4),
CONFIG_DROPDOWN_I("Snapshot Format:", App::zelda,"zeldadx","snapshot_format",3,snapshotFormatList,"The format of snapshots"),
CONFIG_DROPDOWN_I("Snapshot Scale:", App::zelda,"zeldadx","snapshot_scale",2,snapshotScaleList,"The scale of snapshots"),
CONFIG_DROPDOWN_I("Name Entry Mode:", App::zelda,"zeldadx","name_entry_mode",0,nameEntryList,"The entry method of save file names."),
CONFIG_TEXTFIELD_I("Window Width:", App::zelda,"zeldadx","window_width", -1, -1, 3000, "The width of the ZC window, for windowed mode. If -1 the largest possible window will be made without distorting the pixel content."),
CONFIG_TEXTFIELD_I("Window Height:", App::zelda,"zeldadx","window_height", -1, -1, 2250, "The height of the ZC window, for windowed mode. If -1 the largest possible window will be made without distorting the pixel content."),
CONFIG_TEXTFIELD_I("Saved Window X:", App::zelda,"zeldadx","window_x", 0, 0, rightmost, "The top-left corner of the ZQuest Window, for manual positioning and also used by 'Save Window Position'. If 0, uses the default position."),
CONFIG_TEXTFIELD_I("Saved Window Y:", App::zelda,"zeldadx","window_y", 0, 0, bottommost, "The top-left corner of the ZQuest Window, for manual positioning and also used by 'Save Window Position'. If 0, uses the default position."),
GFXCARD_DROPDOWN("Graphics Driver:", App::zelda, "graphics", "driver", 0, gfxDriverList),
CONFIG_DROPDOWN_I("(EXPERIMENTAL) JIT threads:",App::zelda,"ZSCRIPT","jit_threads",-2,jitThreadsList,"Use background threads to speed up JIT compilation"),
//
Button(hAlign = 1.0, forceFitH = true,
text = "Select Save Folder", onPressFunc = [&]()
{
char save_folder[4096] = {0};
strncpy(save_folder, zc_get_config("zeldadx", "save_folder", "saves", App::zelda), 4096);
if(jwin_dfile_select_ex("Save Folder", save_folder, "", 2048, -1, -1, get_zc_font(font_lfont)))
{
const char* ext = get_extension(save_folder);
if (strlen(ext))
return;
char path[4096] = {0};
relativize_path(path, save_folder);
tf_savefile->setText(path);
zc_set_config("zeldadx", "save_folder", path, App::zelda);
}
}),
tf_savefile = TextField(
read_only = true, fitParent = true,
forceFitW = true,
text = zc_get_config("zeldadx", "save_folder", "saves", App::zelda)
),
DummyWidget(),
//
CONFIG_DROPDOWN_I("Quickload Slot:", App::zelda,"zeldadx","quickload_slot",0,quickSlotList,"Unless 'disabled', this save slot will be immediately loaded upon launching."),
CONFIG_TEXTFIELD_I("Fastforward FPS Cap:", App::zelda, "zeldadx", "maxfps", 0, 0, 6000, "If >0 and 'Cap FPS' is off, FPS will not go above this value. This allows fast forwarding while still keeping a consistent and playable speed. Does not work for values < 60.")
)
)),
TabRef(name = "ZC Editor", Row(framed = true,
Rows<2>(fitParent = true,
CONFIG_CHECKBOX_I("Fullscreen", App::zquest,"zquest","fullscreen",0,"Exactly stable."),
CONFIG_CHECKBOX("Disable Resizing", App::zquest,"gui","disable_window_resizing",0),
CONFIG_CHECKBOX("Show FPS", App::zquest,"zquest","showfps",0),
CONFIG_CHECKBOX("Disable Sound", App::zquest,"zquest","nosound",0),
CONFIG_CHECKBOX("Animate Combos", App::zquest,"zquest","animation_on",1),
CONFIG_CHECKBOX("Combo Brush", App::zquest,"zquest","combo_brush",0),
CONFIG_CHECKBOX("Enable Tooltips", App::zquest,"zquest","enable_tooltips",1),
CONFIG_CHECKBOX("Tooltips Highlight Target", App::zquest,"zquest","ttip_highlight",1),
CONFIG_CHECKBOX("Floating Brush", App::zquest,"zquest","float_brush",0),
CONFIG_CHECKBOX("Mouse Scroll", App::zquest,"zquest","mouse_scroll",0),
CONFIG_CHECKBOX("Overwrite Protection", App::zquest,"zquest","overwrite_prevention",0),
CONFIG_CHECKBOX("Palette Cycle", App::zquest,"zquest","cycle_on",1),
CONFIG_CHECKBOX_I("Reload Last Quest", App::zquest,"zquest","open_last_quest",1,"On launching, immediately attempt to open the last file edited."),
CONFIG_CHECKBOX("Save Paths", App::zquest,"zquest","save_paths",1),
CONFIG_CHECKBOX_I("Show Misalignments", App::zquest,"zquest","show_misalignments",0,"Shows blinking arrows on the sides of the screen where the solidity does not match across the screen border."),
CONFIG_CHECKBOX("Tile Protection", App::zquest,"zquest","tile_protection",1)
),
Rows<2>(fitParent = true,
CONFIG_CHECKBOX("Uncompressed Autosaves", App::zquest,"zquest","uncompressed_auto_saves",1),
CONFIG_CHECKBOX_I("Warn on Init Script Change", App::zquest,"zquest","warn_initscript_changes",1,"When compiling ZScript, receive a warning when the global init script changes (which may break existing save files for the quest)"),
CONFIG_CHECKBOX_I("Show Ruleset Dialog on New Quest", App::zquest,"zquest","rulesetdialog",0,"On creating a 'New' quest, automatically pop up the 'Pick Ruleset' menu. (This can be found any time at 'Quest->Options->Pick Ruleset')"),
CONFIG_CHECKBOX_I("Monochrome Debuggers", App::zquest,"CONSOLE","monochrome_debuggers",0,"Use non-colored debugger text."),
CONFIG_CHECKBOX_I("Disable Level Palette Shortcuts", App::zquest,"zquest","dis_lpal_shortcut",1,"If enabled, keyboard shortcuts that change the screen's palette are disabled."),
CONFIG_CHECKBOX_I("Autosave Window Size Changes", App::zquest,"zquest","save_drag_resize",0,"Makes any changes to the window size by dragging get saved for whenever you open the program next."),
CONFIG_CHECKBOX_I("Lock Aspect Ratio On Resize", App::zquest,"zquest","drag_aspect",1,"Makes any changes to the window size by dragging get snapped to ZQuest's default (4:3) aspect ratio."),
CONFIG_CHECKBOX_I("Save Window Position", App::zquest,"zquest","save_window_position",0,"Remembers the last position of the ZQuest Window."),
CONFIG_CHECKBOX_I("Force Integer Values for Scale", App::zquest,"zquest","scaling_force_integer",0,"Locks the screen to only scale by an integer value. Results in perfect pixel art scaling, at the expense of not using the entire availabe window space."),
CONFIG_CHECKBOX_I("Linear Scaling", App::zquest,"zquest","scaling_mode",0,"Use linear scaling when upscaling the window. If off, the default is nearest-neighbor scaling. If on, things will look a little blurry at most resolutions"),
CONFIG_CHECKBOX_I("Custom Fonts", App::zquest,"ZQ_GUI","custom_fonts",1,"Use custom fonts from the 'customfonts' folder for UI elements.")
),
Rows<3>(fitParent = true,
CONFIG_TEXTFIELD_FL("Cursor Scale:", App::zquest,"zquest","cursor_scale_large",1.5,1.0,5.0, 4),
CONFIG_DROPDOWN_I("Invalid Data BG:", App::zquest,"zquest","invalid_bg",0,invalidDataBGList,"What effect to use for 'invalid' things (filtered out combos, nonexistant screens on the minimap, etc)"),
CONFIG_DROPDOWN_I("Bottom 8 pixels:", App::zquest,"ZQ_GUI","bottom_8_pixels",0,bottom8_list,"How to hide the bottom 8 screen pixels"),
CONFIG_DROPDOWN_I("Snapshot Output:", App::zquest,"zquest","snapshot_format",3,snapshotFormatList,"The format of map screen snapshots / window screenshots"),
CONFIG_DROPDOWN_I("Snapshot Scale:", App::zquest,"zquest","snapshot_scale",2,snapshotScaleList,"The scale of snapshots"),
CONFIG_DROPDOWN_I("Auto-Backup Retention:", App::zquest,"zquest","auto_backup_retention",0,autoBackupCopiesList,"The number of auto-backups to keep"),
CONFIG_DROPDOWN_I("Auto-Save Retention:", App::zquest,"zquest","auto_save_retention",9,autoSaveCopiesList,"The number of auto-saves to keep"),
CONFIG_TEXTFIELD_I("Auto-Save Interval:", App::zquest, "zquest", "auto_save_interval", 5, 0, 300, "Frequency of auto saves, in minutes. Valid range is 0-300, where '0' disables autosaves alltogether."),
CONFIG_TEXTFIELD_I("Window Width:", App::zquest,"zquest","window_width", -1, -1, 3000, "The width of the ZQuest window. If -1 the largest possible window will be made without distorting the pixel content."),
CONFIG_TEXTFIELD_I("Window Height:", App::zquest,"zquest","window_height", -1, -1, 2250, "The height of the ZQuest window. If -1 the largest possible window will be made without distorting the pixel content."),
CONFIG_TEXTFIELD_I("Saved Window X:", App::zquest,"zquest","window_x", 0, 0, rightmost, "The top-left corner of the ZQuest Window, for manual positioning and also used by 'Save Window Position'. If 0, uses the default position."),
CONFIG_TEXTFIELD_I("Saved Window Y:", App::zquest,"zquest","window_y", 0, 0, bottommost, "The top-left corner of the ZQuest Window, for manual positioning and also used by 'Save Window Position'. If 0, uses the default position."),
GFXCARD_DROPDOWN("Graphics Driver:", App::zquest, "graphics", "driver", 0, gfxDriverList)
))
),
// WARNING!
// If you ever uncomment this you gotta fix the silly hardcoded indices. Search "newind".
// TabRef(name = "ZC Launcher", Column(padding = 0_px,
// Label(text = "ZCL options may require relaunching ZCL to take effect!"),
// Row(framed = true,
// )
// )),
TabRef(name = "Player Theme", Rows<2>(
tf_theme[0] = TextField(read_only = true, maxLength = 255),
Button(text = "Browse", fitParent = true, onPressFunc = [&]()
{
if(getname("Load Theme", "ztheme", NULL, zthemepath, false))
{
char path[4096] = {0};
relativize_path(path, temppath);
tf_theme[0]->setText(path);
for(int q = strlen(temppath)-1; q > 0 && !(temppath[q] == '/' || temppath[q] == '\\'); --q)
{
temppath[q] = 0;
}
strcpy(zthemepath, temppath);
bool loaded = load_theme(path);
btn_save[0]->setDisabled(!loaded);
if(loaded)
{
pendDraw();
//!TODO connor: add A5 text enter/esc to accept/revert
strcpy(tmp_themefile, path);
queue_revert = 2;
}
}
}),
btn_save[0] = Button(text = "Save", hAlign = 1.0, onPressFunc = [&]()
{
zc_set_config("Theme","theme_filename",tmp_themefile,App::zelda);
}),
Button(text = "Edit", fitParent = true, onPressFunc = [&]()
{
ThemeEditor(theme_saved_filepath).show();
queue_revert = 0;
if(theme_saved_filepath[0])
{
tf_theme[0]->setText(theme_saved_filepath);
strcpy(tmp_themefile, theme_saved_filepath);
}
})
)),
TabRef(name = "Editor Theme", Rows<2>(
tf_theme[1] = TextField(read_only = true, maxLength = 255),
Button(text = "Browse", fitParent = true, onPressFunc = [&]()
{
if(getname("Load Theme", "ztheme", NULL, zthemepath, false))
{
char path[4096] = {0};
relativize_path(path, temppath);
tf_theme[1]->setText(path);
for(int q = strlen(temppath)-1; q > 0 && !(temppath[q] == '/' || temppath[q] == '\\'); --q)
{
temppath[q] = 0;
}
strcpy(zthemepath, temppath);
bool loaded = load_theme(path);
btn_save[1]->setDisabled(!loaded);
if(loaded)
{
pendDraw();
//!TODO connor: add A5 text enter/esc to accept/revert
strcpy(tmp_themefile, path);
queue_revert = 2;
}
//else handle failure?
}
}),
btn_save[1] = Button(text = "Save", hAlign = 1.0, onPressFunc = [&]()
{
zc_set_config("Theme","theme_filename",tmp_themefile,App::zquest);
}),
Button(text = "Edit", fitParent = true, onPressFunc = [&]()
{
ThemeEditor(theme_saved_filepath).show();
queue_revert = 0;
if(theme_saved_filepath[0])
{
tf_theme[1]->setText(theme_saved_filepath);
strcpy(tmp_themefile, theme_saved_filepath);
}
})
)),
TabRef(name = "ZCL Theme", Rows<2>(
tf_theme[2] = TextField(read_only = true, maxLength = 255),
Button(text = "Browse", fitParent = true, onPressFunc = [&]()
{
if(getname("Load Theme", "ztheme", NULL, zthemepath, false))
{
char path[4096] = {0};
relativize_path(path, temppath);
tf_theme[2]->setText(path);
for(int q = strlen(temppath)-1; q > 0 && !(temppath[q] == '/' || temppath[q] == '\\'); --q)
{
temppath[q] = 0;
}
strcpy(zthemepath, temppath);
bool loaded = load_theme(path);
btn_save[2]->setDisabled(!loaded);
if(loaded)
{
pendDraw();
//!TODO connor: add A5 text enter/esc to accept/revert
strcpy(tmp_themefile, path);
queue_revert = 2;
}
}
}),
btn_save[2] = Button(text = "Save", hAlign = 1.0, onPressFunc = [&]()
{
zc_set_config("Theme","theme_filename",tmp_themefile,App::launcher);
}),
Button(text = "Edit", fitParent = true, onPressFunc = [&]()
{
ThemeEditor(theme_saved_filepath).show();
queue_revert = 0;
if(theme_saved_filepath[0])
{
tf_theme[2]->setText(theme_saved_filepath);
strcpy(tmp_themefile, theme_saved_filepath);
}
})
)),
TabRef(name = "Update", Column(padding = 0_px,
Row(framed = true,
Rows<2>(fitParent = true,
CONFIG_CHECKBOX_I("Check for updates on startup",App::launcher,"ZLAUNCH","check_for_updates",0,"Check for updates when starting ZLauncher. When a new version is available, ZLauncher will focus the Update tab on startup.")
)
),
Row(
Rows<2>(fitParent = true,
btn_download_update = Button(
// TODO: Will change button text dynamically, but that breaks an assumption in Button::realize
// re: usage of its `text.data()`. So let's reserve a large enough string to workaround that.
text = std::string(200, ' '),
maxwidth = 250_px,
onClick = message::ZU
),
btn_release_notes = Button(
text = "View Latest Release Notes",
onClick = message::ZU_RELEASE_NOTES_NEXT
)
)
),
#ifdef UPDATER_USES_PYTHON
Label(text = "Note: the updater requires Python 3 to be installed and configured in PATH"),
#endif
Row(framed = true, padding = 10_px, topMargin = 40_px,
Rows<1>(fitParent = true,
Label(text = fmt::format("Current version: {}", getReleaseTag())),
Label(text = fmt::format("Channel: {}", getReleaseChannel())),
Label(text = fmt::format("Platform: {}", getReleasePlatform())),
Button(
text = "View Release Notes",
onClick = message::ZU_RELEASE_NOTES
)
)
)
))
),
Row(
vAlign = 1.0,
spacing = 2_em,
Button(
text = "ZC Player",
minwidth = 90_px,
onClick = message::ZC),
Button(
text = "ZC Editor",
minwidth = 90_px,
onClick = message::ZQ),
Button(
text = "Support ZC <3",
minwidth = 90_px,
onClick = message::SUPPORT)
)
)
);
if (found_new_update)
{
// Note: the onSwitch callback above does not run when calling `switchTo` below because the dialog has not been realized yet.
btn_download_update->setText("Update to " + next_version);
btn_download_update->setDisabled(false);
btn_release_notes->setDisabled(false);
tabPanel->switchTo(6);
}
return window;
}
bool LauncherDialog::handleMessage(const GUI::DialogMessage<message>& msg)
{
switch(msg.message)
{
case message::ZC:
launch_process(ZPLAYER_FILE);
break;
case message::ZQ:
launch_process(ZEDITOR_FILE);
break;
case message::SUPPORT:
{
std::string url = "https://zeldaclassic.com";
#ifdef _WIN32
std::string cmd = "start " + url;
system(cmd.c_str());
#elif defined(__APPLE__)
launch_process("open", {url});
#else
launch_process("xdg-open", {url});
#endif
break;
}
case message::ZU:
{
std::string output;
bool success = run_and_get_output(ZUPDATER_FILE, {
"-headless",
"-install",
"-asset-url", next_asset_url,
}, output);
success &= output.find("Success!") != std::string::npos;
al_trace("%s\n", output.c_str());
if (success)
{
InfoDialog("Updated!", fmt::format("Updated to {}! Restarting ZLauncher...", next_version)).show();
close_button_quit = true;
launch_process(ZLAUNCHER_FILE);
}
else
{
InfoDialog("Updater Error", output).show();
}
}
break;
case message::ZU_RELEASE_NOTES:
{
std::string url = fmt::format("https://zeldaclassic.com/releases/{}/", getReleaseTag());
#ifdef _WIN32
std::string cmd = "start " + url;
system(cmd.c_str());
#elif defined(__APPLE__)
launch_process("open", {url});
#else
launch_process("xdg-open", {url});
#endif
}
break;
case message::ZU_RELEASE_NOTES_NEXT:
{
std::string url = fmt::format("https://zeldaclassic.com/releases/{}/", next_version);
#ifdef _WIN32
std::string cmd = "start " + url;
system(cmd.c_str());
#elif defined(__APPLE__)
launch_process("open", {url});
#else
launch_process("xdg-open", {url});
#endif
}
break;
case message::EXIT:
close_button_quit = true;
return false;
}
return false;
}