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()
configOptions = {
{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 = "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 = "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="manabar", text="Mana Bars", checked=false, enabled=g_game.getFeature(GameHealthInfoBackground) },
{id = "manabar", text = "Mana Bars", checked = false, enabled = g_game.getFeature(GameHealthInfoBackground)}
}
appearanceOptions = {
{id = "presetCat", text = "Preset", enabled = true},
{id = "outfitCat", text = "Outfit", enabled = true},
{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 = "shaderCat", text = "Shader", enabled = g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0},
{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 = {
{id = "move", text = "Movement", checked = false, enabled = true},
{id = "showOutfit", text = "Outfit", checked = true, enabled = true},
{id = "showMount", text = "Mount", checked = false, enabled = g_game.getFeature(GamePlayerMounts)},
{id = "showWings", text = "Wings", 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
function init()
@ -96,16 +89,20 @@ function terminate()
end
function onFilterList(text)
if not outfitWindow then return end
if not outfitWindow then
return
end
filterText = text:lower()
refreshVisiblePreviews()
end
function clearFilterText()
if not outfitWindow then return end
if not outfitWindow then
return
end
outfitWindow.search.filterWindow:setText('')
outfitWindow.search.filterWindow:setText("")
end
function onPresetButtonPress(key)
@ -124,7 +121,6 @@ function onPresetButtonPress(key)
if widget then
widget:destroy()
end
elseif key == "new" then
local outfit = getOutfitFromCurrentChecks(1)
outfit.mount = 0
@ -136,19 +132,17 @@ function onPresetButtonPress(key)
widget:setId("preset." .. outfit.type .. name)
widget.outfit:setOutfit(outfit)
if mount then
widget.mount:setOutfit({
widget.mount:setOutfit(
{
type = mount
})
}
)
end
widget.title:setText(name)
elseif key == "rename" then
if widget then
modules.client_textedit.show(widget.title, {title = "Rename Preset", placeholder = widget.title:getText()})
end
elseif key == "save" then
if widget then
local data = getOutfitFromCurrentChecks()
@ -165,7 +159,9 @@ function onPresetButtonPress(key)
end
function onOptionChange(key, checked, widget)
if not outfitWindow then return end
if not outfitWindow then
return
end
local creature = outfitWindow.preview.creaturePanel.creature
if key:find("show") or key:find("addon") then
@ -196,12 +192,8 @@ function onOptionChange(key, checked, widget)
end
refreshVisiblePreviews()
elseif key == "move" then
creature:setAnimate(checked)
elseif key == "showOutfit" or key == "showMount" then
local options = outfitWindow.preview.options
local showOutfit = options.showOutfit
@ -216,14 +208,13 @@ function onOptionChange(key, checked, widget)
else
options.move:enable()
end
end
end
function refreshVisiblePreviews()
if not outfitWindow then return end
if not outfitWindow then
return
end
for i, child in ipairs(outfitWindow.list:getChildren()) do
local id = child:getId()
@ -240,7 +231,9 @@ function getOutfitFromCurrentChecks(returnVal)
-- 0 - return raw table
-- 1 - return combined outfit according to configure checks
-- 2 - return combined outfit according to preview checks
if not outfitWindow then return end
if not outfitWindow then
return
end
local data = {
cleanOutfit = {}, -- outfit.type & colors
@ -342,7 +335,9 @@ function randomize()
end
function onElementSelect(widget)
if not outfitWindow then return end
if not outfitWindow then
return
end
local catalog = string.split(widget:getId(), ".")[1]
-- apply correct check
@ -366,7 +361,6 @@ function onElementSelect(widget)
addon1:setEnabled(addons == 1 or addons == 3)
addon2:setEnabled(addons > 1)
refreshPreview()
setCategoryDescription(catalog, outfit.type)
elseif catalog == "mount" then
@ -374,7 +368,6 @@ function onElementSelect(widget)
refreshPreview()
setCategoryDescription(catalog, outfit.type)
elseif catalog == "preset" then
local outfit = widget.outfit:getOutfit().type
local mount = widget.mount:getOutfit().type
@ -394,34 +387,26 @@ function onElementSelect(widget)
setCategoryDescription(catalog, widget.title:getText())
refreshPreview()
elseif catalog == "shader" then
local shader = widget.creature:getOutfit().shader
setCategoryDescription(catalog, widget.title:getText())
refreshPreview()
elseif catalog == "healthbar" then
elseif catalog == "manabar" then
elseif catalog == "wings" then
end
end
function refreshPreview()
if not outfitWindow then return end
if not outfitWindow then
return
end
local creature = outfitWindow.preview.creaturePanel.creature
local options = outfitWindow.preview.options
local outfit = getOutfitFromCurrentChecks(2)
local showOutfit = options.showOutfit and options.showOutfit.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()
@ -444,7 +429,9 @@ function refreshPreview()
end
function rotatePreview(side)
if not outfitWindow then return end
if not outfitWindow then
return
end
local creature = outfitWindow.preview.creaturePanel.creature
previewDir = side == "rotateLeft" and (previewDir + 1) or (previewDir - 1)
previewDir = previewDir % 4
@ -453,7 +440,9 @@ function rotatePreview(side)
end
function setCategoryDescription(id, key)
if not outfitWindow then return end
if not outfitWindow then
return
end
-- id can be widgetId so extract id
local type = string.split(id, ".")[1] -- ie. outfit
@ -469,7 +458,9 @@ function setCategoryDescription(id, key)
end
-- 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
if data[1] == key then
@ -477,11 +468,13 @@ function setCategoryDescription(id, key)
end
end
widget:setText('-')
widget:setText("-")
end
function onClotheCheckChange(clotheButtonBox)
if not outfitWindow then return end
if not outfitWindow then
return
end
local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit()
if clotheButtonBox == currentClotheButtonBox then
clotheButtonBox.onCheckChange = nil
@ -509,7 +502,9 @@ function onClotheCheckChange(clotheButtonBox)
end
function onColorCheckChange(colorBox)
if not outfitWindow then return end
if not outfitWindow then
return
end
local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit()
if colorBox == currentColorBox then
colorBox.onCheckChange = nil
@ -540,10 +535,11 @@ function onColorCheckChange(colorBox)
end
function updateOutfits()
if not outfitWindow then return end
if not outfitWindow then
return
end
local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit()
for i, child in ipairs(outfitWindow.list:getChildren()) do
if child.catalog == "outfit" then
local previewOutfit = child.creature:getOutfit()
@ -717,7 +713,6 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
widget.catalog = "manabar"
end
-- check current outfit
for i, child in ipairs(outfitWindow.list:getChildren()) do
local catalog = child.catalog
@ -809,7 +804,7 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
widget.check:setChecked(false)
widget.check:setEnabled(false)
widget:setEnabled(false)
widget.check:setColor('#808080')
widget.check:setColor("#808080")
end
end
end
@ -852,7 +847,6 @@ function create(currentOutfit, outfitList, mountList, wingList, auraList, shader
addon1:setEnabled(availableAddons > 0)
addon2:setEnabled(availableAddons > 1)
for i, setting in ipairs(settings) do
local outfit = setting.outfit
local mount = setting.mount
@ -921,16 +915,22 @@ function save()
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
return onError(
"Error while saving top bar settings. Data won't be saved. Details: " ..
result)
return onError("Error while saving top bar settings. Data won't be saved. Details: " .. result)
end
if result:len() > 100 * 1024 * 1024 then
return onError(
"Something went wrong, file is above 100MB, won't be saved")
return onError("Something went wrong, file is above 100MB, won't be saved")
end
g_resources.writeFileContents(file, result)
@ -939,14 +939,19 @@ end
function load()
local file = "/settings/outfits.json"
if not g_resources.fileExists(file) then
g_resources.makeDir("/settings")
end
if g_resources.fileExists(file) then
local status, result = pcall(function()
local status, result =
pcall(
function()
return json.decode(g_resources.readFileContents(file))
end)
end
)
if not status then
return onError(
"Error while reading top bar settings file. To fix this problem you can delete storage.json. Details: " ..
result)
return onError("Error while reading top bar settings file. To fix this problem you can delete storage.json. Details: " .. result)
end
settings = result
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
GameQuickLootFlags = 123 -- enables quick loot feature for all protocols
GameDontMergeAnimatedText = 124
GameMissionId = 125
LastGameFeature = 130

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.