Add zoom level keybinds

This commit is contained in:
Kae 2023-07-03 04:29:58 +10:00
parent 7d86194cae
commit d7ba113688
2 changed files with 32 additions and 2 deletions

View File

@ -1,8 +1,26 @@
{
"opensb": {
"name": "OpenStarbound",
"bannerName" : "Open^#ebd74a;Starbound",
"groups": {
"camera": { "name": "Camera" }
},
"name": "Open^#ebd74a;Starbound",
"binds": {
"zoomIn": {
"default": [{
"type": "key",
"value": "="
}],
"group" : "camera",
"name": "Zoom In"
},
"zoomOut": {
"default": [{
"type": "key",
"value": "-"
}],
"group" : "camera",
"name": "Zoom Out"
},
"test": {
"default": [{
"type": "key",

View File

@ -315,6 +315,18 @@ void ClientApplication::processInput(InputEvent const& event) {
}
m_input->handleInput(event, processed);
WorldCamera& camera = m_worldPainter->camera();
auto config = m_root->configuration();
int zoomOffset = 0;
if (auto presses = m_input->bindDown("opensb", "zoomIn"))
zoomOffset += *presses;
if (auto presses = m_input->bindDown("opensb", "zoomOut"))
zoomOffset -= *presses;
if (zoomOffset != 0)
config->set("zoomLevel", max(1.0f, round(config->get("zoomLevel").toFloat() + zoomOffset)));
}
void ClientApplication::update() {