-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI Color List Reference.lua
More file actions
323 lines (231 loc) · 8.76 KB
/
UI Color List Reference.lua
File metadata and controls
323 lines (231 loc) · 8.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
--[[
@title: [ UI Color List Reference.lua ]
@author: [ BakaCowpoke ]
@date: [ 1/28/2026 ]
@license: [ CC0 ]
@description: [ Plugion Code for reference for UI Color Customization on the GrandMA3.
Without making your own, GrandMA3 has 1500+ references to colors for use when
designiing custom UI, they actually only use about 200 unique colors.
This plugin shows the colors with the shortest references...
One per unique Color.
IMPORTANT NOTE: Colors that are Global can be assigned with a string
(ie."Global.Text")
Colors that are listed from Root() are Path assignments NOT STRINGS.
Added the ToAddr reporting because it's SO MUCH SHORTER.
A list of the Global color names and info can be found on the MA by entering the
below command in the Command Line
List Root().ColorTheme.ColorGroups.Global.*
Hope this helps!
]
--]]
--For UI Element Functions
local pluginName = select(1, ...)
local componentName = select(2, ...)
local signalTable = select(3, ...)
local myHandle = select(4, ...)
local impy = select(3, ...)
local function main(handleArg1, arg2)
local continue = false
--[[ full list of 1500+ color references overwhelms the scrollbox.
Filterd down to thr condensedList of around 200 ]]
local colorList = {}
local sortedOrder = {}
--Fewer Colors by Shortest Reference length
local condensedList = {}
--UI Box container
local swatchBox = {}
local colorGroups = Root().ColorTheme.ColorGroups
if not colorGroups then
Printf("ColorGroups not found.")
return
end
-- Each Color Group
for i = 1, colorGroups:Count() do
local group = colorGroups[i]
-- Individual Color
for j = 1, group:Count() do
local color = group[j]
local rNatAddr = "Root()."..color:AddrNative()
local totLen = string.len(rNatAddr)
--local grpLen = string.len(group.name)
--local colLen = string.len(color.name)
--local totLen = grpLen + colLen
--Converting to Addresses because it's SO MUCH SHORTER!
local currAddress = tostring(ToAddr(color))
local currColorRef = tostring(color:Get("ColorDefRef"))
--Converting Hex RGBA to Decimal
local cHexRGBA = color.rgba:gsub("#", "")
local r_Dec = tonumber(string.sub(cHexRGBA, 1, 2), 16)
local g_Dec = tonumber(string.sub(cHexRGBA, 3, 4), 16)
local b_Dec = tonumber(string.sub(cHexRGBA, 5, 6), 16)
local a_Dec = tonumber(string.sub(cHexRGBA, 7, 8), 16)
--Converting Alpha to Match the setting Values in Appearances.
local a_Percent = a_Dec/2.55 --divied by 255 * 100
local a_MA = impy.round(a_Percent, 1)
local rgb_DecStr = string.format("(%d. %d, %d)",r_Dec, g_Dec, b_Dec)
local rgba_Dec = {r_Dec, g_Dec, b_Dec, a_Dec}
--[[Omitting the one entry "Global." can't seem to
catch with Name = Nil tests ]]
if totLen ~= 6 then
local tableToInsert = {
group = group.name,
color = color.name,
index = color.index,
rgba = color.rgba,
rgbaDec = rgba_Dec,
rgbDecStr = rgb_DecStr,
r = r_Dec,
g = g_Dec,
b = b_Dec,
a = a_Dec,
alphaMA = a_MA,
natAddress = rNatAddr,
address = currAddress,
length = totLen,
defRef = currColorRef
}
table.insert(colorList, tableToInsert)
end
end
end
sortedOrder = colorList
-- Sort by RGBA Then Reference String Lengths
table.sort(sortedOrder, function(a, b)
if a.rgba == b.rgba then
--Secondary Sort (I want the shortest string to call these by.)
return a.length < b.length
else
--Primary Sort (color by RGBA values)
return a.rgba > b.rgba
end
end)
local cLColor = nil
--Get rid of identical colors keep the one with the shortest reference string
for k, v in pairs(sortedOrder) do
if cLColor == nil then
table.insert(condensedList, v)
elseif cLColor.rgba ~= v.rgba then
table.insert(condensedList, v)
end
cLColor = v
end
local baseLayer = GetFocusDisplay().ScreenOverlay:Append('BaseInput')
baseLayer.Name = 'Basic'
baseLayer.H = '70%' --760
baseLayer.W = '70%' --800
baseLayer.Columns = 1
baseLayer.Rows = 3
baseLayer[1][1].SizePolicy = 'Fixed'
baseLayer[1][1].Size = 100
baseLayer[1][2].SizePolicy = 'Stretch'
baseLayer[1][3].SizePolicy = 'Fixed'
baseLayer[1][3].Size = 100
baseLayer.AutoClose = 'No'
baseLayer.CloseOnEscape = 'Yes'
local titleBar = baseLayer:Append('TitleBar')
titleBar.Columns = 2
titleBar.Rows = 1
titleBar.Anchors = '0,0'
titleBar[2][2].SizePolicy = 'Fixed'
titleBar[2][2].Size = 50
titleBar.Texture = 'corner2'
titleBar.Transparent = "No"
local titleBarIcon = titleBar:Append('TitleButton')
titleBarIcon.Font = 'Regular24'
titleBarIcon.Text = 'UI Color List Reference'
titleBarIcon.Texture = 'corner1'
titleBarIcon.Anchors = '0,0'
titleBarIcon.Icon = 'star'
local titleBarCloseButton = titleBar:Append('CloseButton')
titleBarCloseButton.Anchors = '1,0'
titleBarCloseButton.Texture = 'corner2'
--[[I believe I have Ahuramazda on the GrandMA Forums to thank
for the below ScrollBox Portions of this.
Thanks to "From Dark To Light" for the rest.
]]
local dialog = baseLayer:Append("DialogFrame")
dialog.H, dialog.W, dialog.Columns = '98%', '100%', 2
dialog[2][2].SizePolicy = "Content"
dialog.Anchors = '0,1'
local scrollbox = dialog:Append("ScrollBox")
scrollbox.Name = "mybox"
local scrollbar = dialog:Append("ScrollBarV")
scrollbar.ScrollTarget = "../mybox"
scrollbar.Anchors = '1,0'
--[[ When I used the full 1500+ Sorted List to make the
below swatchBoxes it wouldn't work. I'm guessing it
overwhelmed the scrollBox. ]]
--Swatches for each of the Colors
Printf("Total Swatches = " .. #condensedList)
for i = 1, #condensedList do
local boxSize = 120
local currentSwatchText = nil
local currentSwatchColor = nil
--[[Added ToAddr reference because it's WAY Shorter.
Since you have to look up the names anyway. ]]
local prunedAddress = string.gsub(condensedList[i].address, "Color ", "")
--Shortening the Refence string for Global items.
if condensedList[i].group == "Global" then
currentSwatchText = string.format("\"Global.%s\"\n\nRGB: %s (Alpha: %d / %s%%) Address: %s\n\nie. BackColor = %s", condensedList[i].color, condensedList[i].rgbDecStr, condensedList[i].a, condensedList[i].alphaMA, condensedList[i].address, prunedAddress)
currentSwatchColor = string.format("Global.%s", condensedList[i].color)
else
currentSwatchText = string.format("%s\n\nRGB: %s (Alpha: %d / %s%%) Address: %s\n\nie. BackColor = %s",condensedList[i].natAddress, condensedList[i].rgbDecStr, condensedList[i].a, condensedList[i].alphaMA, condensedList[i].address, prunedAddress)
currentSwatchColor = string.format("%s.%s", condensedList[i].group, condensedList[i].color)
end
swatchBox[i] = scrollbox:Append('UIObject')
swatchBox[i].H = boxSize
swatchBox[i].W = '100%' --700
swatchBox[i].Anchors = "0,0,1,0"
swatchBox[i].TextColor = "Global.Text"
swatchBox[i].Font = 'Medium20'
swatchBox[i].Text = currentSwatchText
swatchBox[i].Textshadow = 10
swatchBox[i].BackColor = currentSwatchColor
local yAdj = (i - 1) * boxSize
swatchBox[i].X, swatchBox[i].Y = 5, yAdj
end
--End of Swatch Boxes
local buttonGrid = baseLayer:Append('UILayoutGrid')
buttonGrid.Columns = 2
buttonGrid.Rows = 1
buttonGrid.H = 80
buttonGrid.Anchors = '0,2'
--[[ Left the Apply Button for If I want to give feedback
to the System Monitor at a later date. ]]
local applyButton = buttonGrid:Append('Button')
applyButton.Anchors = '0,0'
applyButton.Textshadow = 1
applyButton.HasHover = 'Yes'
applyButton.Text = 'Apply'
applyButton.Font = 'Regular28'
applyButton.TextalignmentH = 'Centre'
applyButton.PluginComponent = myHandle
applyButton.Clicked = 'ApplyButtonClicked'
local cancelButton = buttonGrid:Append('Button')
cancelButton.Anchors = '1,0'
cancelButton.Textshadow = 1
cancelButton.HasHover = 'Yes'
cancelButton.Text = 'Cancel'
cancelButton.Font = 'Regular28'
cancelButton.TextalignmentH = 'Centre'
cancelButton.PluginComponent = myHandle
cancelButton.Clicked = 'CancelButtonClicked'
signalTable.CancelButtonClicked = function(caller)
GetFocusDisplay().ScreenOverlay:ClearUIChildren()
checkBoxState = {"Cancelled"}
continue = true
end
--[[ Left the Apply Button for If I want to give feedback
to the System Monitor at a later date. ]]
signalTable.ApplyButtonClicked = function(caller)
GetFocusDisplay().ScreenOverlay:ClearUIChildren()
continue = true
end
repeat
until continue
end
impy.round = function(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
return main