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
|
options = {}
local lg = love.graphics
function options.enter()
state = STATE_OPTIONS
options.selection = 1
end
function options.update(dt)
updateKeys()
end
function options.draw()
lg.push()
lg.scale(config.scale)
lg.setFont(font.bold)
drawBox(40, 51, 176, 123)
lg.printf("OPTIONS", 0, 37, WIDTH, "center")
lg.print("SCALE:", 65, 63) lg.print(config.scale, 167, 63)
lg.print("FULLSCREEN:", 65, 76)
if config.fullscreen == 0 then lg.print("OFF", 167, 76)
elseif config.fullscreen == 1 then lg.print("FILL", 167, 76)
elseif config.fullscreen == 2 then lg.print("ZOOM", 167, 76)
else lg.print("SCALE", 167, 76)
end
lg.print("VSYNC:", 65, 89) lg.print(config.vsync and "ON" or "OFF", 167, 89)
lg.print("SOUND VOL:", 65, 102) lg.print(math.floor(config.sfx_volume*10+0.01), 167, 102)
lg.print("MUSIC VOL:", 65, 115) lg.print(math.floor(config.music_volume*10+0.01), 167, 115)
lg.print("KEYBOARD", 65, 128)
lg.print("JOYSTICK", 65, 141)
lg.print("BACK", 65, 154)
lg.print(">", 52, 49+options.selection*13)
lg.pop()
end
function options.keypressed(k, uni)
if k == "down" then
options.selection = wrap(options.selection + 1, 1,8)
playSound("blip")
elseif k == "up" then
options.selection = wrap(options.selection - 1, 1,8)
playSound("blip")
elseif k == "left" or k == "right" then
if options.selection == 1 then -- SCALE
if k == "left" then
config.scale = cap(config.scale - 1, 1, 10)
else
config.scale = cap(config.scale + 1, 1, 10)
end
setMode()
playSound("blip")
elseif options.selection == 2 then -- FULLSCREEN
if k == "left" then
if config.fullscreen > 0 then
config.fullscreen = cap(config.fullscreen - 1, 0, 3)
setMode()
end
else
if config.fullscreen < 3 then
config.fullscreen = cap(config.fullscreen + 1, 0, 3)
setMode()
end
end
playSound("blip")
elseif options.selection == 3 then -- VSYNC
toggleVSync()
playSound("blip")
elseif options.selection == 4 then -- SFX VOLUME
if k == "left" then
config.sfx_volume = cap(config.sfx_volume - 0.1, 0,1)
else
config.sfx_volume = cap(config.sfx_volume + 0.1, 0,1)
end
love.audio.tags.sfx.setVolume(config.sfx_volume)
playSound("blip")
elseif options.selection == 5 then -- MUSIC VOLUME
if k == "left" then
config.music_volume = cap(config.music_volume - 0.1, 0,1)
else
config.music_volume = cap(config.music_volume + 0.1, 0,1)
end
love.audio.tags.music.setVolume(config.music_volume)
playSound("blip")
end
elseif k == "return" then
if options.selection == 3 then -- VSYNC
toggleVSync()
playSound("blip")
elseif options.selection == 6 then -- KEYBOARD
playSound("confirm")
keyboard.enter()
elseif options.selection == 7 then -- JOYSTICK
playSound("confirm")
joystick.enter()
elseif options.selection == 8 then -- BACK
playSound("confirm")
mainmenu.enter()
saveConfig()
end
elseif k == "escape" then
playSound("confirm")
mainmenu.enter()
saveConfig()
end
end
function options.action(k)
if k == "down" then
options.selection = wrap(options.selection + 1, 1,8)
playSound("blip")
elseif k == "up" then
options.selection = wrap(options.selection - 1, 1,8)
playSound("blip")
elseif k == "left" or k == "right" then
if options.selection == 1 then -- SCALE
if k == "left" then
config.scale = cap(config.scale - 1, 1, 10)
else
config.scale = cap(config.scale + 1, 1, 10)
end
setMode()
playSound("blip")
elseif options.selection == 2 then -- FULLSCREEN
if k == "left" then
if config.fullscreen > 0 then
config.fullscreen = cap(config.fullscreen - 1, 0, 3)
setMode()
end
else
if config.fullscreen < 3 then
config.fullscreen = cap(config.fullscreen + 1, 0, 3)
setMode()
end
end
playSound("blip")
elseif options.selection == 3 then -- VSYNC
toggleVSync()
playSound("blip")
elseif options.selection == 4 then -- SFX VOLUME
if k == "left" then
config.sfx_volume = cap(config.sfx_volume - 0.1, 0,1)
else
config.sfx_volume = cap(config.sfx_volume + 0.1, 0,1)
end
love.audio.tags.sfx.setVolume(config.sfx_volume)
playSound("blip")
elseif options.selection == 5 then -- MUSIC VOLUME
if k == "left" then
config.music_volume = cap(config.music_volume - 0.1, 0,1)
else
config.music_volume = cap(config.music_volume + 0.1, 0,1)
end
love.audio.tags.music.setVolume(config.music_volume)
playSound("blip")
end
elseif k == "jump" then
if options.selection == 2 then -- FULLSCREEN
config.fullscreen = wrap(config.fullscreen + 1, 0, 3)
setMode()
playSound("blip")
elseif options.selection == 3 then -- VSYNC
toggleVSync()
playSound("blip")
elseif options.selection == 6 then -- KEYBOARD
playSound("confirm")
keyboard.enter()
elseif options.selection == 7 then -- JOYSTICK
playSound("confirm")
joystick.enter()
elseif options.selection == 8 then -- BACK
playSound("confirm")
mainmenu.enter()
saveConfig()
end
elseif k == "action" then
playSound("confirm")
mainmenu.enter()
saveConfig()
end
end
|