Add an interface scale slider
This commit is contained in:
parent
e31a374212
commit
f3adb0b9d0
@ -1,11 +1,13 @@
|
||||
function patch(image)
|
||||
-- Camera Pan Speed
|
||||
image:copyInto({119, 68}, image:process("?crop=19;68;117;87"))
|
||||
function patch(original)
|
||||
local image = original:process("?crop=0;0;1;1?scalenearest=236;166")
|
||||
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")
|
||||
-- Anti-Aliasing
|
||||
image:copyInto({119, 26}, checkbox)
|
||||
-- Object Lighting
|
||||
image:copyInto({19, 15}, checkbox)
|
||||
-- Hardware Cursor
|
||||
image:copyInto({119, 15}, checkbox)
|
||||
image:copyInto({119, 26}, checkbox) -- Anti-Aliasing
|
||||
image:copyInto({19, 15}, checkbox) -- Object Lighting
|
||||
image:copyInto({119, 15}, checkbox) -- Hardware Cursor
|
||||
|
||||
image:copyInto({119, 68}, image:process("?crop=19;68;117;87")) -- Camera Pan Speed
|
||||
|
||||
return image
|
||||
end
|
BIN
assets/opensb/interface/graphicsmenu/shine.png
Normal file
BIN
assets/opensb/interface/graphicsmenu/shine.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 740 B |
@ -17,14 +17,21 @@ end
|
||||
function patch(config)
|
||||
local layout = config.paneLayout
|
||||
layout.panefeature.positionLocked = false
|
||||
layout.panefeature.anchor = "center"
|
||||
for i = 1, 32 do config.zoomList[i] = i end
|
||||
-- Create the camera pan speed widgets
|
||||
shift(clone(layout, "zoomLabel", "cameraSpeedLabel"), 100).value = "CAMERA PAN SPEED"
|
||||
shift(clone(layout, "zoomSlider", "cameraSpeedSlider"), 100)
|
||||
shift(clone(layout, "zoomValueLabel", "cameraSpeedValueLabel"), 100)
|
||||
-- Populate camera speed list
|
||||
config.cameraSpeedList = jarray()
|
||||
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
|
||||
shift(clone(layout, "multiTextureLabel", "antiAliasingLabel"), 98).value = "SUPER-SAMPLED AA"
|
||||
shift(clone(layout, "multiTextureCheckbox", "antiAliasingCheckbox"), 99)
|
||||
@ -34,5 +41,10 @@ function patch(config)
|
||||
-- Create hardware cursor toggle
|
||||
shift(clone(layout, "multiTextureLabel", "hardwareCursorLabel"), 98, -11).value = "HARDWARE CURSOR"
|
||||
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
|
||||
end
|
@ -63,6 +63,7 @@ Json const AdditionalDefaultConfiguration = Json::parseJson(R"JSON(
|
||||
"antiAliasing" : false,
|
||||
"zoomLevel" : 3.0,
|
||||
"cameraSpeedFactor" : 1.0,
|
||||
"interfaceScale" : 0,
|
||||
"speechBubbles" : true,
|
||||
|
||||
"title" : {
|
||||
@ -371,7 +372,9 @@ void ClientApplication::render() {
|
||||
renderer->setMultiSampling(config->get("antiAliasing").optBool().value(false) ? 4 : 0);
|
||||
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);
|
||||
else
|
||||
m_guiContext->setInterfaceScale(m_minInterfaceScale);
|
||||
|
@ -28,6 +28,11 @@ GraphicsMenu::GraphicsMenu() {
|
||||
m_localChanges.set("fullscreenResolution", jsonFromVec2U(res));
|
||||
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*) {
|
||||
auto zoomSlider = fetchChild<SliderBarWidget>("zoomSlider");
|
||||
m_localChanges.set("zoomLevel", m_zoomList[zoomSlider->val()]);
|
||||
@ -103,12 +108,14 @@ GraphicsMenu::GraphicsMenu() {
|
||||
|
||||
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_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>("interfaceScaleSlider")->setRange(0, m_interfaceScaleList.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>("cameraSpeedSlider")->setRange(0, m_cameraSpeedList.size() - 1, 1);
|
||||
@ -143,6 +150,7 @@ void GraphicsMenu::toggleFullscreen() {
|
||||
|
||||
StringList const GraphicsMenu::ConfigKeys = {
|
||||
"fullscreenResolution",
|
||||
"interfaceScale",
|
||||
"zoomLevel",
|
||||
"cameraSpeedFactor",
|
||||
"speechBubbles",
|
||||
@ -180,27 +188,38 @@ void GraphicsMenu::syncGui() {
|
||||
}
|
||||
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 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()) {
|
||||
size_t zoomIndex = zoomIt - m_zoomList.begin();
|
||||
zoomIndex = std::min(zoomIndex, m_zoomList.size() - 1);
|
||||
zoomSlider->setVal(zoomIndex, false);
|
||||
zoomSlider->setVal(std::min(zoomIndex, m_zoomList.size() - 1), false);
|
||||
} else {
|
||||
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 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()) {
|
||||
size_t speedIndex = speedIt - m_cameraSpeedList.begin();
|
||||
speedIndex = std::min(speedIndex, m_cameraSpeedList.size() - 1);
|
||||
cameraSpeedSlider->setVal(speedIndex, false);
|
||||
cameraSpeedSlider->setVal(std::min(speedIndex, m_cameraSpeedList.size() - 1), false);
|
||||
} else {
|
||||
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>("interactiveHighlightCheckbox")->setChecked(m_localChanges.get("interactiveHighlight").toBool());
|
||||
|
@ -25,6 +25,7 @@ private:
|
||||
void applyWindowSettings();
|
||||
|
||||
List<Vec2U> m_resList;
|
||||
List<int> m_interfaceScaleList;
|
||||
List<float> m_zoomList;
|
||||
List<float> m_cameraSpeedList;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user