mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-02 16:06:39 +00:00
Merge branch 'serializable_readonly' into 'master'
Support table-valued settings See merge request OpenMW/openmw!3917
This commit is contained in:
commit
1349fdb4f2
2 changed files with 11 additions and 10 deletions
|
@ -316,12 +316,13 @@ namespace LuaUtil
|
||||||
sol::table meta(lua, sol::create);
|
sol::table meta(lua, sol::create);
|
||||||
meta["t"] = table;
|
meta["t"] = table;
|
||||||
if (strictIndex)
|
if (strictIndex)
|
||||||
meta["__index"] = lua["createStrictIndexFn"](table);
|
meta[sol::meta_method::index] = lua["createStrictIndexFn"](table);
|
||||||
else
|
else
|
||||||
meta["__index"] = table;
|
meta[sol::meta_method::index] = table;
|
||||||
meta["__pairs"] = lua["pairsForReadOnly"];
|
meta[sol::meta_method::pairs] = lua["pairsForReadOnly"];
|
||||||
meta["__ipairs"] = lua["ipairsForReadOnly"];
|
meta[sol::meta_method::ipairs] = lua["ipairsForReadOnly"];
|
||||||
meta["__len"] = lua["lenForReadOnly"];
|
meta[sol::meta_method::length] = lua["lenForReadOnly"];
|
||||||
|
meta[sol::meta_method::type] = "ReadOnlyTable";
|
||||||
|
|
||||||
lua_newuserdata(luaState, 0);
|
lua_newuserdata(luaState, 0);
|
||||||
sol::stack::push(luaState, meta);
|
sol::stack::push(luaState, meta);
|
||||||
|
|
|
@ -157,7 +157,7 @@ local function renderGroup(group, global)
|
||||||
sortedSettings[setting.order] = setting
|
sortedSettings[setting.order] = setting
|
||||||
end
|
end
|
||||||
for _, setting in ipairs(sortedSettings) do
|
for _, setting in ipairs(sortedSettings) do
|
||||||
table.insert(settingLayouts, renderSetting(group, setting, valueSection:get(setting.key), global))
|
table.insert(settingLayouts, renderSetting(group, setting, valueSection:getCopy(setting.key), global))
|
||||||
end
|
end
|
||||||
local settingsContent = ui.content(interlaceSeparator(settingLayouts, spacedLines(1)))
|
local settingsContent = ui.content(interlaceSeparator(settingLayouts, spacedLines(1)))
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ local function renderPage(page, options)
|
||||||
table.sort(sortedGroups, pageGroupComparator)
|
table.sort(sortedGroups, pageGroupComparator)
|
||||||
local groupLayouts = {}
|
local groupLayouts = {}
|
||||||
for _, pageGroup in ipairs(sortedGroups) do
|
for _, pageGroup in ipairs(sortedGroups) do
|
||||||
local group = common.getSection(pageGroup.global, common.groupSectionKey):get(pageGroup.key)
|
local group = common.getSection(pageGroup.global, common.groupSectionKey):getCopy(pageGroup.key)
|
||||||
if not group then
|
if not group then
|
||||||
error(string.format('%s group "%s" was not found', pageGroup.global and 'Global' or 'Player', pageGroup.key))
|
error(string.format('%s group "%s" was not found', pageGroup.global and 'Global' or 'Player', pageGroup.key))
|
||||||
end
|
end
|
||||||
|
@ -360,7 +360,7 @@ end
|
||||||
|
|
||||||
local function onSettingChanged(global)
|
local function onSettingChanged(global)
|
||||||
return async:callback(function(groupKey, settingKey)
|
return async:callback(function(groupKey, settingKey)
|
||||||
local group = common.getSection(global, common.groupSectionKey):get(groupKey)
|
local group = common.getSection(global, common.groupSectionKey):getCopy(groupKey)
|
||||||
if not group or not pageOptions[group.page] then return end
|
if not group or not pageOptions[group.page] then return end
|
||||||
|
|
||||||
local groupElement = groupElements[group.page][group.key]
|
local groupElement = groupElements[group.page][group.key]
|
||||||
|
@ -375,7 +375,7 @@ local function onSettingChanged(global)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local value = common.getSection(global, group.key):get(settingKey)
|
local value = common.getSection(global, group.key):getCopy(settingKey)
|
||||||
local settingsContent = groupElement.layout.content.settings.content
|
local settingsContent = groupElement.layout.content.settings.content
|
||||||
auxUi.deepDestroy(settingsContent[settingKey]) -- support setting renderers which return UI elements
|
auxUi.deepDestroy(settingsContent[settingKey]) -- support setting renderers which return UI elements
|
||||||
settingsContent[settingKey] = renderSetting(group, group.settings[settingKey], value, global)
|
settingsContent[settingKey] = renderSetting(group, group.settings[settingKey], value, global)
|
||||||
|
@ -404,7 +404,7 @@ local function onGroupRegistered(global, key)
|
||||||
local group = common.getSection(global, common.groupSectionKey):get(group.key)
|
local group = common.getSection(global, common.groupSectionKey):get(group.key)
|
||||||
if not group or not pageOptions[group.page] then return end
|
if not group or not pageOptions[group.page] then return end
|
||||||
|
|
||||||
local value = common.getSection(global, group.key):get(settingKey)
|
local value = common.getSection(global, group.key):getCopy(settingKey)
|
||||||
|
|
||||||
local element = groupElements[group.page][group.key]
|
local element = groupElements[group.page][group.key]
|
||||||
local settingsContent = element.layout.content.settings.content
|
local settingsContent = element.layout.content.settings.content
|
||||||
|
|
Loading…
Reference in a new issue