diff --git a/flowit-vita/app_skeleton/index.lua b/flowit-vita/app_skeleton/index.lua index 36d7af7..15216a3 100644 --- a/flowit-vita/app_skeleton/index.lua +++ b/flowit-vita/app_skeleton/index.lua @@ -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() @@ -172,7 +174,7 @@ 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) @@ -180,20 +182,22 @@ while true do 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) @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/images/btn_start.png b/images/btn_start.png new file mode 100644 index 0000000..3b02840 Binary files /dev/null and b/images/btn_start.png differ diff --git a/images/btn_triangle.png b/images/btn_triangle.png new file mode 100644 index 0000000..c12c3c5 Binary files /dev/null and b/images/btn_triangle.png differ diff --git a/lib/game_view.lua b/lib/game_view.lua index 130d9e0..be28b33 100644 --- a/lib/game_view.lua +++ b/lib/game_view.lua @@ -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) @@ -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) @@ -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) diff --git a/lib/io_desktop.lua b/lib/io_desktop.lua index 0f5ea71..219cd3c 100644 --- a/lib/io_desktop.lua +++ b/lib/io_desktop.lua @@ -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 diff --git a/lib/io_vita.lua b/lib/io_vita.lua index 7539dd0..c92b76c 100644 --- a/lib/io_vita.lua +++ b/lib/io_vita.lua @@ -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 diff --git a/lib/settings.lua b/lib/settings.lua index 2c0f00f..355c5c5 100644 --- a/lib/settings.lua +++ b/lib/settings.lua @@ -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 @@ -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 diff --git a/lib/settings_view.lua b/lib/settings_view.lua index 9617435..654e5f2 100644 --- a/lib/settings_view.lua +++ b/lib/settings_view.lua @@ -6,11 +6,9 @@ VS.space_size = 15 VS.nx = 0 VS.cell_font = 16 VS.header_font = 50 -VS.sel_buffer_ext = 6 -VS.sel_buffer_int = 3 -VS.header_width = 400 -VS.header_y_buffer = 150 -VS.header_y_step = 200 +VS.header_width = 520 +VS.header_y_buffer = 70 +VS.header_y_step = 110 VS.done_x = VS.screen_margin VS.done_y = 544 - 60 - VS.screen_margin @@ -20,10 +18,11 @@ VS.done_font = 36 VS.done_icon_size = 32 VS.button_width = 120 +VS.button_min_height = 48 VS.button_icon_size = 20 VS.button_font = 24 -VS.label_font = 36 -VS.buttonA_x = VS.header_width + 100 +VS.label_font = 32 +VS.buttonA_x = VS.header_width + 80 VS.buttonB_x = VS.buttonA_x + VS.button_width + 50 settings_items = {} @@ -45,7 +44,7 @@ settings_items["sound"] = { }, } settings_items["buttons"] = { - label = "buttons", + label = "xo_buttons", y_center = VS.header_y_buffer + VS.header_y_step, A = { @@ -67,6 +66,41 @@ settings_items["buttons"] = { icon2 = "circle", }, } +settings_items["reset_button"] = { + label = "reset_button", + y_center = VS.header_y_buffer + 2*VS.header_y_step, + + A = { + x = VS.buttonA_x, y = 0, + width = VS.button_width, height = 0, + msg1 = "", + icon1 = "triangle", + }, + + B = { + x = VS.buttonB_x, y = 0, + width = VS.button_width, height = 0, + msg1 = "", + icon1 = "start", + icon1_size = 44 + }, +} +settings_items["confirmations"] = { + label = "confirmations", + y_center = VS.header_y_buffer + 3*VS.header_y_step, + + A = { + x = VS.buttonA_x, y = 0, + width = VS.button_width, height = 0, + msg1 = "on", + }, + + B = { + x = VS.buttonB_x, y = 0, + width = VS.button_width, height = 0, + msg1 = "off", + }, +} settings_sel_item = nil @@ -123,11 +157,11 @@ local function draw_button(setting_name, AB, selected) end + local button_interior_h = text_h if text2 then - button.height = 3*buffer + text_h*2 - else - button.height = 2*buffer + text_h + button_interior_h = button_interior_h + buffer + text_h end + button.height = math.max(2*buffer + button_interior_h, VS.button_min_height) button.y = math.ceil(item.y_center - button.height/2) @@ -141,9 +175,12 @@ local function draw_button(setting_name, AB, selected) -- draw text local icon_x local text_x + + local icon1_size = button.icon1_size or VS.button_icon_size + if button.icon1 then - icon_x = math.floor(button.x + (button.width - text_w - VS.button_icon_size - buffer)/2) - text_x = icon_x + VS.button_icon_size + buffer + icon_x = math.floor(button.x + (button.width - text_w - icon1_size - buffer)/2) + text_x = icon_x + icon1_size + buffer else text_x = math.floor(button.x + (button.width - text_w)/2) end @@ -151,16 +188,22 @@ local function draw_button(setting_name, AB, selected) draw_text(text_x, text1_y, font_size, text1, fg_color, message_font_name) if button.icon1 then - local icon1_y = text1_y + (text_h - VS.button_icon_size)/2 - draw_general_icon(icon_x, icon1_y, icon_x + VS.button_icon_size, icon1_y + VS.button_icon_size, misc_images[button.icon1], fg_color) + local icon1_y = math.ceil(text1_y + (text_h - icon1_size)/2) + if not text1 or #text1 == 0 then + icon1_y = math.ceil(button.y + (button.height - icon1_size)/2) + icon1_x = math.floor(button.x + (button.width - icon1_size)/2) + end + + draw_general_icon(icon_x, icon1_y, icon_x + icon1_size, icon1_y + icon1_size, misc_images[button.icon1], fg_color) end if text2 then + local icon2_size = button.icon2_size or VS.button_icon_size local text2_y = text1_y + buffer + text_h draw_text(text_x, text2_y, font_size, text2, fg_color, message_font_name) if button.icon2 then - local icon2_y = text2_y + (text_h - VS.button_icon_size)/2 - draw_general_icon(icon_x, icon2_y, icon_x + VS.button_icon_size, icon2_y + VS.button_icon_size, misc_images[button.icon2], fg_color) + local icon2_y = text2_y + (text_h - icon2_size)/2 + draw_general_icon(icon_x, icon2_y, icon_x + icon2_size, icon2_y + icon2_size, misc_images[button.icon2], fg_color) end end end @@ -183,6 +226,8 @@ local function draw_settings_item(setting_name) local A_sel = (setting_name == "sound" and SETTINGS.sound.value == "on") or (setting_name == "buttons" and SETTINGS.buttons.value == "ox") + or (setting_name == "reset_button" and SETTINGS.reset_button.value == "triangle") + or (setting_name == "confirmations" and SETTINGS.confirmations.value == "on") draw_button(setting_name, "A", A_sel) draw_button(setting_name, "B", not A_sel) @@ -191,7 +236,7 @@ local function draw_settings_item(setting_name) item.x1 = VS.screen_margin item.x2 = screen_width() - VS.screen_margin - local h = math.max(VS.header_y_step/2, math.max(item.A.height, item.B.height) + 2*VS.screen_margin) + local h = math.max(VS.header_y_step/2, math.max(item.A.height, item.B.height) + 2*0.5*VS.screen_margin) item.y1 = math.floor(item.y_center - h/2) item.y2 = math.ceil(item.y_center + h/2) @@ -228,6 +273,8 @@ function draw_settings() -- draw settings items draw_settings_item("sound") draw_settings_item("buttons") + draw_settings_item("reset_button") + draw_settings_item("confirmations") -- draw done button draw_done_button() @@ -247,22 +294,17 @@ end function handle_tap_settings(x, y) -- select setting (NOT button, so we don't return) - if xy_in_xyxy(x, y, - settings_items["sound"].x1, - settings_items["sound"].y1, - settings_items["sound"].x2, - settings_items["sound"].y2) then - - settings_sel_item = "sound" - elseif xy_in_xyxy(x, y, - settings_items["buttons"].x1, - settings_items["buttons"].y1, - settings_items["buttons"].x2, - settings_items["buttons"].y2) then - - settings_sel_item = "buttons" - else - settings_sel_item = nil + settings_sel_item = nil + for setting_name, setting_item in pairs(settings_items) do + if xy_in_xyxy(x, y, + setting_item.x1, + setting_item.y1, + setting_item.x2, + setting_item.y2) then + + settings_sel_item = setting_name + break + end end -- done button @@ -324,5 +366,49 @@ function handle_tap_settings(x, y) return end + if xy_in_xywh(x, y, + settings_items["reset_button"].A.x, + settings_items["reset_button"].A.y, + settings_items["reset_button"].A.width, + settings_items["reset_button"].A.height) then + + SETTINGS.reset_button.value = "triangle" + play_sound("click") + + return + end + if xy_in_xywh(x, y, + settings_items["reset_button"].B.x, + settings_items["reset_button"].B.y, + settings_items["reset_button"].B.width, + settings_items["reset_button"].B.height) then + + SETTINGS.reset_button.value = "start" + play_sound("click") + + return + end + if xy_in_xywh(x, y, + settings_items["confirmations"].A.x, + settings_items["confirmations"].A.y, + settings_items["confirmations"].A.width, + settings_items["confirmations"].A.height) then + + SETTINGS.confirmations.value = "on" + play_sound("click") + + return + end + if xy_in_xywh(x, y, + settings_items["confirmations"].B.x, + settings_items["confirmations"].B.y, + settings_items["confirmations"].B.width, + settings_items["confirmations"].B.height) then + + SETTINGS.confirmations.value = "off" + play_sound("click") + + return + end end diff --git a/lib/translation.lua b/lib/translation.lua index 552f695..92469e8 100644 --- a/lib/translation.lua +++ b/lib/translation.lua @@ -15,7 +15,9 @@ strings_i18n["en"] = { -- settings ["sound"] = "sound", - ["buttons"] = "buttons", + ["xo_buttons"] = "X/O buttons", + ["reset_button"] = "reset button", + ["confirmations"] = "confirmation dialogs", ["done"] = "done", ["on"] = "on", ["off"] = "off", @@ -48,7 +50,9 @@ strings_i18n["ja"] = { -- settings ["sound"] = "効果音", - ["buttons"] = "ボタン", + ["xo_buttons"] = "OXボタン", + ["reset_button"] = "リセットボタン", + ["confirmations"] = "確認メッセージ", ["done"] = "完了", ["on"] = "オン", ["off"] = "オフ", @@ -59,7 +63,7 @@ strings_i18n["ja"] = { ["conf_levelmenu"] = "レベルメニューへ戻りますか?", ["conf_nextlevel"] = "次のレベルへ進みますか?", ["conf_prevlevel"] = "前のレベルへ戻りますか?", - ["conf_reset"] = "レベルをやり直しますか?", + ["conf_reset"] = "レベルをリセットしますか?", ["progresslost"] = "このレベルの状態は消えます。", ["no"] = "いいえ", @@ -81,7 +85,9 @@ strings_i18n["zh_t"] = { -- settings ["sound"] = "音效", - ["buttons"] = "按鈕", + ["xo_buttons"] = "OX按鈕", + ["reset_button"] = "復位按鈕", + ["confirmations"] = "確認提示", ["done"] = "完成", ["on"] = "開啟", ["off"] = "關閉", @@ -114,7 +120,9 @@ strings_i18n["zh_s"] = { -- settings ["sound"] = "音效", - ["buttons"] = "按钮", + ["xo_buttons"] = "OX按钮", + ["reset_button"] = "复位按钮", + ["confirmations"] = "确认提示", ["done"] = "完成", ["on"] = "开启", ["off"] = "关闭",