From fa4f7c8bda829484100e0b58f6842ec069de37d8 Mon Sep 17 00:00:00 2001 From: Ben Boudaoud Date: Tue, 13 Dec 2022 12:31:54 -0500 Subject: [PATCH 1/2] Fixes for reticle preview and allowReticleChange --- source/FPSciApp.cpp | 21 +++++++++++++++++++-- source/GuiElements.cpp | 23 +++++++++++++++-------- source/UserConfig.h | 7 +++++++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/source/FPSciApp.cpp b/source/FPSciApp.cpp index 30208c6a..21d0fb2e 100644 --- a/source/FPSciApp.cpp +++ b/source/FPSciApp.cpp @@ -710,6 +710,7 @@ void FPSciApp::updateSession(const String& id, const bool forceSceneReload) { void FPSciApp::updateTrial(const shared_ptr config, const bool forceSceneReload, const bool respawn) { trialConfig = config; // Naive way to store trial config pointer for now + updateUserMenu = true; updateConfigParameters(config, forceSceneReload, respawn); } @@ -1404,12 +1405,28 @@ void FPSciApp::onUserInput(UserInput* ui) { } } - if (m_lastReticleLoaded != currentUser()->reticle.index || m_userSettingsWindow->visible()) { + // Update reticle from user settings change (if needed) + if (reticleConfig != currentUser()->reticle || m_userSettingsWindow->visible()) { + bool updateReticlePreview = false; // Slider was used to change the reticle if (!trialConfig->reticle.indexSpecified) { // Only allow reticle change if it isn't specified in experiment config setReticle(currentUser()->reticle.index); - m_userSettingsWindow->updateReticlePreview(); + updateReticlePreview = true; + } + if (!trialConfig->reticle.scaleSpecified) { + reticleConfig.scale = currentUser()->reticle.scale; + updateReticlePreview = true; + } + if (!trialConfig->reticle.colorSpecified) { + reticleConfig.color = currentUser()->reticle.color; + updateReticlePreview = true; } + if (!trialConfig->reticle.changeTimeSpecified) { + reticleConfig.changeTimeS = currentUser()->reticle.changeTimeS; + updateReticlePreview = true; + } + if(updateReticlePreview) m_userSettingsWindow->updateReticlePreview(); + } playerCamera->filmSettings().setSensitivity(sceneBrightness); diff --git a/source/GuiElements.cpp b/source/GuiElements.cpp index ed9af5bb..9cb538bf 100644 --- a/source/GuiElements.cpp +++ b/source/GuiElements.cpp @@ -463,6 +463,12 @@ UserMenu::UserMenu(FPSciApp* app, UserTable& users, UserStatusTable& userStatus, // User Settings Pane if (config.showUserSettings && !needUser) { m_currentUserPane = m_parent->addPane("Current User Settings"); + // Update config based on what is specified at the trial-level + if (app->trialConfig->reticle.indexSpecified) config.allowReticleIdxChange = false; + if (app->trialConfig->reticle.scaleSpecified) config.allowReticleSizeChange = false; + if (app->trialConfig->reticle.colorSpecified) config.allowReticleColorChange = false; + if (app->trialConfig->reticle.changeTimeSpecified) config.allowReticleChangeTimeChange = false; + config.allowReticleChange = config.allowReticleIdxChange || config.allowReticleSizeChange || config.allowReticleColorChange || config.allowReticleChangeTimeChange; drawUserPane(config, m_users.users[m_users.getUserIndex(m_userStatus.currentUser)]); } @@ -610,13 +616,14 @@ void UserMenu::drawUserPane(const MenuConfig& config, UserConfig& user) a->setWidth(m_rgbSliderWidth); a->moveRightOf(b, rgbCaptionWidth); } reticleControlPane->endRow(); - if (config.allowReticleChangeTimeChange) { - reticleControlPane->beginRow(); { - auto c = reticleControlPane->addNumberBox("Reticle Change Time", &(user.reticle.changeTimeS), "s", GuiTheme::LINEAR_SLIDER, 0.0f, 5.0f, 0.01f); - c->setCaptionWidth(150.0f); - c->setWidth(m_sliderWidth); - } reticleControlPane->endRow(); - } + } + + if (config.allowReticleChangeTimeChange) { + reticleControlPane->beginRow(); { + auto c = reticleControlPane->addNumberBox("Reticle Change Time", &(user.reticle.changeTimeS), "s", GuiTheme::LINEAR_SLIDER, 0.0f, 5.0f, 0.01f); + c->setCaptionWidth(150.0f); + c->setWidth(m_sliderWidth); + } reticleControlPane->endRow(); } // Draw a preview of the reticle here @@ -761,7 +768,7 @@ void UserMenu::updateReticlePreview() { m_reticlePreviewPane->removeAllChildren(); // Redraw the preview shared_ptr reticleTex = m_app->reticleTexture; - Color4 rColor = m_users.getUserById(m_userStatus.currentUser)->reticle.color[0]; + Color4 rColor = m_app->reticleConfig.color[0]; RenderDevice* rd = m_app->renderDevice; rd->push2D(m_reticleBuffer); { diff --git a/source/UserConfig.h b/source/UserConfig.h index 0b0daaf1..72a4c8c8 100644 --- a/source/UserConfig.h +++ b/source/UserConfig.h @@ -18,6 +18,13 @@ class ReticleConfig { void load(FPSciAnyTableReader reader, int settingsVersion = 1); Any addToAny(Any a, bool forceAll = false) const; + bool operator!=(ReticleConfig other) { + return index != other.index || + scale[0] != other.scale[0] || scale[1] != other.scale[1] || + color[0] != other.color[0] || color[1] != other.color[1] || + changeTimeS != other.changeTimeS; + } + }; /**Class for managing user configuration*/ From b1a969c475391c33f0190c686581f3c16bbb2714 Mon Sep 17 00:00:00 2001 From: Ben Boudaoud Date: Tue, 13 Dec 2022 13:01:17 -0500 Subject: [PATCH 2/2] Document fix --- docs/general_config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/general_config.md b/docs/general_config.md index 1c71e481..c19fb423 100644 --- a/docs/general_config.md +++ b/docs/general_config.md @@ -474,7 +474,7 @@ In addition to being able to be specified on a per-user basis, the experiment/se |`reticleColor` |`Array` |Provides a range of colors over which to set the reticle color as an `Array` w/ 2 elements (min, max)| |`reticleChangeTime` |`float` |Provides the time (in seconds) for the reticle to change color and/or size following a shot | -Note that when these values are specified at the experiment or session level the `allowReticleChange` property of the [menu configuration](#menu-config) should be set to `false` as user changes to the reticle will not apply. +Note that when these values are specified at the experiment, session, or trial level the `allowReticleChange` property of the [menu configuration](#menu-config) can still be set to `true` but only fields *not* specified in the experiment/session/trial will be displayed as editable in the user menu. If all config is specified in by the experiment then the reticle pane/preview is not shown in the user menu. ### Weapon Cooldown | Parameter Name |Units| Description |