Updated to OTCv8 3.1 rev 161

This commit is contained in:
OTCv8 2022-03-31 11:44:11 +00:00
parent b5ca12f0e0
commit ed493239af
7 changed files with 159 additions and 153 deletions

View File

@ -28,9 +28,9 @@ localShaders = {}
local shaderFiles = g_resources.listDirectoryFiles("/data/shaders/", true, false) local shaderFiles = g_resources.listDirectoryFiles("/data/shaders/", true, false)
for i, file in ipairs(shaderFiles) do for i, file in ipairs(shaderFiles) do
local name = file:split(".")[1]:trim():lower() local name = file:split(".")[1]:trim():lower()
name = name:gsub("/data/shaders//","") name = name:gsub("/data/shaders//", "")
name = name:gsub("_fragment","") name = name:gsub("_fragment", "")
name = name:gsub("_vertex","") name = name:gsub("_vertex", "")
if name:find("outfit") and not table.find(localShaders, name) then if name:find("outfit") and not table.find(localShaders, name) then
table.insert(localShaders, name) table.insert(localShaders, name)
end end
@ -38,40 +38,33 @@ end
function setupTables() function setupTables()
configOptions = { configOptions = {
{id = "addon1", text = "Addon 1", checked = false, enabled = g_game.getClientVersion() >= 780},
{ id="addon1", text="Addon 1", checked=false, enabled=g_game.getClientVersion()>=780 }, {id = "addon2", text = "Addon 2", checked = false, enabled = g_game.getClientVersion() >= 780},
{ id="addon2", text="Addon 2", checked=false, enabled=g_game.getClientVersion()>=780 }, {id = "mount", text = "Mount", checked = false, enabled = g_game.getFeature(GamePlayerMounts)},
{ id="mount", text="Mount", checked=false, enabled=g_game.getFeature(GamePlayerMounts) }, {id = "wings", text = "Wings", checked = false, enabled = g_game.getFeature(GameWingsAndAura)},
{ id="wings", text="Wings", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, {id = "aura", text = "Aura", checked = false, enabled = g_game.getFeature(GameWingsAndAura)},
{ id="aura", text="Aura", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, {id = "shader", text = "Shaders", checked = false, enabled = g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0},
{ id="shader", text="Shaders", checked=false, enabled=g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0 }, {id = "healtbar", text = "Health Bars", checked = false, enabled = g_game.getFeature(GameHealthInfoBackground)},
{ id="healtbar", text="Health Bars", checked=false, enabled=g_game.getFeature(GameHealthInfoBackground) }, {id = "manabar", text = "Mana Bars", checked = false, enabled = g_game.getFeature(GameHealthInfoBackground)}
{ id="manabar", text="Mana Bars", checked=false, enabled=g_game.getFeature(GameHealthInfoBackground) },
} }
appearanceOptions = { appearanceOptions = {
{id = "presetCat", text = "Preset", enabled = true},
{ id="presetCat", text="Preset", enabled=true }, {id = "outfitCat", text = "Outfit", enabled = true},
{ id="outfitCat", text="Outfit", enabled=true }, {id = "mountCat", text = "Mount", enabled = g_game.getFeature(GamePlayerMounts)},
{ id="mountCat", text="Mount", enabled=g_game.getFeature(GamePlayerMounts) }, {id = "wingsCat", text = "Wings", enabled = g_game.getFeature(GameWingsAndAura)},
{ id="wingsCat", text="Wings", enabled=g_game.getFeature(GameWingsAndAura) }, {id = "auraCat", text = "Aura", enabled = g_game.getFeature(GameWingsAndAura)},
{ id="auraCat", text="Aura", enabled=g_game.getFeature(GameWingsAndAura) }, {id = "shaderCat", text = "Shader", enabled = g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0},
{ id="shaderCat", text="Shader", enabled=g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0 }, {id = "healtbarCat", text = "Health Bars", enabled = g_game.getFeature(GameHealthInfoBackground)},
{ id="healtbarCat", text="Health Bars", enabled=g_game.getFeature(GameHealthInfoBackground) }, {id = "manabarCat", text = "Mana Bars", enabled = g_game.getFeature(GameHealthInfoBackground)}
{ id="manabarCat", text="Mana Bars", enabled=g_game.getFeature(GameHealthInfoBackground) },
} }
previewOptions = { previewOptions = {
{id = "move", text = "Movement", checked = false, enabled = true},
{ id="move", text="Movement", checked=false, enabled=true }, {id = "showOutfit", text = "Outfit", checked = true, enabled = true},
{ id="showOutfit", text="Outfit", checked=true, enabled=true }, {id = "showMount", text = "Mount", checked = false, enabled = g_game.getFeature(GamePlayerMounts)},
{ id="showMount", text="Mount", checked=false, enabled=g_game.getFeature(GamePlayerMounts) }, {id = "showWings", text = "Wings", checked = false, enabled = g_game.getFeature(GameWingsAndAura)},
{ id="showWings", text="Wings", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, {id = "showAura", text = "Aura", checked = false, enabled = g_game.getFeature(GameWingsAndAura)},
{ id="showAura", text="Aura", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, {id = "showShader", text = "Shader", checked = false, enabled = g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0}
{ id="showShader", text="Shader", checked=false, enabled=g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0 },
} }
end end
function init() function init()
@ -96,16 +89,20 @@ function terminate()
end end
function onFilterList(text) function onFilterList(text)
if not outfitWindow then return end if not outfitWindow then
return
end
filterText = text:lower() filterText = text:lower()
refreshVisiblePreviews() refreshVisiblePreviews()
end end
function clearFilterText() function clearFilterText()
if not outfitWindow then return end if not outfitWindow then
return
end
outfitWindow.search.filterWindow:setText('') outfitWindow.search.filterWindow:setText("")
end end
function onPresetButtonPress(key) function onPresetButtonPress(key)
@ -124,7 +121,6 @@ function onPresetButtonPress(key)
if widget then if widget then
widget:destroy() widget:destroy()
end end
elseif key == "new" then elseif key == "new" then
local outfit = getOutfitFromCurrentChecks(1) local outfit = getOutfitFromCurrentChecks(1)
outfit.mount = 0 outfit.mount = 0
@ -133,22 +129,20 @@ function onPresetButtonPress(key)
local widget = g_ui.createWidget("LargePreviewTile", outfitWindow.list) local widget = g_ui.createWidget("LargePreviewTile", outfitWindow.list)
widget.catalog = "preset" widget.catalog = "preset"
widget:setId("preset."..outfit.type..name) widget:setId("preset." .. outfit.type .. name)
widget.outfit:setOutfit(outfit) widget.outfit:setOutfit(outfit)
if mount then if mount then
widget.mount:setOutfit({ widget.mount:setOutfit(
type = mount {
}) type = mount
}
)
end end
widget.title:setText(name) widget.title:setText(name)
elseif key == "rename" then elseif key == "rename" then
if widget then if widget then
modules.client_textedit.show(widget.title, {title="Rename Preset", placeholder=widget.title:getText()}) modules.client_textedit.show(widget.title, {title = "Rename Preset", placeholder = widget.title:getText()})
end end
elseif key == "save" then elseif key == "save" then
if widget then if widget then
local data = getOutfitFromCurrentChecks() local data = getOutfitFromCurrentChecks()
@ -165,7 +159,9 @@ function onPresetButtonPress(key)
end end
function onOptionChange(key, checked, widget) function onOptionChange(key, checked, widget)
if not outfitWindow then return end if not outfitWindow then
return
end
local creature = outfitWindow.preview.creaturePanel.creature local creature = outfitWindow.preview.creaturePanel.creature
if key:find("show") or key:find("addon") then if key:find("show") or key:find("addon") then
@ -173,10 +169,10 @@ function onOptionChange(key, checked, widget)
end end
if key:find("Cat") then if key:find("Cat") then
currentCategory = string.sub(key, 1, key:len()-3) currentCategory = string.sub(key, 1, key:len() - 3)
-- set filter window title -- set filter window title
outfitWindow.search.title:setText("Filter "..currentCategory.."s") outfitWindow.search.title:setText("Filter " .. currentCategory .. "s")
if key == "presetCat" then if key == "presetCat" then
outfitWindow.list:getLayout():setNumColumns(1) outfitWindow.list:getLayout():setNumColumns(1)
@ -192,16 +188,12 @@ function onOptionChange(key, checked, widget)
-- set correct checks -- set correct checks
for i, child in ipairs(widget:getParent():getParent():getChildren()) do for i, child in ipairs(widget:getParent():getParent():getChildren()) do
child.checkBox:setChecked(widget==child.checkBox) child.checkBox:setChecked(widget == child.checkBox)
end end
refreshVisiblePreviews() refreshVisiblePreviews()
elseif key == "move" then elseif key == "move" then
creature:setAnimate(checked) creature:setAnimate(checked)
elseif key == "showOutfit" or key == "showMount" then elseif key == "showOutfit" or key == "showMount" then
local options = outfitWindow.preview.options local options = outfitWindow.preview.options
local showOutfit = options.showOutfit local showOutfit = options.showOutfit
@ -216,14 +208,13 @@ function onOptionChange(key, checked, widget)
else else
options.move:enable() options.move:enable()
end end
end end
end end
function refreshVisiblePreviews() function refreshVisiblePreviews()
if not outfitWindow then return end if not outfitWindow then
return
end
for i, child in ipairs(outfitWindow.list:getChildren()) do for i, child in ipairs(outfitWindow.list:getChildren()) do
local id = child:getId() local id = child:getId()
@ -240,17 +231,19 @@ function getOutfitFromCurrentChecks(returnVal)
-- 0 - return raw table -- 0 - return raw table
-- 1 - return combined outfit according to configure checks -- 1 - return combined outfit according to configure checks
-- 2 - return combined outfit according to preview checks -- 2 - return combined outfit according to preview checks
if not outfitWindow then return end if not outfitWindow then
return
end
local data = { local data = {
cleanOutfit = {}, -- outfit.type & colors cleanOutfit = {}, -- outfit.type & colors
mount = 0, -- outfit.mount mount = 0, -- outfit.mount
addons = 0, -- outfit.addons addons = 0, -- outfit.addons
shader = "", -- outfit.shader shader = "", -- outfit.shader
wings = 0, -- outfit.wings wings = 0, -- outfit.wings
aura = 0, -- outfit.aura aura = 0, -- outfit.aura
healthbar = "", -- outfit.healthbar healthbar = "", -- outfit.healthbar
manabar = "" -- outfit.manabar manabar = "" -- outfit.manabar
} }
local combinedOutfit local combinedOutfit
@ -315,11 +308,11 @@ function getOutfitFromCurrentChecks(returnVal)
-- TODO: test & most likely fix all custom features (wings, auras, shaders, bars) -- TODO: test & most likely fix all custom features (wings, auras, shaders, bars)
if returnVal == 0 then if returnVal == 0 then
return data -- raw return data -- raw
elseif returnVal == 1 then elseif returnVal == 1 then
return combinedOutfit -- combined @ configure return combinedOutfit -- combined @ configure
else else
return previewOutfit -- combined @ preview return previewOutfit -- combined @ preview
end end
end end
@ -342,14 +335,16 @@ function randomize()
end end
function onElementSelect(widget) function onElementSelect(widget)
if not outfitWindow then return end if not outfitWindow then
return
end
local catalog = string.split(widget:getId(), ".")[1] local catalog = string.split(widget:getId(), ".")[1]
-- apply correct check -- apply correct check
for i, child in ipairs(widget:getParent():getChildren()) do for i, child in ipairs(widget:getParent():getChildren()) do
-- there can be few items checked, but only one per catalog -- there can be few items checked, but only one per catalog
if child.catalog == widget.catalog then if child.catalog == widget.catalog then
child:setChecked(widget==child) child:setChecked(widget == child)
end end
end end
@ -366,7 +361,6 @@ function onElementSelect(widget)
addon1:setEnabled(addons == 1 or addons == 3) addon1:setEnabled(addons == 1 or addons == 3)
addon2:setEnabled(addons > 1) addon2:setEnabled(addons > 1)
refreshPreview() refreshPreview()
setCategoryDescription(catalog, outfit.type) setCategoryDescription(catalog, outfit.type)
elseif catalog == "mount" then elseif catalog == "mount" then
@ -374,7 +368,6 @@ function onElementSelect(widget)
refreshPreview() refreshPreview()
setCategoryDescription(catalog, outfit.type) setCategoryDescription(catalog, outfit.type)
elseif catalog == "preset" then elseif catalog == "preset" then
local outfit = widget.outfit:getOutfit().type local outfit = widget.outfit:getOutfit().type
local mount = widget.mount:getOutfit().type local mount = widget.mount:getOutfit().type
@ -394,34 +387,26 @@ function onElementSelect(widget)
setCategoryDescription(catalog, widget.title:getText()) setCategoryDescription(catalog, widget.title:getText())
refreshPreview() refreshPreview()
elseif catalog == "shader" then elseif catalog == "shader" then
local shader = widget.creature:getOutfit().shader local shader = widget.creature:getOutfit().shader
setCategoryDescription(catalog, widget.title:getText()) setCategoryDescription(catalog, widget.title:getText())
refreshPreview() refreshPreview()
elseif catalog == "healthbar" then elseif catalog == "healthbar" then
elseif catalog == "manabar" then elseif catalog == "manabar" then
elseif catalog == "wings" then elseif catalog == "wings" then
end end
end end
function refreshPreview() function refreshPreview()
if not outfitWindow then return end if not outfitWindow then
return
end
local creature = outfitWindow.preview.creaturePanel.creature local creature = outfitWindow.preview.creaturePanel.creature
local options = outfitWindow.preview.options local options = outfitWindow.preview.options
local outfit = getOutfitFromCurrentChecks(2) local outfit = getOutfitFromCurrentChecks(2)
local showOutfit = options.showOutfit and options.showOutfit.check:isChecked() local showOutfit = options.showOutfit and options.showOutfit.check:isChecked()
local showMount = g_game.getFeature(GamePlayerMounts) and options.showMount and options.showMount.check:isChecked() local showMount = g_game.getFeature(GamePlayerMounts) and options.showMount and options.showMount.check:isChecked()
local showShader = (g_game.getFeature(GameOutfitShaders) or #localShaders > 0) and options.showShader and options.showShader.check:isChecked() local showShader = (g_game.getFeature(GameOutfitShaders) or #localShaders > 0) and options.showShader and options.showShader.check:isChecked()
@ -444,7 +429,9 @@ function refreshPreview()
end end
function rotatePreview(side) function rotatePreview(side)
if not outfitWindow then return end if not outfitWindow then
return
end
local creature = outfitWindow.preview.creaturePanel.creature local creature = outfitWindow.preview.creaturePanel.creature
previewDir = side == "rotateLeft" and (previewDir + 1) or (previewDir - 1) previewDir = side == "rotateLeft" and (previewDir + 1) or (previewDir - 1)
previewDir = previewDir % 4 previewDir = previewDir % 4
@ -453,12 +440,14 @@ function rotatePreview(side)
end end
function setCategoryDescription(id, key) function setCategoryDescription(id, key)
if not outfitWindow then return end if not outfitWindow then
return
end
-- id can be widgetId so extract id -- id can be widgetId so extract id
local type = string.split(id, ".")[1] -- ie. outfit local type = string.split(id, ".")[1] -- ie. outfit
local tableKey = type.."s" -- ie. outfits local tableKey = type .. "s" -- ie. outfits
local newId = type.."Cat" -- ie. outfitCat local newId = type .. "Cat" -- ie. outfitCat
local table = dataTables[tableKey] local table = dataTables[tableKey]
local widget = outfitWindow.appearance.categories[newId] local widget = outfitWindow.appearance.categories[newId]
@ -469,7 +458,9 @@ function setCategoryDescription(id, key)
end end
-- something went wrong -- something went wrong
if not table or not widget then return end if not table or not widget then
return
end
for i, data in ipairs(table) do for i, data in ipairs(table) do
if data[1] == key then if data[1] == key then
@ -477,11 +468,13 @@ function setCategoryDescription(id, key)
end end
end end
widget:setText('-') widget:setText("-")
end end
function onClotheCheckChange(clotheButtonBox) function onClotheCheckChange(clotheButtonBox)
if not outfitWindow then return end if not outfitWindow then
return
end
local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit() local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit()
if clotheButtonBox == currentClotheButtonBox then if clotheButtonBox == currentClotheButtonBox then
clotheButtonBox.onCheckChange = nil clotheButtonBox.onCheckChange = nil
@ -509,7 +502,9 @@ function onClotheCheckChange(clotheButtonBox)
end end
function onColorCheckChange(colorBox) function onColorCheckChange(colorBox)
if not outfitWindow then return end if not outfitWindow then
return
end
local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit() local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit()
if colorBox == currentColorBox then if colorBox == currentColorBox then
colorBox.onCheckChange = nil colorBox.onCheckChange = nil
@ -540,10 +535,11 @@ function onColorCheckChange(colorBox)
end end
function updateOutfits() function updateOutfits()
if not outfitWindow then return end if not outfitWindow then
return
end
local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit() local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit()
for i, child in ipairs(outfitWindow.list:getChildren()) do for i, child in ipairs(outfitWindow.list:getChildren()) do
if child.catalog == "outfit" then if child.catalog == "outfit" then
local previewOutfit = child.creature:getOutfit() local previewOutfit = child.creature:getOutfit()
@ -615,7 +611,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
outfit.addons = addons outfit.addons = addons
local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list)
widget:setId("outfit."..name:lower().." "..id) widget:setId("outfit." .. name:lower() .. " " .. id)
widget.title:setText(name) widget.title:setText(name)
outfit.mount = 0 outfit.mount = 0
widget.creature:setOutfit(outfit) widget.creature:setOutfit(outfit)
@ -631,7 +627,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
} }
local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list)
widget:setId("mount."..name:lower().." "..id) widget:setId("mount." .. name:lower() .. " " .. id)
widget.title:setText(name) widget.title:setText(name)
widget.creature:setOutfit(mountOufit) widget.creature:setOutfit(mountOufit)
widget.catalog = "mount" widget.catalog = "mount"
@ -646,7 +642,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
} }
local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list)
widget:setId("wings."..name:lower().." "..id) widget:setId("wings." .. name:lower() .. " " .. id)
widget.title:setText(name) widget.title:setText(name)
widget.creature:setOutfit(wingsOufit) widget.creature:setOutfit(wingsOufit)
widget.catalog = "wings" widget.catalog = "wings"
@ -661,7 +657,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
} }
local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list)
widget:setId("aura."..name:lower().." "..id) widget:setId("aura." .. name:lower() .. " " .. id)
widget.title:setText(name) widget.title:setText(name)
widget.creature:setOutfit(auraOufit) widget.creature:setOutfit(auraOufit)
widget.catalog = "aura" widget.catalog = "aura"
@ -679,7 +675,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
shaderOutfit.type = outfitType shaderOutfit.type = outfitType
local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list)
widget:setId("shader."..name:lower().." "..id) widget:setId("shader." .. name:lower() .. " " .. id)
widget.title:setText(name) widget.title:setText(name)
widget.creature:setOutfit(shaderOutfit) widget.creature:setOutfit(shaderOutfit)
widget.catalog = "shader" widget.catalog = "shader"
@ -698,7 +694,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
local path = g_healthBars.getHealthBarPath(id) local path = g_healthBars.getHealthBarPath(id)
local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list)
widget:setId("healthbar."..name:lower().." "..id) widget:setId("healthbar." .. name:lower() .. " " .. id)
widget.item:setImageSource(i > 1 and path or "") widget.item:setImageSource(i > 1 and path or "")
widget.title:setText(i > i and name or "Standard") widget.title:setText(i > i and name or "Standard")
widget.catalog = "healthbar" widget.catalog = "healthbar"
@ -711,13 +707,12 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
local path = g_healthBars.getHealthBarPath(id) local path = g_healthBars.getHealthBarPath(id)
local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list)
widget:setId("manabar."..name:lower().." "..id) widget:setId("manabar." .. name:lower() .. " " .. id)
widget.item:setImageSource(i > 1 and path or "") widget.item:setImageSource(i > 1 and path or "")
widget.title:setText(i > i and name or "Standard") widget.title:setText(i > i and name or "Standard")
widget.catalog = "manabar" widget.catalog = "manabar"
end end
-- check current outfit -- check current outfit
for i, child in ipairs(outfitWindow.list:getChildren()) do for i, child in ipairs(outfitWindow.list:getChildren()) do
local catalog = child.catalog local catalog = child.catalog
@ -802,14 +797,14 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
if i > 1 then if i > 1 then
local catalog = string.sub(settings.id, 5):lower() local catalog = string.sub(settings.id, 5):lower()
local data = dataTables[catalog.."s"] local data = dataTables[catalog .. "s"]
-- if there's no options for certain category disable widget -- if there's no options for certain category disable widget
if not data or #data == 0 then if not data or #data == 0 then
widget.check:setChecked(false) widget.check:setChecked(false)
widget.check:setEnabled(false) widget.check:setEnabled(false)
widget:setEnabled(false) widget:setEnabled(false)
widget.check:setColor('#808080') widget.check:setColor("#808080")
end end
end end
end end
@ -831,7 +826,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
local widget = g_ui.createWidget("AppearanceCategory", outfitWindow.appearance.categories) local widget = g_ui.createWidget("AppearanceCategory", outfitWindow.appearance.categories)
widget:setId(settings.id) widget:setId(settings.id)
widget.checkBox:setText(settings.text) widget.checkBox:setText(settings.text)
widget.checkBox:setChecked(i==2) widget.checkBox:setChecked(i == 2)
end end
end end
@ -852,20 +847,19 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
addon1:setEnabled(availableAddons > 0) addon1:setEnabled(availableAddons > 0)
addon2:setEnabled(availableAddons > 1) addon2:setEnabled(availableAddons > 1)
for i, setting in ipairs(settings) do for i, setting in ipairs(settings) do
local outfit = setting.outfit local outfit = setting.outfit
local mount = setting.mount local mount = setting.mount
local name = setting.name local name = setting.name
local widget = g_ui.createWidget("LargePreviewTile", outfitWindow.list) local widget = g_ui.createWidget("LargePreviewTile", outfitWindow.list)
widget.catalog = "preset" widget.catalog = "preset"
widget:setId("preset."..outfit.type..name) widget:setId("preset." .. outfit.type .. name)
widget.outfit:setOutfit(outfit) widget.outfit:setOutfit(outfit)
if mount then if mount then
widget.mount:setOutfit(mount) widget.mount:setOutfit(mount)
end end
widget.title:setText(name) widget.title:setText(name)
end end
refreshVisiblePreviews() refreshVisiblePreviews()
@ -921,16 +915,22 @@ function save()
local file = "/settings/outfits.json" local file = "/settings/outfits.json"
local status, result = pcall(function() return json.encode(settings, 2) end) if not g_resources.fileExists(file) then
g_resources.makeDir("/settings")
end
local status, result =
pcall(
function()
return json.encode(settings, 2)
end
)
if not status then if not status then
return onError( return onError("Error while saving top bar settings. Data won't be saved. Details: " .. result)
"Error while saving top bar settings. Data won't be saved. Details: " ..
result)
end end
if result:len() > 100 * 1024 * 1024 then if result:len() > 100 * 1024 * 1024 then
return onError( return onError("Something went wrong, file is above 100MB, won't be saved")
"Something went wrong, file is above 100MB, won't be saved")
end end
g_resources.writeFileContents(file, result) g_resources.writeFileContents(file, result)
@ -939,17 +939,22 @@ end
function load() function load()
local file = "/settings/outfits.json" local file = "/settings/outfits.json"
if not g_resources.fileExists(file) then
g_resources.makeDir("/settings")
end
if g_resources.fileExists(file) then if g_resources.fileExists(file) then
local status, result = pcall(function() local status, result =
return json.decode(g_resources.readFileContents(file)) pcall(
end) function()
if not status then return json.decode(g_resources.readFileContents(file))
return onError(
"Error while reading top bar settings file. To fix this problem you can delete storage.json. Details: " ..
result)
end end
settings = result )
if not status then
return onError("Error while reading top bar settings file. To fix this problem you can delete storage.json. Details: " .. result)
end
settings = result
else else
settings = {} settings = {}
end end
end end

View File

@ -210,6 +210,7 @@ GameNewCreatureStacking = 121 -- Ignore MAX_THINGS limit while adding to tile
GameCreaturesMana = 122 -- get mana from server for creatures other than Player GameCreaturesMana = 122 -- get mana from server for creatures other than Player
GameQuickLootFlags = 123 -- enables quick loot feature for all protocols GameQuickLootFlags = 123 -- enables quick loot feature for all protocols
GameDontMergeAnimatedText = 124 GameDontMergeAnimatedText = 124
GameMissionId = 125
LastGameFeature = 130 LastGameFeature = 130

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.