Add an interface scale slider

This commit is contained in:
Kae 2024-05-25 12:52:07 +10:00
parent e31a374212
commit f3adb0b9d0
6 changed files with 57 additions and 20 deletions

View File

@ -1,11 +1,13 @@
function patch(image) function patch(original)
-- Camera Pan Speed local image = original:process("?crop=0;0;1;1?scalenearest=236;166")
image:copyInto({119, 68}, image:process("?crop=19;68;117;87")) image:copyInto({0, 28}, original)
image:copyInto({0, 0}, original:process("?crop=0;0;236;96"))
local checkbox = image:process("?crop=19;26;117;35") local checkbox = image:process("?crop=19;26;117;35")
-- Anti-Aliasing image:copyInto({119, 26}, checkbox) -- Anti-Aliasing
image:copyInto({119, 26}, checkbox) image:copyInto({19, 15}, checkbox) -- Object Lighting
-- Object Lighting image:copyInto({119, 15}, checkbox) -- Hardware Cursor
image:copyInto({19, 15}, checkbox)
-- Hardware Cursor image:copyInto({119, 68}, image:process("?crop=19;68;117;87")) -- Camera Pan Speed
image:copyInto({119, 15}, checkbox)
return image
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

View File

@ -17,14 +17,21 @@ end
function patch(config) function patch(config)
local layout = config.paneLayout local layout = config.paneLayout
layout.panefeature.positionLocked = false layout.panefeature.positionLocked = false
layout.panefeature.anchor = "center"
for i = 1, 32 do config.zoomList[i] = i end
-- Create the camera pan speed widgets -- Create the camera pan speed widgets
shift(clone(layout, "zoomLabel", "cameraSpeedLabel"), 100).value = "CAMERA PAN SPEED" shift(clone(layout, "zoomLabel", "cameraSpeedLabel"), 100).value = "CAMERA PAN SPEED"
shift(clone(layout, "zoomSlider", "cameraSpeedSlider"), 100) shift(clone(layout, "zoomSlider", "cameraSpeedSlider"), 100)
shift(clone(layout, "zoomValueLabel", "cameraSpeedValueLabel"), 100) shift(clone(layout, "zoomValueLabel", "cameraSpeedValueLabel"), 100)
-- Populate camera speed list
config.cameraSpeedList = jarray() config.cameraSpeedList = jarray()
for i = 1, 50 do config.cameraSpeedList[i] = i / 10 end for i = 1, 50 do config.cameraSpeedList[i] = i / 10 end
for i = 1, 32 do config.zoomList[i] = i end
-- Create the interface scale widgets
shift(clone(layout, "zoomLabel", "interfaceScaleLabel"), 0, 28).value = "INTERFACE SCALE"
shift(clone(layout, "zoomSlider", "interfaceScaleSlider"), 0, 28)
shift(clone(layout, "zoomValueLabel", "interfaceScaleValueLabel"), 0, 28)
config.interfaceScaleList = {0, 1, 2, 3, 4, 5, 6} -- 0 = AUTO!
-- Create anti-aliasing toggle -- Create anti-aliasing toggle
shift(clone(layout, "multiTextureLabel", "antiAliasingLabel"), 98).value = "SUPER-SAMPLED AA" shift(clone(layout, "multiTextureLabel", "antiAliasingLabel"), 98).value = "SUPER-SAMPLED AA"
shift(clone(layout, "multiTextureCheckbox", "antiAliasingCheckbox"), 99) shift(clone(layout, "multiTextureCheckbox", "antiAliasingCheckbox"), 99)
@ -34,5 +41,10 @@ function patch(config)
-- Create hardware cursor toggle -- Create hardware cursor toggle
shift(clone(layout, "multiTextureLabel", "hardwareCursorLabel"), 98, -11).value = "HARDWARE CURSOR" shift(clone(layout, "multiTextureLabel", "hardwareCursorLabel"), 98, -11).value = "HARDWARE CURSOR"
shift(clone(layout, "multiTextureCheckbox", "hardwareCursorCheckbox"), 99, -11) shift(clone(layout, "multiTextureCheckbox", "hardwareCursorCheckbox"), 99, -11)
shift(layout.title, 0, 28)
shift(layout.resLabel, 0, 28)
shift(layout.resSlider, 0, 28)
shift(layout.resValueLabel, 0, 28)
return config return config
end end

View File

