From 6294e9ed1c07b41ee7051c760b0f54b60cfc83ca Mon Sep 17 00:00:00 2001 From: WereTech <17415815+WereTech@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:04:45 -0600 Subject: [PATCH] add camera panning speed setting - adds a setting that changes the speed of the camera when panning with the CameraShift keybind. - fixes what I assume is a typo in the zoom slider that referenced the resolution list size instead of the zoom list size --- assets/opensb/interface/graphicsmenu/body.png | Bin 0 -> 1037 bytes .../windowconfig/graphicsmenu.config.patch | 28 +++++++++++++++++- source/client/StarClientApplication.cpp | 11 +++---- source/frontend/StarGraphicsMenu.cpp | 27 ++++++++++++++--- source/frontend/StarGraphicsMenu.hpp | 1 + 5 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 assets/opensb/interface/graphicsmenu/body.png diff --git a/assets/opensb/interface/graphicsmenu/body.png b/assets/opensb/interface/graphicsmenu/body.png new file mode 100644 index 0000000000000000000000000000000000000000..198ca05313377d4351d11a49ba0a3017a0b67158 GIT binary patch literal 1037 zcmeAS@N?(olHy`uVBq!ia0vp^Z-BUqgAGWotXmcgq!^2X+?^QKos)S9a~60+7BevL9R^{>dMNWQDu*H#Jc-ar|V|PC9>YW zp><>V^5y5BCiZOJyjj2LZf|gs#FPZZ4oq~g^O%p7to>v^fg?+VdAv3VEP18*@zaL- zK%fUU^|CKNg5rL-M+7z>anJbWR&+n_0{iA81{y#QETjgf*3BAeC@AF(=zy0fp zr;CJH1a(l5rN@TFes{k7Dv$1uQJb6gY5&Ptn|`aQ%`LlLWLp!;9{pBIr~TpMQm_jS zI!##hK5_cJ=K)T z*eci5s(?Ve8+RG)+&Oi5#)7L=JJvEAzy4;o=HY)kiGT0AAJ$7u2~L_3xqbPOrn$$r zaZ9z&+VJq|zSn`q5zCJ#UUPr2Y^{we^V)098w6Ys2ub2_t}IaZ_rzYcZwE7y;z4mY zN9gdGUAC%XZ)~>3Ua+{*!n+>sKszS$T&xa6NaVdfaAwzD{%n(t{BFX(lS~BJo=*AE zVR`7=LBTSE`rQW%bDxGwv?Mrhk!oG6kMJYVzq}8*47J}KmNWdG_&eaU-I|L>lv7ML z>c{f=+1T4pw@uK)OoH%;pOCefEK&(;^e;^1~gTe~DWM4fkVwhs literal 0 HcmV?d00001 diff --git a/assets/opensb/interface/windowconfig/graphicsmenu.config.patch b/assets/opensb/interface/windowconfig/graphicsmenu.config.patch index ab97f2f..d8da2c5 100644 --- a/assets/opensb/interface/windowconfig/graphicsmenu.config.patch +++ b/assets/opensb/interface/windowconfig/graphicsmenu.config.patch @@ -1,5 +1,24 @@ { - "paneLayout": { "panefeature": { "positionLocked": false } }, + "paneLayout": { + "panefeature": { "positionLocked": false }, + "cameraSpeedLabel" : { + "type" : "label", + "position" : [170, 112], + "hAnchor" : "mid", + "value" : "CAMERA PAN SPEED" + }, + "cameraSpeedValueLabel" : { + "type" : "label", + "position" : [202, 99], + "hAnchor" : "mid", + "value" : "Replace Me" + }, + "cameraSpeedSlider" : { + "type" : "slider", + "position" : [126, 98], + "gridImage" : "/interface/optionsmenu/smallselection.png" + } + }, "zoomList": [ 1, 1.125, @@ -40,5 +59,12 @@ 30, 31, 32 + ], + "cameraSpeedList" : [ + 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, + 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, + 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, + 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, + 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0 ] } \ No newline at end of file diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index 6c891c2..ea24c36 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -51,6 +51,7 @@ Json const AdditionalDefaultConfiguration = Json::parseJson(R"JSON( "borderless" : false, "maximized" : true, "zoomLevel" : 3.0, + "cameraSpeedFactor" : 1.0, "speechBubbles" : true, "title" : { @@ -1008,8 +1009,8 @@ void ClientApplication::updateCamera(float dt) { const float triggerRadius = 100.0f; const float deadzone = 0.1f; - const float smoothFactor = 30.0f; const float panFactor = 1.5f; + float cameraSpeedFactor = 30.0f / m_root->configuration()->get("cameraSpeedFactor").toFloat(); auto playerCameraPosition = m_player->cameraPosition(); @@ -1027,15 +1028,15 @@ void ClientApplication::updateCamera(float dt) { magnitude = 1; cameraXOffset *= magnitude * 0.5f * camera.pixelRatio() * panFactor; cameraYOffset *= magnitude * 0.5f * camera.pixelRatio() * panFactor; - m_cameraXOffset = (m_cameraXOffset * (smoothFactor - 1.0) + cameraXOffset) / smoothFactor; - m_cameraYOffset = (m_cameraYOffset * (smoothFactor - 1.0) + cameraYOffset) / smoothFactor; + m_cameraXOffset = (m_cameraXOffset * (cameraSpeedFactor - 1.0) + cameraXOffset) / cameraSpeedFactor; + m_cameraYOffset = (m_cameraYOffset * (cameraSpeedFactor - 1.0) + cameraYOffset) / cameraSpeedFactor; } } else { if ((m_cameraOffsetDownTicks > 0) && (m_cameraOffsetDownTicks < 20)) m_snapBackCameraOffset = true; if (m_snapBackCameraOffset) { - m_cameraXOffset = (m_cameraXOffset * (smoothFactor - 1.0)) / smoothFactor; - m_cameraYOffset = (m_cameraYOffset * (smoothFactor - 1.0)) / smoothFactor; + m_cameraXOffset = (m_cameraXOffset * (cameraSpeedFactor - 1.0)) / cameraSpeedFactor; + m_cameraYOffset = (m_cameraYOffset * (cameraSpeedFactor - 1.0)) / cameraSpeedFactor; } m_cameraOffsetDownTicks = 0; } diff --git a/source/frontend/StarGraphicsMenu.cpp b/source/frontend/StarGraphicsMenu.cpp index 852a217..f1a93a9 100644 --- a/source/frontend/StarGraphicsMenu.cpp +++ b/source/frontend/StarGraphicsMenu.cpp @@ -29,9 +29,15 @@ GraphicsMenu::GraphicsMenu() { syncGui(); }); reader.registerCallback("zoomSlider", [=](Widget*) { - auto slider = fetchChild("zoomSlider"); - m_localChanges.set("zoomLevel", m_zoomList[slider->val()]); - Root::singleton().configuration()->set("zoomLevel", m_zoomList[slider->val()]); + auto zoomSlider = fetchChild("zoomSlider"); + m_localChanges.set("zoomLevel", m_zoomList[zoomSlider->val()]); + Root::singleton().configuration()->set("zoomLevel", m_zoomList[zoomSlider->val()]); + syncGui(); + }); + reader.registerCallback("cameraSpeedSlider", [=](Widget*) { + auto cameraSpeedSlider = fetchChild("cameraSpeedSlider"); + m_localChanges.set("cameraSpeedFactor", m_cameraSpeedList[cameraSpeedSlider->val()]); + Root::singleton().configuration()->set("cameraSpeedFactor", m_cameraSpeedList[cameraSpeedSlider->val()]); syncGui(); }); reader.registerCallback("speechBubbleCheckbox", [=](Widget*) { @@ -81,11 +87,13 @@ GraphicsMenu::GraphicsMenu() { m_resList = jsonToVec2UList(assets->json("/interface/windowconfig/graphicsmenu.config:resolutionList")); m_zoomList = jsonToFloatList(assets->json("/interface/windowconfig/graphicsmenu.config:zoomList")); + m_cameraSpeedList = jsonToFloatList(assets->json("/interface/windowconfig/graphicsmenu.config:cameraSpeedList")); reader.construct(paneLayout, this); fetchChild("resSlider")->setRange(0, m_resList.size() - 1, 1); fetchChild("zoomSlider")->setRange(0, m_zoomList.size() - 1, 1); + fetchChild("cameraSpeedSlider")->setRange(0, m_cameraSpeedList.size() - 1, 1); initConfig(); syncGui(); @@ -118,6 +126,7 @@ void GraphicsMenu::toggleFullscreen() { StringList const GraphicsMenu::ConfigKeys = { "fullscreenResolution", "zoomLevel", + "cameraSpeedFactor", "speechBubbles", "interactiveHighlight", "fullscreen", @@ -154,13 +163,23 @@ void GraphicsMenu::syncGui() { auto zoomIt = std::lower_bound(m_zoomList.begin(), m_zoomList.end(), m_localChanges.get("zoomLevel").toFloat()); if (zoomIt != m_zoomList.end()) { size_t zoomIndex = zoomIt - m_zoomList.begin(); - zoomIndex = std::min(zoomIndex, m_resList.size() - 1); + zoomIndex = std::min(zoomIndex, m_zoomList.size() - 1); zoomSlider->setVal(zoomIndex, false); } else { zoomSlider->setVal(m_zoomList.size() - 1); } fetchChild("zoomValueLabel")->setText(strf("{}x", m_localChanges.get("zoomLevel").toFloat())); + auto cameraSpeedSlider = fetchChild("cameraSpeedSlider"); + auto speedIt = std::lower_bound(m_cameraSpeedList.begin(), m_cameraSpeedList.end(), m_localChanges.get("cameraSpeedFactor").toFloat()); + if (speedIt != m_cameraSpeedList.end()) { + size_t speedIndex = speedIt - m_cameraSpeedList.begin(); + speedIndex = std::min(speedIndex, m_cameraSpeedList.size() - 1); + cameraSpeedSlider->setVal(speedIndex, false); + } else { + cameraSpeedSlider->setVal(m_cameraSpeedList.size() - 1); + } + fetchChild("cameraSpeedValueLabel")->setText(strf("{}x", m_localChanges.get("cameraSpeedFactor").toFloat())); fetchChild("speechBubbleCheckbox")->setChecked(m_localChanges.get("speechBubbles").toBool()); fetchChild("interactiveHighlightCheckbox")->setChecked(m_localChanges.get("interactiveHighlight").toBool()); diff --git a/source/frontend/StarGraphicsMenu.hpp b/source/frontend/StarGraphicsMenu.hpp index 8801bfe..c081778 100644 --- a/source/frontend/StarGraphicsMenu.hpp +++ b/source/frontend/StarGraphicsMenu.hpp @@ -27,6 +27,7 @@ private: List m_resList; List m_zoomList; + List m_cameraSpeedList; JsonObject m_localChanges; };