From 8545c437badd5cff40f1509f5931d097c8e195c8 Mon Sep 17 00:00:00 2001 From: VoxelTek <53562267+VoxelTek@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:21:44 +1000 Subject: [PATCH] Implement new Config tool --- CONFIG/MainDlg.cpp | 166 +++++++++-- CONFIG/MainDlg.h | 16 +- CONFIG/config.cpp | 21 ++ CONFIG/config.h | 2 + CONFIG/res/maindialog.ui | 604 +++++++++++++++++++++++++++++---------- 5 files changed, 630 insertions(+), 179 deletions(-) diff --git a/CONFIG/MainDlg.cpp b/CONFIG/MainDlg.cpp index a535d658..2e046341 100644 --- a/CONFIG/MainDlg.cpp +++ b/CONFIG/MainDlg.cpp @@ -30,20 +30,38 @@ CMainDialog::CMainDialog(QWidget* pParent) : QDialog(pParent) // Populate the dialog prior to connecting all signals OnInitDialog(); - connect(m_ui->colorPalette16bitRadioButton, &QRadioButton::toggled, this, &CMainDialog::OnRadiobuttonPalette16bit); - connect(m_ui->colorPalette256RadioButton, &QRadioButton::toggled, this, &CMainDialog::OnRadiobuttonPalette256); connect( - m_ui->modelQualityFastRadioButton, + m_ui->colorPalette16bitRadioButton, + &QRadioButton::toggled, + this, + &CMainDialog::OnRadiobuttonPalette16bit + ); + connect( + m_ui->colorPalette256RadioButton, + &QRadioButton::toggled, + this, + &CMainDialog::OnRadiobuttonPalette256 + ); + + connect( + m_ui->modelQualityLowRadioButton, &QRadioButton::toggled, this, &CMainDialog::OnRadiobuttonModelLowQuality ); + connect( + m_ui->modelQualityMediumRadioButton, + &QRadioButton::toggled, + this, + &CMainDialog::OnRadiobuttonModelMediumQuality + ); connect( m_ui->modelQualityHighRadioButton, &QRadioButton::toggled, this, &CMainDialog::OnRadiobuttonModelHighQuality ); + connect( m_ui->textureQualityFastRadioButton, &QRadioButton::toggled, @@ -64,12 +82,25 @@ CMainDialog::CMainDialog(QWidget* pParent) : QDialog(pParent) connect(m_ui->joystickCheckBox, &QCheckBox::toggled, this, &CMainDialog::OnCheckboxJoystick); connect(m_ui->okButton, &QPushButton::clicked, this, &CMainDialog::accept); connect(m_ui->cancelButton, &QPushButton::clicked, this, &CMainDialog::reject); - connect(m_ui->advancedButton, &QPushButton::clicked, this, &CMainDialog::OnButtonAdvanced); + + connect(m_ui->diskPathOpen, &QPushButton::clicked, this, &CMainDialog::SelectDiskPathDialog); + connect(m_ui->cdPathOpen, &QPushButton::clicked, this, &CMainDialog::SelectCDPathDialog); + connect(m_ui->mediaPathOpen, &QPushButton::clicked, this, &CMainDialog::SelectMediaPathDialog); + connect(m_ui->savePathOpen, &QPushButton::clicked, this, &CMainDialog::SelectSavePathDialog); + + connect(m_ui->diskPath, &QLineEdit::textEdited, this, &CMainDialog::DiskPathEdited); + connect(m_ui->cdPath, &QLineEdit::textEdited, this, &CMainDialog::CDPathEdited); + connect(m_ui->mediaPath, &QLineEdit::textEdited, this, &CMainDialog::MediaPathEdited); + connect(m_ui->savePath, &QLineEdit::textEdited, this, &CMainDialog::SavePathEdited); + + connect(m_ui->maxLoDSlider, &QSlider::valueChanged, this, &CMainDialog::MaxLoDChanged); + connect(m_ui->maxActorsSlider, &QSlider::valueChanged, this, &CMainDialog::MaxActorsChanged); + + layout()->setSizeConstraint( QLayout::SetFixedSize ); } // FUNCTION: CONFIG 0x00403e80 bool CMainDialog::OnInitDialog() { - SwitchToAdvanced(false); LegoDeviceEnumerate* enumerator = currentConfigApp->m_device_enumerator; enumerator->FUN_1009d210(); m_modified = currentConfigApp->ReadRegisterSettings(); @@ -172,8 +203,11 @@ void CMainDialog::UpdateInterface() m_ui->colorPalette16bitRadioButton->setEnabled(full_screen && currentConfigApp->GetDeviceRenderBitStatus()); m_ui->sound3DCheckBox->setChecked(currentConfigApp->m_3d_sound); switch (currentConfigApp->m_model_quality) { + case 0: + m_ui->modelQualityLowRadioButton->setChecked(true); + break; case 1: - m_ui->modelQualityFastRadioButton->setChecked(true); + m_ui->modelQualityMediumRadioButton->setChecked(true); break; case 2: m_ui->modelQualityHighRadioButton->setChecked(true); @@ -187,6 +221,10 @@ void CMainDialog::UpdateInterface() } m_ui->joystickCheckBox->setChecked(currentConfigApp->m_use_joystick); m_ui->musicCheckBox->setChecked(currentConfigApp->m_music); + m_ui->diskPath->setText(QString::fromStdString(currentConfigApp->m_base_path)); + m_ui->cdPath->setText(QString::fromStdString(currentConfigApp->m_cd_path)); + m_ui->mediaPath->setText(QString::fromStdString(currentConfigApp->m_media_path)); + m_ui->savePath->setText(QString::fromStdString(currentConfigApp->m_save_path)); } // FUNCTION: CONFIG 0x004045e0 @@ -239,6 +277,17 @@ void CMainDialog::OnRadiobuttonModelLowQuality(bool checked) if (checked) { // FIXME: are OnRadiobuttonModelLowQuality and OnRadiobuttonModelHighQuality triggered both? qInfo() << "OnRadiobuttonModelLowQuality"; + currentConfigApp->m_model_quality = 0; + m_modified = true; + UpdateInterface(); + } +} + +void CMainDialog::OnRadiobuttonModelMediumQuality(bool checked) +{ + if (checked) { + // FIXME: are OnRadiobuttonModelLowQuality and OnRadiobuttonModelHighQuality triggered both? + qInfo() << "OnRadiobuttonModelMediumQuality"; currentConfigApp->m_model_quality = 1; m_modified = true; UpdateInterface(); @@ -288,20 +337,6 @@ void CMainDialog::OnCheckboxJoystick(bool checked) UpdateInterface(); } -// FUNCTION: CONFIG 0x004047c0 -void CMainDialog::OnButtonAdvanced() -{ - SwitchToAdvanced(!m_advanced); -} - -// FUNCTION: CONFIG 0x004047d0 -void CMainDialog::SwitchToAdvanced(bool p_advanced) -{ - m_ui->advancedGroup->setVisible(p_advanced); - layout()->setSizeConstraint(QLayout::SetMinAndMaxSize); - m_advanced = p_advanced; -} - // FUNCTION: CONFIG 0x004048c0 void CMainDialog::OnCheckboxMusic(bool checked) { @@ -309,3 +344,94 @@ void CMainDialog::OnCheckboxMusic(bool checked) m_modified = true; UpdateInterface(); } + + +void CMainDialog::SelectDiskPathDialog() +{ + QString disk_path = QString::fromStdString(currentConfigApp->m_base_path); + disk_path = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + disk_path, + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + currentConfigApp->m_base_path = disk_path.toStdString(); + m_modified = true; + UpdateInterface(); +} + +void CMainDialog::SelectCDPathDialog() +{ + QString cd_path = QString::fromStdString(currentConfigApp->m_cd_path); + cd_path = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + cd_path, + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + currentConfigApp->m_cd_path = cd_path.toStdString(); + m_modified = true; + UpdateInterface(); +} + +void CMainDialog::SelectMediaPathDialog() +{ + QString media_path = QString::fromStdString(currentConfigApp->m_media_path); + media_path = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + media_path, + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + currentConfigApp->m_media_path = media_path.toStdString(); + m_modified = true; + UpdateInterface(); +} + +void CMainDialog::SelectSavePathDialog() +{ + QString save_path = QString::fromStdString(currentConfigApp->m_save_path); + save_path = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + save_path, + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + currentConfigApp->m_save_path = save_path.toStdString(); + m_modified = true; + UpdateInterface(); +} + + +void CMainDialog::DiskPathEdited(QString &text) +{ + currentConfigApp->m_base_path = text.toStdString(); + m_modified = true; + UpdateInterface(); +} + +void CMainDialog::CDPathEdited(QString &text) +{ + currentConfigApp->m_cd_path = text.toStdString(); + m_modified = true; + UpdateInterface(); +} + +void CMainDialog::MediaPathEdited(QString &text) +{ + currentConfigApp->m_media_path = text.toStdString(); + m_modified = true; + UpdateInterface(); +} + +void CMainDialog::SavePathEdited(QString &text) +{ + currentConfigApp->m_save_path = text.toStdString(); + m_modified = true; + UpdateInterface(); +} + + +void CMainDialog::MaxLoDChanged(int value) +{ + currentConfigApp->m_max_lod = static_cast(value) / 10.0f; + m_modified = true; +} + +void CMainDialog::MaxActorsChanged(int value) +{ + currentConfigApp->m_max_actors = value; + m_modified = true; +} diff --git a/CONFIG/MainDlg.h b/CONFIG/MainDlg.h index 21158da0..c0ea9739 100644 --- a/CONFIG/MainDlg.h +++ b/CONFIG/MainDlg.h @@ -6,6 +6,7 @@ #include "res/resource.h" #include +#include namespace Ui { @@ -22,7 +23,6 @@ class CMainDialog : public QDialog { protected: void UpdateInterface(); - void SwitchToAdvanced(bool p_advanced); private: bool m_modified = false; @@ -39,14 +39,24 @@ private slots: void OnRadiobuttonPalette256(bool checked); void OnCheckboxFlipVideoMemPages(bool checked); void OnRadiobuttonModelLowQuality(bool checked); + void OnRadiobuttonModelMediumQuality(bool checked); void OnRadiobuttonModelHighQuality(bool checked); void OnRadiobuttonTextureLowQuality(bool checked); void OnRadiobuttonTextureHighQuality(bool checked); - void OnCheckboxJoystick(bool chedked); + void OnCheckboxJoystick(bool checked); void OnCheckboxMusic(bool checked); - void OnButtonAdvanced(); void accept() override; void reject() override; + void SelectDiskPathDialog(); + void SelectCDPathDialog(); + void SelectMediaPathDialog(); + void SelectSavePathDialog(); + void DiskPathEdited(QString &text); + void CDPathEdited(QString &text); + void MediaPathEdited(QString &text); + void SavePathEdited(QString &text); + void MaxLoDChanged(int value); + void MaxActorsChanged(int value); }; // SYNTHETIC: CONFIG 0x00403de0 diff --git a/CONFIG/config.cpp b/CONFIG/config.cpp index b00bece1..81c9e965 100644 --- a/CONFIG/config.cpp +++ b/CONFIG/config.cpp @@ -74,16 +74,22 @@ bool CConfigApp::InitInstance() m_3d_sound = FALSE; m_model_quality = 0; m_texture_quality = 1; + m_max_lod = 1.5f; + m_max_actors = 5; } else if (totalRamMiB < 20) { m_3d_sound = FALSE; m_model_quality = 1; m_texture_quality = 1; + m_max_lod = 2.5f; + m_max_actors = 10; } else { m_model_quality = 2; m_3d_sound = TRUE; m_texture_quality = 1; + m_max_lod = 3.5f; + m_max_actors = 20; } return true; } @@ -149,6 +155,8 @@ bool CConfigApp::ReadRegisterSettings() m_use_joystick = iniparser_getboolean(dict, "isle:UseJoystick", m_use_joystick); m_music = iniparser_getboolean(dict, "isle:Music", m_music); m_joystick_index = iniparser_getint(dict, "isle:JoystickIndex", m_joystick_index); + m_max_lod = iniparser_getdouble(dict, "isle:Max LOD", m_max_lod); + m_max_actors = iniparser_getint(dict, "isle:Max Allowed Extras", m_max_actors); return true; } @@ -211,6 +219,16 @@ bool CConfigApp::ValidateSettings() m_texture_quality = 0; is_modified = TRUE; } + + if (m_max_lod < 0.0f || m_max_lod > 5.0f) { + m_max_lod = 3.5f; + is_modified = TRUE; + } + if (m_max_actors < 5 || m_max_actors > 40) { + m_max_actors = 20; + is_modified = TRUE; + } + return is_modified; } @@ -303,6 +321,9 @@ void CConfigApp::WriteRegisterSettings() const SetIniInt(dict, "isle:Island Quality", m_model_quality); SetIniInt(dict, "isle:Island Texture", m_texture_quality); + iniparser_set(dict, "isle:Max LOD", (const char)m_max_lod); + SetIniInt(dict, "isle:Max Allowed Extras", m_max_actors); + #undef SetIniBool #undef SetIniInt diff --git a/CONFIG/config.h b/CONFIG/config.h index 687da4d3..276dc755 100644 --- a/CONFIG/config.h +++ b/CONFIG/config.h @@ -79,6 +79,8 @@ class CConfigApp { std::string m_cd_path; std::string m_media_path; std::string m_save_path; + float m_max_lod; + int m_max_actors; }; extern CConfigApp g_theApp; diff --git a/CONFIG/res/maindialog.ui b/CONFIG/res/maindialog.ui index a3bec12e..aae18e52 100644 --- a/CONFIG/res/maindialog.ui +++ b/CONFIG/res/maindialog.ui @@ -6,8 +6,8 @@ 0 0 - 549 - 563 + 575 + 750 @@ -27,7 +27,7 @@ - + 0 0 @@ -35,7 +35,13 @@ 143 - 545 + 383 + + + + + 16777215 + 16777215 @@ -45,81 +51,216 @@ :/shark.png - true + false - - 0 - - - 0 - - - 0 - - - 0 - - + 0 - 41 + 0 - + + + + + + + + + + + + 0 + 0 + + + + + 55 + 16777215 + + + + Open + + + + + + + + 0 + 0 + + + + + 55 + 16777215 + + + + Open + + + + + + + + 0 + 0 + + + + + 55 + 16777215 + + + + Open + + + + + + + + 0 + 0 + + + + CD Path: + + + Qt::PlainText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 0 + + + + + 55 + 16777215 + + + + Open + + + + + + + + 0 + 0 + + + + Disk Path: + + + Qt::PlainText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Save Path: + + + Qt::PlainText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + Media Path: + + + Qt::PlainText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + 0 + 80 + + + 0 - - 0 - 0 - - 0 - - - - - Island Texture Quality - - - - 0 - - - 0 - - - - - Fast - - - - - - - High - - - - - - - + + + + 16777215 + 120 + + Island Model Quality - + @@ -144,107 +285,121 @@ - - - - Color Palette + + + + + 0 + 70 + - - - 0 - - - 0 - + + Maximum Level of Detail (LOD). A higher setting will cause higher quality textures to be drawn regardless of distance. + + + Maximum LOD + + + Qt::AlignCenter + + - - - 256 Color + + + 50 - - - - - - High Color (16 bit) + + 5 - - - - - - - - - - 0 - - - 0 - - - - - 3D Sound + + 10 - - - - - - Music + + 35 - - - - - - Use Joystick - - - - - - - - - - - 30 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Advanced - - - - - - - OK - - + true + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 10 + + + + + + + + + + Island Texture Quality + + + + 0 + + + 0 + + + + + Fast + - + - Cancel + High + + + + + + + + + + Maximum number of LEGO actors to exist in the world at a time. The game will gradually increase the number of actors until this maximum is reached and while performance is acceptable. + + + Maximum Actors (5..40) + + + Qt::AlignCenter + + + + + + 5 + + + 40 + + + 5 + + + 20 + + + 20 + + + Qt::Horizontal + + + QSlider::TicksBothSides + + + 5 @@ -255,9 +410,89 @@ - + + + + 0 + 60 + + - Advanced Settings + Color Palette + + + + 0 + + + 0 + + + + + 256 Color + + + + + + + High Color (16 bit) + + + + + + + + + + + 0 + + + 0 + + + + + 3D Sound + + + + + + + Music + + + + + + + Use Joystick + + + + + + + + + + + 16777215 + 225 + + + + + + + Qt::AlignCenter + + + false @@ -293,6 +528,12 @@ true + + + 16777215 + 125 + + QAbstractItemView::NoEditTriggers @@ -306,7 +547,13 @@ - + + + 0 + 20 + + + 0 @@ -319,13 +566,6 @@ 0 - - - - Draw 3D to Video Memory - - - @@ -333,12 +573,64 @@ + + + + Draw 3D to Video Memory + + + + + + + + 30 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + OK + + + true + + + + + + + PushButton + + + + + + + Cancel + + + + + +