forked from ComputerNerd/Retro-Graphics-Toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.lua
73 lines (60 loc) · 2.12 KB
/
gui.lua
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
--[[
This file is part of Retro Graphics Toolkit
Retro Graphics Toolkit is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any later version.
Retro Graphics Toolkit is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Retro Graphics Toolkit. If not, see <http://www.gnu.org/licenses/>.
Copyright Sega16 (or whatever you wish to call me) (2012-2019)
--]]
function setPalTypeCB(menuItm)
local vStr = menuItm:value()
local v = palTabSelLUT[vStr]
local p = projects.current
p:setPalType(v)
p.palette:toRgbAll()
rgt.damage()
end
spriteSizeTextToValueTable = nil
function setSpriteSizeCB(unused)
local p = projects.current
local spriteSizeTxt = spriteSizeSel:value()
local spriteSizeID = spriteSizeTextToValueTable[spriteSizeTxt]
p:setSpriteSizeID(spriteSizeID)
rgt.redraw()
end
function generateLutFromList(choiceList)
local tmp = {}
for i = 1, #choiceList do
tmp[choiceList[i]] = i - 1
end
return tmp
end
function addItemsToChoice(menu, choiceList)
for i = 1, #choiceList do
local menuItemEscaped = choiceList[i]:gsub('/', '\\/')
menu:add(menuItemEscaped)
end
end
function tabConfig(tab)
if tab == rgt.paletteTab then
palTabSel = fltk.choice(336, 464, 128, 24, "Palette table selection")
palTabSel:align(FL.ALIGN_TOP)
palTabSel:callback(setPalTypeCB)
palTabSelOptions = {"HardwareMan's measured values", 'round(255*v/7)', 'Steps of 36', 'Steps of 32'}
palTabSelLUT = generateLutFromList(palTabSelOptions)
addItemsToChoice(palTabSel, palTabSelOptions)
palTabSel:labelsize(12)
spriteSizeSel = fltk.choice(336, 464, 128, 24, "Sprite size")
spriteSizeSel:align(FL.ALIGN_TOP)
spriteSizeSel:callback(setSpriteSizeCB)
spriteSizeSel:labelsize(12)
spriteSizeSel:hide()
elseif tab==rgt.levelTab then
initLevelEditor()
end
end