Repository navigation
Expand file tree
/
Copy pathpreferences.cpp
More file actions
5449 lines (4777 loc) · 236 KB
/
Copy pathpreferences.cpp
File metadata and controls
5449 lines (4777 loc) · 236 KB
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
#include "pch.h"
#include "preferences.h"
#include "core/control_panel_core.h"
#include <uxtheme.h>
#include <commdlg.h>
#include <fstream>
#include <sstream>
#include <vector>
#include <map>
#pragma comment(lib, "uxtheme.lib")
#pragma comment(lib, "comdlg32.lib")
// External declaration from component.cpp
extern HINSTANCE g_hInstance;
// Configuration variables - stored in foobar2000's config system
static cfg_int cfg_nowbar_theme_mode(
GUID{0xABCDEF01, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89}},
0 // Default: Auto
);
static cfg_int cfg_nowbar_cover_margin(
GUID{0xABCDEF05, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8D}},
1 // Default: Yes (margin enabled)
);
static cfg_int cfg_nowbar_cover_style(
GUID{0xABCDEF54, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE4}},
1 // Default: Rounded (0=Square, 1=Rounded)
);
static cfg_int cfg_nowbar_cover_artwork_visible(
GUID{0xABCDEF53, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE3}},
1 // Default: Yes (show artwork)
);
static cfg_int cfg_nowbar_online_artwork(
GUID{0xABCDEF90, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF0}},
0 // Default: Disabled
);
static cfg_int cfg_nowbar_bar_style(
GUID{0xABCDEF06, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8E}},
0 // Default: Pill-shaped
);
static cfg_int cfg_nowbar_seekbar_visible(
GUID{0xABCDEF06, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x03}},
1 // Default: On
);
static cfg_int cfg_nowbar_seekbar_length(
GUID{0xABCDEF06, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x01}},
0 // Default: Fixed
);
static cfg_int cfg_nowbar_seekbar_position(
GUID{0xABCDEF06, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x02}},
0 // Default: centered (no offset)
);
static cfg_int cfg_nowbar_button_scaling_enabled(
GUID{0xABCDEFD1, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD1}},
0 // Default: 0 (dynamic scaling)
);
static cfg_int cfg_nowbar_button_scaling_percent(
GUID{0xABCDEFD2, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD2}},
80 // Default: 80% of max button size
);
static cfg_int cfg_nowbar_mood_icon_visible(
GUID{0xABCDEF07, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8F}},
1 // Default: Show (visible)
);
static cfg_int cfg_nowbar_shuffle_icon_visible(
GUID{0xABCDEF6B, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xFB}},
1 // Default: Show (visible)
);
static cfg_int cfg_nowbar_repeat_icon_visible(
GUID{0xABCDEF6C, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xFC}},
1 // Default: Show (visible)
);
static cfg_int cfg_nowbar_rating_visible(
GUID{0xABCDEFA2, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA2}},
0 // Default: Hidden
);
static cfg_int cfg_nowbar_mood_tag_mode(
GUID{0xABCDEF57, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE7}},
0 // Default: 0=FEEDBACK, 1=2003_LOVED, 2=LFM_LOVED, 3=SMP_LOVED, 4=MOOD
);
static cfg_int cfg_nowbar_stop_icon_visible(
GUID{0xABCDEF51, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE1}},
0 // Default: Hidden
);
static cfg_int cfg_nowbar_stop_after_current_icon_visible(
GUID{0xABCDEF5D, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xED}},
0 // Default: Hidden
);
static cfg_int cfg_nowbar_super_icon_visible(
GUID{0xABCDEF52, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE2}},
1 // Default: Show
);
static cfg_int cfg_nowbar_miniplayer_icon_visible(
GUID{0xABCDEF08, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x90}},
0 // Default: Hidden
);
static cfg_int cfg_nowbar_custom_button_visible(
GUID{0xABCDEF09, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x91}},
1 // Default: Show (visible)
);
static cfg_int cfg_nowbar_hover_circles(
GUID{0xABCDEF1C, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xAC}},
1 // Default: Yes (show hover circles)
);
static cfg_int cfg_nowbar_alternate_icons(
GUID{0xABCDEF1D, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xAD}},
0 // Default: Disabled
);
static cfg_int cfg_nowbar_play_icon_style(
GUID{0xABCDEFBA, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xBA}},
0 // Default: Normal (0=Normal, 1=Inverted)
);
static cfg_int cfg_nowbar_cbutton_autohide(
GUID{0xABCDEF1E, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xAE}},
0 // Default: No (don't auto-hide)
);
static cfg_int cfg_nowbar_volume_icon_visible(
GUID{0xABCDEF69, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF9}},
1 // Default: Show (visible)
);
static cfg_int cfg_nowbar_volume_bar_visible(
GUID{0xABCDEF6A, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xFA}},
1 // Default: Show (visible)
);
static cfg_int cfg_nowbar_background_style(
GUID{0xABCDEF50, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE0}},
0 // Default: Solid (0=Solid, 1=Artwork Colors, 2=Blurred Artwork)
);
static cfg_int cfg_nowbar_smooth_animations(
GUID{0xABCDEF80, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x80}},
0 // Default: Disabled
);
static cfg_int cfg_nowbar_button_accent_color(
GUID{0xABCDEFC0, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC0}},
RGB(100, 180, 255) // Default: Light blue (matches current m_accent_color)
);
static cfg_int cfg_nowbar_progress_accent_color(
GUID{0xABCDEF55, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE5}},
RGB(140, 140, 140) // Default: Gray (matches current progress bar color)
);
static cfg_int cfg_nowbar_volume_accent_color(
GUID{0xABCDEF56, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE6}},
RGB(140, 140, 140) // Default: Gray (matches current volume bar color)
);
// Play/Pause button accent color
static cfg_int cfg_nowbar_play_accent_color(
GUID{0xABCDEFA0, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA0}},
RGB(100, 180, 255) // Default: same as button accent
);
// Button hover color
static cfg_int cfg_nowbar_hover_color(
GUID{0xABCDEFA1, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA1}},
RGB(255, 255, 255) // Default: white (40 alpha applied at render time)
);
// Custom color enable flags (0=use theme, 1=use custom)
static cfg_int cfg_custom_button_accent_enabled(
GUID{0xABCDEFB0, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB0}},
0 // Default: use theme color
);
static cfg_int cfg_custom_play_accent_enabled(
GUID{0xABCDEFB1, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB1}},
0 // Default: use theme color
);
static cfg_int cfg_custom_progress_accent_enabled(
GUID{0xABCDEFB2, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB2}},
0 // Default: use theme color
);
static cfg_int cfg_custom_volume_accent_enabled(
GUID{0xABCDEFB3, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB3}},
0 // Default: use theme color
);
static cfg_int cfg_custom_hover_color_enabled(
GUID{0xABCDEFB4, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB4}},
0 // Default: use theme color (Selection)
);
static cfg_int cfg_custom_spectrum_color_enabled(
GUID{0xABCDEFB5, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB5}},
0 // Default: use theme color
);
static cfg_int cfg_custom_waveform_color_enabled(
GUID{0xABCDEFB6, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB6}},
0 // Default: use theme color
);
static cfg_int cfg_custom_waveform_unplayed_enabled(
GUID{0xABCDEFB7, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB7}},
0 // Default: use theme color (Text)
);
static cfg_int cfg_custom_progress_track_enabled(
GUID{0xABCDEFB8, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB8}},
0 // Default: use theme color (Text)
);
static cfg_int cfg_custom_volume_track_enabled(
GUID{0xABCDEFB9, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB9}},
0 // Default: use theme color (Text)
);
static cfg_int cfg_nowbar_infinite_playback(
GUID{0xABCDEF58, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE8}},
0 // Default: Disabled
);
static cfg_int cfg_nowbar_preview_mode(
GUID{0xABCDEF59, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xE9}},
0 // Default: Off (0=Off, 1=35%, 2=50%, 3=60sec)
);
static cfg_int cfg_nowbar_skip_low_rating_enabled(
GUID{0xABCDEF5A, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xEA}},
0 // Default: Disabled
);
static cfg_int cfg_nowbar_skip_low_rating_threshold(
GUID{0xABCDEF5B, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xEB}},
1 // Default: 1 (skip if rating <= 1)
);
static cfg_int cfg_nowbar_selection_mode(
GUID{0xABCDEF5F, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xEF}},
0 // Default: 0=Prioritize Now Playing Mode, 1=Follow Selection
);
static cfg_int cfg_nowbar_visualization_mode(
GUID{0xABCDEF5C, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xEC}},
0 // Default: Disabled (0=Disabled, 1=Spectrum, 2=Waveform)
);
// Remembers spectrum vs waveform selection independently of the enable checkbox,
// so the user's choice persists even when visualization is disabled.
static cfg_int cfg_nowbar_vis_type(
GUID{0xABCDEF5E, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xEE}},
1 // Default: Spectrum (1=Spectrum, 2=Waveform)
);
static cfg_int cfg_nowbar_spectrum_color(
GUID{0xABCDEF81, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x81}},
RGB(100, 180, 255) // Default: light blue
);
static cfg_int cfg_nowbar_spectrum_width(
GUID{0xABCDEF82, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x82}},
1 // Default: Normal (0=Thin, 1=Normal, 2=Wide)
);
static cfg_int cfg_nowbar_spectrum_style(
GUID{0xABCDEF8A, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8A}},
1 // Default: Curve (0=Mono, 1=Curve, 2=Dominoes)
);
static cfg_int cfg_nowbar_spectrum_height(
GUID{0xABCDEF8B, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8B}},
2 // Default: High (0=Low, 1=Normal, 2=High)
);
static cfg_int cfg_nowbar_spectrum_opacity(
GUID{0xABCDEF87, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x87}},
75 // Default: 75% opacity
);
static cfg_int cfg_nowbar_spectrum_gradient_mode(
GUID{0xABCDEF88, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x88}},
0 // Default: Adaptive (0=Adaptive, 1=Solid, 2=Gradient, 3=Frequency)
);
static cfg_int cfg_nowbar_spectrum_color2(
GUID{0xABCDEF89, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89}},
RGB(30, 80, 160) // Default: darker blue (gradient bottom)
);
static cfg_int cfg_nowbar_vis_60fps(
GUID{0xABCDEF84, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x84}},
0 // Default: Disabled (0=30fps spectrum, 1=60fps spectrum)
);
static cfg_int cfg_nowbar_waveform_color(
GUID{0xABCDEF86, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x86}},
RGB(255, 85, 0) // Default: SoundCloud orange
);
static cfg_int cfg_nowbar_waveform_width(
GUID{0xABCDEF85, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x85}},
0 // Default: Thin (0=Thin, 1=Wide, 2=Wide (4K))
);
static cfg_int cfg_nowbar_waveform_style(
GUID{0xABCDEF8C, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8C}},
0 // Default: Waveform 1 (0=Waveform 1 / Bottom bars, 1=Waveform 2 / Centered envelope)
);
static cfg_int cfg_nowbar_waveform_unplayed_color(
GUID{0xABCDEF66, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF6}},
RGB(60, 60, 60) // Default: dim gray (fully opaque)
);
static cfg_int cfg_nowbar_progress_track_color(
GUID{0xABCDEF67, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF7}},
RGB(60, 60, 60) // Default: dark grey
);
static cfg_int cfg_nowbar_volume_track_color(
GUID{0xABCDEF68, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF8}},
RGB(60, 60, 60) // Default: dark grey
);
static cfg_int cfg_nowbar_custom_button_action(
GUID{0xABCDEF0A, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x92}},
0 // Default: None (0=None, 1=Open URL, 2=Run Executable, 3=Foobar2k Action, 4=Open Folder)
);
static cfg_string cfg_nowbar_custom_button_url(
GUID{0xABCDEF0B, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x93}},
"" // Default: empty
);
static cfg_string cfg_nowbar_custom_button_executable(
GUID{0xABCDEF0C, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x94}},
"" // Default: empty
);
static cfg_string cfg_nowbar_custom_button_fb2k_action(
GUID{0xABCDEF0D, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x95}},
"" // Default: empty (e.g., "Playback/Matrix Now Playing/Announce current track to Matrix")
);
// Display format configuration
static cfg_string cfg_nowbar_line1_format(
GUID{0xABCDEF30, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC0}},
"%title%" // Default: title only
);
static cfg_string cfg_nowbar_line2_format(
GUID{0xABCDEF31, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC1}},
"%artist%" // Default: artist only
);
static cfg_string cfg_nowbar_line3_format(
GUID{0xABCDEF32, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC2}},
"" // Default: empty (disabled)
);
// Font configuration
static cfg_struct_t<LOGFONT> cfg_nowbar_artist_font(
GUID{0xABCDEF02, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8A}},
[]() {
LOGFONT lf = {};
lf.lfHeight = -17; // ~12.6pt at 96 DPI (40% larger than 9pt)
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = CLEARTYPE_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
wcscpy_s(lf.lfFaceName, L"Microsoft YaHei UI");
return lf;
}()
);
static cfg_struct_t<LOGFONT> cfg_nowbar_track_font(
GUID{0xABCDEF03, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8B}},
[]() {
LOGFONT lf = {};
lf.lfHeight = -21; // ~15.4pt at 96 DPI (40% larger than 11pt)
lf.lfWeight = FW_BOLD;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = CLEARTYPE_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
wcscpy_s(lf.lfFaceName, L"Microsoft YaHei UI");
return lf;
}()
);
static cfg_struct_t<LOGFONT> cfg_nowbar_line3_font(
GUID{0xABCDEF0F, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x97}},
[]() {
LOGFONT lf = {};
lf.lfHeight = -17; // Same as artist font default
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = CLEARTYPE_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
wcscpy_s(lf.lfFaceName, L"Microsoft YaHei UI");
return lf;
}()
);
static cfg_struct_t<LOGFONT> cfg_nowbar_time_font(
GUID{0xABCDEF0E, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x96}},
[]() {
LOGFONT lf = {};
lf.lfHeight = -12; // ~9pt at 96 DPI
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = CLEARTYPE_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
wcscpy_s(lf.lfFaceName, L"Microsoft YaHei UI");
return lf;
}()
);
static cfg_int cfg_nowbar_use_custom_fonts(
GUID{0xABCDEF04, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x8C}},
0 // Default: use built-in fonts
);
// Font color configuration (-1 = use theme color)
static cfg_int cfg_nowbar_track_font_color(
GUID{0xABCDEF04, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC0}},
-1 // Default: use theme color
);
static cfg_int cfg_nowbar_artist_font_color(
GUID{0xABCDEF04, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC1}},
-1 // Default: use theme color
);
static cfg_int cfg_nowbar_line3_font_color(
GUID{0xABCDEF04, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC3}},
-1 // Default: use theme color
);
static cfg_int cfg_nowbar_time_font_color(
GUID{0xABCDEF04, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC2}},
-1 // Default: use theme color
);
// Custom Button tab configuration (4 buttons)
static cfg_int cfg_cbutton1_enabled(
GUID{0xABCDEF10, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA0}},
0 // Default: disabled
);
static cfg_int cfg_cbutton1_action(
GUID{0xABCDEF11, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA1}},
0 // Default: None
);
static cfg_int cfg_cbutton2_enabled(
GUID{0xABCDEF12, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA2}},
0 // Default: disabled
);
static cfg_int cfg_cbutton2_action(
GUID{0xABCDEF13, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA3}},
0 // Default: None
);
static cfg_int cfg_cbutton3_enabled(
GUID{0xABCDEF14, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA4}},
0 // Default: disabled
);
static cfg_int cfg_cbutton3_action(
GUID{0xABCDEF15, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA5}},
0 // Default: None
);
static cfg_int cfg_cbutton4_enabled(
GUID{0xABCDEF16, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA6}},
0 // Default: disabled
);
static cfg_int cfg_cbutton4_action(
GUID{0xABCDEF17, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA7}},
0 // Default: None
);
static cfg_string cfg_cbutton1_path(
GUID{0xABCDEF18, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA8}},
"" // Default: empty
);
static cfg_string cfg_cbutton2_path(
GUID{0xABCDEF19, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xA9}},
"" // Default: empty
);
static cfg_string cfg_cbutton3_path(
GUID{0xABCDEF1A, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xAA}},
"" // Default: empty
);
static cfg_string cfg_cbutton4_path(
GUID{0xABCDEF1B, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xAB}},
"" // Default: empty
);
// Custom Button 5 and 6 config
static cfg_int cfg_cbutton5_enabled(
GUID{0xABCDEF20, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB0}},
0 // Default: disabled
);
static cfg_int cfg_cbutton5_action(
GUID{0xABCDEF21, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB1}},
0 // Default: None
);
static cfg_string cfg_cbutton5_path(
GUID{0xABCDEF22, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB2}},
"" // Default: empty
);
static cfg_int cfg_cbutton6_enabled(
GUID{0xABCDEF23, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB3}},
0 // Default: disabled
);
static cfg_int cfg_cbutton6_action(
GUID{0xABCDEF24, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB4}},
0 // Default: None
);
static cfg_string cfg_cbutton6_path(
GUID{0xABCDEF25, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xB5}},
"" // Default: empty
);
// Custom Button Icon paths (PNG/ICO files for custom icons)
static cfg_string cfg_cbutton1_icon(
GUID{0xABCDEF40, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD0}},
"" // Default: empty (use default numbered icon)
);
static cfg_string cfg_cbutton2_icon(
GUID{0xABCDEF41, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD1}},
"" // Default: empty
);
static cfg_string cfg_cbutton3_icon(
GUID{0xABCDEF42, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD2}},
"" // Default: empty
);
static cfg_string cfg_cbutton4_icon(
GUID{0xABCDEF43, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD3}},
"" // Default: empty
);
static cfg_string cfg_cbutton5_icon(
GUID{0xABCDEF44, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD4}},
"" // Default: empty
);
static cfg_string cfg_cbutton6_icon(
GUID{0xABCDEF45, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xD5}},
"" // Default: empty
);
// Custom Button Glyph sizes (percentage of icon area, default 80%)
static cfg_int cfg_cbutton1_glyph_size(
GUID{0xABCDEF70, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x01}},
80
);
static cfg_int cfg_cbutton2_glyph_size(
GUID{0xABCDEF71, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x02}},
80
);
static cfg_int cfg_cbutton3_glyph_size(
GUID{0xABCDEF72, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x03}},
80
);
static cfg_int cfg_cbutton4_glyph_size(
GUID{0xABCDEF73, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x04}},
80
);
static cfg_int cfg_cbutton5_glyph_size(
GUID{0xABCDEF74, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x05}},
80
);
static cfg_int cfg_cbutton6_glyph_size(
GUID{0xABCDEF75, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x06}},
80
);
// Custom Button Tooltip labels (user-friendly names for tooltips)
static cfg_string cfg_cbutton1_label(
GUID{0xABCDEF60, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF0}},
"" // Default: empty (will show "Button #1")
);
static cfg_string cfg_cbutton2_label(
GUID{0xABCDEF61, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF1}},
"" // Default: empty (will show "Button #2")
);
static cfg_string cfg_cbutton3_label(
GUID{0xABCDEF62, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF2}},
"" // Default: empty (will show "Button #3")
);
static cfg_string cfg_cbutton4_label(
GUID{0xABCDEF63, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF3}},
"" // Default: empty (will show "Button #4")
);
static cfg_string cfg_cbutton5_label(
GUID{0xABCDEF64, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF4}},
"" // Default: empty (will show "Button #5")
);
static cfg_string cfg_cbutton6_label(
GUID{0xABCDEF65, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF5}},
"" // Default: empty (will show "Button #6")
);
// Custom Button Font names (per-button font for glyph rendering)
static cfg_string cfg_cbutton1_font(
GUID{0xABCDEF80, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x01}},
"Segoe UI"
);
static cfg_string cfg_cbutton2_font(
GUID{0xABCDEF81, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x02}},
"Segoe UI"
);
static cfg_string cfg_cbutton3_font(
GUID{0xABCDEF82, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x03}},
"Segoe UI"
);
static cfg_string cfg_cbutton4_font(
GUID{0xABCDEF83, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x04}},
"Segoe UI"
);
static cfg_string cfg_cbutton5_font(
GUID{0xABCDEF84, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x05}},
"Segoe UI"
);
static cfg_string cfg_cbutton6_font(
GUID{0xABCDEF85, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x06}},
"Segoe UI"
);
// Color picker custom colors (16 user-defined slots in ChooseColor dialog)
static cfg_string cfg_color_picker_custom(
GUID{0xABCDEF90, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x68, 0x90}},
""
);
// Profile configuration storage
static cfg_string cfg_cbutton_profiles(
GUID{0xABCDEF70, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF6}},
"" // Default: empty (will create "Default" profile on first use)
);
static cfg_string cfg_cbutton_current_profile(
GUID{0xABCDEF71, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xF7}},
"Default" // Default profile name
);
static cfg_int cfg_nowbar_3d_buttons(
GUID{0xABCDEFC1, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC1}},
1 // Default: Enabled (3D style)
);
static cfg_int cfg_nowbar_volume_number(
GUID{0xABCDEFC2, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC2}},
0 // Default: Disabled
);
static cfg_int cfg_nowbar_playback_time_visible(
GUID{0xABCDEFC3, 0x1234, 0x5678, {0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0xC3}},
1 // Default: Show (1)
);
//=============================================================================
// Config File for All 12 Custom Buttons
// Buttons 1-6: Visible on panel, have enabled/icon fields
// Buttons 7-12: Hidden, keyboard shortcuts only
//=============================================================================
// Cached config for all 12 buttons (loaded from config file)
struct ConfigFileButtonConfig {
bool enabled = false; // Only used for buttons 1-6
int action = 0; // 0=none, 1=url, 2=executable, 3=foobar2k
pfc::string8 path; // URL, exe path, or fb2k command
pfc::string8 icon; // Glyph character (only used for buttons 1-6)
pfc::string8 font; // Font name (default "Segoe UI")
int glyph_size = 80; // Glyph size percentage (default 80%)
pfc::string8 label; // Tooltip/description
};
static ConfigFileButtonConfig g_config_buttons[12];
static bool g_config_loaded = false;
static pfc::string8 g_config_file_path;
// Get the config file directory path
pfc::string8 get_config_dir_path() {
pfc::string8 profile_path = core_api::get_profile_path();
// Remove "file://" prefix if present
if (profile_path.has_prefix("file://")) {
profile_path = profile_path.subString(7);
}
// Ensure trailing backslash
if (!profile_path.is_empty() && profile_path[profile_path.length() - 1] != '\\' && profile_path[profile_path.length() - 1] != '/') {
profile_path << "\\";
}
pfc::string8 dir_path;
dir_path << profile_path << "foo_nowbar_data";
return dir_path;
}
// Get the full config file path
static pfc::string8 get_config_file_path() {
if (g_config_file_path.is_empty()) {
g_config_file_path = get_config_dir_path();
g_config_file_path << "\\custom_buttons.conf";
}
return g_config_file_path;
}
// Helper to trim whitespace from a string
static pfc::string8 trim_string(const char* str) {
pfc::string8 result;
const char* start = str;
while (*start && (*start == ' ' || *start == '\t')) start++;
const char* end = start + strlen(start);
while (end > start && (*(end-1) == ' ' || *(end-1) == '\t' || *(end-1) == '\r' || *(end-1) == '\n')) end--;
result.set_string(start, end - start);
return result;
}
// Parse action string to int
static int parse_action_string(const char* str) {
pfc::string8 action = trim_string(str);
if (stricmp_utf8(action, "url") == 0) return 1;
if (stricmp_utf8(action, "executable") == 0) return 2;
if (stricmp_utf8(action, "foobar2k") == 0) return 3;
if (stricmp_utf8(action, "open_folder") == 0) return 4;
if (stricmp_utf8(action, "output_device") == 0 ||
stricmp_utf8(action, "output_devices") == 0 ||
stricmp_utf8(action, "output_device_menu") == 0 ||
stricmp_utf8(action, "device") == 0) return 5;
return 0; // none
}
// Convert action int to string
static const char* action_to_string(int action) {
switch (action) {
case 1: return "url";
case 2: return "executable";
case 3: return "foobar2k";
case 4: return "open_folder";
case 5: return "output_device";
default: return "none";
}
}
// Create the foo_nowbar_data directory if it doesn't exist
void ensure_config_dir_exists() {
pfc::string8 dir_path = get_config_dir_path();
pfc::stringcvt::string_wide_from_utf8 wide_path(dir_path);
CreateDirectoryW(wide_path, NULL); // Ignore error if already exists
}
// Create default config file with template
static void create_default_config_file() {
ensure_config_dir_exists();
pfc::string8 file_path = get_config_file_path();
pfc::stringcvt::string_wide_from_utf8 wide_path(file_path);
std::ofstream file(wide_path.get_ptr(), std::ios::out | std::ios::binary);
if (!file.is_open()) return;
// Write UTF-8 BOM for proper encoding detection
file.write("\xEF\xBB\xBF", 3);
file << "# Now Bar Custom Buttons Configuration\n";
file << "# Buttons 1-6: Visible on panel + keyboard shortcuts\n";
file << "# Buttons 7-12: Hidden (keyboard shortcuts only)\n";
file << "#\n";
file << "# Action values: none, url, executable, foobar2k, open_folder, output_device\n";
file << "# Path: URL for 'url', executable path for 'executable',\n";
file << "# menu path like 'Library/Search' for 'foobar2k',\n";
file << "# or leave empty for 'open_folder' or 'output_device'\n";
file << "#\n";
file << "# Title formatting is supported in URLs and paths (e.g., %artist%, %title%)\n";
file << "\n";
// Buttons 1-6 (visible)
for (int i = 1; i <= 6; i++) {
file << "[button:" << i << "]\n";
file << "enabled = " << (get_nowbar_cbutton_enabled(i-1) ? "true" : "false") << "\n";
file << "action = " << action_to_string(get_nowbar_cbutton_action(i-1)) << "\n";
file << "path = " << get_nowbar_cbutton_path(i-1).c_str() << "\n";
file << "icon = " << get_nowbar_cbutton_icon_path(i-1).c_str() << "\n";
file << "font = " << get_nowbar_cbutton_font(i-1).c_str() << "\n";
file << "glyph_size = " << get_nowbar_cbutton_glyph_size(i-1) << "\n";
file << "label = " << get_nowbar_cbutton_label(i-1).c_str() << "\n";
file << "\n";
}
// Buttons 7-12 (hidden)
for (int i = 7; i <= 12; i++) {
file << "[button:" << i << "]\n";
file << "action = none\n";
file << "path = \n";
file << "label = Custom Button " << i << "\n";
file << "\n";
}
file.close();
}
// Load config from file
static void load_config_file() {
if (g_config_loaded) return;
// Initialize with defaults
for (int i = 0; i < 12; i++) {
g_config_buttons[i] = ConfigFileButtonConfig();
pfc::string8 label;
label << "Custom Button " << (i + 1);
g_config_buttons[i].label = label;
}
pfc::string8 file_path = get_config_file_path();
pfc::stringcvt::string_wide_from_utf8 wide_path(file_path);
std::ifstream file(wide_path.get_ptr());
if (!file.is_open()) {
// Config file doesn't exist - create it with current settings
create_default_config_file();
// Reload after creation
file.open(wide_path.get_ptr());
if (!file.is_open()) {
g_config_loaded = true;
return;
}
}
std::string line;
int current_button = -1; // 0-based index
while (std::getline(file, line)) {
// Trim line
size_t start = line.find_first_not_of(" \t");
if (start == std::string::npos) continue;
line = line.substr(start);
// Skip comments and empty lines
if (line.empty() || line[0] == '#' || line[0] == ';') continue;
// Check for section header [button:N]
if (line[0] == '[') {
size_t end = line.find(']');
if (end != std::string::npos) {
std::string section = line.substr(1, end - 1);
if (section.find("button:") == 0) {
int btn_num = std::atoi(section.substr(7).c_str());
if (btn_num >= 1 && btn_num <= 12) {
current_button = btn_num - 1; // Convert to 0-based
}
}
}
continue;
}
// Parse key=value
size_t eq_pos = line.find('=');
if (eq_pos == std::string::npos || current_button < 0) continue;
std::string key = line.substr(0, eq_pos);
std::string value = line.substr(eq_pos + 1);
// Trim key and value
while (!key.empty() && (key.back() == ' ' || key.back() == '\t')) key.pop_back();
while (!value.empty() && (value[0] == ' ' || value[0] == '\t')) value = value.substr(1);
while (!value.empty() && (value.back() == '\r' || value.back() == '\n')) value.pop_back();
if (key == "enabled") {
g_config_buttons[current_button].enabled =
(value == "true" || value == "1" || value == "yes");
} else if (key == "action") {
g_config_buttons[current_button].action = parse_action_string(value.c_str());
} else if (key == "path") {
g_config_buttons[current_button].path = value.c_str();
} else if (key == "icon") {
g_config_buttons[current_button].icon = value.c_str();
} else if (key == "font") {
g_config_buttons[current_button].font = value.c_str();
} else if (key == "glyph_size") {
g_config_buttons[current_button].glyph_size = atoi(std::string(value).c_str());
} else if (key == "label") {
g_config_buttons[current_button].label = value.c_str();
}
}
file.close();
g_config_loaded = true;
}
// Reload config from file (call when settings may have changed)
static void reload_config_file() {
g_config_loaded = false;
load_config_file();
}
// Save config file to disk (syncs buttons 1-6 from preferences, preserves 7-12 from cache)
static void save_config_file() {
// Make sure config is loaded first so we have buttons 7-12
if (!g_config_loaded) load_config_file();
ensure_config_dir_exists();
pfc::string8 file_path = get_config_file_path();
pfc::stringcvt::string_wide_from_utf8 wide_path(file_path);
std::ofstream file(wide_path.get_ptr(), std::ios::out | std::ios::binary);
if (!file.is_open()) return;
// Write UTF-8 BOM for proper encoding detection
file.write("\xEF\xBB\xBF", 3);
file << "# Now Bar Custom Buttons Configuration\n";
file << "# Buttons 1-6: Visible on panel + keyboard shortcuts\n";
file << "# Buttons 7-12: Hidden (keyboard shortcuts only)\n";
file << "#\n";
file << "# Action values: none, url, executable, foobar2k, open_folder, output_device\n";
file << "# Path: URL for 'url', executable path for 'executable',\n";
file << "# menu path like 'Library/Search' for 'foobar2k',\n";
file << "# or leave empty for 'open_folder' or 'output_device'\n";
file << "#\n";
file << "# Title formatting is supported in URLs and paths (e.g., %artist%, %title%)\n";
file << "\n";
// Buttons 1-6 (visible) - read from preferences (cfg_* variables)
for (int i = 1; i <= 6; i++) {
file << "[button:" << i << "]\n";
file << "enabled = " << (get_nowbar_cbutton_enabled(i-1) ? "true" : "false") << "\n";
file << "action = " << action_to_string(get_nowbar_cbutton_action(i-1)) << "\n";
file << "path = " << get_nowbar_cbutton_path(i-1).c_str() << "\n";
file << "icon = " << get_nowbar_cbutton_icon_path(i-1).c_str() << "\n";
file << "font = " << get_nowbar_cbutton_font(i-1).c_str() << "\n";
file << "glyph_size = " << get_nowbar_cbutton_glyph_size(i-1) << "\n";
file << "label = " << get_nowbar_cbutton_label(i-1).c_str() << "\n";
file << "\n";
}
// Buttons 7-12 (hidden) - read from cached config
for (int i = 7; i <= 12; i++) {
file << "[button:" << i << "]\n";
file << "action = " << action_to_string(g_config_buttons[i-1].action) << "\n";
file << "path = " << g_config_buttons[i-1].path.c_str() << "\n";
file << "label = " << g_config_buttons[i-1].label.c_str() << "\n";
file << "\n";
}
file.close();
// Update cache for buttons 1-6 to match preferences
for (int i = 0; i < 6; i++) {
g_config_buttons[i].enabled = get_nowbar_cbutton_enabled(i);
g_config_buttons[i].action = get_nowbar_cbutton_action(i);
g_config_buttons[i].path = get_nowbar_cbutton_path(i);
g_config_buttons[i].icon = get_nowbar_cbutton_icon_path(i);
g_config_buttons[i].font = get_nowbar_cbutton_font(i);
g_config_buttons[i].glyph_size = get_nowbar_cbutton_glyph_size(i);
g_config_buttons[i].label = get_nowbar_cbutton_label(i);
}
}
// Get button config from config file (for buttons 7-12, always; for 1-6, optional)
static const ConfigFileButtonConfig& get_config_button(int index) {
if (!g_config_loaded) load_config_file();
if (index < 0 || index >= 12) {
static ConfigFileButtonConfig empty;
return empty;
}
return g_config_buttons[index];
}
//=============================================================================
// Profile Management - Simple JSON-like serialization
//=============================================================================
// Escape a string for JSON-like storage
static pfc::string8 escape_json_string(const char* str) {
pfc::string8 result;
while (*str) {
if (*str == '"') result << "\\\"";
else if (*str == '\\') result << "\\\\";
else if (*str == '\n') result << "\\n";
else if (*str == '\r') result << "\\r";
else if (*str == '\t') result << "\\t";
else result.add_byte(*str);