-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathmod.lua
150 lines (138 loc) · 4.12 KB
/
mod.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
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
local scene={}
local selected-- Mod selected
local function _toggleMod(M,back)
local number=M.no+1
assert(MODOPT[number]==M)
if M.list then
if back then
GAME.mod[number]=(GAME.mod[number]-1)%(#M.list+1)
else
GAME.mod[number]=(GAME.mod[number]+1)%(#M.list+1)
end
else
GAME.mod[number]=1-GAME.mod[number]
end
SFX.play(GAME.mod[number]>0 and 'mod_on' or 'mod_off')
scene.widgetList.unranked.hide=scoreValid()
end
function scene.enter()
selected=false
scene.widgetList.unranked.hide=scoreValid()
BG.set('tunnel')
end
function scene.mouseMove(x,y)
selected=false
for _,M in next,MODOPT do
if (x-M.x)^2+(y-M.y)^2<2000 then
selected=M
break
end
end
end
function scene.mouseDown(x,y,k)
for _,M in next,MODOPT do
if (x-M.x)^2+(y-M.y)^2<2000 then
_toggleMod(M,k==2 or love.keyboard.isDown('lshift','rshift'))
break
end
end
end
scene.touchMove=scene.mouseMove
function scene.touchDown(x,y)
scene.mouseMove(x,y)
scene.mouseDown(x,y)
end
function scene.keyDown(key)
if key=='tab' or key=='delete' then
local modUsed=false
for i=1,#GAME.mod do
if GAME.mod[i]>0 then
modUsed=true
end
GAME.mod[i]=0
end
if modUsed then
scene.widgetList.unranked.hide=scoreValid()
SFX.play('hold')
end
elseif #key==1 then
for _,M in next,MODOPT do
if key==M.key then
_toggleMod(M,love.keyboard.isDown('lshift','rshift'))
selected=M
break
end
end
elseif key=='escape' then
SCN.back()
end
end
function scene.update()
for number,sel in next,GAME.mod do
local M=MODOPT[number]
if sel==0 then
if M.time>0 then
M.time=M.time-1
end
else
if M.time<10 then
M.time=M.time+1
end
end
end
end
function scene.draw()
setFont(40)
GC.setLineWidth(5)
for number,M in next,MODOPT do
local sel=GAME.mod[number]
GC.push('transform')
GC.translate(M.x,M.y)
local t=M.time*.01-- t range:0~0.1
GC.scale(1+3*t)
GC.rotate(t)
local rad,side=45,5
if GAME.modApplyAt=='always' then
if M.funcA then side=nil
elseif M.funcA1 then side=8
else side=5 end
end
local color=M.color
GC.setColor(color[1],color[2],color[3],5*t)
GC.circle('fill',0,0,rad,side)
GC.setColor(color)
GC.circle('line',0,0,rad,side)
GC.setColor(COLOR.Z)
GC.mStr(M.id,0,-27)
if sel>0 and M.list then
setFont(25)
GC.setColor(1,1,1,10*t)
GC.mStr(M.list[sel],20,8)
setFont(40)
end
if M.list then
GC.setColor(1,1,1,t*6)
GC.arc('line','open',0,0,rad+6,0,(sel/#M.list)*6.2832)
end
GC.pop()
end
GC.setColor(COLOR.Z)
if selected then
setFont(30)
GC.printf(text.modInfo[selected.name],70,540,950)
elseif WIDGET.isFocus(scene.widgetList.modApplyAt) then
setFont(20)
GC.printf(text.modApplyAtInstruction,70,540,950)
else
setFont(25)
GC.printf(text.modInstruction,70,540,950)
end
end
scene.widgetList={
WIDGET.newText{name='title', x= 80,y=50,font=70,align='L'},
WIDGET.newText{name='unranked', x= 970,y=70,color='Y',font=50,align='R'},
WIDGET.newSelector{name='modApplyAt',x=1100,y=100,w=230,color='Y',font=20,list={'preInit','postInit','always'},disp=function() return GAME.modApplyAt end,code=function(v) GAME.modApplyAt=v end},
WIDGET.newButton{name='reset', x=1140,y=540,w=170,h=80,font=25,code=pressKey'tab'},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
}
return scene