Skip to content

Commit

Permalink
Merge pull request #1 from ywnico/main
Browse files Browse the repository at this point in the history
Add settings to 1) change reset button, 2) disable confirmation dialogs
  • Loading branch information
ywnico authored Jan 3, 2022
2 parents 9398914 + fbcf6d4 commit bd917bd
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 60 deletions.
58 changes: 45 additions & 13 deletions flowit-vita/app_skeleton/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ text_dimensions(get_i18n("conf_prevlevel"), VD.font_msg1, message_font_name)
text_dimensions(get_i18n("conf_reset"), VD.font_msg1, message_font_name)
--text_dimensions(get_i18n("high score!"), VD.font_msg1, default_font_name)
--text_dimensions(get_i18n("level complete"), VD.font_msg1, default_font_name)
text_dimensions(get_i18n("xo_buttons"), VS.header_font, default_font_name)
text_dimensions(get_i18n("confirmations"), VS.header_font, default_font_name)

-- load settings
load_settings()
Expand Down Expand Up @@ -172,28 +174,30 @@ while true do
if not is_showing_dialog then
if (button == BUTTON_SINGLE_LTRIGGER or button == BUTTON_HELD_LTRIGGER) then
if get_prev_unlocked_level(all_levels, game_status.pack, game_status.level) then
if game_status.steps > 0 then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.PREV_LEVEL)
else
go_to_prev_level(tridata)
end
end
elseif (button == BUTTON_SINGLE_RTRIGGER or button == BUTTON_HELD_RTRIGGER) then
if get_next_unlocked_level(all_levels, game_status.pack, game_status.level) then
if game_status.steps > 0 then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.NEXT_LEVEL)
else
go_to_next_level(tridata)
end
end
elseif (button == BUTTON_SINGLE_TRIANGLE) then
if game_status.steps > 0 then
show_dialog(DIALOG.RESET_GAME)
else
reset_game(tridata)
if SETTINGS.reset_button.value == "triangle" then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.RESET_GAME)
else
reset_game(tridata)
end
end
elseif (button == BUTTON_SINGLE_CROSS) then
if game_status.steps > 0 then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.LEVEL_MENU)
else
--reset_game(tridata)
Expand All @@ -202,6 +206,14 @@ while true do
elseif (button == BUTTON_SINGLE_SELECT) then
app_state_before_menu = app_state
app_state = APP_STATE_SETTINGS
elseif (button == BUTTON_SINGLE_START) then
if SETTINGS.reset_button.value == "start" then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.RESET_GAME)
else
reset_game(tridata)
end
end
end
elseif (cur_dialog == DIALOG.WIN) or (cur_dialog == DIALOG.WIN_HIGHSCORE) then
if (button == BUTTON_SINGLE_CIRCLE) or (button == BUTTON_SINGLE_CROSS) then
Expand Down Expand Up @@ -275,16 +287,24 @@ while true do
end
else
if (button == BUTTON_SINGLE_LTRIGGER or button == BUTTON_HELD_LTRIGGER or button == BUTTON_SINGLE_UP or button == BUTTON_HELD_UP) then
if settings_sel_item == "buttons" then
settings_sel_item = "sound"
elseif settings_sel_item == nil then
if settings_sel_item == nil then
settings_sel_item = "confirmations"
elseif settings_sel_item == "confirmations" then
settings_sel_item = "reset_button"
elseif settings_sel_item == "reset_button" then
settings_sel_item = "buttons"
elseif settings_sel_item == "buttons" then
settings_sel_item = "sound"
end
elseif (button == BUTTON_SINGLE_RTRIGGER or button == BUTTON_HELD_RTRIGGER or button == BUTTON_SINGLE_DOWN or button == BUTTON_HELD_DOWN) then
if settings_sel_item == "sound" then
settings_sel_item = "buttons"
elseif settings_sel_item == nil then
if settings_sel_item == nil then
settings_sel_item = "sound"
elseif settings_sel_item == "sound" then
settings_sel_item = "buttons"
elseif settings_sel_item == "buttons" then
settings_sel_item = "reset_button"
elseif settings_sel_item == "reset_button" then
settings_sel_item = "confirmations"
end
--elseif (button == BUTTON_SINGLE_CIRCLE) then
elseif (button == BUTTON_SINGLE_CROSS) then
Expand All @@ -301,6 +321,12 @@ while true do
elseif settings_sel_item == "buttons" then
SETTINGS.buttons.value = "xo"
play_sound("click")
elseif settings_sel_item == "reset_button" then
SETTINGS.reset_button.value = "start"
play_sound("click")
elseif settings_sel_item == "confirmations" then
SETTINGS.confirmations.value = "off"
play_sound("click")
end
elseif (button == BUTTON_SINGLE_LEFT or button == BUTTON_HELD_LEFT) then
if settings_sel_item == "sound" then
Expand All @@ -309,6 +335,12 @@ while true do
elseif settings_sel_item == "buttons" then
SETTINGS.buttons.value = "ox"
play_sound("click")
elseif settings_sel_item == "reset_button" then
SETTINGS.reset_button.value = "triangle"
play_sound("click")
elseif settings_sel_item == "confirmations" then
SETTINGS.confirmations.value = "on"
play_sound("click")
end
end
end
Expand Down
Binary file added images/btn_start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/btn_triangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions lib/game_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function handle_tap_ingame(tridata, x, y)
if get_next_unlocked_level(all_levels, game_status.pack, game_status.level) then
play_sound("click")

