diff --git a/src/editor/dialogs/globalgamesettingsdialog.cpp b/src/editor/dialogs/globalgamesettingsdialog.cpp index de5ee14..a73825c 100644 --- a/src/editor/dialogs/globalgamesettingsdialog.cpp +++ b/src/editor/dialogs/globalgamesettingsdialog.cpp @@ -5,9 +5,10 @@ #include #include -GlobalGameSettingsDialog::GlobalGameSettingsDialog(QWidget *parent) : +GlobalGameSettingsDialog::GlobalGameSettingsDialog(GlobalGameSettings &globalGameSettings, QWidget *parent) : QDialog{parent}, - m_ui{std::make_unique()} + m_ui{std::make_unique()}, + m_globalGameSettings{globalGameSettings} { m_ui->setupUi(this); @@ -18,6 +19,14 @@ GlobalGameSettingsDialog::GlobalGameSettingsDialog(QWidget *parent) : updateTitle(); + QWidget* widgets[]{ m_ui->widgetResolution, m_ui->widgetCustomProgressBar }; + for (QWidget *widget : widgets) + { + QSizePolicy sp_retain = widget->sizePolicy(); + sp_retain.setRetainSizeWhenHidden(true); + widget->setSizePolicy(sp_retain); + } + if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok)) button->setIcon(QIcon{":/qtgameengine/icons/ok.png"}); if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel)) diff --git a/src/editor/dialogs/globalgamesettingsdialog.h b/src/editor/dialogs/globalgamesettingsdialog.h index 2001a25..0e06e6e 100644 --- a/src/editor/dialogs/globalgamesettingsdialog.h +++ b/src/editor/dialogs/globalgamesettingsdialog.h @@ -5,13 +5,14 @@ #include namespace Ui { class GlobalGameSettingsDialog; } +class GlobalGameSettings; class GlobalGameSettingsDialog : public QDialog { Q_OBJECT public: - explicit GlobalGameSettingsDialog(QWidget *parent = nullptr); + explicit GlobalGameSettingsDialog(GlobalGameSettings &globalGameSettings, QWidget *parent = nullptr); ~GlobalGameSettingsDialog(); void accept() override; @@ -25,5 +26,7 @@ private: const std::unique_ptr m_ui; + GlobalGameSettings &m_globalGameSettings; + bool m_unsavedChanges{}; }; diff --git a/src/editor/dialogs/globalgamesettingsdialog.ui b/src/editor/dialogs/globalgamesettingsdialog.ui index d563bcf..5e409ea 100644 --- a/src/editor/dialogs/globalgamesettingsdialog.ui +++ b/src/editor/dialogs/globalgamesettingsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 426 - 556 + 511 + 608 @@ -21,13 +21,13 @@ - Graphics + &Graphics - Start in full-screen mode + Start in &full-screen mode @@ -65,6 +65,9 @@ Keep aspect ratio + + true + @@ -95,7 +98,7 @@ - Interpolate colors between pixels + &Interpolate colors between pixels @@ -136,49 +139,55 @@ - Allow the player to resize the game window + &Allow the player to resize the game window - Let the game window always stay on top + Le&t the game window always stay on top - Don't draw a border in windowed mode + Don't draw a &border in windowed mode - Don't show the buttons in the window caption + Don't &show the buttons in the window caption - Display the cursor + Display the c&ursor + + + true - Freeze the game when the form loses focus + &Freeze the game when the form loses focus - Disable screensavers and power saving actions + &Disable screensavers and power saving actions + + + true @@ -199,12 +208,249 @@ - Resolution + &Resolution + + + + + Set the &resolution of the screen + + + + + + + false + + + + + + + + Color Depth + + + + + + No Change + + + true + + + + + + + 16-bit + + + + + + + 32-bit + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Resolution + + + + + + No Change + + + true + + + + + + + 320x240 + + + + + + + 640x480 + + + + + + + 800x600 + + + + + + + 1024x768 + + + + + + + 1280x1024 + + + + + + + RadioButton + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Frequency + + + + + + No Change + + + true + + + + + + + 60 + + + + + + + 70 + + + + + + + 85 + + + + + + + 100 + + + + + + + 120 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + &Use synchronization to avoid tearing + + + + + + + Qt::Vertical + + + + 20 + 138 + + + + + - Other + &Other @@ -216,42 +462,77 @@ - Let <Esc> end the game + Let <Esc> en&d the game + + + true - - - Treat the close button as <Esc> key - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &Treat the close button as <Esc> key + + + true + + + + - Let <F1> show the game information + Let <F1> show the game i&nformation + + + true - Let <F4> switch between screen modes + Let <F4> s&witch between screen modes + + + true - Let <F5> save the game and <F6> load a game + Let <F5> s&ave the game and <F6> load a game + + + true - Let <F9> take a screenshot of the game + Let <F9> take a &screenshot of the game + + + true @@ -269,6 +550,9 @@ Normal + + true + @@ -307,7 +591,11 @@ - + + + 1 + + @@ -413,18 +701,403 @@ - Loading + &Loading + + + + + Show your own i&mage while loading + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Ch&ange Image + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Make image partially transparent + + + + + + + + + Make translucent with &alpha value: + + + spinBoxLoadingImageAlpha + + + + + + + 255 + + + 255 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + No loading progress bar + + + + + + + Default loading progress bar + + + true + + + + + + + Own loading progress bar + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + false + + + + + + &Back Image + + + + + + + &Front Image + + + + + + + + + + Scale progress bar image + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Game Icon: + + + + + + + TextLabel + + + + + + + PushButton + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Ga&me Identifier: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - Errors + &Errors + + + + + &Display error messages + + + + + + + &Write error messages to game_errors.log + + + + + + + &Abort on all error messages + + + + + + + &Treat uninitialized variables as value 0 + + + + + + + Throw an error when arguments aren't initialized correctly + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - Info + In&fo + + + + + + + Author: + + + lineEditAuthor + + + + + + + + + + Version: + + + lineEditVersion + + + + + + + 100 + + + + + + + Last Changed: + + + dateTimeEditLastChanged + + + + + + + + + + + + Information: + + + plainTextEditInformation + + + + + + + @@ -446,8 +1119,8 @@ accept() - 184 - 506 + 193 + 598 184 @@ -462,8 +1135,8 @@ reject() - 184 - 506 + 193 + 598 184 @@ -471,5 +1144,37 @@ + + checkBoxResolution + toggled(bool) + widgetResolution + setVisible(bool) + + + 255 + 59 + + + 110 + 68 + + + + + radioButtonProgressbarCustom + toggled(bool) + widgetCustomProgressBar + setVisible(bool) + + + 255 + 267 + + + 173 + 309 + + + diff --git a/src/editor/mainwindow.cpp b/src/editor/mainwindow.cpp index f7eb247..97e1135 100644 --- a/src/editor/mainwindow.cpp +++ b/src/editor/mainwindow.cpp @@ -740,7 +740,7 @@ void MainWindow::showGameInformation() void MainWindow::showGlobalGameSettings() { - GlobalGameSettingsDialog dialog{this}; + GlobalGameSettingsDialog dialog{m_project.globalGameSettings, this}; if (dialog.exec() == QDialog::Accepted) changed(); } diff --git a/src/projectcontainer.h b/src/projectcontainer.h index 84e6e50..b3554ab 100644 --- a/src/projectcontainer.h +++ b/src/projectcontainer.h @@ -12,6 +12,31 @@ struct GlobalGameSettings { + bool startInFullscreenMode{}; + struct FixedScale { + int percent{100}; + }; + struct KeepAspectRatio { + }; + struct FullScale { + }; + std::variant scaling{ + KeepAspectRatio{} + }; + bool interpolateBetweenColors{}; + QColor colorOutsideRoomRegion; + bool resizable{}; + bool topMost{}; + bool noBorder{}; + bool noButtons{}; + bool displayCursor{true}; + bool freezeWhenFocusLost{}; + bool disableScreensaver{true}; + struct Resolution { + + }; + std::optional resolution; + bool vsync{}; }; struct Sprite diff --git a/src/projectserialization.cpp b/src/projectserialization.cpp index ea99f62..f6e0416 100644 --- a/src/projectserialization.cpp +++ b/src/projectserialization.cpp @@ -4,15 +4,91 @@ QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings &globalGameSettings) { - Q_UNUSED(globalGameSettings); - //ds << globalGameSettings.; + ds << globalGameSettings.startInFullscreenMode + << globalGameSettings.scaling + << globalGameSettings.interpolateBetweenColors + << globalGameSettings.colorOutsideRoomRegion + << globalGameSettings.resizable + << globalGameSettings.topMost + << globalGameSettings.noBorder + << globalGameSettings.noButtons + << globalGameSettings.displayCursor + << globalGameSettings.freezeWhenFocusLost + << globalGameSettings.disableScreensaver + << globalGameSettings.resolution + << globalGameSettings.vsync; return ds; } QDataStream &operator>>(QDataStream &ds, GlobalGameSettings &globalGameSettings) { - Q_UNUSED(globalGameSettings); - //ds >> globalGameSettings.; + ds >> globalGameSettings.startInFullscreenMode + >> globalGameSettings.scaling + >> globalGameSettings.interpolateBetweenColors + >> globalGameSettings.colorOutsideRoomRegion + >> globalGameSettings.resizable + >> globalGameSettings.topMost + >> globalGameSettings.noBorder + >> globalGameSettings.noButtons + >> globalGameSettings.displayCursor + >> globalGameSettings.freezeWhenFocusLost + >> globalGameSettings.disableScreensaver + >> globalGameSettings.resolution + >> globalGameSettings.vsync; + return ds; +} + +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::FixedScale &fixedScale) +{ + ds << fixedScale.percent; + return ds; +} + +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::FixedScale &fixedScale) +{ + ds >> fixedScale.percent; + return ds; +} + +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::KeepAspectRatio &keepAspectRatio) +{ + Q_UNUSED(keepAspectRatio); + //ds << keepAspectRatio.; + return ds; +} + +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::KeepAspectRatio &keepAspectRatio) +{ + Q_UNUSED(keepAspectRatio); + //ds >> keepAspectRatio.; + return ds; +} + +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::FullScale &fullScale) +{ + Q_UNUSED(fullScale); + //ds << fullScale.; + return ds; +} + +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::FullScale &fullScale) +{ + Q_UNUSED(fullScale); + //ds >> fullScale.; + return ds; +} + +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::Resolution &resolution) +{ + Q_UNUSED(resolution); + //ds << resolution.; + return ds; +} + +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::Resolution &resolution) +{ + Q_UNUSED(resolution); + //ds >> resolution.; return ds; } diff --git a/src/projectserialization.h b/src/projectserialization.h index 3cd9c65..3e97a6c 100644 --- a/src/projectserialization.h +++ b/src/projectserialization.h @@ -6,6 +6,14 @@ QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings &globalGameSettings); QDataStream &operator>>(QDataStream &ds, GlobalGameSettings &globalGameSettings); +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::FixedScale &fixedScale); +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::FixedScale &fixedScale); +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::KeepAspectRatio &keepAspectRatio); +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::KeepAspectRatio &keepAspectRatio); +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::FullScale &fullScale); +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::FullScale &fullScale); +QDataStream &operator<<(QDataStream &ds, const GlobalGameSettings::Resolution &resolution); +QDataStream &operator>>(QDataStream &ds, GlobalGameSettings::Resolution &resolution); QDataStream &operator<<(QDataStream &ds, const Sprite &sprite); QDataStream &operator>>(QDataStream &ds, Sprite &sprite); QDataStream &operator<<(QDataStream &ds, const Sound &sound); diff --git a/src/stdserialization.h b/src/stdserialization.h index fcdd623..7697af5 100644 --- a/src/stdserialization.h +++ b/src/stdserialization.h @@ -1,11 +1,13 @@ #pragma once -#include #include #include #include #include #include +#include + +#include template QDataStream &operator<<(QDataStream &ds, const std::array &array) @@ -150,3 +152,33 @@ QDataStream &operator>>(QDataStream &ds, std::variant &variant) return ds; } + +template +QDataStream &operator<<(QDataStream &ds, const std::optional &optional) +{ + { + bool hasValue = optional.has_value(); + ds << hasValue; + } + if (optional) + ds << *optional; + return ds; +} + +template +QDataStream &operator>>(QDataStream &ds, std::optional &optional) +{ + bool hasValue; + ds >> hasValue; + + if (hasValue) + { + T entry; + ds >> entry; + optional = std::move(entry); + } + else + optional = std::nullopt; + + return ds; +}