@ -63,6 +63,7 @@ Json const AdditionalDefaultConfiguration = Json::parseJson(R"JSON(
"antiAliasing" : false, "antiAliasing" : false,
"zoomLevel" : 3.0, "zoomLevel" : 3.0,
"cameraSpeedFactor" : 1.0, "cameraSpeedFactor" : 1.0,
"interfaceScale" : 0,
"speechBubbles" : true, "speechBubbles" : true,
"title" : { "title" : {
@ -371,7 +372,9 @@ void ClientApplication::render() {
renderer->setMultiSampling(config->get("antiAliasing").optBool().value(false) ? 4 : 0); renderer->setMultiSampling(config->get("antiAliasing").optBool().value(false) ? 4 : 0);
renderer->switchEffectConfig("interface"); renderer->switchEffectConfig("interface");
if (m_guiContext->windowWidth() >= m_crossoverRes[0] && m_guiContext->windowHeight() >= m_crossoverRes[1]) if (auto interfaceScale = config->get("interfaceScale").optUInt().value())
m_guiContext->setInterfaceScale(interfaceScale);
else if (m_guiContext->windowWidth() >= m_crossoverRes[0] && m_guiContext->windowHeight() >= m_crossoverRes[1])
m_guiContext->setInterfaceScale(m_maxInterfaceScale); m_guiContext->setInterfaceScale(m_maxInterfaceScale);
else else
m_guiContext->setInterfaceScale(m_minInterfaceScale); m_guiContext->setInterfaceScale(m_minInterfaceScale);

View File

@ -28,6 +28,11 @@ GraphicsMenu::GraphicsMenu() {
m_localChanges.set("fullscreenResolution", jsonFromVec2U(res)); m_localChanges.set("fullscreenResolution", jsonFromVec2U(res));
syncGui(); syncGui();
}); });
reader.registerCallback("interfaceScaleSlider", [=](Widget*) {
auto interfaceScaleSlider = fetchChild<SliderBarWidget>("interfaceScaleSlider");
m_localChanges.set("interfaceScale", (uint64_t)m_interfaceScaleList[interfaceScaleSlider->val()]);
syncGui();
});
reader.registerCallback("zoomSlider", [=](Widget*) { reader.registerCallback("zoomSlider", [=](Widget*) {
auto zoomSlider = fetchChild<SliderBarWidget>("zoomSlider"); auto zoomSlider = fetchChild<SliderBarWidget>("zoomSlider");
m_localChanges.set("zoomLevel", m_zoomList[zoomSlider->val()]); m_localChanges.set("zoomLevel", m_zoomList[zoomSlider->val()]);
@ -103,12 +108,14 @@ GraphicsMenu::GraphicsMenu() {
Json paneLayout = assets->json("/interface/windowconfig/graphicsmenu.config:paneLayout"); Json paneLayout = assets->json("/interface/windowconfig/graphicsmenu.config:paneLayout");
m_interfaceScaleList = jsonToIntList(assets->json("/interface/windowconfig/graphicsmenu.config:interfaceScaleList"));
m_resList = jsonToVec2UList(assets->json("/interface/windowconfig/graphicsmenu.config:resolutionList")); m_resList = jsonToVec2UList(assets->json("/interface/windowconfig/graphicsmenu.config:resolutionList"));
m_zoomList = jsonToFloatList(assets->json("/interface/windowconfig/graphicsmenu.config:zoomList")); m_zoomList = jsonToFloatList(assets->json("/interface/windowconfig/graphicsmenu.config:zoomList"));
m_cameraSpeedList = jsonToFloatList(assets->json("/interface/windowconfig/graphicsmenu.config:cameraSpeedList")); m_cameraSpeedList = jsonToFloatList(assets->json("/interface/windowconfig/graphicsmenu.config:cameraSpeedList"));
reader.construct(paneLayout, this); reader.construct(paneLayout, this);
fetchChild<SliderBarWidget>("interfaceScaleSlider")->setRange(0, m_interfaceScaleList.size() - 1, 1);
fetchChild<SliderBarWidget>("resSlider")->setRange(0, m_resList.size() - 1, 1); fetchChild<SliderBarWidget>("resSlider")->setRange(0, m_resList.size() - 1, 1);
fetchChild<SliderBarWidget>("zoomSlider")->setRange(0, m_zoomList.size() - 1, 1); fetchChild<SliderBarWidget>("zoomSlider")->setRange(0, m_zoomList.size() - 1, 1);
fetchChild<SliderBarWidget>("cameraSpeedSlider")->setRange(0, m_cameraSpeedList.size() - 1, 1); fetchChild<SliderBarWidget>("cameraSpeedSlider")->setRange(0, m_cameraSpeedList.size() - 1, 1);
@ -143,6 +150,7 @@ void GraphicsMenu::toggleFullscreen() {
StringList const GraphicsMenu::ConfigKeys = { StringList const GraphicsMenu::ConfigKeys = {
"fullscreenResolution", "fullscreenResolution",
"interfaceScale",
"zoomLevel", "zoomLevel",
"cameraSpeedFactor", "cameraSpeedFactor",
"speechBubbles", "speechBubbles",
@ -180,27 +188,38 @@ void GraphicsMenu::syncGui() {
} }
fetchChild<LabelWidget>("resValueLabel")->setText(strf("{}x{}", res[0], res[1])); fetchChild<LabelWidget>("resValueLabel")->setText(strf("{}x{}", res[0], res[1]));
auto interfaceScaleSlider = fetchChild<SliderBarWidget>("interfaceScaleSlider");
auto interfaceScale = m_localChanges.get("interfaceScale").optUInt().value();
auto interfaceScaleIt = std::lower_bound(m_interfaceScaleList.begin(), m_interfaceScaleList.end(), interfaceScale);
if (interfaceScaleIt != m_interfaceScaleList.end()) {
size_t scaleIndex = interfaceScaleIt - m_interfaceScaleList.begin();
interfaceScaleSlider->setVal(std::min(scaleIndex, m_interfaceScaleList.size() - 1), false);
} else {
interfaceScaleSlider->setVal(m_interfaceScaleList.size() - 1);
}
fetchChild<LabelWidget>("interfaceScaleValueLabel")->setText(interfaceScale ? toString(interfaceScale) : "AUTO");
auto zoomSlider = fetchChild<SliderBarWidget>("zoomSlider"); auto zoomSlider = fetchChild<SliderBarWidget>("zoomSlider");
auto zoomIt = std::lower_bound(m_zoomList.begin(), m_zoomList.end(), m_localChanges.get("zoomLevel").toFloat()); auto zoomLevel = m_localChanges.get("zoomLevel").toFloat();
auto zoomIt = std::lower_bound(m_zoomList.begin(), m_zoomList.end(), zoomLevel);
if (zoomIt != m_zoomList.end()) { if (zoomIt != m_zoomList.end()) {
size_t zoomIndex = zoomIt - m_zoomList.begin(); size_t zoomIndex = zoomIt - m_zoomList.begin();
zoomIndex = std::min(zoomIndex, m_zoomList.size() - 1); zoomSlider->setVal(std::min(zoomIndex, m_zoomList.size() - 1), false);
zoomSlider->setVal(zoomIndex, false);
} else { } else {
zoomSlider->setVal(m_zoomList.size() - 1); zoomSlider->setVal(m_zoomList.size() - 1);
} }
fetchChild<LabelWidget>("zoomValueLabel")->setText(strf("{}x", m_localChanges.get("zoomLevel").toFloat())); fetchChild<LabelWidget>("zoomValueLabel")->setText(strf("{}x", zoomLevel));
auto cameraSpeedSlider = fetchChild<SliderBarWidget>("cameraSpeedSlider"); auto cameraSpeedSlider = fetchChild<SliderBarWidget>("cameraSpeedSlider");
auto speedIt = std::lower_bound(m_cameraSpeedList.begin(), m_cameraSpeedList.end(), m_localChanges.get("cameraSpeedFactor").toFloat()); auto cameraSpeedFactor = m_localChanges.get("cameraSpeedFactor").toFloat();
auto speedIt = std::lower_bound(m_cameraSpeedList.begin(), m_cameraSpeedList.end(), cameraSpeedFactor);
if (speedIt != m_cameraSpeedList.end()) { if (speedIt != m_cameraSpeedList.end()) {
size_t speedIndex = speedIt - m_cameraSpeedList.begin(); size_t speedIndex = speedIt - m_cameraSpeedList.begin();
speedIndex = std::min(speedIndex, m_cameraSpeedList.size() - 1); cameraSpeedSlider->setVal(std::min(speedIndex, m_cameraSpeedList.size() - 1), false);
cameraSpeedSlider->setVal(speedIndex, false);
} else { } else {
cameraSpeedSlider->setVal(m_cameraSpeedList.size() - 1); cameraSpeedSlider->setVal(m_cameraSpeedList.size() - 1);
} }
fetchChild<LabelWidget>("cameraSpeedValueLabel")->setText(strf("{}x", m_localChanges.get("cameraSpeedFactor").toFloat())); fetchChild<LabelWidget>("cameraSpeedValueLabel")->setText(strf("{}x", cameraSpeedFactor));
fetchChild<ButtonWidget>("speechBubbleCheckbox")->setChecked(m_localChanges.get("speechBubbles").toBool()); fetchChild<ButtonWidget>("speechBubbleCheckbox")->setChecked(m_localChanges.get("speechBubbles").toBool());
fetchChild<ButtonWidget>("interactiveHighlightCheckbox")->setChecked(m_localChanges.get("interactiveHighlight").toBool()); fetchChild<ButtonWidget>("interactiveHighlightCheckbox")->setChecked(m_localChanges.get("interactiveHighlight").toBool());

View File

@ -25,6 +25,7 @@ private:
void applyWindowSettings(); void applyWindowSettings();
List<Vec2U> m_resList; List<Vec2U> m_resList;
List<int> m_interfaceScaleList;
List<float> m_zoomList; List<float> m_zoomList;
List<float> m_cameraSpeedList; List<float> m_cameraSpeedList;