Browse code

Add warnings to building with GCC/Clang.

* These were mostly copied from the old Makefile.
* The files including wxWidgets need -Wno-old-style-cast done in the code via pragmas because I do not want to disable that warning for the rest of the files. (It might've been overkill for some places where wxWidgets was included, but whatever.)

Naram Qashat authored on 2021/04/04 23:35:09
Showing 1 changed files
... ...
@@ -6,6 +6,13 @@
6 6
  */
7 7
 
8 8
 #include <string>
9
+#ifdef __GNUC__
10
+# pragma GCC diagnostic push
11
+# pragma GCC diagnostic ignored "-Wold-style-cast"
12
+#elif defined(__clang__)
13
+# pragma clang diagnostic push
14
+# pragma clang diagnostic ignored "-Wold-style-cast"
15
+#endif
9 16
 #include <wx/button.h>
10 17
 #include <wx/checkbox.h>
11 18
 #include <wx/choice.h>
... ...
@@ -19,6 +26,11 @@
19 26
 #include <wx/valgen.h>
20 27
 #include <wx/valnum.h>
21 28
 #include <wx/window.h>
29
+#ifdef __GNUC__
30
+# pragma GCC diagnostic pop
31
+#elif defined(__clang__)
32
+# pragma clang diagnostic pop
33
+#endif
22 34
 #include "RegExValidator.h"
23 35
 #include "XSFConfig.h"
24 36
 #include "XSFConfigDialog.h"
... ...
@@ -29,7 +41,7 @@ enum
29 41
 };
30 42
 
31 43
 // This just sets up the base dialog box's controls, it does not do the auto-sizing at this stage.
