Skip to content

Commit 881e2cf

Browse files
committed
if defined consistency and general fixes
1 parent 700cb19 commit 881e2cf

11 files changed

+83
-41
lines changed

src/controllerconfig.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
ControllerConfig::ControllerConfig(const QString& guid, QObject* parent)
88
: QObject(parent) {
9-
#ifndef GAME_ANONYMOUSCODE
9+
#if !defined(GAME_ANONYMOUSCODE)
1010
_path = rbApp->gameConfigDirectory() + "/" + guid;
1111

1212
loadDefaults();
@@ -37,7 +37,7 @@ ControllerConfig::ControllerConfig(const QString& guid, QObject* parent)
3737
}
3838

3939
void ControllerConfig::loadDefaults() {
40-
#ifndef GAME_ANONYMOUSCODE
40+
#if !defined(GAME_ANONYMOUSCODE)
4141
preset = Preset::Default;
4242

4343
binds[(int)Bind::Enter] = Button::A;
@@ -55,7 +55,7 @@ void ControllerConfig::loadDefaults() {
5555
}
5656

5757
void ControllerConfig::save() {
58-
#ifndef GAME_ANONYMOUSCODE
58+
#if !defined(GAME_ANONYMOUSCODE)
5959
QFile outFile(_path);
6060
if (!outFile.open(QIODevice::WriteOnly)) {
6161
QMessageBox::critical(0, "Launcher error",
@@ -66,7 +66,7 @@ void ControllerConfig::save() {
6666
outFile.write((const char*)&preset, 4);
6767
outFile.write((const char*)&binds, (qint64)Bind::Num);
6868
#endif
69-
#ifdef GAME_CHAOSCHILD
69+
#if defined(GAME_CHAOSCHILD)
7070
outFile.write((const char*)game_ExtraControllerData,
7171
sizeof(game_ExtraControllerData));
7272
#endif

src/controllertab.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ QMap<ControllerConfig::Bind, QString> bindLabelTexts{
2727
{ControllerConfig::Bind::Custom1, game_Custom1ButtonLabel},
2828
{ControllerConfig::Bind::Custom2, game_Custom2ButtonLabel}};
2929

30-
#ifndef GAME_ANONYMOUSCODE
30+
#if !defined(GAME_ANONYMOUSCODE)
3131
QString buttonToText(ControllerConfig::Button btn) {
3232
if (btn == ControllerConfig::Button::Invalid) return "";
3333

@@ -41,7 +41,7 @@ QString buttonToText(ControllerConfig::Button btn) {
4141
#endif
4242

4343
ControllerTab::ControllerTab(QWidget *parent) : QWidget(parent) {
44-
#ifndef GAME_ANONYMOUSCODE
44+
#if !defined(GAME_ANONYMOUSCODE)
4545
QVBoxLayout *mainLayout = new QVBoxLayout(this);
4646
mainLayout->setSpacing(12);
4747
mainLayout->setMargin(0);
@@ -141,7 +141,7 @@ ControllerTab::ControllerTab(QWidget *parent) : QWidget(parent) {
141141
}
142142

143143
void ControllerTab::showEvent(QShowEvent *e) {
144-
#ifndef GAME_ANONYMOUSCODE
144+
#if !defined(GAME_ANONYMOUSCODE)
145145
QWidget::showEvent(e);
146146
if (_firstShowCaught) return;
147147
_firstShowCaught = true;
@@ -172,7 +172,7 @@ void ControllerTab::showEvent(QShowEvent *e) {
172172
}
173173

174174
void ControllerTab::setConfig() {
175-
#ifndef GAME_ANONYMOUSCODE
175+
#if !defined(GAME_ANONYMOUSCODE)
176176
if (_controllerCb->isChecked()) {
177177
rbApp->patchConfig()->controllerEnabled = true;
178178
if (rbApp->controllerManager()->activeController() != nullptr) {
@@ -190,7 +190,7 @@ void ControllerTab::setConfig() {
190190
}
191191

192192
void ControllerTab::reloadData() {
193-
#ifndef GAME_ANONYMOUSCODE
193+
#if !defined(GAME_ANONYMOUSCODE)
194194
_controllerCb->setChecked(rbApp->patchConfig()->controllerEnabled);
195195
if (rbApp->controllerManager()->activeController() != nullptr) {
196196
for (int i = 0; i < (int)ControllerConfig::Bind::Num; i++) {
@@ -204,25 +204,23 @@ void ControllerTab::reloadData() {
204204
}
205205

206206
BtnRow *ControllerTab::findFocusedBtnRow() {
207-
#ifndef GAME_ANONYMOUSCODE
208207
QWidget *fw = rbApp->focusWidget();
209208
BtnRow *br = nullptr;
210209
while (fw != nullptr && (br = qobject_cast<BtnRow *>(fw)) == nullptr) {
211210
fw = fw->parentWidget();
212211
}
213212
return br;
214-
#endif
215213
}
216214

217215
void ControllerTab::resetButtonClicked() {
218-
#ifndef GAME_ANONYMOUSCODE
216+
#if !defined(GAME_ANONYMOUSCODE)
219217
rbApp->controllerManager()->activeController()->config()->loadDefaults();
220218
reloadData();
221219
#endif
222220
}
223221

224222
void ControllerTab::controllerSelected(int index) {
225-
#ifndef GAME_ANONYMOUSCODE
223+
#if !defined(GAME_ANONYMOUSCODE)
226224
rbApp->controllerManager()->setActiveController(
227225
_controllerBox->currentData().toString());
228226
rbApp->patchConfig()->selectedController =
@@ -232,7 +230,7 @@ void ControllerTab::controllerSelected(int index) {
232230

233231
void ControllerTab::onActiveControllerChanged(DinputController *oldController,
234232
DinputController *newController) {
235-
#ifndef GAME_ANONYMOUSCODE
233+
#if !defined(GAME_ANONYMOUSCODE)
236234
if (oldController != nullptr) {
237235
disconnect(oldController, 0, this, 0);
238236
oldController->stopTracking();
@@ -269,7 +267,7 @@ void ControllerTab::updateAxesLabel() {
269267
}
270268

271269
void ControllerTab::onButtonPressed(ControllerConfig::Button button) {
272-
#ifndef GAME_ANONYMOUSCODE
270+
#if !defined(GAME_ANONYMOUSCODE)
273271
BtnRow *br = findFocusedBtnRow();
274272
if (br != nullptr) {
275273
auto &confBinds =

src/dinputcontroller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class ControllerManager;
1313

14-
#ifndef SAFE_RELEASE
14+
#if !defined(SAFE_RELEASE)
1515
#define SAFE_RELEASE(p) \
1616
{ \
1717
if (p) { \

src/gameconfig.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <QMessageBox>
55

66
GameConfig::GameConfig(QObject* parent) : QObject(parent) {
7-
#ifndef GAME_ANONYMOUSCODE
7+
#if !defined(GAME_ANONYMOUSCODE)
88
_path = rbApp->gameConfigDirectory() + "/config.dat";
99

1010
loadDefaults();
@@ -34,15 +34,17 @@ GameConfig::GameConfig(QObject* parent) : QObject(parent) {
3434
uint32_t movieQuality_ = *(const uint32_t*)(data + 0x44);
3535
if (movieQuality_ < (uint32_t)MovieQuality::Num)
3636
movieQuality = (MovieQuality)movieQuality_;
37+
#if defined(GAME_CHAOSHEADNOAH)
3738
language = *(const Language*)(data + 0x48);
3839
uint32_t language_ = *(const uint32_t*)(data + 0x48);
3940
if (language_ < (uint32_t)Language::Num) language = (Language)language_;
41+
#endif
4042
}
4143
#endif
4244
}
4345

4446
void GameConfig::save() {
45-
#ifndef GAME_ANONYMOUSCODE
47+
#if !defined(GAME_ANONYMOUSCODE)
4648
QFile outFile(_path);
4749
if (!outFile.open(QIODevice::WriteOnly)) {
4850
QMessageBox::critical(0, "Launcher error",
@@ -61,20 +63,24 @@ void GameConfig::save() {
6163
outFile.write((const char*)&startWindowX, 4);
6264
outFile.write((const char*)&startWindowY, 4);
6365
outFile.write((const char*)&movieQuality, 4);
66+
#if defined(GAME_CHAOSHEADNOAH)
6467
outFile.write((const char*)&language, 4);
68+
#endif
6569
outFile.seek(0x6C); // padding
6670
#endif
6771
}
6872

6973
void GameConfig::loadDefaults() {
70-
#ifndef GAME_ANONYMOUSCODE
74+
#if !defined(GAME_ANONYMOUSCODE)
7175
width = 1280;
7276
height = 720;
7377
displayMode = DisplayMode::Windowed;
7478
resolution = Resolution::Res720p;
7579
startWindowX = 0;
7680
startWindowY = 0;
81+
#if defined(GAME_CHAOSHEADNOAH)
7782
language = Language::English;
83+
#endif
7884
movieQuality = MovieQuality::Low720p;
7985
#endif
8086
}

src/gameconfig.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ class GameConfig : public QObject {
66
Q_OBJECT
77

88
public:
9-
#ifndef GAME_ANONYMOUSCODE
9+
#if !defined(GAME_CHAOSHEADNOAH) && !defined(GAME_ROBOTICSNOTESELITE) && \
10+
!defined(GAME_ROBOTICSNOTESDASH) && !defined(GAME_ANONYMOUSCODE)
1011
enum class MovieQuality : uint32_t{High1080p = 0, Low720p = 1, Num};
1112
Q_ENUM(MovieQuality)
1213
#endif
@@ -54,7 +55,8 @@ class GameConfig : public QObject {
5455
int startWindowX;
5556
int startWindowY;
5657
Language language;
57-
#ifndef GAME_ANONYMOUSCODE
58+
#if !defined(GAME_CHAOSHEADNOAH) && !defined(GAME_ROBOTICSNOTESELITE) && \
59+
!defined(GAME_ROBOTICSNOTESDASH) && !defined(GAME_ANONYMOUSCODE)
5860
MovieQuality movieQuality;
5961
#endif
6062
QString controllerGuid = QString();

src/generaltab.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ GeneralTab::GeneralTab(QWidget *parent) : QWidget(parent) {
9494
}
9595

9696
#if !defined(GAME_CHAOSHEADNOAH) && !defined(GAME_ROBOTICSNOTESELITE) && \
97-
!defined(GAME_ROBOTICSNOTESDASH)
97+
!defined(GAME_ROBOTICSNOTESDASH) && !defined(GAME_ANONYMOUSCODE)
9898
_outlineCb = new QCheckBox("Improve dialogue outlines", this);
9999
mainLayout->addWidget(_outlineCb);
100100
#endif
@@ -104,15 +104,19 @@ GeneralTab::GeneralTab(QWidget *parent) : QWidget(parent) {
104104
new QCheckBox("Use solid black text for names in RINE", this);
105105
mainLayout->addWidget(_rineBlackNamesCb);
106106
}
107+
#if defined(GAME_ANONYMOUSCODE)
108+
_voiceSubsCb = new QCheckBox("Enable subtitles for voice-only lines", this);
109+
mainLayout->addWidget(_voiceSubsCb);
110+
#endif
107111

108112
mainLayout->addSpacing(16);
109113

114+
#if !defined(GAME_CHAOSHEADNOAH) && !defined(GAME_ROBOTICSNOTESELITE) && \
115+
!defined(GAME_ROBOTICSNOTESDASH) && !defined(GAME_ANONYMOUSCODE)
110116
QLabel *fmvLabel = new QLabel(this);
111117
fmvLabel->setText("<b>Videos</b>");
112118
mainLayout->addWidget(fmvLabel);
113119

114-
#if !defined(GAME_CHAOSHEADNOAH) && !defined(GAME_ROBOTICSNOTESELITE) && \
115-
!defined(GAME_ROBOTICSNOTESDASH) && !defined(GAME_ANONYMOUSCODE)
116120
QHBoxLayout *movieQualityRow = new QHBoxLayout(this);
117121
movieQualityRow->setSpacing(8);
118122
movieQualityRow->setMargin(0);
@@ -157,6 +161,7 @@ GeneralTab::GeneralTab(QWidget *parent) : QWidget(parent) {
157161
#endif
158162

159163
mainLayout->addStretch(1);
164+
#if defined(GAME_STEINSGATE)
160165
if (rbApp->patchConfig()->hasCosplayPatch) {
161166
_cosplayPatch = new QCheckBox(
162167
"Enable Cosplay Patch\n(Mayuri's Tutturu beam has been fired?! Its "
@@ -165,6 +170,7 @@ GeneralTab::GeneralTab(QWidget *parent) : QWidget(parent) {
165170
mainLayout->addWidget(_cosplayPatch);
166171
}
167172
mainLayout->addStretch(1);
173+
#endif
168174
reloadData();
169175
}
170176

@@ -175,12 +181,12 @@ void GeneralTab::setConfig() {
175181
? GameConfig::DisplayMode::Fullscreen
176182
: GameConfig::DisplayMode::Windowed;
177183

178-
#ifdef GAME_CHAOSHEADNOAH
184+
#if defined(GAME_CHAOSHEADNOAH)
179185
rbApp->gameConfig()->language =
180186
(GameConfig::Language)_languageGroup->checkedId();
181187
#endif
182188

183-
#ifdef GAME_ANONYMOUSCODE
189+
#if defined(GAME_ANONYMOUSCODE)
184190
rbApp->patchConfig()->voiceSubs = _voiceSubsCb->isChecked();
185191
#endif
186192

@@ -199,12 +205,14 @@ void GeneralTab::setConfig() {
199205
if (rbApp->patchConfig()->hasrineBlackNames) {
200206
rbApp->patchConfig()->rineBlackNames = _rineBlackNamesCb->isChecked();
201207
}
208+
#if !defined(GAME_ANONYMOUSCODE)
202209
rbApp->patchConfig()->karaokeSubs =
203210
PatchConfig::SongSubsOptions[_songSubsComboBox->currentData().toInt()];
211+
#endif
204212
if (rbApp->patchConfig()->hasCosplayPatch) {
205213
rbApp->patchConfig()->cosplayPatch = _cosplayPatch->isChecked();
206214
}
207-
#ifdef defined(GAME_ROBOTICSNOTESELITE) || defined(GAME_ROBOTICSNOTESDASH)
215+
#if defined(GAME_ROBOTICSNOTESELITE) || defined(GAME_ROBOTICSNOTESDASH)
208216
rbApp->patchConfig()->rneMouseControls = _rneMouseControls->isChecked();
209217
rbApp->patchConfig()->scrollDownToAdvanceText =
210218
_scrollDownToAdvanceText->isChecked();
@@ -215,7 +223,7 @@ void GeneralTab::setConfig() {
215223
rbApp->patchConfig()->swimsuitPatch = _swimsuitPatch->isChecked();
216224
#endif
217225
#if !defined(GAME_CHAOSHEADNOAH) && !defined(GAME_ROBOTICSNOTESELITE) && \
218-
!defined(GAME_ROBOTICSNOTESDASH)
226+
!defined(GAME_ROBOTICSNOTESDASH) && !defined(GAME_ANONYMOUSCODE)
219227
rbApp->patchConfig()->hqFmvAudio = _hqAudioCb->isChecked();
220228
#endif
221229
}

src/generaltab.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class GeneralTab : public QWidget {
1818
private:
1919
QComboBox* _resolutionComboBox;
2020
QCheckBox* _fullscreenCb;
21-
#ifndef GAME_ANONYMOUSCODE
2221
#if defined(GAME_CHAOSHEADNOAH)
2322
QButtonGroup* _languageGroup;
2423
#endif
@@ -38,5 +37,7 @@ class GeneralTab : public QWidget {
3837
#if defined(GAME_ROBOTICSNOTESDASH)
3938
QCheckBox* _swimsuitPatch;
4039
#endif
40+
#if defined(GAME_ANONYMOUSCODE)
41+
QCheckBox* _voiceSubsCb;
4142
#endif
4243
};

src/globals.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,30 @@ const uint32_t game_ipcIn = 0x23F4F1DE;
162162
const uint32_t game_ipcOut = 0xF0973746;
163163
const wchar_t game_ipcName[] = L"ROBOTICS;NOTES DaSH";
164164
#endif
165+
#endif
166+
167+
#if defined(GAME_ANONYMOUSCODE)
168+
const uint8_t game_ExtraControllerData[] = {
169+
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x28, 0x02, 0x01, 0x00, 0x05,
170+
0x09, 0x08, 0x04, 0x03, 0x0B, 0x06, 0x07, 0x00, 0x00, 0x00};
171+
const QString game_Custom1ButtonLabel = "Unused";
172+
const QString game_Custom2ButtonLabel = "Unused";
173+
const QString game_ReleaseUrl =
174+
"https://github.com/CommitteeOfZero/ac-patch/releases";
175+
#if defined(GAME_STEAM)
176+
const QString game_LauncherTitle =
177+
"ANONYMOUS;CODE Improvement Patch (Steam) Launcher";
178+
const QString game_PatchConfPath = "Committee of Zero/ACSteam";
179+
const QString game_GameConfPath = "mages_steam/ANONYMOUS;CODE";
180+
const QString game_LaunchCommand = "game.exe";
181+
#else
182+
const QString game_LauncherTitle = "ANONYMOUS;CODE Improvement Patch Launcher";
183+
const QString game_PatchConfPath = "Committee of Zero/AC";
184+
const QString game_GameConfPath = "mages_dmm/ANONYMOUS;CODE";
185+
const QString game_LaunchCommand = "game.exe";
186+
#define IPC_ENABLED
187+
const uint32_t game_ipcIn = 0x23F4F1DE;
188+
const uint32_t game_ipcOut = 0xF0973746;
189+
const wchar_t game_ipcName[] = L"ANONYMOUS;CODE";
190+
#endif
165191
#endif

src/launcherwindow.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QtConcurrent>
2424
#include <QFuture>
2525
#include <QFutureWatcher>
26+
#include <QMovie>
2627

2728
// https://curl.haxx.se/libcurl/c/getinmemory.html
2829
struct MemoryStruct {
@@ -56,7 +57,7 @@ LauncherWindow::LauncherWindow(QWidget *parent)
5657
ui->setupUi(this);
5758

5859
if (QFileInfo(":/assets/start_button.png").exists()) {
59-
#ifdef GAME_ANONYMOUSCODE
60+
#if defined(GAME_ANONYMOUSCODE)
6061
QMovie *gifIcon = new QMovie(this);
6162
gifIcon->setFileName(":/assets/start_button.png");
6263
connect(gifIcon, &QMovie::frameChanged,
@@ -124,7 +125,7 @@ LauncherWindow::LauncherWindow(QWidget *parent)
124125
"underline; color: #fff'>Technical Support</span></a>")
125126
.arg(game_TechSupportUrl));
126127

127-
#ifdef GAME_ANONYMOUSCODE
128+
#if defined(GAME_ANONYMOUSCODE)
128129
QString version = "1.0.1";
129130
#else
130131
QFile patchdefFile("languagebarrier/patchdef.json");
@@ -205,7 +206,7 @@ void LauncherWindow::startGame() {
205206

206207
saveChanges();
207208

208-
#ifdef IPC_ENABLED
209+
#if defined(IPC_ENABLED)
209210
volatile void *ipc;
210211
HANDLE ipcFile;
211212
ipcFile = CreateFileMappingW(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 8,
@@ -214,7 +215,7 @@ void LauncherWindow::startGame() {
214215
((volatile uint32_t *)ipc)[1] = game_ipcOut;
215216
#endif
216217

217-
#ifdef GAME_ANONYMOUSCODE
218+
#if defined(IGAME_ANONYMOUSCODE)
218219
if (rbApp->patchConfig()->voiceSubs) {
219220
QFile file("./c0_subs_disabled.nut");
220221
file.rename("./c0_subs.nut");
@@ -273,7 +274,7 @@ void LauncherWindow::startGame() {
273274
"cmd", QStringList() << "/c" << "start " + game_LaunchCommand);
274275
#endif
275276

276-
#ifdef IPC_ENABLED
277+
#if defined(IPC_ENABLED)
277278
QElapsedTimer timer;
278279
bool started = false;
279280
timer.start();

0 commit comments

Comments
 (0)