From f71b1d16a6c143ac84f281020abeb3fd86810b54 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 29 Jun 2024 15:55:27 +0200 Subject: [PATCH] first shot at xml creation --- src/playermat/Playermat.ttslua | 155 +++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 1f8ffce8..093677d7 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -7,6 +7,19 @@ local searchLib = require("util/SearchLib") local tokenChecker = require("core/token/TokenChecker") local tokenManager = require("core/token/TokenManager") +-- option panel data +local availableOptions = { + ["Personal Settings"] = { + { + id = "slotEditing", + title = "Enable Slot Edit Mode", + tooltip = "Makes each slot clickable to change the symbol.", + type = "toggle", + data = "false" + } + } +} + -- we use this to turn off collision handling until onLoad() is complete local collisionEnabled = false local currentlyEditingSlots = false @@ -646,6 +659,148 @@ function createXML() end -- create the personal option panel + local defaultsXML = { + tag = "Defaults", + children = { + { + tag = "Text", + attributes = { color = "#FFFFFF", alignment = "MiddleLeft" } + }, + { + tag = "Dropdown", + attributes = { rectAlignment = "MiddleCenter" } + }, + { + tag = "Cell", + attributes = { dontUseTableCellBackground = "true", outlineSize = "0 1", outline = "grey" } + } + } + } + table.insert(xml, defaultsXML) + + -- main window + local optionPanelXML = { + tag = "TableLayout", + attributes = { + width = "100", + height = "100", + rotation = "0 0 180", + position = "300 0 -100", + --active = "false", + color = "#000000", + outlineSize = "2 2", + outline = "grey", + showAnimation = "SlideIn_Right", + hideAnimation = "SlideOut_Right", + animationDuration = "0.2" + }, + children = { + -- header + { + tag = "Row", + attributes = { preferredHeight = "60" }, + children = { + { + tag = "Cell", + children = { + { + tag = "Panel", + attributes = { padding = "10 0 0 0", scale = "0.3 0.3" }, + children = { + { + tag = "Text", + attributes = { font = "font_teutonic-arkham", fontSize = "35", text = "Options" } + } + } + } + } + } + } + } + } + } + + -- add options groups + for groupName, groupData in pairs(availableOptions) do + -- group header + local groupXML = { + tag = "Row", + attributes = { preferredHeight = "44" }, + children = { + { + tag = "Cell", + attributes = { padding = "10 10 0 0", columnSpan = "3", color = "#222222" }, + children = { + { + tag = "Panel", + attributes = { padding = "5 0 0 0" }, + children = { + { + tag = "Text", + attributes = { fontSize = "28", font = "font_teutonic-arkham", text = groupName } + } + } + } + } + } + } + } + + -- options + for i, optionData in ipairs(groupData) do + local optionXML = { + { + tag = "Row", + attributes = { preferredHeight = "50", tooltip = optionData.tooltip, tooltipPosition = "Left", tooltipBackgroundColor = "rgba(0,0,0,1)" }, + children = { + -- option title + { + tag = "Cell", + attributes = { padding = "10 10 5 5", color = "#333333", columnSpan = "2" }, + children = { + { + tag = "Panel", + attributes = { padding = "10 0 0 0" }, + children = { + { + tag = "Text", + attributes = { fontSize = "22", font = "font_teutonic-arkham", text = optionData.title } + } + } + } + } + }, + -- option button + { + tag = "Cell", + attributes = { padding = "10 10 5 5", color = "#333333" }, + children = { + { + tag = "Button", + attributes = { + id = optionData.id, + image = "option-off", + onClick="onClick_toggleOption", + rectAlignment = "MiddleRight", + offsetXY = "-30 0", + colors = "#FFFFFF|#dfdfdf", + height = "36", + width = "65", + ignoreLayout = "True" + } + } + } + } + } + } + } + table.insert(groupXML, optionXML) + end + table.insert(optionPanelXML, groupXML) + end + table.insert(xml, optionPanelXML) + + -- create buttons at the bottom self.UI.setXmlTable(xml) end