From 07be63e505802d9e74376d745f39322662043852 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 20 Dec 2022 15:27:47 +0100 Subject: [PATCH] rebuilding UI for scrollview, bugfix for token arranger --- modsettings/CustomUIAssets.json | 18 +- .../TokenArranger.022907.ttslua | 47 ++-- src/core/Global.ttslua | 4 + xml/OptionPanel.xml | 242 ++++++++++++------ 4 files changed, 195 insertions(+), 116 deletions(-) diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index 89293b1c..325dfa56 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -75,13 +75,23 @@ "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118466516005/113C19D37CFFA9E554394FD5B11B32967F846A62/" }, { - "Name": "option_image1", + "Name": "option_header1", "Type": 0, - "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118468280563/911BA319CD7502258D570B23BD51B3D8DA8B2AC3/" + "URL": "http://cloud-3.steamusercontent.com/ugc/2024962321894443102/5727544F24E8C4546031F4DDE8BD4B45D93AC3FC/" }, { - "Name": "option_image2", + "Name": "option_header2", "Type": 0, - "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118470839572/FB133C41A6D8915A44C138BCF947ECFE3D111813/" + "URL": "http://cloud-3.steamusercontent.com/ugc/2024962321894443022/3262DF2ABAE8D9A2BF64ECB74C1BB34B33814554/" + }, + { + "Name": "option_on", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2024962321889555728/22ABD35CBB49A001F3A5318E4AFCFB22D24FEA39/" + }, + { + "Name": "option_off", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2024962321889555661/6643E5CC9160FF4624672C255D0DF7B313DA00A5/" } ] diff --git a/objects/Fan-MadeAccessories.aa8b38/TokenArranger.022907.ttslua b/objects/Fan-MadeAccessories.aa8b38/TokenArranger.022907.ttslua index 485eb56d..b47dede3 100644 --- a/objects/Fan-MadeAccessories.aa8b38/TokenArranger.022907.ttslua +++ b/objects/Fan-MadeAccessories.aa8b38/TokenArranger.022907.ttslua @@ -193,37 +193,22 @@ function layout(_, _, isRightClick) -- stop here if right-clicked if isRightClick then return end - local chaos_bag = getChaosBag() - local chaos_bag_objects = chaos_bag.getObjects() - - -- take each token out and clone it - for _, data in ipairs(chaos_bag_objects) do - chaos_bag.takeObject { - guid = data.guid, - smooth = false, - callback_function = function(tok) - chaos_bag.putObject(tok.clone()) - tok.addTag("to_be_deleted") - end - } - end - - -- wait until all tokens have finished spawning - Wait.condition(function() placeTokens() end, function() return #chaos_bag_objects == #getObjectsWithTag("to_be_deleted") end) -end - --- position tokens sorted by value -function placeTokens() + local chaosBag = getChaosBag() local data = {} - -- create table with tokens - for i, token in ipairs(getObjectsWithTag("to_be_deleted")) do - local name = token.getName() or "" - local value = tonumber(name) - local precedence = TOKEN_PRECEDENCE[name] + -- clone tokens from chaos bag (default position above trash can) + for i, obj in ipairs(chaosBag.getData().ContainedObjects) do + obj["Tags"] = { "to_be_deleted" } + local spawnedObj = spawnObjectData({ + data = obj, + position = { 0.49, 3, 0 } + }) + + local value = tonumber(obj["Nickname"]) + local precedence = TOKEN_PRECEDENCE[obj["Nickname"]] data[i] = { - token = token, + token = spawnedObj, value = value or precedence[1] } @@ -237,11 +222,17 @@ function placeTokens() -- sort table by value (symbols last if same value) table.sort(data, token_value_comparator) + -- error handling for removal of token arranger + if self == nil then + for _, token in ipairs(getObjectsWithTag("to_be_deleted")) do token.destruct() end + return + end + -- laying out the tokens local pos = self.getPosition() + Vector(3.55, -0.05, -3.95) local location = { x = pos.x, y = pos.y, z = pos.z } local current_value = data[1].value - + for _, item in ipairs(data) do if item.value ~= current_value then location.x = location.x - 1.75 diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 53e9d6c3..c8c54782 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -857,6 +857,10 @@ function applyOptionPanelChange(id, state) -- option: Show chaos bag manager elseif id == "showChaosBagManager" then spawnOrRemoveHelper(state, "Chaos Bag Manager", {-67.8, 1.4, -49.5}) + + -- option: Show navigation overlay + elseif id == "showNavigationOverlay" then + spawnOrRemoveHelper(state, "jaqenZann's Navigation Overlay", {-11.7, 1.4, -15}) end end diff --git a/xml/OptionPanel.xml b/xml/OptionPanel.xml index 507677b4..0a9af3bf 100644 --- a/xml/OptionPanel.xml +++ b/xml/OptionPanel.xml @@ -1,18 +1,27 @@ - + + - - - + + - + + + + + - - + + + + + + + + - - - - - - - \ No newline at end of file + + + \ No newline at end of file