-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
gui_settings.cpp
1025 lines (939 loc) · 34.3 KB
/
gui_settings.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
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include "gui_settings.h"
inline static void header(const char *title)
{
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.f, 0.5f)); // Left
ImGui::ButtonEx(title, ImVec2(-1, 0), ImGuiButtonFlags_Disabled);
ImGui::PopStyleVar();
}
void GuiSettings::settings_body_general(ImVec2 normal_padding)
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding);
const char *languages[] = {"Japanese", "English", "German", "French", "Spanish", "Italian", "Default"};
OptionComboBox("Language", config::Language, languages, ARRAY_SIZE(languages),
"The language as configured in the Dreamcast BIOS");
const char *broadcast[] = {"NTSC", "PAL", "PAL/M", "PAL/N", "Default"};
OptionComboBox("Broadcast", config::Broadcast, broadcast, ARRAY_SIZE(broadcast),
"TV broadcasting standard for non-VGA modes");
const char *region[] = {"Japan", "USA", "Europe", "Default"};
OptionComboBox("Region", config::Region, region, ARRAY_SIZE(region),
"BIOS region");
const char *cable[] = {"VGA", "RGB Component", "TV Composite"};
{
DisabledScope scope(config::Cable.isReadOnly());
const char *value = config::Cable == 0 ? cable[0]
: config::Cable > 0 && config::Cable <= ARRAY_SIZE(cable) ? cable[config::Cable - 1]
: "?";
if (ImGui::BeginCombo("Cable", value, ImGuiComboFlags_None))
{
for (int i = 0; i < IM_ARRAYSIZE(cable); i++)
{
bool is_selected = i == 0 ? config::Cable <= 1 : config::Cable - 1 == i;
if (ImGui::Selectable(cable[i], &is_selected))
config::Cable = i == 0 ? 0 : i + 1;
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
}
ImGui::SameLine();
ShowHelpMarker("Video connection type");
#if !defined(TARGET_IPHONE)
ImVec2 size;
size.x = 0.0f;
size.y = (ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().FramePadding.y * 2.f) * (config::ContentPath.get().size() + 1); //+ ImGui::GetStyle().FramePadding.y * 2.f;
if (ImGui::ListBoxHeader("Content Location", size))
{
int to_delete = -1;
for (u32 i = 0; i < config::ContentPath.get().size(); i++)
{
ImGui::PushID(config::ContentPath.get()[i].c_str());
ImGui::AlignTextToFramePadding();
ImGui::Text("%s", config::ContentPath.get()[i].c_str());
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize("X").x - ImGui::GetStyle().FramePadding.x);
if (ImGui::Button("X"))
to_delete = i;
ImGui::PopID();
}
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ScaledVec2(24, 3));
if (ImGui::Button("Add"))
ImGui::OpenPopup("Select Directory");
select_file_popup("Select Directory", [](bool cancelled, std::string selection)
{
if (!cancelled)
{
scanner_stop();
config::ContentPath.get().push_back(selection);
scanner_refresh();
}
return true; });
ImGui::PopStyleVar();
scrollWhenDraggingOnVoid();
ImGui::ListBoxFooter();
if (to_delete >= 0)
{
scanner_stop();
config::ContentPath.get().erase(config::ContentPath.get().begin() + to_delete);
scanner_refresh();
}
}
ImGui::SameLine();
ShowHelpMarker("The directories where your games are stored");
#if defined(__linux__) && !defined(__ANDROID__)
if (ImGui::ListBoxHeader("Data Directory", 1))
{
ImGui::AlignTextToFramePadding();
ImGui::Text("%s", get_writable_data_path("").c_str());
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize("Open").x - ImGui::GetStyle().FramePadding.x);
if (ImGui::Button("Open"))
{
char temp[512];
sprintf(temp, "xdg-open \"%s\"", get_writable_data_path("").c_str());
system(temp);
}
ImGui::ListBoxFooter();
}
ImGui::SameLine();
ShowHelpMarker("The directory containing BIOS files, as well as saved VMUs and states");
if (ImGui::ListBoxHeader("Config Directory", 1))
{
ImGui::AlignTextToFramePadding();
ImGui::Text("%s", get_writable_config_path("").c_str());
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize("Open").x - ImGui::GetStyle().FramePadding.x);
if (ImGui::Button("Open"))
{
char temp[512];
sprintf(temp, "xdg-open \"%s\"", get_writable_config_path("").c_str());
system(temp);
}
ImGui::ListBoxFooter();
}
ImGui::SameLine();
ShowHelpMarker("The directory where Flycast saves configuration files and controller mappings");
#else
#ifdef __ANDROID__
if (ImGui::ListBoxHeader("Home Directory", 2))
#elif defined(__WIN32)
ImVec2 home_size;
home_size.x = 0.0f;
home_size.y = (ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().FramePadding.y * 2.f) * 2;
if (ImGui::ListBoxHeader("Home Directory", home_size))
#else
if (ImGui::ListBoxHeader("Home Directory", 1))
#endif
{
ImGui::AlignTextToFramePadding();
ImGui::Text("%s", get_writable_config_path("").c_str());
#ifdef __ANDROID__
//ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize("Change").x - ImGui::GetStyle().FramePadding.x);
if (ImGui::Button("Change"))
gui_state = GuiState::Onboarding;
#endif
#if defined(__APPLE__) && TARGET_OS_OSX
ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize("Reveal in Finder").x - ImGui::GetStyle().FramePadding.x);
if (ImGui::Button("Reveal in Finder"))
{
char temp[512];
sprintf(temp, "open \"%s\"", get_writable_config_path("").c_str());
system(temp);
}
#elif defined(__WIN32)
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ScaledVec2(24, 3));
if (ImGui::Button("Open"))
ShellExecute(0, "open", get_writable_config_path("").c_str(), 0, 0 , SW_SHOW );
ImGui::PopStyleVar();
#endif
ImGui::ListBoxFooter();
}
ImGui::SameLine();
ShowHelpMarker("The directory where Flycast saves configuration files and VMUs. BIOS files should be in a subfolder named \"data\"");
#endif // !linux
#endif // !TARGET_IPHONE
OptionCheckbox("Box Art Game List", config::BoxartDisplayMode,
"Display game covert art in the game list.");
OptionCheckbox("Fetch Box Art", config::FetchBoxart,
"Fetch cover images from TheGamesDB.net.");
if (OptionCheckbox("Hide Legacy Naomi Roms", config::HideLegacyNaomiRoms,
"Hide .bin, .dat and .lst files from the content browser"))
scanner_refresh();
ImGui::Text("Automatic State:");
OptionCheckbox("Load", config::AutoLoadState,
"Load the last saved state of the game when starting");
ImGui::SameLine();
OptionCheckbox("Save", config::AutoSaveState,
"Save the state of the game when stopping");
OptionCheckbox("Naomi Free Play", config::ForceFreePlay, "Configure Naomi games in Free Play mode.");
ImGui::PopStyleVar();
}
void GuiSettings::settings_body_audio(ImVec2 normal_padding)
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding);
OptionCheckbox("Audio Frame Sync", config::LimitFPS, "Sync frames with audio output");
OptionCheckbox("Enable DSP", config::DSPEnabled,
"Enable the Dreamcast Digital Sound Processor. Only recommended on fast platforms");
if (OptionSlider("Volume Level", config::AudioVolume, 0, 100, "Adjust the emulator's audio level"))
{
config::AudioVolume.calcDbPower();
};
#ifdef __ANDROID__
if (config::AudioBackend.get() == "auto" || config::AudioBackend.get() == "android")
OptionCheckbox("Automatic Latency", config::AutoLatency,
"Automatically set audio latency. Recommended");
#endif
if (!config::AutoLatency || (config::AudioBackend.get() != "auto" && config::AudioBackend.get() != "android"))
{
int latency = (int)roundf(config::AudioBufferSize * 1000.f / 44100.f);
ImGui::SliderInt("Latency", &latency, 12, 512, "%d ms");
config::AudioBufferSize = (int)roundf(latency * 44100.f / 1000.f);
ImGui::SameLine();
ShowHelpMarker("Sets the maximum audio latency. Not supported by all audio drivers.");
}
AudioBackend *backend = nullptr;
std::string backend_name = config::AudioBackend;
if (backend_name != "auto")
{
backend = AudioBackend::getBackend(config::AudioBackend);
if (backend != NULL)
backend_name = backend->slug;
}
AudioBackend *current_backend = backend;
if (ImGui::BeginCombo("Audio Driver", backend_name.c_str(), ImGuiComboFlags_None))
{
bool is_selected = (config::AudioBackend.get() == "auto");
if (ImGui::Selectable("auto - Automatic driver selection", &is_selected))
config::AudioBackend.set("auto");
for (u32 i = 0; i < AudioBackend::getCount(); i++)
{
backend = AudioBackend::getBackend(i);
is_selected = (config::AudioBackend.get() == backend->slug);
if (is_selected)
current_backend = backend;
if (ImGui::Selectable((backend->slug + " - " + backend->name).c_str(), &is_selected))
config::AudioBackend.set(backend->slug);
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::SameLine();
ShowHelpMarker("The audio driver to use");
if (current_backend != nullptr)
{
// get backend specific options
int option_count;
const AudioBackend::Option *options = current_backend->getOptions(&option_count);
for (int o = 0; o < option_count; o++)
{
std::string value = cfgLoadStr(current_backend->slug, options->name, "");
if (options->type == AudioBackend::Option::integer)
{
int val = stoi(value);
if (ImGui::SliderInt(options->caption.c_str(), &val, options->minValue, options->maxValue))
{
std::string s = std::to_string(val);
cfgSaveStr(current_backend->slug, options->name, s);
}
}
else if (options->type == AudioBackend::Option::checkbox)
{
bool check = value == "1";
if (ImGui::Checkbox(options->caption.c_str(), &check))
cfgSaveStr(current_backend->slug, options->name,
check ? "1" : "0");
}
else if (options->type == AudioBackend::Option::list)
{
if (ImGui::BeginCombo(options->caption.c_str(), value.c_str(), ImGuiComboFlags_None))
{
bool is_selected = false;
for (const auto &cur : options->values)
{
is_selected = value == cur;
if (ImGui::Selectable(cur.c_str(), &is_selected))
cfgSaveStr(current_backend->slug, options->name, cur);
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
}
else
{
WARN_LOG(RENDERER, "Unknown option");
}
options++;
}
}
ImGui::PopStyleVar();
}
void GuiSettings::settings_body_advanced(ImVec2 normal_padding)
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding);
header("CPU Mode");
{
ImGui::Columns(2, "cpu_modes", false);
OptionRadioButton("Dynarec", config::DynarecEnabled, true,
"Use the dynamic recompiler. Recommended in most cases");
ImGui::NextColumn();
OptionRadioButton("Interpreter", config::DynarecEnabled, false,
"Use the interpreter. Very slow but may help in case of a dynarec problem");
ImGui::Columns(1, NULL, false);
}
if (config::DynarecEnabled)
{
ImGui::Spacing();
header("Dynarec Options");
OptionCheckbox("Idle Skip", config::DynarecIdleSkip, "Skip wait loops. Recommended");
}
ImGui::Spacing();
header("Network");
{
{
DisabledScope scope(game_started);
OptionCheckbox("Broadband Adapter Emulation", config::EmulateBBA,
"Emulate the Ethernet Broadband Adapter (BBA) instead of the Modem");
}
OptionCheckbox("Enable Naomi Networking", config::NetworkEnable,
"Enable networking for supported Naomi games");
if (config::NetworkEnable)
{
OptionCheckbox("Act as Server", config::ActAsServer,
"Create a local server for Naomi network games");
if (!config::ActAsServer)
{
char server_name[256];
strcpy(server_name, config::NetworkServer.get().c_str());
ImGui::InputText("Server", server_name, sizeof(server_name), ImGuiInputTextFlags_CharsNoBlank, nullptr, nullptr);
ImGui::SameLine();
ShowHelpMarker("The server to connect to. Leave blank to find a server automatically on the default port");
config::NetworkServer.set(server_name);
}
char localPort[256];
sprintf(localPort, "%d", (int)config::LocalPort);
ImGui::InputText("Local Port", localPort, sizeof(localPort), ImGuiInputTextFlags_CharsDecimal, nullptr, nullptr);
ImGui::SameLine();
ShowHelpMarker("The local UDP port to use");
config::LocalPort.set(atoi(localPort));
}
OptionCheckbox("Enable UPnP", config::EnableUPnP);
ImGui::SameLine();
ShowHelpMarker("Automatically configure your network router for netplay");
OptionCheckbox("Broadcast Digital Outputs", config::NetworkOutput, "Broadcast digital outputs and force-feedback state on TCP port 8000. "
"Compatible with the \"-output network\" MAME option. Arcade games only.");
}
ImGui::Spacing();
header("Other");
{
OptionCheckbox("Output Session Details to Text Files", config::OutputStreamTxt, "Outputs in-game overlay details to external text files (in the 'out' folder). Useful for online streams.");
if (config::UseReios)
{
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
}
OptionCheckbox("Online & Replays: Force Real DC BIOS", config::ForceRealBios, "Forces real Dreamcast BIOS when made available. Disabled by default for online & games and replays.");
if (config::UseReios)
{
ImGui::PopItemFlag();
ImGui::PopStyleVar();
}
if (config::ForceRealBios)
{
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
}
OptionCheckbox("HLE BIOS", config::UseReios, "Force high-level BIOS emulation");
if (config::ForceRealBios)
{
ImGui::PopItemFlag();
ImGui::PopStyleVar();
}
OptionCheckbox("Force Windows CE", config::ForceWindowsCE,
"Enable full MMU emulation and other Windows CE settings. Do not enable unless necessary");
OptionCheckbox("Multi-threaded emulation", config::ThreadedRendering,
"Run the emulated CPU and GPU on different threads");
#ifndef __ANDROID
OptionCheckbox("Serial Console", config::SerialConsole,
"Dump the Dreamcast serial console to stdout");
#endif
OptionCheckbox("Dump Textures", config::DumpTextures,
"Dump all textures into data/texdump/<game id>");
OptionCheckbox("Show Eject Disk", config::ShowEjectDisk,
"Show Eject Disk button in Menu");
bool logToFile = cfgLoadBool("log", "LogToFile", false);
bool newLogToFile = logToFile;
ImGui::Checkbox("Log to File", &newLogToFile);
if (logToFile != newLogToFile)
{
cfgSaveBool("log", "LogToFile", newLogToFile);
LogManager::Shutdown();
LogManager::Init();
}
ImGui::SameLine();
ShowHelpMarker("Log debug information to flycast.log");
#ifdef SENTRY_UPLOAD
OptionCheckbox("Automatically Report Crashes", config::UploadCrashLogs,
"Automatically upload crash reports to sentry.io to help in troubleshooting. No personal information is included.");
#endif
}
ImGui::PopStyleVar();
#ifdef USE_LUA
header("Lua Scripting");
{
char LuaFileName[256];
strcpy(LuaFileName, config::LuaFileName.get().c_str());
ImGui::InputText("Lua Filename", LuaFileName, sizeof(LuaFileName), ImGuiInputTextFlags_CharsNoBlank, nullptr, nullptr);
ImGui::SameLine();
ShowHelpMarker("Specify lua filename to use. Should be located in Flycast config directory. Defaults to flycast.lua when empty.");
config::LuaFileName = LuaFileName;
}
#endif
}
void GuiSettings::settings_body_about(ImVec2 normal_padding)
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding);
header("Flycast Dojo");
{
ImGui::Text("Version: %s", GIT_VERSION);
#ifdef _WIN32
ImGui::SameLine();
if (ImGui::Button("Update"))
{
dojo_file.tag_download = dojo_file.GetLatestDownloadUrl();
ImGui::OpenPopup("Update?");
}
dojo_gui.update_action();
#endif
ImGui::Text("Git Hash: %s", GIT_HASH);
ImGui::Text("Build Date: %s", BUILD_DATE);
}
ImGui::Spacing();
header("Platform");
{
ImGui::Text("CPU: %s",
#if HOST_CPU == CPU_X86
"x86"
#elif HOST_CPU == CPU_ARM
"ARM"
#elif HOST_CPU == CPU_MIPS
"MIPS"
#elif HOST_CPU == CPU_X64
"x86/64"
#elif HOST_CPU == CPU_GENERIC
"Generic"
#elif HOST_CPU == CPU_ARM64
"ARM64"
#else
"Unknown"
#endif
);
ImGui::Text("Operating System: %s",
#ifdef __ANDROID__
"Android"
#elif defined(__unix__)
"Linux"
#elif defined(__APPLE__)
#ifdef TARGET_IPHONE
"iOS"
#else
"macOS"
#endif
#elif defined(TARGET_UWP)
"Windows Universal Platform"
#elif defined(_WIN32)
"Windows"
#elif defined(__SWITCH__)
"Switch"
#else
"Unknown"
#endif
);
#ifdef TARGET_IPHONE
extern std::string iosJitStatus;
ImGui::Text("JIT Status: %s", iosJitStatus.c_str());
#endif
}
ImGui::Spacing();
if (isOpenGL(config::RendererType))
header("OpenGL");
else if (isVulkan(config::RendererType))
header("Vulkan");
else if (isDirectX(config::RendererType))
header("DirectX");
ImGui::Text("Driver Name: %s", GraphicsContext::Instance()->getDriverName().c_str());
ImGui::Text("Version: %s", GraphicsContext::Instance()->getDriverVersion().c_str());
ImGui::PopStyleVar();
}
void GuiSettings::settings_body_credits(ImVec2 normal_padding)
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding);
{
ImGui::Text("Flycast Dojo is maintained by blueminder");
ImGui::Text("Based on the Flycast emulator maintained by flyinghead");
std::string contributors_url = "https://github.com/blueminder/flycast-dojo/graphs/contributors";
#if !defined(__ANDROID__)
if (ImGui::Button("GitHub Contributors"))
#ifdef _WIN32
ShellExecute(0, 0, contributors_url.c_str(), 0, 0 , SW_SHOW );
#elif defined(__APPLE__)
system(std::string("open " + contributors_url).c_str());
#elif defined(__linux__)
system(std::string("xdg-open " + contributors_url).c_str());
#endif
#endif
}
ImGui::Spacing();
header("Special Thanks");
{
ImGui::BulletText("flyinghead");
ImGui::SameLine();
ShowHelpMarker("For making Flycast possible. Thank you for your continued maintenance and guidance.");
ImGui::BulletText("vkedwardli");
ImGui::SameLine();
ShowHelpMarker("For regular feedback and Mac OS optimizations.");
ImGui::BulletText("pof & shine");
ImGui::SameLine();
ShowHelpMarker("For consistently giving good advice and integrating Flycast Dojo into Fightcade.");
}
ImGui::Spacing();
header("Champion Patrons");
{
ImGui::BulletText("styroteqe");
ImGui::BulletText("The Code Always Wins");
ImGui::BulletText("Jasen Parayno");
ImGui::BulletText("Carmine Macchia");
ImGui::Spacing();
std::string patreon_url = "https://www.patreon.com/projectdojo";
#if !defined(__ANDROID__)
if (ImGui::Button("Support on Patreon"))
#ifdef _WIN32
ShellExecute(0, 0, patreon_url.c_str(), 0, 0 , SW_SHOW );
#elif defined(__APPLE__)
system(std::string("open " + patreon_url).c_str());
#elif defined(__linux__)
system(std::string("xdg-open " + patreon_url).c_str());
#endif
#endif
}
ImGui::PopStyleVar();
}
void GuiSettings::settings_body_video(ImVec2 normal_padding)
{
int renderApi;
bool perPixel;
switch (config::RendererType)
{
default:
case RenderType::OpenGL:
renderApi = 0;
perPixel = false;
break;
case RenderType::OpenGL_OIT:
renderApi = 0;
perPixel = true;
break;
case RenderType::Vulkan:
renderApi = 1;
perPixel = false;
break;
case RenderType::Vulkan_OIT:
renderApi = 1;
perPixel = true;
break;
case RenderType::DirectX9:
renderApi = 2;
perPixel = false;
break;
case RenderType::DirectX11:
renderApi = 3;
perPixel = false;
break;
case RenderType::DirectX11_OIT:
renderApi = 3;
perPixel = true;
break;
}
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, normal_padding);
ImGuiStyle &style = ImGui::GetStyle();
float innerSpacing = style.ItemInnerSpacing.x;
const bool has_per_pixel = GraphicsContext::Instance()->hasPerPixel();
header("Basic Settings");
{
constexpr int apiCount = 0
#ifdef USE_VULKAN
+ 1
#endif
#ifdef USE_DX9
+ 1
#endif
#ifdef USE_OPENGL
+ 1
#endif
#ifdef USE_DX11
+ 1
#endif
;
std::vector<int> graphapi;
std::vector<std::string> graphapiText;
if (apiCount > 0)
{
#ifdef USE_OPENGL
graphapi.push_back(0);
graphapiText.push_back("OpenGL");
#endif
#ifdef USE_VULKAN
graphapi.push_back(1);
#ifdef __APPLE__
graphapiText.push_back("Vulkan (Metal)");
#else
graphapiText.push_back("Vulkan");
#endif
#endif
#ifdef USE_DX9
graphapi.push_back(2);
graphapiText.push_back("DirectX 9");
#endif
#ifdef USE_DX11
graphapi.push_back(3);
graphapiText.push_back("DirectX 11");
#endif
}
u32 gaSelected = 0;
for (u32 i = 0; i < graphapi.size(); i++)
{
if (graphapi[i] == renderApi)
gaSelected = i;
}
ImGui::PushItemWidth(ImGui::CalcItemWidth() - innerSpacing * 2.0f - ImGui::GetFrameHeight() * 2.0f);
if (ImGui::BeginCombo("##Graphics API", graphapiText[gaSelected].c_str(), ImGuiComboFlags_None))
{
for (u32 i = 0; i < graphapi.size(); i++)
{
bool is_selected = graphapi[i] == renderApi;
if (ImGui::Selectable(graphapiText[i].c_str(), is_selected))
renderApi = graphapi[i];
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::PopItemWidth();
ImGui::SameLine(0, innerSpacing);
ImGui::Text("Graphics API");
ImGui::SameLine();
ShowHelpMarker("Chooses the backend to use for rendering. DirectX 9 offers the best compatibility on Windows, while OpenGL does for other platforms.");
const std::array<float, 13> scalings{0.5f, 1.f, 1.5f, 2.f, 2.5f, 3.f, 4.f, 4.5f, 5.f, 6.f, 7.f, 8.f, 9.f};
const std::array<std::string, 13> scalingsText{"Half", "Native", "x1.5", "x2", "x2.5", "x3", "x4", "x4.5", "x5", "x6", "x7", "x8", "x9"};
std::array<int, scalings.size()> vres;
std::array<std::string, scalings.size()> resLabels;
u32 selected = 0;
for (u32 i = 0; i < scalings.size(); i++)
{
vres[i] = scalings[i] * 480;
if (vres[i] == config::RenderResolution)
selected = i;
if (!config::Widescreen)
resLabels[i] = std::to_string((int)(scalings[i] * 640)) + "x" + std::to_string((int)(scalings[i] * 480));
else
resLabels[i] = std::to_string((int)(scalings[i] * 480 * 16 / 9)) + "x" + std::to_string((int)(scalings[i] * 480));
resLabels[i] += " (" + scalingsText[i] + ")";
}
ImGui::PushItemWidth(ImGui::CalcItemWidth() - innerSpacing * 2.0f - ImGui::GetFrameHeight() * 2.0f);
if (ImGui::BeginCombo("##Resolution", resLabels[selected].c_str(), ImGuiComboFlags_None))
{
for (u32 i = 0; i < scalings.size(); i++)
{
bool is_selected = vres[i] == config::RenderResolution;
if (ImGui::Selectable(resLabels[i].c_str(), is_selected))
config::RenderResolution = vres[i];
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::PopItemWidth();
ImGui::SameLine(0, innerSpacing);
ImGui::Text("Internal Resolution");
ImGui::SameLine();
ShowHelpMarker("Internal render resolution. Higher is better, but more demanding on the GPU. Values higher than your display resolution (but no more than double your display resolution) can be used for supersampling, which provides high-quality antialiasing without reducing sharpness.");
int renderer = perPixel ? 2 : config::PerStripSorting ? 1
: 0;
std::vector<int> tsort{0, 1};
std::vector<std::string> tsortText{"Per Triangle", "Per Strip"};
if (has_per_pixel)
{
tsort.push_back(2);
tsortText.push_back("Per Pixel");
}
u32 tsSelected = 0;
for (u32 i = 0; i < tsort.size(); i++)
{
if (tsort[i] == renderer)
tsSelected = i;
}
ImGui::PushItemWidth(ImGui::CalcItemWidth() - innerSpacing * 2.0f - ImGui::GetFrameHeight() * 2.0f);
if (ImGui::BeginCombo("##Transparent Sorting", tsortText[tsSelected].c_str(), ImGuiComboFlags_None))
{
for (u32 i = 0; i < tsort.size(); i++)
{
bool is_selected = tsort[i] == renderer;
if (ImGui::Selectable(tsortText[i].c_str(), is_selected))
renderer = tsort[i];
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::PopItemWidth();
ImGui::SameLine(0, innerSpacing);
ImGui::Text("Transparent Sorting");
ImGui::SameLine();
std::string help_text;
switch (renderer)
{
case 0:
perPixel = false;
config::PerStripSorting.set(false);
help_text = "Per Triangle: Sort transparent polygons per triangle. Fast but may produce graphical glitches";
break;
case 1:
perPixel = false;
config::PerStripSorting.set(true);
help_text = "Per Strip: Sort transparent polygons per strip. Faster but may produce graphical glitches";
break;
case 2:
perPixel = true;
help_text = "Per Pixel: Sort transparent polygons per pixel. Slower but accurate";
break;
}
ShowHelpMarker(help_text.c_str());
}
if (perPixel)
{
ImGui::Spacing();
if (ImGui::CollapsingHeader("Per Pixel Settings", ImGuiTreeNodeFlags_None))
{
const std::array<int64_t, 4> bufSizes{(u64)512 * 1024 * 1024, (u64)1024 * 1024 * 1024, (u64)2 * 1024 * 1024 * 1024, (u64)4 * 1024 * 1024 * 1024};
const std::array<std::string, 4> bufSizesText{"512 MB", "1 GB", "2 GB", "4 GB"};
ImGui::PushItemWidth(ImGui::CalcItemWidth() - innerSpacing * 2.0f - ImGui::GetFrameHeight() * 2.0f);
u32 selected = 0;
for (; selected < bufSizes.size(); selected++)
if (bufSizes[selected] == config::PixelBufferSize)
break;
if (selected == bufSizes.size())
selected = 0;
if (ImGui::BeginCombo("##PixelBuffer", bufSizesText[selected].c_str(), ImGuiComboFlags_NoArrowButton))
{
for (u32 i = 0; i < bufSizes.size(); i++)
{
bool is_selected = i == selected;
if (ImGui::Selectable(bufSizesText[i].c_str(), is_selected))
config::PixelBufferSize = bufSizes[i];
if (is_selected)
{
ImGui::SetItemDefaultFocus();
selected = i;
}
}
ImGui::EndCombo();
}
ImGui::PopItemWidth();
ImGui::SameLine(0, innerSpacing);
if (ImGui::ArrowButton("##Decrease BufSize", ImGuiDir_Left))
{
if (selected > 0)
config::PixelBufferSize = bufSizes[selected - 1];
}
ImGui::SameLine(0, innerSpacing);
if (ImGui::ArrowButton("##Increase BufSize", ImGuiDir_Right))
{
if (selected < bufSizes.size() - 1)
config::PixelBufferSize = bufSizes[selected + 1];
}
ImGui::SameLine(0, style.ItemInnerSpacing.x);
ImGui::Text("Pixel Buffer Size");
ImGui::SameLine();
ShowHelpMarker("The size of the pixel buffer. May need to be increased when upscaling by a large factor.");
OptionSlider("Maximum Layers", config::PerPixelLayers, 8, 128,
"Maximum number of transparent layers. May need to be increased for some complex scenes. Decreasing it may improve performance.");
}
}
header("On-Screen Display");
{
OptionCheckbox("Show FPS Counter", config::ShowFPS, "Show on-screen frame/sec counter");
OptionCheckbox("Show VMU In-game", config::FloatVMUs, "Show the VMU LCD screens while in-game");
}
ImGui::Spacing();
if (ImGui::CollapsingHeader("Advanced", ImGuiTreeNodeFlags_None))
{
ImGui::Spacing();
if (ImGui::CollapsingHeader("Texture", ImGuiTreeNodeFlags_None))
{
ImGui::Text("Texture Filtering:");
ImGui::Columns(2, "textureFiltering", false);
OptionRadioButton("Default", config::TextureFiltering, 0, "Use the game's default texture filtering");
ImGui::NextColumn();
ImGui::NextColumn();
OptionRadioButton("Force Nearest-Neighbor", config::TextureFiltering, 1, "Force nearest-neighbor filtering for all textures. Crisper appearance, but may cause various rendering issues. This option usually does not affect performance.");
ImGui::NextColumn();
OptionRadioButton("Force Linear", config::TextureFiltering, 2, "Force linear filtering for all textures. Smoother appearance, but may cause various rendering issues. This option usually does not affect performance.");
ImGui::Columns(1, nullptr, false);
const std::array<int, 5> aniso{ 1, 2, 4, 8, 16 };
const std::array<std::string, 5> anisoText{ "Disabled", "2x", "4x", "8x", "16x" };
u32 afSelected = 0;
for (u32 i = 0; i < aniso.size(); i++)
{
if (aniso[i] == config::AnisotropicFiltering)
afSelected = i;
}
ImGui::PushItemWidth(ImGui::CalcItemWidth() - innerSpacing * 2.0f - ImGui::GetFrameHeight() * 2.0f);
if (ImGui::BeginCombo("##Anisotropic Filtering", anisoText[afSelected].c_str(), ImGuiComboFlags_NoArrowButton))
{
for (u32 i = 0; i < aniso.size(); i++)
{
bool is_selected = aniso[i] == config::AnisotropicFiltering;
if (ImGui::Selectable(anisoText[i].c_str(), is_selected))
config::AnisotropicFiltering = aniso[i];
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::PopItemWidth();
ImGui::SameLine(0, innerSpacing);
if (ImGui::ArrowButton("##Decrease Anisotropic Filtering", ImGuiDir_Left))
{
if (afSelected > 0)
config::AnisotropicFiltering = aniso[afSelected - 1];
}
ImGui::SameLine(0, innerSpacing);
if (ImGui::ArrowButton("##Increase Anisotropic Filtering", ImGuiDir_Right))
{
if (afSelected < aniso.size() - 1)
config::AnisotropicFiltering = aniso[afSelected + 1];
}
ImGui::SameLine(0, style.ItemInnerSpacing.x);
ImGui::Text("Anisotropic Filtering");
ImGui::SameLine();
ShowHelpMarker("Higher values make textures viewed at oblique angles look sharper, but are more demanding on the GPU. This option only has a visible impact on mipmapped textures.");
ImGui::Spacing();
header("Texture Upscaling");
{
#ifdef _OPENMP
OptionArrowButtons("Texture Upscaling", config::TextureUpscale, 1, 8,
"Upscale textures with the xBRZ algorithm. Only on fast platforms and for certain 2D games");
OptionSlider("Texture Max Size", config::MaxFilteredTextureSize, 8, 1024,
"Textures larger than this dimension squared will not be upscaled");
OptionArrowButtons("Max Threads", config::MaxThreads, 1, 8,
"Maximum number of threads to use for texture upscaling. Recommended: number of physical cores minus one");
#endif
OptionCheckbox("Load Custom Textures", config::CustomTextures,
"Load custom/high-res textures from data/textures/<game id>");
}
OptionCheckbox("Render to Texture Buffer", config::RenderToTextureBuffer,
"Copy rendered-to textures back to VRAM. Slower but accurate");
}
ImGui::Spacing();
if (ImGui::CollapsingHeader("Display", ImGuiTreeNodeFlags_None))
{
ImGui::Text("Fixed Frequency:");
ImGui::SameLine();
ShowHelpMarker("Set static frequency. Optimized for consistent input polling & frame rate. Recommended");
ImGui::Columns(3, "fixed_freq", false);
OptionRadioButton("Disabled##FF", config::FixedFrequency, 0, "Frame rate will be dependent on VSync or Audio Sync");
ImGui::NextColumn();
OptionRadioButton("Auto", config::FixedFrequency, 1, "Automatically sets frequency by Cable & Broadcast type");
ImGui::NextColumn();
OptionRadioButton("59.94 Hz", config::FixedFrequency, 2, "Native NTSC/VGA frequency");
ImGui::NextColumn();
OptionRadioButton("60 Hz", config::FixedFrequency, 3, "Approximate NTSC/VGA frequency");
ImGui::NextColumn();
OptionRadioButton("50 Hz", config::FixedFrequency, 4, "Native PAL frequency");
ImGui::NextColumn();
OptionRadioButton("30 Hz", config::FixedFrequency, 5, "Half NTSC/VGA frequency");
ImGui::Columns(1, nullptr, false);
if (config::FixedFrequency != 0)
{
OptionCheckbox("FF CPU Optimizations", config::FixedFrequencyThreadSleep, "Improves CPU Usage in exchange for less precise frame timing. Only enable on older PCs.");
}
#ifndef TARGET_IPHONE
OptionCheckbox("VSync", config::VSync, "Synchronizes the frame rate with the screen refresh rate.");
if (isVulkan(config::RendererType))
{
ImGui::Indent();
{
DisabledScope scope(!config::VSync);
OptionCheckbox("Duplicate frames", config::DupeFrames, "Duplicate frames on high refresh rate monitors (120 Hz and higher)");
}
ImGui::Unindent();
}
#endif
OptionCheckbox("Delay Frame Swapping", config::DelayFrameSwapping,
"Useful to avoid flashing screen or glitchy videos. Not recommended on slow platforms");
OptionCheckbox("Native Depth Interpolation", config::NativeDepthInterpolation,
"Helps with texture corruption and depth issues on AMD GPUs. Can also help Intel GPUs in some cases.");
}
ImGui::Spacing();
if (ImGui::CollapsingHeader("Effects", ImGuiTreeNodeFlags_None))
{
OptionCheckbox("Shadows", config::ModifierVolumes,
"Enable modifier volumes, usually used for shadows");
OptionCheckbox("Fog", config::Fog, "Enable fog effects");
}
ImGui::Spacing();
if (ImGui::CollapsingHeader("Widescreen##Section", ImGuiTreeNodeFlags_None))
{
OptionCheckbox("Widescreen", config::Widescreen,
"Draw geometry outside of the normal 4:3 aspect ratio. May produce graphical glitches in the revealed areas.\nAspect Fit and shows the full 16:9 content.");
{
DisabledScope scope(!config::Widescreen);
ImGui::Indent();
{
DisabledScope scope(!config::Widescreen);
OptionCheckbox("Super Widescreen", config::SuperWidescreen,
"Use the full width of the screen or window when its aspect ratio is greater than 16:9.\nAspect Fill and remove black bars.");
ImGui::Unindent();
}
}
OptionCheckbox("Widescreen Game Cheats", config::WidescreenGameHacks,
"Modify the game so that it displays in 16:9 anamorphic format and use horizontal screen stretching. Only some games are supported.");
}
ImGui::Spacing();
if (ImGui::CollapsingHeader("Geometry", ImGuiTreeNodeFlags_None))
{
OptionSlider("Horizontal Stretching", config::ScreenStretching, 100, 150,
"Stretch the screen horizontally");
OptionCheckbox("Rotate Screen 90°", config::Rotate90, "Rotate the screen 90° counterclockwise");
}
ImGui::Spacing();
if (ImGui::CollapsingHeader("Frame Skipping", ImGuiTreeNodeFlags_None))
{
OptionArrowButtons("Frame Skipping", config::SkipFrame, 0, 6,
"Number of frames to skip between two actually rendered frames");
ImGui::Text("Automatic Frame Skipping:");
ImGui::Columns(3, "autoskip", false);
OptionRadioButton("Disabled", config::AutoSkipFrame, 0, "No frame skipping");
ImGui::NextColumn();