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

@ -38,7 +38,6 @@ 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)},
@ -46,11 +45,9 @@ function setupTables()
{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)},
@ -58,20 +55,16 @@ function setupTables()
{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
@ -136,19 +132,17 @@ function onPresetButtonPress(key)
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
@ -196,12 +192,8 @@ function onOptionChange(key, checked, widget)
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,7 +231,9 @@ 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
@ -342,7 +335,9 @@ 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
@ -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,7 +440,9 @@ 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
@ -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()
@ -717,7 +713,6 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
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
@ -809,7 +804,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
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
@ -852,7 +847,6 @@ 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
@ -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,14 +939,19 @@ 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 =
pcall(
function()
return json.decode(g_resources.readFileContents(file)) return json.decode(g_resources.readFileContents(file))
end) end
)
if not status then if not status then
return onError( return onError("Error while reading top bar settings file. To fix this problem you can delete storage.json. Details: " .. result)
"Error while reading top bar settings file. To fix this problem you can delete storage.json. Details: " ..
result)
end end
settings = result settings = result
else else

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.