-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmenu.lua
More file actions
72 lines (62 loc) · 2.56 KB
/
menu.lua
File metadata and controls
72 lines (62 loc) · 2.56 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
local sprite_textures = require 'data'
local dictionaries = {}
for dict, textures in pairs(sprite_textures) do
dictionaries[#dictionaries + 1] = dict
end
table.sort(dictionaries, function(a, b)
return a:lower() < b:lower()
end)
local currentDictionary, currentTexture
local function registerMenu(dictionary, currentDictIndex)
lib.registerMenu({
id = 'texture_viewer',
title = 'Sprite Textures',
position = 'top-right',
onSideScroll = function(selected, scrollIndex, args)
if selected == 1 then
local newdictionary = dictionaries[scrollIndex]
currentDictionary, currentTexture = newdictionary, sprite_textures[newdictionary][1]
print(currentDictionary)
lib.requestStreamedTextureDict(currentDictionary)
registerMenu(dictionaries[scrollIndex], scrollIndex)
lib.hideMenu()
Wait(50)
lib.showMenu('texture_viewer')
end
if selected == 2 then
print(currentDictionary, selected, scrollIndex, args)
currentTexture = sprite_textures[currentDictionary][scrollIndex]
end
end,
onClose = function()
currentDictionary, currentTexture = nil, nil
end,
options = {
{ label = 'dictionary', values = dictionaries, defaultIndex = currentDictIndex },
{ label = 'texture', values = sprite_textures[dictionary], defaultIndex = 1 },
}
}, function(selected, scrollIndex, args, checked)
currentDictionary, currentTexture = nil, nil
end)
end
registerMenu(dictionaries[1])
local function getScale()
local screenx, screeny = GetActiveScreenResolution()
local textureResVec = GetTextureResolution(currentDictionary, currentTexture)
local scale_x = math.min(screenx / textureResVec.x, 1.0)
local scale_y = math.min(screeny / textureResVec.y, 1.0)
return scale_x, scale_y
end
RegisterCommand('spriteviewer', function()
currentDictionary = dictionaries[1]
currentTexture = sprite_textures[currentDictionary][1]
lib.requestStreamedTextureDict(currentDictionary)
lib.requestStreamedTextureDict('commonmenu')
lib.showMenu('texture_viewer')
while currentDictionary and currentTexture do
Wait(0)
local x, y = getScale()
DrawSprite('commonmenu', 'gradient_bgd', 0.5, 0.5, 1.0, 1.0, 0.0, 255, 255, 255, 255)
DrawSprite(currentDictionary, currentTexture, 0.5, 0.5, x / 5, y / 5, 0.0, 255, 255, 255, 255)
end
end)