mirror of
https://github.com/SashLilac/cambridge.git
synced 2025-04-11 19:42:55 -05:00
Unnecessary features.
This commit is contained in:
parent
92d67968f5
commit
e386b47f35
29
main.lua
29
main.lua
@ -58,7 +58,34 @@ function initModules()
|
||||
table.sort(rulesets, function(a,b)
|
||||
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
||||
end
|
||||
left_clicked_before = false
|
||||
right_clicked_before = false
|
||||
-- For when mouse controls are part of menu controls
|
||||
function getScaledPos(cursor_x, cursor_y)
|
||||
local screen_x, screen_y = love.graphics.getDimensions()
|
||||
local scale_factor = math.min(screen_x / 640, screen_y / 480)
|
||||
love.graphics.print((cursor_x - (screen_x - scale_factor * 640) / 2)/scale_factor..(cursor_y - (screen_y - scale_factor * 480) / 2)/scale_factor)
|
||||
return (cursor_x - (screen_x - scale_factor * 640) / 2)/scale_factor, (cursor_y - (screen_y - scale_factor * 480) / 2)/scale_factor
|
||||
end
|
||||
|
||||
--Interpolates in a smooth fashion.
|
||||
function interpolateListHeight(input, from)
|
||||
if config.gamesettings["smooth_scroll"] == 2 then
|
||||
return from
|
||||
end
|
||||
if from > input then
|
||||
input = input + (from - input) / 4
|
||||
if input > from - 0.02 then
|
||||
input = from
|
||||
end
|
||||
elseif from < input then
|
||||
input = input + (from - input) / 4
|
||||
if input < from + 0.02 then
|
||||
input = from
|
||||
end
|
||||
end
|
||||
return input
|
||||
end
|
||||
function love.draw()
|
||||
love.graphics.setCanvas(GLOBAL_CANVAS)
|
||||
love.graphics.clear()
|
||||
@ -85,6 +112,7 @@ function love.draw()
|
||||
"fps - " .. version, 0, 460, 635, "right"
|
||||
)
|
||||
end
|
||||
getScaledPos(love.mouse.getPosition())
|
||||
|
||||
love.graphics.pop()
|
||||
|
||||
@ -338,6 +366,7 @@ function love.run()
|
||||
end
|
||||
time_accumulator = time_accumulator - frame_duration
|
||||
end
|
||||
if love.mouse then left_clicked_before = love.mouse.isDown(1) right_clicked_before = love.mouse.isDown(2) end
|
||||
last_time = love.timer.getTime()
|
||||
end
|
||||
end
|
||||
|
@ -19,8 +19,8 @@ function CreditsScene:update()
|
||||
if love.window.hasFocus() then
|
||||
self.frames = self.frames + 1
|
||||
end
|
||||
if self.frames >= 2100 * self.scroll_speed then
|
||||
playSE("mode_decide")
|
||||
if self.frames >= 2100 * self.scroll_speed or (love.mouse.isDown(1) and not left_clicked_before) then
|
||||
if(not (love.mouse.isDown(1) and not left_clicked_before)) then playSE("mode_decide") end
|
||||
scene = TitleScene()
|
||||
switchBGM(nil)
|
||||
elseif self.frames == math.floor(1950 * self.scroll_speed) then
|
||||
|
@ -19,6 +19,7 @@ ConfigScene.options = {
|
||||
{"das_last_key", "DAS Last Key", false, {"Off", "On"}},
|
||||
{"buffer_lock", "Buffer Drop Type", false, {"Off", "Hold", "Tap"}},
|
||||
{"synchroes_allowed", "Synchroes", false, {"Per ruleset", "On", "Off"}},
|
||||
{"smooth_scroll", "Smooth Scrolling", false, {"On", "Off"}},
|
||||
{"sfx_volume", "SFX", true, "sfxSlider"},
|
||||
{"bgm_volume", "BGM", true, "bgmSlider"},
|
||||
}
|
||||
@ -39,8 +40,25 @@ function ConfigScene:new()
|
||||
end
|
||||
|
||||
function ConfigScene:update()
|
||||
self.sfxSlider:update()
|
||||
self.bgmSlider:update()
|
||||
local x, y = getScaledPos(love.mouse.getPosition())
|
||||
self.sfxSlider:update(x,y)
|
||||
self.bgmSlider:update(x,y)
|
||||
--#region Mouse
|
||||
if not love.mouse.isDown(1) or left_clicked_before then return end
|
||||
for i, option in ipairs(ConfigScene.options) do
|
||||
if not option[3] then
|
||||
for j, setting in ipairs(option[4]) do
|
||||
if x > 100 + 110 * j and x < 200 + 110 * j then
|
||||
if y > 100 + i * 20 and y < 120 + i * 20 then
|
||||
self.main_menu_state = math.floor((y - 280) / 20)
|
||||
playSE("cursor_lr")
|
||||
config.gamesettings[option[1]] = Mod1(j, #option[4])
|
||||
end
|
||||
end
|
||||
-- local option = ConfigScene.options[self.highlight]
|
||||
end end
|
||||
end
|
||||
--#endregion
|
||||
end
|
||||
|
||||
function ConfigScene:render()
|
||||
@ -53,6 +71,13 @@ function ConfigScene:render()
|
||||
|
||||
love.graphics.setFont(font_3x5_4)
|
||||
love.graphics.print("GAME SETTINGS", 80, 40)
|
||||
-- love.graphics.setColor(1, 1, 1, 0.5)
|
||||
-- love.graphics.rectangle("fill", 580, 40, 60, 35)
|
||||
-- love.graphics.setColor(1, 1, 1, 1)
|
||||
-- love.graphics.setFont(font_3x5_3)
|
||||
-- love.graphics.printf("SAVE", 580, 40, 60, "center")
|
||||
-- love.graphics.setFont(font_3x5)
|
||||
-- love.graphics.printf("(MOUSE ONLY)", 580, 62, 60, "center")
|
||||
|
||||
--Lazy check to see if we're on the SFX or BGM slider. Probably will need to be rewritten if more options get added.
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
@ -112,7 +137,7 @@ function ConfigScene:onInputPress(e)
|
||||
local option = ConfigScene.options[self.highlight]
|
||||
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[4])
|
||||
else
|
||||
sld = self[self.options[self.highlight][4]]
|
||||
local sld = self[self.options[self.highlight][4]]
|
||||
sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() + 5) / (sld.max - sld.min)))
|
||||
sld:update()
|
||||
playSE("cursor")
|
||||
|
@ -16,7 +16,17 @@ function ConfigScene:new()
|
||||
})
|
||||
end
|
||||
|
||||
function ConfigScene:update() end
|
||||
function ConfigScene:update()
|
||||
if not love.mouse.isDown(1) or left_clicked_before then return end
|
||||
local mouse_x, mouse_y = getScaledPos(love.mouse.getPosition())
|
||||
if mouse_x > 75 and mouse_x < 275 then
|
||||
if mouse_y > 170 and mouse_y < 270 then
|
||||
self.menu_state = math.floor((mouse_y - 120) / 50)
|
||||
playSE("main_decide")
|
||||
scene = menu_screens[self.menu_state]()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ConfigScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
|
@ -29,6 +29,12 @@ function ModeSelectScene:new()
|
||||
}
|
||||
self.secret_inputs = {}
|
||||
self.das = 0
|
||||
-- It's not exactly self-descriptive.
|
||||
self.menu_mode_height = 20
|
||||
-- It's not exactly self-descriptive.
|
||||
self.menu_ruleset_height = 20
|
||||
self.auto_menu_offset = 0
|
||||
self.auto_menu_state = "mode"
|
||||
DiscordRPC:update({
|
||||
details = "In menus",
|
||||
state = "Choosing a mode",
|
||||
@ -39,12 +45,31 @@ end
|
||||
function ModeSelectScene:update()
|
||||
switchBGM(nil) -- experimental
|
||||
|
||||
local mouse_x, mouse_y = getScaledPos(love.mouse.getPosition())
|
||||
if love.mouse.isDown(1) and not left_clicked_before then
|
||||
if mouse_x < 320 then
|
||||
self.auto_menu_state = "mode"
|
||||
else
|
||||
self.auto_menu_state = "ruleset"
|
||||
end
|
||||
if self.auto_menu_state ~= self.menu_state.select then
|
||||
self:switchSelect()
|
||||
end
|
||||
self.auto_menu_offset = math.floor((mouse_y - 260)/20)
|
||||
if self.auto_menu_offset == 0 and self.auto_menu_state == "mode" then
|
||||
self:startMode()
|
||||
end
|
||||
end
|
||||
if self.das_up or self.das_down then
|
||||
self.das = self.das + 1
|
||||
else
|
||||
self.das = 0
|
||||
end
|
||||
|
||||
if self.auto_menu_offset ~= 0 then
|
||||
self:changeOption(self.auto_menu_offset < 0 and -1 or 1)
|
||||
if self.auto_menu_offset > 0 then self.auto_menu_offset = self.auto_menu_offset - 1 end
|
||||
if self.auto_menu_offset < 0 then self.auto_menu_offset = self.auto_menu_offset + 1 end
|
||||
end
|
||||
if self.das >= 15 then
|
||||
self:changeOption(self.das_up and -1 or 1)
|
||||
self.das = self.das - 4
|
||||
@ -97,17 +122,44 @@ function ModeSelectScene:render()
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
|
||||
self.menu_mode_height = interpolateListHeight(self.menu_mode_height / 20, self.menu_state.mode) * 20
|
||||
self.menu_ruleset_height = interpolateListHeight(self.menu_ruleset_height / 20, self.menu_state.ruleset) * 20
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
for idx, mode in pairs(game_modes) do
|
||||
if(idx >= self.menu_state.mode-9 and idx <= self.menu_state.mode+9) then
|
||||
love.graphics.printf(mode.name, 40, (260 - 20*(self.menu_state.mode)) + 20 * idx, 200, "left")
|
||||
if(idx >= self.menu_mode_height / 20-10 and idx <= self.menu_mode_height / 20+10) then
|
||||
love.graphics.setColor(1,1,1,FadeoutAtEdges((-self.menu_mode_height) + 20 * idx, 180, 20))
|
||||
love.graphics.printf(mode.name, 40, (260 - self.menu_mode_height) + 20 * idx, 200, "left")
|
||||
end
|
||||
end
|
||||
for idx, ruleset in pairs(rulesets) do
|
||||
if(idx >= self.menu_state.ruleset-9 and idx <= self.menu_state.ruleset+9) then
|
||||
love.graphics.printf(ruleset.name, 360, (260 - 20*(self.menu_state.ruleset)) + 20 * idx, 160, "left")
|
||||
if(idx >= self.menu_ruleset_height / 20-10 and idx <= self.menu_ruleset_height / 20+10) then
|
||||
love.graphics.setColor(1,1,1,FadeoutAtEdges(-self.menu_ruleset_height + 20 * idx, 180, 20))
|
||||
love.graphics.printf(ruleset.name, 360, (260 - self.menu_ruleset_height) + 20 * idx, 160, "left")
|
||||
end
|
||||
end
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
end
|
||||
function FadeoutAtEdges(input, edge_distance, edge_width)
|
||||
if input < 0 then
|
||||
input = input * -1
|
||||
end
|
||||
if input > edge_distance then
|
||||
return 1 - (input - edge_distance) / edge_width
|
||||
end
|
||||
return 1
|
||||
end
|
||||
function ModeSelectScene:startMode()
|
||||
current_mode = self.menu_state.mode
|
||||
current_ruleset = self.menu_state.ruleset
|
||||
config.current_mode = current_mode
|
||||
config.current_ruleset = current_ruleset
|
||||
playSE("mode_decide")
|
||||
saveConfig()
|
||||
scene = GameScene(
|
||||
game_modes[self.menu_state.mode],
|
||||
rulesets[self.menu_state.ruleset],
|
||||
self.secret_inputs
|
||||
)
|
||||
end
|
||||
|
||||
function ModeSelectScene:onInputPress(e)
|
||||
@ -121,17 +173,7 @@ function ModeSelectScene:onInputPress(e)
|
||||
self:changeOption(-e.y)
|
||||
end
|
||||
elseif e.input == "menu_decide" or e.scancode == "return" then
|
||||
current_mode = self.menu_state.mode
|
||||
current_ruleset = self.menu_state.ruleset
|
||||
config.current_mode = current_mode
|
||||
config.current_ruleset = current_ruleset
|
||||
playSE("mode_decide")
|
||||
saveConfig()
|
||||
scene = GameScene(
|
||||
game_modes[self.menu_state.mode],
|
||||
rulesets[self.menu_state.ruleset],
|
||||
self.secret_inputs
|
||||
)
|
||||
self:startMode()
|
||||
elseif e.input == "up" or e.scancode == "up" then
|
||||
self:changeOption(-1)
|
||||
self.das_up = true
|
||||
|
@ -35,6 +35,8 @@ function ReplaySelectScene:new()
|
||||
replay = current_replay,
|
||||
}
|
||||
self.das = 0
|
||||
self.height_offset = 0
|
||||
self.auto_menu_offset = 0
|
||||
DiscordRPC:update({
|
||||
details = "In menus",
|
||||
state = "Choosing a replay",
|
||||
@ -51,6 +53,18 @@ function ReplaySelectScene:update()
|
||||
self.das = 0
|
||||
end
|
||||
|
||||
local mouse_x, mouse_y = getScaledPos(love.mouse.getPosition())
|
||||
if love.mouse.isDown(1) and not left_clicked_before then
|
||||
self.auto_menu_offset = math.floor((mouse_y - 260)/20)
|
||||
if self.auto_menu_offset == 0 then
|
||||
self:startReplay()
|
||||
end
|
||||
end
|
||||
if self.auto_menu_offset ~= 0 then
|
||||
self:changeOption(self.auto_menu_offset < 0 and -1 or 1)
|
||||
if self.auto_menu_offset > 0 then self.auto_menu_offset = self.auto_menu_offset - 1 end
|
||||
if self.auto_menu_offset < 0 then self.auto_menu_offset = self.auto_menu_offset + 1 end
|
||||
end
|
||||
if self.das >= 15 then
|
||||
local change = 0
|
||||
if self.das_up then
|
||||
@ -79,6 +93,8 @@ function ReplaySelectScene:render()
|
||||
0, 0, 0,
|
||||
0.5, 0.5
|
||||
)
|
||||
|
||||
self.height_offset = interpolateListHeight(self.height_offset / 20, self.menu_state.replay) * 20
|
||||
|
||||
-- Same graphic as mode select
|
||||
--love.graphics.draw(misc_graphics["select_mode"], 20, 40)
|
||||
@ -115,12 +131,12 @@ function ReplaySelectScene:render()
|
||||
end
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
love.graphics.rectangle("fill", 3, 258, 634, 22)
|
||||
love.graphics.rectangle("fill", 3, 258 + (self.menu_state.replay * 20) - self.height_offset, 634, 22)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
for idx, replay in ipairs(replays) do
|
||||
if(idx >= self.menu_state.replay-9 and idx <= self.menu_state.replay+9) then
|
||||
if(idx >= self.height_offset/20-9.5 and idx <= self.height_offset/20+9.5) then
|
||||
local display_string = os.date("%c", replay["timestamp"]).." - "..replay["mode"].." - "..replay["ruleset"]
|
||||
if replay["level"] ~= nil then
|
||||
display_string = display_string.." - Level: "..replay["level"]
|
||||
@ -131,11 +147,42 @@ function ReplaySelectScene:render()
|
||||
if #display_string > 75 then
|
||||
display_string = display_string:sub(1, 75) .. "..."
|
||||
end
|
||||
love.graphics.printf(display_string, 6, (260 - 20*(self.menu_state.replay)) + 20 * idx, 640, "left")
|
||||
love.graphics.printf(display_string, 6, (260 - self.height_offset) + 20 * idx, 640, "left")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ReplaySelectScene:startReplay()
|
||||
current_replay = self.menu_state.replay
|
||||
-- Same as mode decide
|
||||
playSE("mode_decide")
|
||||
-- Get game mode and ruleset
|
||||
local mode
|
||||
local rules
|
||||
for key, value in pairs(game_modes) do
|
||||
if value.name == replays[self.menu_state.replay]["mode"] then
|
||||
mode = value
|
||||
break
|
||||
end
|
||||
end
|
||||
for key, value in pairs(rulesets) do
|
||||
if value.name == replays[self.menu_state.replay]["ruleset"] then
|
||||
rules = value
|
||||
break
|
||||
end
|
||||
end
|
||||
if mode == nil or rules == nil then
|
||||
self.display_error = true
|
||||
return
|
||||
end
|
||||
-- TODO compare replay versions to current versions for Cambridge, ruleset, and mode
|
||||
scene = ReplayScene(
|
||||
replays[self.menu_state.replay],
|
||||
mode,
|
||||
rules
|
||||
)
|
||||
end
|
||||
|
||||
function ReplaySelectScene:onInputPress(e)
|
||||
if (self.display_warning or self.display_error) and e.input then
|
||||
scene = TitleScene()
|
||||
@ -144,34 +191,7 @@ function ReplaySelectScene:onInputPress(e)
|
||||
self:changeOption(-e.y)
|
||||
end
|
||||
elseif e.input == "menu_decide" or e.scancode == "return" then
|
||||
current_replay = self.menu_state.replay
|
||||
-- Same as mode decide
|
||||
playSE("mode_decide")
|
||||
-- Get game mode and ruleset
|
||||
local mode
|
||||
local rules
|
||||
for key, value in pairs(game_modes) do
|
||||
if value.name == replays[self.menu_state.replay]["mode"] then
|
||||
mode = value
|
||||
break
|
||||
end
|
||||
end
|
||||
for key, value in pairs(rulesets) do
|
||||
if value.name == replays[self.menu_state.replay]["ruleset"] then
|
||||
rules = value
|
||||
break
|
||||
end
|
||||
end
|
||||
if mode == nil or rules == nil then
|
||||
self.display_error = true
|
||||
return
|
||||
end
|
||||
-- TODO compare replay versions to current versions for Cambridge, ruleset, and mode
|
||||
scene = ReplayScene(
|
||||
replays[self.menu_state.replay],
|
||||
mode,
|
||||
rules
|
||||
)
|
||||
self:startReplay()
|
||||
elseif e.input == "up" or e.scancode == "up" then
|
||||
self:changeOption(-1)
|
||||
self.das_up = true
|
||||
|
@ -25,7 +25,17 @@ function SettingsScene:new()
|
||||
})
|
||||
end
|
||||
|
||||
function SettingsScene:update() end
|
||||
function SettingsScene:update()
|
||||
if not love.mouse.isDown(1) or left_clicked_before then return end
|
||||
local mouse_x, mouse_y = getScaledPos(love.mouse.getPosition())
|
||||
if mouse_x > 75 and mouse_x < 275 then
|
||||
if mouse_y > 170 and mouse_y < 320 then
|
||||
self.menu_state = math.floor((mouse_y - 120) / 50)
|
||||
playSE("main_decide")
|
||||
scene = menu_screens[self.menu_state]()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function SettingsScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
|
@ -58,6 +58,15 @@ function TitleScene:update()
|
||||
if self.frames < 125 then self.y_offset = self.frames
|
||||
elseif self.frames < 185 then self.y_offset = 125
|
||||
else self.y_offset = 310 - self.frames end
|
||||
local mouse_x, mouse_y = getScaledPos(love.mouse.getPosition())
|
||||
if not love.mouse.isDown(1) or left_clicked_before then return end
|
||||
if mouse_x > 40 and mouse_x < 160 then
|
||||
if mouse_y > 300 and mouse_y < 400 then
|
||||
self.main_menu_state = math.floor((mouse_y - 280) / 20)
|
||||
playSE("main_decide")
|
||||
scene = main_menu_screens[self.main_menu_state]()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local block_offsets = {
|
||||
|
@ -27,9 +27,10 @@ function TuningScene:new()
|
||||
end
|
||||
|
||||
function TuningScene:update()
|
||||
self.dasSlider:update()
|
||||
self.arrSlider:update()
|
||||
self.dcdSlider:update()
|
||||
local x, y = getScaledPos(love.mouse.getPosition())
|
||||
self.dasSlider:update(x,y)
|
||||
self.arrSlider:update(x,y)
|
||||
self.dcdSlider:update(x,y)
|
||||
end
|
||||
|
||||
function TuningScene:render()
|
||||
|
Loading…
Reference in New Issue
Block a user