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
This commit is contained in:
parent
24c2820ce1
commit
6294e9ed1c
BIN
assets/opensb/interface/graphicsmenu/body.png
Normal file
BIN
assets/opensb/interface/graphicsmenu/body.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -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
|
||||
]
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -29,9 +29,15 @@ GraphicsMenu::GraphicsMenu() {
|
||||
syncGui();
|
||||
});
|
||||
reader.registerCallback("zoomSlider", [=](Widget*) {
|
||||
auto slider = fetchChild<SliderBarWidget>("zoomSlider");
|
||||
m_localChanges.set("zoomLevel", m_zoomList[slider->val()]);
|
||||
Root::singleton().configuration()->set("zoomLevel", m_zoomList[slider->val()]);
|
||||
auto zoomSlider = fetchChild<SliderBarWidget>("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<SliderBarWidget>("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<SliderBarWidget>("resSlider")->setRange(0, m_resList.size() - 1, 1);
|
||||
fetchChild<SliderBarWidget>("zoomSlider")->setRange(0, m_zoomList.size() - 1, 1);
|
||||
fetchChild<SliderBarWidget>("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<LabelWidget>("zoomValueLabel")->setText(strf("{}x", m_localChanges.get("zoomLevel").toFloat()));
|
||||
|
||||
auto cameraSpeedSlider = fetchChild<SliderBarWidget>("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<LabelWidget>("cameraSpeedValueLabel")->setText(strf("{}x", m_localChanges.get("cameraSpeedFactor").toFloat()));
|
||||
|
||||
fetchChild<ButtonWidget>("speechBubbleCheckbox")->setChecked(m_localChanges.get("speechBubbles").toBool());
|
||||
fetchChild<ButtonWidget>("interactiveHighlightCheckbox")->setChecked(m_localChanges.get("interactiveHighlight").toBool());
|
||||
|
@ -27,6 +27,7 @@ private:
|
||||
|
||||
List<Vec2U> m_resList;
|
||||
List<float> m_zoomList;
|
||||
List<float> m_cameraSpeedList;
|
||||
|
||||
JsonObject m_localChanges;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user