if game_status.steps > 0 then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.NEXT_LEVEL)
else
go_to_next_level(tridata)
Expand All @@ -225,7 +225,7 @@ function handle_tap_ingame(tridata, x, y)
if get_prev_unlocked_level(all_levels, game_status.pack, game_status.level) then
play_sound("click")

if game_status.steps > 0 then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.PREV_LEVEL)
else
go_to_prev_level(tridata)
Expand All @@ -234,14 +234,14 @@ function handle_tap_ingame(tridata, x, y)

elseif tapped_control == "reset" then
play_sound("click")
if game_status.steps > 0 then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.RESET_GAME)
else
reset_game(tridata)
end
elseif tapped_control == "back" then
play_sound("click")
if game_status.steps > 0 then
if (game_status.steps > 0) and (SETTINGS.confirmations.value ~= "off") then
show_dialog(DIALOG.LEVEL_MENU)
else
--reset_game(tridata)
Expand Down
10 changes: 6 additions & 4 deletions lib/io_desktop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ end

function load_misc_images()
local misc_images = {}
misc_images["lock"] = love.graphics.newImage("images/lock.png")
misc_images["check"] = love.graphics.newImage("images/check.png")
misc_images["circle"] = love.graphics.newImage("images/btn_circle.png")
misc_images["cross"] = love.graphics.newImage("images/btn_cross.png")
misc_images["lock"] = love.graphics.newImage("images/lock.png")
misc_images["check"] = love.graphics.newImage("images/check.png")
misc_images["circle"] = love.graphics.newImage("images/btn_circle.png")
misc_images["cross"] = love.graphics.newImage("images/btn_cross.png")
misc_images["triangle"] = love.graphics.newImage("images/btn_triangle.png")
misc_images["start"] = love.graphics.newImage("images/btn_start.png")

return misc_images
end
Expand Down
2 changes: 2 additions & 0 deletions lib/io_vita.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ function load_misc_images()
misc_images["check"] = Graphics.loadImage(image_dir .. "/check.png")
misc_images["circle"] = Graphics.loadImage(image_dir .. "/btn_circle.png")
misc_images["cross"] = Graphics.loadImage(image_dir .. "/btn_cross.png")
misc_images["triangle"] = Graphics.loadImage(image_dir .. "/btn_triangle.png")
misc_images["start"] = Graphics.loadImage(image_dir .. "/btn_start.png")

return misc_images
end
Expand Down
14 changes: 14 additions & 0 deletions lib/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ SETTINGS.buttons = {
default = "xo",
value = "xo",
}
SETTINGS.reset_button = {
options = {"triangle", "start"},
default = "triangle",
value = "triangle",
}
SETTINGS.confirmations = {
options = {"on", "off"},
default = "on",
value = "on",
}

local function reset_invalid_settings()
for k, setting in pairs(SETTINGS) do
Expand Down Expand Up @@ -42,6 +52,10 @@ function load_settings()
SETTINGS.sound.value = val
elseif key == "buttons" then
SETTINGS.buttons.value = val
elseif key == "reset_button" then
SETTINGS.reset_button.value = val
elseif key == "confirmations" then
SETTINGS.confirmations.value = val
end
end

Expand Down
Loading

0 comments on commit bd917bd

Please sign in to comment.