settings tooltips

This commit is contained in:
MihailRis 2024-06-04 12:44:33 +03:00
parent 5e4dab1b6b
commit df2c024a3e
5 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,7 @@
function create_setting(id, name, step, postfix)
function create_setting(id, name, step, postfix, tooltip)
local info = core.get_setting_info(id)
postfix = postfix or ""
tooltip = tooltip or ""
document.root:add(gui.template("track_setting", {
id=id,
name=gui.str(name, "settings"),
@ -8,7 +9,8 @@ function create_setting(id, name, step, postfix)
min=info.min,
max=info.max,
step=step,
postfix=postfix
postfix=postfix,
tooltip=tooltip
}))
update_setting(core.get_setting(id), id, name, postfix)
end
@ -24,10 +26,11 @@ function update_setting(x, id, name, postfix)
)
end
function create_checkbox(id, name)
function create_checkbox(id, name, tooltip)
tooltip = tooltip or ''
document.root:add(string.format(
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s'>%s</checkbox>",
id, core.str_setting(id), gui.str(name, "settings")
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s' tooltip='%s'>%s</checkbox>",
id, core.str_setting(id), gui.str(tooltip, "settings"), gui.str(name, "settings")
))
end
@ -35,10 +38,10 @@ function on_open()
create_setting("chunks.load-distance", "Load Distance", 1)
create_setting("chunks.load-speed", "Load Speed", 1)
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
create_setting("graphics.gamma", "Gamma", 0.05)
create_setting("graphics.gamma", "Gamma", 0.05, "", "graphics.gamma.tooltip")
create_setting("camera.fov", "FOV", 1, "°")
create_checkbox("display.fullscreen", "Fullscreen")
create_checkbox("display.vsync", "V-Sync")
create_checkbox("graphics.backlight", "Backlight")
create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip")
create_checkbox("camera.shaking", "Camera Shaking")
end

View File

@ -1,6 +1,6 @@
<panel color='0' context='settings'>
<label id='%{id}.L' margin='0,3,0,0'>%{name}: %{value}%{postfix}</label>
<trackbar
value='%{value}' min='%{min}' max='%{max}' step='%{step}'
value='%{value}' min='%{min}' max='%{max}' step='%{step}' tooltip='%{tooltip}'
consumer='function(x) update_setting(x, "%{id}", "%{name}", "%{postfix}") end'/>
</panel>

View File

@ -8,6 +8,10 @@ world.delete-confirm=Do you want to delete world forever?
world.generators.default=Default
world.generators.flat=Flat
# Tooltips
graphics.gamma.tooltip=Lighting brightness curve
graphics.backlight.tooltip=Backlight to prevent total darkness
# Bindings
devtools.console=Console
movement.forward=Forward

View File

@ -12,6 +12,10 @@ error.pack-not-found=Не удалось найти пакет
error.dependency-not-found=Используемая зависимость не найдена
pack.remove-confirm=Удалить весь поставляемый паком/паками контент из мира (безвозвратно)?
# Подсказки
graphics.gamma.tooltip=Кривая яркости освещения
graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту
# Меню
menu.Apply=Применить
menu.Audio=Звук

View File

@ -50,6 +50,10 @@ namespace gui {
virtual bool isChecked() const {
return checkbox->isChecked();
}
virtual void setTooltip(const std::wstring& text) override {
checkbox->setTooltip(text);
}
};
}