diff --git a/assets/opensb/interface/graphicsmenu/body.png b/assets/opensb/interface/graphicsmenu/body.png new file mode 100644 index 0000000..198ca05 Binary files /dev/null and b/assets/opensb/interface/graphicsmenu/body.png differ 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; };