forked from crosire/reshade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime_gui.cpp
2826 lines (2377 loc) · 118 KB
/
runtime_gui.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
/*
* Copyright (C) 2014 Patrick Mours. All rights reserved.
* License: https://github.com/crosire/reshade#license
*/
#if RESHADE_GUI
#include "dll_log.hpp"
#include "version.h"
#include "runtime.hpp"
#include "runtime_config.hpp"
#include "runtime_objects.hpp"
#include "input.hpp"
#include "imgui_widgets.hpp"
#include <cassert>
#include <fstream>
#include <algorithm>
extern volatile long g_network_traffic;
extern std::filesystem::path g_reshade_dll_path;
extern std::filesystem::path g_target_executable_path;
const ImVec4 COLOR_RED = ImColor(240, 100, 100);
const ImVec4 COLOR_YELLOW = ImColor(204, 204, 0);
void reshade::runtime::init_ui()
{
std::filesystem::path reshadegui_ini_path = _configuration_path;
reshadegui_ini_path.replace_filename("ReShadeGUI.ini");
_window_state_path = reshadegui_ini_path.u8string();
// Default shortcut: Home
_menu_key_data[0] = 0x24;
_menu_key_data[1] = false;
_menu_key_data[2] = false;
_menu_key_data[3] = false;
_variable_editor_height = 300;
_imgui_context = ImGui::CreateContext();
auto &imgui_io = _imgui_context->IO;
auto &imgui_style = _imgui_context->Style;
imgui_io.IniFilename = nullptr;
imgui_io.KeyMap[ImGuiKey_Tab] = 0x09; // VK_TAB
imgui_io.KeyMap[ImGuiKey_LeftArrow] = 0x25; // VK_LEFT
imgui_io.KeyMap[ImGuiKey_RightArrow] = 0x27; // VK_RIGHT
imgui_io.KeyMap[ImGuiKey_UpArrow] = 0x26; // VK_UP
imgui_io.KeyMap[ImGuiKey_DownArrow] = 0x28; // VK_DOWN
imgui_io.KeyMap[ImGuiKey_PageUp] = 0x21; // VK_PRIOR
imgui_io.KeyMap[ImGuiKey_PageDown] = 0x22; // VK_NEXT
imgui_io.KeyMap[ImGuiKey_Home] = 0x24; // VK_HOME
imgui_io.KeyMap[ImGuiKey_End] = 0x23; // VK_END
imgui_io.KeyMap[ImGuiKey_Insert] = 0x2D; // VK_INSERT
imgui_io.KeyMap[ImGuiKey_Delete] = 0x2E; // VK_DELETE
imgui_io.KeyMap[ImGuiKey_Backspace] = 0x08; // VK_BACK
imgui_io.KeyMap[ImGuiKey_Space] = 0x20; // VK_SPACE
imgui_io.KeyMap[ImGuiKey_Enter] = 0x0D; // VK_RETURN
imgui_io.KeyMap[ImGuiKey_Escape] = 0x1B; // VK_ESCAPE
imgui_io.KeyMap[ImGuiKey_A] = 'A';
imgui_io.KeyMap[ImGuiKey_C] = 'C';
imgui_io.KeyMap[ImGuiKey_V] = 'V';
imgui_io.KeyMap[ImGuiKey_X] = 'X';
imgui_io.KeyMap[ImGuiKey_Y] = 'Y';
imgui_io.KeyMap[ImGuiKey_Z] = 'Z';
imgui_io.ConfigFlags = ImGuiConfigFlags_DockingEnable | ImGuiConfigFlags_NavEnableKeyboard;
imgui_io.BackendFlags = ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_RendererHasVtxOffset;
// Disable rounding by default
imgui_style.GrabRounding = 0.0f;
imgui_style.FrameRounding = 0.0f;
imgui_style.ChildRounding = 0.0f;
imgui_style.ScrollbarRounding = 0.0f;
imgui_style.WindowRounding = 0.0f;
imgui_style.WindowBorderSize = 0.0f;
ImGui::SetCurrentContext(nullptr);
subscribe_to_ui("Home", [this]() { draw_ui_home(); });
subscribe_to_ui("Settings", [this]() { draw_ui_settings(); });
subscribe_to_ui("Statistics", [this]() { draw_ui_statistics(); });
subscribe_to_ui("Log", [this]() { draw_ui_log(); });
subscribe_to_ui("About", [this]() { draw_ui_about(); });
_load_config_callables.push_back([this](const ini_file &config) {
bool save_imgui_window_state = false;
config.get("INPUT", "KeyMenu", _menu_key_data);
config.get("INPUT", "InputProcessing", _input_processing_mode);
config.get("GENERAL", "ShowClock", _show_clock);
config.get("GENERAL", "ShowFPS", _show_fps);
config.get("GENERAL", "ShowFrameTime", _show_frametime);
config.get("GENERAL", "ShowScreenshotMessage", _show_screenshot_message);
config.get("GENERAL", "FPSPosition", _fps_pos);
config.get("GENERAL", "ClockFormat", _clock_format);
config.get("GENERAL", "NoFontScaling", _no_font_scaling);
config.get("GENERAL", "SaveWindowState", save_imgui_window_state);
config.get("GENERAL", "TutorialProgress", _tutorial_index);
config.get("GENERAL", "NewVariableUI", _variable_editor_tabs);
config.get("STYLE", "Alpha", _imgui_context->Style.Alpha);
config.get("STYLE", "GrabRounding", _imgui_context->Style.GrabRounding);
config.get("STYLE", "FrameRounding", _imgui_context->Style.FrameRounding);
config.get("STYLE", "ChildRounding", _imgui_context->Style.ChildRounding);
config.get("STYLE", "PopupRounding", _imgui_context->Style.PopupRounding);
config.get("STYLE", "WindowRounding", _imgui_context->Style.WindowRounding);
config.get("STYLE", "ScrollbarRounding", _imgui_context->Style.ScrollbarRounding);
config.get("STYLE", "TabRounding", _imgui_context->Style.TabRounding);
config.get("STYLE", "FPSScale", _fps_scale);
config.get("STYLE", "ColFPSText", _fps_col);
config.get("STYLE", "Font", _font);
config.get("STYLE", "FontSize", _font_size);
config.get("STYLE", "EditorFont", _editor_font);
config.get("STYLE", "EditorFontSize", _editor_font_size);
config.get("STYLE", "StyleIndex", _style_index);
config.get("STYLE", "EditorStyleIndex", _editor_style_index);
_imgui_context->IO.IniFilename = save_imgui_window_state ? _window_state_path.c_str() : nullptr;
// For compatibility with older versions, set the alpha value if it is missing
if (_fps_col[3] == 0.0f) _fps_col[3] = 1.0f;
ImVec4 *const colors = _imgui_context->Style.Colors;
switch (_style_index)
{
case 0:
ImGui::StyleColorsDark(&_imgui_context->Style);
break;
case 1:
ImGui::StyleColorsLight(&_imgui_context->Style);
break;
case 2:
colors[ImGuiCol_Text] = ImVec4(0.862745f, 0.862745f, 0.862745f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.862745f, 0.862745f, 0.862745f, 0.58f);
colors[ImGuiCol_WindowBg] = ImVec4(0.117647f, 0.117647f, 0.117647f, 1.00f);
colors[ImGuiCol_ChildBg] = ImVec4(0.156863f, 0.156863f, 0.156863f, 0.00f);
colors[ImGuiCol_Border] = ImVec4(0.862745f, 0.862745f, 0.862745f, 0.30f);
colors[ImGuiCol_FrameBg] = ImVec4(0.156863f, 0.156863f, 0.156863f, 1.00f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.470588f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.588235f);
colors[ImGuiCol_TitleBg] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.45f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.35f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.58f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.156863f, 0.156863f, 0.156863f, 0.57f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.156863f, 0.156863f, 0.156863f, 1.00f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.31f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.78f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.392157f, 0.588235f, 0.941176f, 1.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.117647f, 0.117647f, 0.117647f, 0.92f);
colors[ImGuiCol_CheckMark] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.80f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.784314f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.392157f, 0.588235f, 0.941176f, 1.00f);
colors[ImGuiCol_Button] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.44f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.86f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.392157f, 0.588235f, 0.941176f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.76f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.86f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.392157f, 0.588235f, 0.941176f, 1.00f);
colors[ImGuiCol_Separator] = ImVec4(0.862745f, 0.862745f, 0.862745f, 0.32f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.862745f, 0.862745f, 0.862745f, 0.78f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.862745f, 0.862745f, 0.862745f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.20f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.78f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.392157f, 0.588235f, 0.941176f, 1.00f);
colors[ImGuiCol_Tab] = colors[ImGuiCol_Button];
colors[ImGuiCol_TabActive] = colors[ImGuiCol_ButtonActive];
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_ButtonHovered];
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.862745f, 0.862745f, 0.862745f, 0.63f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.392157f, 0.588235f, 0.941176f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.862745f, 0.862745f, 0.862745f, 0.63f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.392157f, 0.588235f, 0.941176f, 1.00f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.392157f, 0.588235f, 0.941176f, 0.43f);
break;
case 5:
colors[ImGuiCol_Text] = ImColor(0xff969483);
colors[ImGuiCol_TextDisabled] = ImColor(0xff756e58);
colors[ImGuiCol_WindowBg] = ImColor(0xff362b00);
colors[ImGuiCol_ChildBg] = ImColor();
colors[ImGuiCol_PopupBg] = ImColor(0xfc362b00); // Customized
colors[ImGuiCol_Border] = ImColor(0xff423607);
colors[ImGuiCol_BorderShadow] = ImColor();
colors[ImGuiCol_FrameBg] = ImColor(0xfc423607); // Customized
colors[ImGuiCol_FrameBgHovered] = ImColor(0xff423607);
colors[ImGuiCol_FrameBgActive] = ImColor(0xff423607);
colors[ImGuiCol_TitleBg] = ImColor(0xff362b00);
colors[ImGuiCol_TitleBgActive] = ImColor(0xff362b00);
colors[ImGuiCol_TitleBgCollapsed] = ImColor(0xff362b00);
colors[ImGuiCol_MenuBarBg] = ImColor(0xff423607);
colors[ImGuiCol_ScrollbarBg] = ImColor(0xff362b00);
colors[ImGuiCol_ScrollbarGrab] = ImColor(0xff423607);
colors[ImGuiCol_ScrollbarGrabHovered] = ImColor(0xff423607);
colors[ImGuiCol_ScrollbarGrabActive] = ImColor(0xff423607);
colors[ImGuiCol_CheckMark] = ImColor(0xff756e58);
colors[ImGuiCol_SliderGrab] = ImColor(0xff5e5025); // Customized
colors[ImGuiCol_SliderGrabActive] = ImColor(0xff5e5025); // Customized
colors[ImGuiCol_Button] = ImColor(0xff423607);
colors[ImGuiCol_ButtonHovered] = ImColor(0xff423607);
colors[ImGuiCol_ButtonActive] = ImColor(0xff362b00);
colors[ImGuiCol_Header] = ImColor(0xff423607);
colors[ImGuiCol_HeaderHovered] = ImColor(0xff423607);
colors[ImGuiCol_HeaderActive] = ImColor(0xff423607);
colors[ImGuiCol_Separator] = ImColor(0xff423607);
colors[ImGuiCol_SeparatorHovered] = ImColor(0xff423607);
colors[ImGuiCol_SeparatorActive] = ImColor(0xff423607);
colors[ImGuiCol_ResizeGrip] = ImColor(0xff423607);
colors[ImGuiCol_ResizeGripHovered] = ImColor(0xff423607);
colors[ImGuiCol_ResizeGripActive] = ImColor(0xff756e58);
colors[ImGuiCol_Tab] = ImColor(0xff362b00);
colors[ImGuiCol_TabHovered] = ImColor(0xff423607);
colors[ImGuiCol_TabActive] = ImColor(0xff423607);
colors[ImGuiCol_TabUnfocused] = ImColor(0xff362b00);
colors[ImGuiCol_TabUnfocusedActive] = ImColor(0xff423607);
colors[ImGuiCol_DockingPreview] = ImColor(0xee837b65); // Customized
colors[ImGuiCol_DockingEmptyBg] = ImColor();
colors[ImGuiCol_PlotLines] = ImColor(0xff756e58);
colors[ImGuiCol_PlotLinesHovered] = ImColor(0xff756e58);
colors[ImGuiCol_PlotHistogram] = ImColor(0xff756e58);
colors[ImGuiCol_PlotHistogramHovered] = ImColor(0xff756e58);
colors[ImGuiCol_TextSelectedBg] = ImColor(0xff756e58);
colors[ImGuiCol_DragDropTarget] = ImColor(0xff756e58);
colors[ImGuiCol_NavHighlight] = ImColor();
colors[ImGuiCol_NavWindowingHighlight] = ImColor(0xee969483); // Customized
colors[ImGuiCol_NavWindowingDimBg] = ImColor(0x20e3f6fd); // Customized
colors[ImGuiCol_ModalWindowDimBg] = ImColor(0x20e3f6fd); // Customized
break;
case 6:
colors[ImGuiCol_Text] = ImColor(0xff837b65);
colors[ImGuiCol_TextDisabled] = ImColor(0xffa1a193);
colors[ImGuiCol_WindowBg] = ImColor(0xffe3f6fd);
colors[ImGuiCol_ChildBg] = ImColor();
colors[ImGuiCol_PopupBg] = ImColor(0xfce3f6fd); // Customized
colors[ImGuiCol_Border] = ImColor(0xffd5e8ee);
colors[ImGuiCol_BorderShadow] = ImColor();
colors[ImGuiCol_FrameBg] = ImColor(0xfcd5e8ee); // Customized
colors[ImGuiCol_FrameBgHovered] = ImColor(0xffd5e8ee);
colors[ImGuiCol_FrameBgActive] = ImColor(0xffd5e8ee);
colors[ImGuiCol_TitleBg] = ImColor(0xffe3f6fd);
colors[ImGuiCol_TitleBgActive] = ImColor(0xffe3f6fd);
colors[ImGuiCol_TitleBgCollapsed] = ImColor(0xffe3f6fd);
colors[ImGuiCol_MenuBarBg] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ScrollbarBg] = ImColor(0xffe3f6fd);
colors[ImGuiCol_ScrollbarGrab] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ScrollbarGrabHovered] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ScrollbarGrabActive] = ImColor(0xffd5e8ee);
colors[ImGuiCol_CheckMark] = ImColor(0xffa1a193);
colors[ImGuiCol_SliderGrab] = ImColor(0xffc3d3d9); // Customized
colors[ImGuiCol_SliderGrabActive] = ImColor(0xffc3d3d9); // Customized
colors[ImGuiCol_Button] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ButtonHovered] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ButtonActive] = ImColor(0xffe3f6fd);
colors[ImGuiCol_Header] = ImColor(0xffd5e8ee);
colors[ImGuiCol_HeaderHovered] = ImColor(0xffd5e8ee);
colors[ImGuiCol_HeaderActive] = ImColor(0xffd5e8ee);
colors[ImGuiCol_Separator] = ImColor(0xffd5e8ee);
colors[ImGuiCol_SeparatorHovered] = ImColor(0xffd5e8ee);
colors[ImGuiCol_SeparatorActive] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ResizeGrip] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ResizeGripHovered] = ImColor(0xffd5e8ee);
colors[ImGuiCol_ResizeGripActive] = ImColor(0xffa1a193);
colors[ImGuiCol_Tab] = ImColor(0xffe3f6fd);
colors[ImGuiCol_TabHovered] = ImColor(0xffd5e8ee);
colors[ImGuiCol_TabActive] = ImColor(0xffd5e8ee);
colors[ImGuiCol_TabUnfocused] = ImColor(0xffe3f6fd);
colors[ImGuiCol_TabUnfocusedActive] = ImColor(0xffd5e8ee);
colors[ImGuiCol_DockingPreview] = ImColor(0xeea1a193); // Customized
colors[ImGuiCol_DockingEmptyBg] = ImColor();
colors[ImGuiCol_PlotLines] = ImColor(0xffa1a193);
colors[ImGuiCol_PlotLinesHovered] = ImColor(0xffa1a193);
colors[ImGuiCol_PlotHistogram] = ImColor(0xffa1a193);
colors[ImGuiCol_PlotHistogramHovered] = ImColor(0xffa1a193);
colors[ImGuiCol_TextSelectedBg] = ImColor(0xffa1a193);
colors[ImGuiCol_DragDropTarget] = ImColor(0xffa1a193);
colors[ImGuiCol_NavHighlight] = ImColor();
colors[ImGuiCol_NavWindowingHighlight] = ImColor(0xee837b65); // Customized
colors[ImGuiCol_NavWindowingDimBg] = ImColor(0x20362b00); // Customized
colors[ImGuiCol_ModalWindowDimBg] = ImColor(0x20362b00); // Customized
break;
default:
for (ImGuiCol i = 0; i < ImGuiCol_COUNT; i++)
config.get("STYLE", ImGui::GetStyleColorName(i), (float(&)[4])colors[i]);
break;
}
switch (_editor_style_index)
{
case 0:
_editor.set_palette({ // Dark
0xffffffff, 0xffd69c56, 0xff00ff00, 0xff7070e0, 0xffffffff, 0xff409090, 0xffaaaaaa,
0xff9bc64d, 0xffc040a0, 0xff206020, 0xff406020, 0xff101010, 0xffe0e0e0, 0x80a06020,
0x800020ff, 0x8000ffff, 0xff707000, 0x40000000, 0x40808080, 0x40a0a0a0 });
break;
case 1:
_editor.set_palette({ // Light
0xff000000, 0xffff0c06, 0xff008000, 0xff2020a0, 0xff000000, 0xff409090, 0xff404040,
0xff606010, 0xffc040a0, 0xff205020, 0xff405020, 0xffffffff, 0xff000000, 0x80600000,
0xa00010ff, 0x8000ffff, 0xff505000, 0x40000000, 0x40808080, 0x40000000 });
break;
case 3:
_editor.set_palette({ // Solarized Dark
0xff969483, 0xff0089b5, 0xff98a12a, 0xff98a12a, 0xff969483, 0xff164bcb, 0xff969483,
0xff969483, 0xffc4716c, 0xff756e58, 0xff756e58, 0xff362b00, 0xff969483, 0xA0756e58,
0x7f2f32dc, 0x7f0089b5, 0xff756e58, 0x7f423607, 0x7f423607, 0x7f423607 });
break;
case 4:
_editor.set_palette({ // Solarized Light
0xff837b65, 0xff0089b5, 0xff98a12a, 0xff98a12a, 0xff756e58, 0xff164bcb, 0xff837b65,
0xff837b65, 0xffc4716c, 0xffa1a193, 0xffa1a193, 0xffe3f6fd, 0xff837b65, 0x60a1a193,
0x7f2f32dc, 0x7f0089b5, 0xffa1a193, 0x7fd5e8ee, 0x7fd5e8ee, 0x7fd5e8ee });
break;
default:
case 2:
ImVec4 value; // Note: This expects that all colors exist in the config
for (ImGuiCol i = 0; i < imgui_code_editor::color_palette_max; i++)
config.get("STYLE", imgui_code_editor::get_palette_color_name(i), (float(&)[4])value),
_editor.get_palette_index(i) = ImGui::ColorConvertFloat4ToU32(value);
break;
}
});
_save_config_callables.push_back([this](ini_file &config) {
config.set("INPUT", "KeyMenu", _menu_key_data);
config.set("INPUT", "InputProcessing", _input_processing_mode);
config.set("GENERAL", "ShowClock", _show_clock);
config.set("GENERAL", "ShowFPS", _show_fps);
config.set("GENERAL", "ShowFrameTime", _show_frametime);
config.set("GENERAL", "ShowScreenshotMessage", _show_screenshot_message);
config.set("GENERAL", "FPSPosition", _fps_pos);
config.set("GENERAL", "ClockFormat", _clock_format);
config.set("GENERAL", "NoFontScaling", _no_font_scaling);
config.set("GENERAL", "SaveWindowState", _imgui_context->IO.IniFilename != nullptr);
config.set("GENERAL", "TutorialProgress", _tutorial_index);
config.set("GENERAL", "NewVariableUI", _variable_editor_tabs);
config.set("STYLE", "Alpha", _imgui_context->Style.Alpha);
config.set("STYLE", "GrabRounding", _imgui_context->Style.GrabRounding);
config.set("STYLE", "FrameRounding", _imgui_context->Style.FrameRounding);
config.set("STYLE", "ChildRounding", _imgui_context->Style.ChildRounding);
config.set("STYLE", "PopupRounding", _imgui_context->Style.PopupRounding);
config.set("STYLE", "WindowRounding", _imgui_context->Style.WindowRounding);
config.set("STYLE", "ScrollbarRounding", _imgui_context->Style.ScrollbarRounding);
config.set("STYLE", "TabRounding", _imgui_context->Style.TabRounding);
config.set("STYLE", "FPSScale", _fps_scale);
config.set("STYLE", "ColFPSText", _fps_col);
config.set("STYLE", "Font", _font);
config.set("STYLE", "FontSize", _font_size);
config.set("STYLE", "EditorFont", _editor_font);
config.set("STYLE", "EditorFontSize", _editor_font_size);
config.set("STYLE", "StyleIndex", _style_index);
config.set("STYLE", "EditorStyleIndex", _editor_style_index);
if (_style_index > 2)
{
for (ImGuiCol i = 0; i < ImGuiCol_COUNT; i++)
config.set("STYLE", ImGui::GetStyleColorName(i), (const float(&)[4])_imgui_context->Style.Colors[i]);
}
if (_editor_style_index > 1)
{
ImVec4 value;
for (ImGuiCol i = 0; i < imgui_code_editor::color_palette_max; i++)
value = ImGui::ColorConvertU32ToFloat4(_editor.get_palette_index(i)),
config.set("STYLE", imgui_code_editor::get_palette_color_name(i), (const float(&)[4])value);
}
});
}
void reshade::runtime::deinit_ui()
{
ImGui::DestroyContext(_imgui_context);
}
void reshade::runtime::build_font_atlas()
{
ImFontAtlas *const atlas = _imgui_context->IO.Fonts;
// Remove any existing fonts from atlas first
atlas->Clear();
for (unsigned int i = 0; i < 2; ++i)
{
ImFontConfig cfg;
cfg.SizePixels = static_cast<float>(i == 0 ? _font_size : _editor_font_size);
const std::filesystem::path &font_path = i == 0 ? _font : _editor_font;
if (std::error_code ec; !std::filesystem::is_regular_file(font_path, ec) || !atlas->AddFontFromFileTTF(font_path.u8string().c_str(), cfg.SizePixels))
atlas->AddFontDefault(&cfg); // Use default font if custom font failed to load or does not exist
}
// If unable to build font atlas due to an invalid font, revert to the default font
if (!atlas->Build())
{
_font.clear();
_editor_font.clear();
atlas->Clear();
for (unsigned int i = 0; i < 2; ++i)
{
ImFontConfig cfg;
cfg.SizePixels = static_cast<float>(i == 0 ? _font_size : _editor_font_size);
atlas->AddFontDefault(&cfg);
}
}
_show_splash = true;
_rebuild_font_atlas = false;
int width, height;
unsigned char *pixels;
atlas->GetTexDataAsRGBA32(&pixels, &width, &height);
// Create font atlas texture and upload it
if (_imgui_font_atlas != nullptr)
destroy_texture(*_imgui_font_atlas);
if (_imgui_font_atlas == nullptr)
_imgui_font_atlas = std::make_unique<texture>();
_imgui_font_atlas->width = width;
_imgui_font_atlas->height = height;
_imgui_font_atlas->format = reshadefx::texture_format::rgba8;
_imgui_font_atlas->unique_name = "ImGUI Font Atlas";
if (init_texture(*_imgui_font_atlas))
upload_texture(*_imgui_font_atlas, pixels);
}
void reshade::runtime::draw_ui()
{
assert(_is_initialized);
const bool show_splash = _show_splash && (is_loading() || !_reload_compile_queue.empty() || (_last_present_time - _last_reload_time) < std::chrono::seconds(5));
// Do not show this message in the same frame the screenshot is taken (so that it won't show up on the UI screenshot)
const bool show_screenshot_message = (_show_screenshot_message || !_screenshot_save_success) && !_should_save_screenshot && (_last_present_time - _last_screenshot_time) < std::chrono::seconds(_screenshot_save_success ? 3 : 5);
if (_show_menu && !_ignore_shortcuts && !_imgui_context->IO.NavVisible && _input->is_key_pressed(0x1B /* VK_ESCAPE */))
_show_menu = false; // Close when pressing the escape button and not currently navigating with the keyboard
else if (!_ignore_shortcuts && _input->is_key_pressed(_menu_key_data) && _imgui_context->ActiveId == 0)
_show_menu = !_show_menu;
_ignore_shortcuts = false;
_effects_expanded_state &= 2;
if (_rebuild_font_atlas)
build_font_atlas();
ImGui::SetCurrentContext(_imgui_context);
auto &imgui_io = _imgui_context->IO;
imgui_io.DeltaTime = _last_frame_duration.count() * 1e-9f;
imgui_io.MouseDrawCursor = _show_menu && (!_should_save_screenshot || !_screenshot_save_ui);
imgui_io.MousePos.x = static_cast<float>(_input->mouse_position_x());
imgui_io.MousePos.y = static_cast<float>(_input->mouse_position_y());
imgui_io.DisplaySize.x = static_cast<float>(_width);
imgui_io.DisplaySize.y = static_cast<float>(_height);
imgui_io.Fonts->TexID = _imgui_font_atlas->impl;
// Add wheel delta to the current absolute mouse wheel position
imgui_io.MouseWheel += _input->mouse_wheel_delta();
// Scale mouse position in case render resolution does not match the window size
if (_window_width != 0 && _window_height != 0)
{
imgui_io.MousePos.x *= imgui_io.DisplaySize.x / _window_width;
imgui_io.MousePos.y *= imgui_io.DisplaySize.y / _window_height;
}
// Update all the button states
imgui_io.KeyAlt = _input->is_key_down(0x12); // VK_MENU
imgui_io.KeyCtrl = _input->is_key_down(0x11); // VK_CONTROL
imgui_io.KeyShift = _input->is_key_down(0x10); // VK_SHIFT
for (unsigned int i = 0; i < 256; i++)
imgui_io.KeysDown[i] = _input->is_key_down(i);
for (unsigned int i = 0; i < 5; i++)
imgui_io.MouseDown[i] = _input->is_mouse_button_down(i);
for (wchar_t c : _input->text_input())
imgui_io.AddInputCharacter(c);
ImGui::NewFrame();
ImVec2 viewport_offset = ImVec2(0, 0);
// Create ImGui widgets and windows
if (show_splash || show_screenshot_message || !_preset_save_success || (!_show_menu && _tutorial_index == 0))
{
ImGui::SetNextWindowPos(ImVec2(10, 10));
ImGui::SetNextWindowSize(ImVec2(imgui_io.DisplaySize.x - 20.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.0f);
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.862745f, 0.862745f, 0.862745f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.117647f, 0.117647f, 0.117647f, 0.7f));
ImGui::Begin("Splash Screen", nullptr,
ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoInputs |
ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoDocking |
ImGuiWindowFlags_NoFocusOnAppearing);
if (!_preset_save_success)
{
ImGui::TextColored(COLOR_RED, "Unable to save current preset. Make sure you have write permissions to %s.", _current_preset_path.u8string().c_str());
}
else if (show_screenshot_message)
{
if (!_screenshot_save_success)
if (std::error_code ec; std::filesystem::exists(_screenshot_path, ec))
ImGui::TextColored(COLOR_RED, "Unable to save screenshot because of an internal error (the format may not be supported).");
else
ImGui::TextColored(COLOR_RED, "Unable to save screenshot because path doesn't exist: %s.", _screenshot_path.u8string().c_str());
else
ImGui::Text("Screenshot successfully saved to %s", _last_screenshot_file.u8string().c_str());
}
else
{
ImGui::TextUnformatted("ReShade " VERSION_STRING_FILE " by crosire");
if (_needs_update)
{
ImGui::TextColored(COLOR_YELLOW,
"An update is available! Please visit https://reshade.me and install the new version (v%lu.%lu.%lu).",
_latest_version[0], _latest_version[1], _latest_version[2]);
}
else
{
ImGui::TextUnformatted("Visit https://reshade.me for news, updates, shaders and discussion.");
}
ImGui::Spacing();
ImGui::ProgressBar(1.0f - _reload_remaining_effects / float(_reload_total_effects), ImVec2(-1, 0), "");
ImGui::SameLine(15);
if (_reload_remaining_effects != 0 && _reload_remaining_effects != std::numeric_limits<size_t>::max())
{
ImGui::Text(
"Loading (%zu effects remaining) ... "
"This might take a while. The application could become unresponsive for some time.",
_reload_remaining_effects.load());
}
else if (!_reload_compile_queue.empty())
{
ImGui::Text(
"Compiling (%zu effects remaining) ... "
"This might take a while. The application could become unresponsive for some time.",
_reload_compile_queue.size());
}
else if (_tutorial_index == 0)
{
ImGui::TextUnformatted("ReShade is now installed successfully! Press '");
ImGui::SameLine(0.0f, 0.0f);
ImGui::TextColored(ImVec4(1, 1, 1, 1), "%s", input::key_name(_menu_key_data).c_str());
ImGui::SameLine(0.0f, 0.0f);
ImGui::TextUnformatted("' to start the tutorial.");
}
else
{
ImGui::TextUnformatted("Press '");
ImGui::SameLine(0.0f, 0.0f);
ImGui::TextColored(ImVec4(1, 1, 1, 1), "%s", input::key_name(_menu_key_data).c_str());
ImGui::SameLine(0.0f, 0.0f);
ImGui::TextUnformatted("' to open the configuration menu.");
}
if (!_last_reload_successful)
{
ImGui::Spacing();
ImGui::TextColored(COLOR_RED,
"There were errors compiling some shaders. Check the log for more details.");
}
}
viewport_offset.y += ImGui::GetWindowHeight() + 10; // Add small space between windows
ImGui::End();
ImGui::PopStyleColor(2);
ImGui::PopStyleVar();
}
else if (_show_clock || _show_fps || _show_frametime)
{
float window_height = _imgui_context->FontBaseSize * _fps_scale + _imgui_context->Style.ItemSpacing.y;
window_height *= (_show_clock ? 1 : 0) + (_show_fps ? 1 : 0) + (_show_frametime ? 1 : 0);
window_height += _imgui_context->Style.FramePadding.y * 4.0f;
ImVec2 fps_window_pos(5, 5);
if (_fps_pos % 2)
fps_window_pos.x = imgui_io.DisplaySize.x - 200.0f;
if (_fps_pos > 1)
fps_window_pos.y = imgui_io.DisplaySize.y - window_height - 5;
ImGui::SetNextWindowPos(fps_window_pos);
ImGui::SetNextWindowSize(ImVec2(200.0f, window_height));
ImGui::PushStyleColor(ImGuiCol_Text, (const ImVec4 &)_fps_col);
ImGui::Begin("FPS", nullptr,
ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoInputs |
ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoDocking |
ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoBackground);
ImGui::SetWindowFontScale(_fps_scale);
char temp[512];
if (_show_clock)
{
const int hour = _date[3] / 3600;
const int minute = (_date[3] - hour * 3600) / 60;
const int seconds = _date[3] - hour * 3600 - minute * 60;
ImFormatString(temp, sizeof(temp), _clock_format != 0 ? "%02u:%02u:%02u" : "%02u:%02u", hour, minute, seconds);
if (_fps_pos % 2) // Align text to the right of the window
ImGui::SetCursorPosX(ImGui::GetWindowContentRegionWidth() - ImGui::CalcTextSize(temp).x);
ImGui::TextUnformatted(temp);
}
if (_show_fps)
{
ImFormatString(temp, sizeof(temp), "%.0f fps", imgui_io.Framerate);
if (_fps_pos % 2)
ImGui::SetCursorPosX(ImGui::GetWindowContentRegionWidth() - ImGui::CalcTextSize(temp).x);
ImGui::TextUnformatted(temp);
}
if (_show_frametime)
{
ImFormatString(temp, sizeof(temp), "%5.2f ms", 1000.0f / imgui_io.Framerate);
if (_fps_pos % 2)
ImGui::SetCursorPosX(ImGui::GetWindowContentRegionWidth() - ImGui::CalcTextSize(temp).x);
ImGui::TextUnformatted(temp);
}
ImGui::End();
ImGui::PopStyleColor();
}
if (_show_menu)
{
// Change font size if user presses the control key and moves the mouse wheel
if (imgui_io.KeyCtrl && imgui_io.MouseWheel != 0 && !_no_font_scaling)
{
_font_size = ImClamp(_font_size + static_cast<int>(imgui_io.MouseWheel), 8, 32);
_editor_font_size = ImClamp(_editor_font_size + static_cast<int>(imgui_io.MouseWheel), 8, 32);
_rebuild_font_atlas = true;
save_config();
}
const ImGuiID root_space_id = ImGui::GetID("Dockspace");
const ImGuiViewport *const viewport = ImGui::GetMainViewport();
// Set up default dock layout if this was not done yet
const bool init_window_layout = !ImGui::DockBuilderGetNode(root_space_id);
if (init_window_layout)
{
// Add the root node
ImGui::DockBuilderAddNode(root_space_id, ImGuiDockNodeFlags_DockSpace);
ImGui::DockBuilderSetNodeSize(root_space_id, viewport->Size);
// Split root node into two spaces
ImGuiID main_space_id = 0;
ImGuiID right_space_id = 0;
ImGui::DockBuilderSplitNode(root_space_id, ImGuiDir_Left, 0.35f, &main_space_id, &right_space_id);
// Attach most windows to the main dock space
for (const auto &widget : _menu_callables)
ImGui::DockBuilderDockWindow(widget.first.c_str(), main_space_id);
// Attach editor window to the remaining dock space
ImGui::DockBuilderDockWindow("###editor", right_space_id);
// Commit the layout
ImGui::DockBuilderFinish(root_space_id);
}
ImGui::SetNextWindowPos(viewport->Pos + viewport_offset);
ImGui::SetNextWindowSize(viewport->Size - viewport_offset);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::Begin("Viewport", nullptr,
ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoDocking | // This is the background viewport, the docking space is a child of it
ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoBackground);
ImGui::DockSpace(root_space_id, ImVec2(0, 0), ImGuiDockNodeFlags_PassthruCentralNode);
ImGui::End();
for (const auto &widget : _menu_callables)
{
if (ImGui::Begin(widget.first.c_str(), nullptr, ImGuiWindowFlags_NoFocusOnAppearing)) // No focus so that window state is preserved between opening/closing the UI
widget.second();
ImGui::End();
}
if (_show_code_editor)
{
const std::string title = !_editor_file.empty() ? "Editing " + _editor_file.filename().u8string() + " ###editor" : "Viewing code###editor";
if (ImGui::Begin(title.c_str(), &_show_code_editor))
draw_code_editor();
ImGui::End();
}
}
if (_preview_texture != nullptr && _effects_enabled)
{
if (!_show_menu)
{
// Create a temporary viewport window to attach image to when menu is not open
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowSize(ImVec2(imgui_io.DisplaySize.x, imgui_io.DisplaySize.y));
ImGui::Begin("Viewport", nullptr,
ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoDocking |
ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoBackground);
ImGui::End();
}
// The preview texture is unset in 'unload_effects', so should not be able to reach this while loading
assert(!is_loading() && _reload_compile_queue.empty());
// Scale image to fill the entire viewport by default
ImVec2 preview_min = ImVec2(0, 0);
ImVec2 preview_max = imgui_io.DisplaySize;
// Positing image in the middle of the viewport when using original size
if (_preview_size[0])
{
preview_min.x = (preview_max.x * 0.5f) - (_preview_size[0] * 0.5f);
preview_max.x = (preview_max.x * 0.5f) + (_preview_size[0] * 0.5f);
}
if (_preview_size[1])
{
preview_min.y = (preview_max.y * 0.5f) - (_preview_size[1] * 0.5f);
preview_max.y = (preview_max.y * 0.5f) + (_preview_size[1] * 0.5f);
}
ImGui::FindWindowByName("Viewport")->DrawList->AddImage(_preview_texture, preview_min, preview_max, ImVec2(0, 0), ImVec2(1, 1), _preview_size[2]);
}
// Render ImGui widgets and windows
ImGui::Render();
_input->block_mouse_input(_input_processing_mode != 0 && _show_menu && (imgui_io.WantCaptureMouse || _input_processing_mode == 2));
_input->block_keyboard_input(_input_processing_mode != 0 && _show_menu && (imgui_io.WantCaptureKeyboard || _input_processing_mode == 2));
if (const auto draw_data = ImGui::GetDrawData(); draw_data != nullptr && draw_data->CmdListsCount != 0 && draw_data->TotalVtxCount != 0)
{
render_imgui_draw_data(draw_data);
}
}
void reshade::runtime::draw_ui_home()
{
const char *tutorial_text =
"Welcome! Since this is the first time you start ReShade, we'll go through a quick tutorial covering the most important features.\n\n"
"If you have difficulties reading this text, press the 'Ctrl' key and adjust the font size with your mouse wheel. "
"The window size is variable as well, just grab the right edge and move it around.\n\n"
"You can also use the keyboard for navigation in case mouse input does not work. Use the arrow keys to navigate, space bar to confirm an action or enter a control and the 'Esc' key to leave a control. "
"Press 'Ctrl + Tab' to switch between tabs and windows (use this to focus this page in case the other navigation keys do not work at first).\n\n"
"Click on the 'Continue' button to continue the tutorial.";
// It is not possible to follow some of the tutorial steps while performance mode is active, so skip them
if (_performance_mode && _tutorial_index <= 3)
_tutorial_index = 4;
if (_tutorial_index > 0)
{
if (_tutorial_index == 1)
{
tutorial_text =
"This is the preset selection. All changes will be saved to the selected preset file.\n\n"
"Click on the '+' button to name and add a new one.\n\n"
"Make sure you always have a preset selected here before starting to tweak any values later, or else your changes won't be saved!";
ImGui::PushStyleColor(ImGuiCol_FrameBg, COLOR_RED);
ImGui::PushStyleColor(ImGuiCol_Button, COLOR_RED);
}
draw_preset_explorer();
if (_tutorial_index == 1)
ImGui::PopStyleColor(2);
}
if (_tutorial_index > 1)
{
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
}
if (is_loading())
{
const char *const loading_message = "Loading ...";
ImGui::SetCursorPos((ImGui::GetWindowSize() - ImGui::CalcTextSize(loading_message)) * 0.5f);
ImGui::TextUnformatted(loading_message);
return; // Cannot show techniques and variables while effects are loading, since they are being modified in other different threads during that time
}
if (!_effects_enabled)
ImGui::Text("Effects are disabled. Press '%s' to enable them again.", input::key_name(_effects_key_data).c_str());
if (!_last_reload_successful)
{
std::string error_message = "There were errors compiling the following shaders:";
for (const effect &effect : _effects)
if (!effect.compile_sucess)
error_message += ' ' + effect.source_file.filename().u8string() + ',';
error_message.pop_back();
// Make sure there are actually effects that failed to compile, since the last reload flag may not have been reset
if (error_message.size() > 50)
{
ImGui::TextColored(COLOR_RED, "%s", error_message.c_str());
ImGui::Spacing();
}
else
{
_last_reload_successful = true;
}
}
if (_tutorial_index > 1)
{
const bool show_clear_button = strcmp(_effect_filter, "Search") != 0 && _effect_filter[0] != '\0';
ImGui::PushItemWidth((_variable_editor_tabs ? -10.0f : -20.0f) * _font_size - (show_clear_button ? ImGui::GetFrameHeight() + _imgui_context->Style.ItemSpacing.x : 0));
if (ImGui::InputText("##filter", _effect_filter, sizeof(_effect_filter), ImGuiInputTextFlags_AutoSelectAll))
{
_effects_expanded_state = 3;
if (_effect_filter[0] == '\0')
{
// Reset visibility state
for (technique &technique : _techniques)
technique.hidden = technique.annotation_as_int("hidden") != 0;
}
else
{
const std::string filter = _effect_filter;
for (technique &technique : _techniques)
technique.hidden = technique.annotation_as_int("hidden") != 0 ||
std::search(technique.name.begin(), technique.name.end(), filter.begin(), filter.end(),
[](auto c1, auto c2) { return tolower(c1) == tolower(c2); }) == technique.name.end() && _effects[technique.effect_index].source_file.filename().u8string().find(filter) == std::string::npos;
}
}
else if (!ImGui::IsItemActive() && _effect_filter[0] == '\0')
{
strcpy_s(_effect_filter, "Search");
}
ImGui::PopItemWidth();
ImGui::SameLine();
if (show_clear_button && ImGui::Button("X", ImVec2(ImGui::GetFrameHeight(), 0)))
{
strcpy_s(_effect_filter, "Search");
// Reset visibility state
for (technique &technique : _techniques)
technique.hidden = technique.annotation_as_int("hidden") != 0;
}
ImGui::SameLine();
if (ImGui::Button("Active to top", ImVec2(10 * _font_size - _imgui_context->Style.ItemSpacing.x, 0)))
{
for (auto i = _techniques.begin(); i != _techniques.end(); ++i)
{
if (!i->enabled && i->toggle_key_data[0] == 0)
{
for (auto k = i + 1; k != _techniques.end(); ++k)
{
if (k->enabled || k->toggle_key_data[0] != 0)
{
std::iter_swap(i, k);
break;
}
}
}
}
if (const auto it = std::find_if_not(_techniques.begin(), _techniques.end(), [](const reshade::technique &a) {
return a.enabled || a.toggle_key_data[0] != 0;
}); it != _techniques.end())
{
std::stable_sort(it, _techniques.end(), [](const reshade::technique &lhs, const reshade::technique &rhs) {
std::string lhs_label(lhs.annotation_as_string("ui_label"));
if (lhs_label.empty()) lhs_label = lhs.name;
std::transform(lhs_label.begin(), lhs_label.end(), lhs_label.begin(), [](char c) { return static_cast<char>(toupper(c)); });
std::string rhs_label(rhs.annotation_as_string("ui_label"));
if (rhs_label.empty()) rhs_label = rhs.name;
std::transform(rhs_label.begin(), rhs_label.end(), rhs_label.begin(), [](char c) { return static_cast<char>(toupper(c)); });
return lhs_label < rhs_label;
});
}
save_current_preset();
}
ImGui::SameLine();
if (ImGui::Button(_effects_expanded_state & 2 ? "Collapse all" : "Expand all", ImVec2(10 * _font_size - _imgui_context->Style.ItemSpacing.x, 0)))
_effects_expanded_state = (~_effects_expanded_state & 2) | 1;
if (_tutorial_index == 2)
{
tutorial_text =
"This is the list of effects. It contains all techniques found in the effect files (*.fx) from the effect search paths as specified in the settings.\n\n"
"Enter text in the box at the top to filter it and search for specific techniques.\n\n"
"Click on a technique to enable or disable it or drag it to a new location in the list to change the order in which the effects are applied.\n"
"Use the right mouse button and click on an item to open the context menu with additional options.\n\n";
ImGui::PushStyleColor(ImGuiCol_Border, COLOR_RED);
}
ImGui::Spacing();
const float bottom_height = _performance_mode ? ImGui::GetFrameHeightWithSpacing() + _imgui_context->Style.ItemSpacing.y : (_variable_editor_height + (_tutorial_index == 3 ? 175 : 0));
if (ImGui::BeginChild("##techniques", ImVec2(0, -bottom_height), true))
draw_technique_editor();
ImGui::EndChild();
if (_tutorial_index == 2)
ImGui::PopStyleColor();
}
if (_tutorial_index > 2 && !_performance_mode)
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
ImGui::ButtonEx("##splitter", ImVec2(ImGui::GetContentRegionAvail().x, 5));
ImGui::PopStyleVar();
if (ImGui::IsItemHovered())
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeNS);
if (ImGui::IsItemActive())
_variable_editor_height -= _imgui_context->IO.MouseDelta.y;
if (_tutorial_index == 3)
{
tutorial_text =
"This is the list of variables. It contains all tweakable options the active effects expose. Values here apply in real-time.\n\n"
"Enter text in the box at the top to filter it and search for specific variables.\n\n"
"Press 'Ctrl' and click on a widget to manually edit the value.\n"
"Use the right mouse button and click on an item to open the context menu with additional options.\n\n"
"Once you have finished tweaking your preset, be sure to enable the 'Performance Mode' check box. "
"This will recompile all shaders into a more optimal representation that can give a performance boost, but will disable variable tweaking and this list.";
ImGui::PushStyleColor(ImGuiCol_Border, COLOR_RED);
}
const float bottom_height = ImGui::GetFrameHeightWithSpacing() + _imgui_context->Style.ItemSpacing.y + (_tutorial_index == 3 ? 175 : 0);
if (ImGui::BeginChild("##variables", ImVec2(0, -bottom_height), true))
draw_variable_editor();
ImGui::EndChild();
if (_tutorial_index == 3)
ImGui::PopStyleColor();
}
if (_tutorial_index > 3)
{
ImGui::Spacing();
if (ImGui::Button("Reload", ImVec2(-11.5f * _font_size, 0)))
{
load_effects();
}
ImGui::SameLine();
if (ImGui::Checkbox("Performance Mode", &_performance_mode))
{
save_config();
load_effects(); // Reload effects after switching
}
}
else
{
ImGui::BeginChildFrame(ImGui::GetID("tutorial"), ImVec2(0, 175));
ImGui::TextWrapped(tutorial_text);
ImGui::EndChildFrame();
const float max_button_width = ImGui::GetContentRegionAvail().x;
if (_tutorial_index == 0)
{
if (ImGui::Button("Continue", ImVec2(max_button_width * 0.66666666f, 0)))
{
_tutorial_index++;
save_config();