32
-XSFConfigDialog::XSFConfigDialog(XSFConfig &config, wxWindow *parent, const wxString &title) : wxDialog(parent, wxID_ANY, title), config(config)
44
+XSFConfigDialog::XSFConfigDialog(XSFConfig &newConfig, wxWindow *parent, const wxString &title) : wxDialog(parent, wxID_ANY, title), config(newConfig)
33 45
 {
34 46
 	this->mainSizer = new wxGridBagSizer;
35 47
 
Browse code

Add wxWidgets-based configuration dialog boxes.

* Removes the configuration dialog boxes that used my DialogBuilder.
* Move default configuration values to be inlined within the headers.
* Moved 2SF's and GSF's XSFConfig classes to their own headers to accommodate the new wxWidgets dialog boxes.
* Make it so NCSF's SoundView dialog can be toggled on or off from the configuration dialog box.

Naram Qashat authored on 2021/04/04 12:46:14
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,156 @@
1
+/*
2
+ * xSF - Core configuration dialog
3
+ * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
+ *
5
+ * Partially based on the vio*sf framework
6
+ */
7
+
8
+#include <string>
9
+#include <wx/button.h>
10
+#include <wx/checkbox.h>
11
+#include <wx/choice.h>
12
+#include <wx/dialog.h>
13
+#include <wx/gbsizer.h>
14
+#include <wx/notebook.h>
15
+#include <wx/sizer.h>
16
+#include <wx/stattext.h>
17
+#include <wx/string.h>
18
+#include <wx/textctrl.h>
19
+#include <wx/valgen.h>
20
+#include <wx/valnum.h>
21
+#include <wx/window.h>
22
+#include "RegExValidator.h"
23
+#include "XSFConfig.h"
24
+#include "XSFConfigDialog.h"
25
+
26
+enum
27
+{
28
+	idResetDefaults = 1
29
+};
30
+
31
+// This just sets up the base dialog box's controls, it does not do the auto-sizing at this stage.
32
+XSFConfigDialog::XSFConfigDialog(XSFConfig &config, wxWindow *parent, const wxString &title) : wxDialog(parent, wxID_ANY, title), config(config)
33
+{
34
+	this->mainSizer = new wxGridBagSizer;
35
+
36
+	auto notebook = new wxNotebook(this, wxID_ANY);
37
+
38
+	this->generalPanel = new wxPanel(notebook, wxID_ANY);
39
+	this->generalSizer = new wxGridBagSizer;
40
+
41
+	auto playInfinitelyCheckBox = new wxCheckBox(this->generalPanel, wxID_ANY, "Play Infinitely", wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator{ &this->playInfinitely });
42
+	this->generalSizer->Add(playInfinitelyCheckBox, { 0, 0 }, { 1, 2 }, wxALL, 5);
43
+
44
+	auto defaultPlayLengthLabel = new wxStaticText(this->generalPanel, wxID_ANY, "Default play length (m:s)");
45
+	this->generalSizer->Add(defaultPlayLengthLabel, { 1, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
46
+	auto defaultPlayLengthTextCtrl = new wxTextCtrl(this->generalPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, { 38, -1 }, 0, RegExValidator{ XSFConfigDialog::timeRegex, &this->defaultPlayLength, wxRE_ADVANCED });
47
+	this->generalSizer->Add(defaultPlayLengthTextCtrl, { 1, 1 }, { 1, 1 }, wxALL, 5);
48
+
49
+	auto defaultFadeoutLengthLabel = new wxStaticText(this->generalPanel, wxID_ANY, "Default fadeout length (m:s)");
50
+	this->generalSizer->Add(defaultFadeoutLengthLabel, { 2, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
51
+	auto defaultFadeoutLengthTextCtrl = new wxTextCtrl(this->generalPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, { 38, -1 }, 0, RegExValidator{ XSFConfigDialog::timeRegex, &this->defaultFadeoutLength, wxRE_ADVANCED });
52
+	this->generalSizer->Add(defaultFadeoutLengthTextCtrl, { 2, 1 }, { 1, 1 }, wxALL, 5);
53
+
54
+	auto skipSilenceOnStartLabel = new wxStaticText(this->generalPanel, wxID_ANY, "Skip silence on start (s)");
55
+	this->generalSizer->Add(skipSilenceOnStartLabel, { 3, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
56
+	auto skipSilenceOnStartTextCtrl = new wxTextCtrl(this->generalPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, { 38, -1 }, 0, RegExValidator{ XSFConfigDialog::timeRegex, &this->skipSilenceOnStart, wxRE_ADVANCED });
57
+	this->generalSizer->Add(skipSilenceOnStartTextCtrl, { 3, 1 }, { 1, 1 }, wxALL, 5);
58
+
59
+	auto detectSilenceLabel = new wxStaticText(this->generalPanel, wxID_ANY, "Detect silence (s)");
60
+	this->generalSizer->Add(detectSilenceLabel, { 4, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
61
+	auto detectSilenceTextCtrl = new wxTextCtrl(this->generalPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, { 38, -1 }, 0, RegExValidator{ XSFConfigDialog::timeRegex, &this->detectSilence, wxRE_ADVANCED });
62
+	this->generalSizer->Add(detectSilenceTextCtrl, { 4, 1 }, { 1, 1 }, wxALL, 5);
63
+
64
+	notebook->AddPage(this->generalPanel, "General");
65
+
66
+	this->outputPanel = new wxPanel(notebook, wxID_ANY);
67
+	this->outputSizer = new wxGridBagSizer;
68
+
69
+	auto volumeLabel = new wxStaticText(this->outputPanel, wxID_ANY, "Volume");
70
+	this->outputSizer->Add(volumeLabel, { 0, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
71
+	auto volumeTextCtrl = new wxTextCtrl(this->outputPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, { 38, -1 }, 0, wxFloatingPointValidator<double>{ &this->volume, wxNUM_VAL_NO_TRAILING_ZEROES });
72
+	this->outputSizer->Add(volumeTextCtrl, { 0, 1 }, { 1, 1 }, wxALL, 5);
73
+
74
+	auto replayGainLabel = new wxStaticText(this->outputPanel, wxID_ANY, "ReplayGain");
75
+	this->outputSizer->Add(replayGainLabel, { 1, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
76
+	wxArrayString replayGainChoices;
77
+	replayGainChoices.Add("Disabled");
78
+	replayGainChoices.Add("Use Volume Tag");
79
+	replayGainChoices.Add("Track");
80
+	replayGainChoices.Add("Album");
81
+	auto replayGainChoice = new wxChoice(this->outputPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, replayGainChoices, 0, wxGenericValidator{ &this->replayGain });
82
+	this->outputSizer->Add(replayGainChoice, { 1, 1 }, { 1, 1 }, wxALL, 5);
83
+
84
+	auto clipProtectLabel = new wxStaticText(this->outputPanel, wxID_ANY, "Clip Protect");
85
+	this->outputSizer->Add(clipProtectLabel, { 2, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
86
+	wxArrayString clipProtectChoices;
87
+	clipProtectChoices.Add("Disabled");
88
+	clipProtectChoices.Add("Track");
89
+	clipProtectChoices.Add("Album");
90
+	auto clipProtectChoice = new wxChoice(this->outputPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, clipProtectChoices, 0, wxGenericValidator{ &this->clipProtect });
91
+	this->outputSizer->Add(clipProtectChoice, { 2, 1 }, { 1, 1 }, wxALL, 5);
92
+
93
+	auto sampleRateLabel = new wxStaticText(this->outputPanel, wxID_ANY, "Sample Rate");
94
+	this->outputSizer->Add(sampleRateLabel, { 3, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
95
+	wxArrayString sampleRateChoices;
96
+	for (auto supportedSampleRate : this->config.GetSupportedSampleRates())
97
+		sampleRateChoices.Add(std::to_string(supportedSampleRate));
98
+	auto sampleRateChoice = new wxChoice(this->outputPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, sampleRateChoices, 0, wxGenericValidator{ &this->sampleRate });
99
+	this->outputSizer->Add(sampleRateChoice, { 3, 1 }, { 1, 1 }, wxALL, 5);
100
+
101
+	notebook->AddPage(this->outputPanel, "Output");
102
+
103
+	auto titleFormatPanel = new wxPanel(notebook, wxID_ANY);
104
+	auto titleFormatSizer = new wxBoxSizer(wxVERTICAL);
105
+
106
+	auto titleFormatPreText = new wxStaticText(titleFormatPanel, wxID_ANY, "NOTE: This is only used if Advanced Title Formatting is disabled in Winamp.");
107
+	titleFormatPreText->Wrap(300);
108
+	titleFormatSizer->Add(titleFormatPreText, 0, wxALL, 5);
109
+
110
+	auto titleFormatTextCtrl = new wxTextCtrl(titleFormatPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, { 225, -1 }, 0, wxGenericValidator{ &this->titleFormat });
111
+	titleFormatSizer->Add(titleFormatTextCtrl, 0, wxALL, 5);
112
+
113
+	auto titleFormatPostText = new wxStaticText(titleFormatPanel, wxID_ANY, "Names between percent symbols (e.g. %game%, %title%) will be replaced with the respective value from the file's tags. "
114
+		"Using square brackets around any items will cause them to only be displayed if there was a replacement done (e.g. [%disc%.] will display 01. if disc was in the tags as 01, but will "
115
+		"display nothing if disc was not in the tags). Square bracket blocks can be nested.");
116
+	titleFormatPostText->Wrap(300);
117
+	titleFormatSizer->Add(titleFormatPostText, 0, wxALL, 5);
118
+
119
+	titleFormatPanel->SetSizer(titleFormatSizer);
120
+	titleFormatPanel->Layout();
121
+	titleFormatSizer->Fit(titleFormatPanel);
122
+	notebook->AddPage(titleFormatPanel, "Title Format");
123
+
124
+	this->mainSizer->Add(notebook, { 0, 0 }, { 1, 2 }, wxALL | wxEXPAND, 5);
125
+
126
+	auto resetDefaults = new wxButton(this, idResetDefaults, "Reset Defaults");
127
+	this->mainSizer->Add(resetDefaults, { 1, 1 }, { 1, 1 }, wxALIGN_RIGHT | wxALL, 5);
128
+	this->Bind(wxEVT_BUTTON, [&](wxCommandEvent &)
129
+	{
130
+		this->config.ResetConfigDefaults(this);
131
+		this->TransferDataToWindow();
132
+	}, idResetDefaults);
133
+
134
+	auto standardButtons = new wxStdDialogButtonSizer;
135
+	auto standardButtonOK = new wxButton(this, wxID_OK);
136
+	standardButtons->AddButton(standardButtonOK);
137
+	auto standardButtonCancel = new wxButton(this, wxID_CANCEL);
138
+	standardButtons->AddButton(standardButtonCancel);
139
+	standardButtons->Realize();
140
+	this->mainSizer->Add(standardButtons, { 2, 0 }, { 1, 2 }, wxBOTTOM | wxEXPAND | wxTOP, 5);
141
+}
142
+
143
+void XSFConfigDialog::Finalize()
144
+{
145
+	this->generalPanel->SetSizer(this->generalSizer);
146
+	this->generalPanel->Layout();
147
+	this->generalSizer->Fit(this->generalPanel);
148
+
149
+	this->outputPanel->SetSizer(this->outputSizer);
150
+	this->outputPanel->Layout();
151
+	this->outputSizer->Fit(this->outputPanel);
152
+
153
+	this->SetSizer(this->mainSizer);
154
+	this->Layout();
155
+	this->mainSizer->Fit(this);
156
+}