From c7699f081cc6a9f1c4153a29db2d9d5a5f744275 Mon Sep 17 00:00:00 2001 From: SemvdH Date: Tue, 2 Nov 2021 10:32:32 +0100 Subject: [PATCH] added windows for #2 and #9. only need to add proper functionality --- Makefile | 137 ++++++++++++++++++------------------------ cmake_install.cmake | 9 +-- src/main.c | 90 ++++++++++++++++++++++----- src/toolbox/drawing.c | 19 +++--- src/toolbox/drawing.h | 13 ++++ 5 files changed, 158 insertions(+), 110 deletions(-) diff --git a/Makefile b/Makefile index cfad7f4..bbc2b46 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.18 +# Generated by "Unix Makefiles" Generator, CMake Version 3.16 # Default target executed when no arguments are given to make. default_target: all @@ -17,35 +17,16 @@ default_target: all .SUFFIXES: -# Disable VCS-based implicit rules. -% : %,v - - -# Disable VCS-based implicit rules. -% : RCS/% - - -# Disable VCS-based implicit rules. -% : RCS/%,v - - -# Disable VCS-based implicit rules. -% : SCCS/s.% - - -# Disable VCS-based implicit rules. -% : s.% - +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = .SUFFIXES: .hpux_make_needs_suffix_list -# Command-line flag to silence nested $(MAKE). -$(VERBOSE)MAKESILENT = -s - -#Suppress display of executed commands. +# Suppress display of executed commands. $(VERBOSE).SILENT: + # A target that is always out of date. cmake_force: @@ -61,16 +42,16 @@ SHELL = /bin/sh CMAKE_COMMAND = /usr/bin/cmake # The command to remove a file. -RM = /usr/bin/cmake -E rm -f +RM = /usr/bin/cmake -E remove -f # Escaping for special characters. EQUALS = = # The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/semtex/samples/cybershot-PSVita +CMAKE_SOURCE_DIR = /home/semtex99/vita/samples/cybershot-PSVita # The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/semtex/samples/cybershot-PSVita +CMAKE_BINARY_DIR = /home/semtex99/vita/samples/cybershot-PSVita #============================================================================= # Targets provided globally by CMake. @@ -78,7 +59,7 @@ CMAKE_BINARY_DIR = /home/semtex/samples/cybershot-PSVita # Special rule for the target rebuild_cache rebuild_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) + /usr/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : rebuild_cache # Special rule for the target rebuild_cache @@ -99,14 +80,14 @@ edit_cache/fast: edit_cache # The main all target all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/semtex/samples/cybershot-PSVita/CMakeFiles /home/semtex/samples/cybershot-PSVita//CMakeFiles/progress.marks - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /home/semtex/samples/cybershot-PSVita/CMakeFiles 0 + $(CMAKE_COMMAND) -E cmake_progress_start /home/semtex99/vita/samples/cybershot-PSVita/CMakeFiles /home/semtex99/vita/samples/cybershot-PSVita/CMakeFiles/progress.marks + $(MAKE) -f CMakeFiles/Makefile2 all + $(CMAKE_COMMAND) -E cmake_progress_start /home/semtex99/vita/samples/cybershot-PSVita/CMakeFiles 0 .PHONY : all # The main clean target clean: - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean + $(MAKE) -f CMakeFiles/Makefile2 clean .PHONY : clean # The main clean target @@ -116,12 +97,12 @@ clean/fast: clean # Prepare targets for installation. preinstall: all - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall + $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall # Prepare targets for installation. preinstall/fast: - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall + $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall/fast # clear depends @@ -134,12 +115,12 @@ depend: # Build rule for target. cybershot.vpk: cmake_check_build_system - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 cybershot.vpk + $(MAKE) -f CMakeFiles/Makefile2 cybershot.vpk .PHONY : cybershot.vpk # fast build rule for target. cybershot.vpk/fast: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.vpk.dir/build.make CMakeFiles/cybershot.vpk.dir/build + $(MAKE) -f CMakeFiles/cybershot.vpk.dir/build.make CMakeFiles/cybershot.vpk.dir/build .PHONY : cybershot.vpk/fast #============================================================================= @@ -147,12 +128,12 @@ cybershot.vpk/fast: # Build rule for target. cybershot.self: cmake_check_build_system - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 cybershot.self + $(MAKE) -f CMakeFiles/Makefile2 cybershot.self .PHONY : cybershot.self # fast build rule for target. cybershot.self/fast: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.self.dir/build.make CMakeFiles/cybershot.self.dir/build + $(MAKE) -f CMakeFiles/cybershot.self.dir/build.make CMakeFiles/cybershot.self.dir/build .PHONY : cybershot.self/fast #============================================================================= @@ -160,40 +141,40 @@ cybershot.self/fast: # Build rule for target. cybershot: cmake_check_build_system - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 cybershot + $(MAKE) -f CMakeFiles/Makefile2 cybershot .PHONY : cybershot # fast build rule for target. cybershot/fast: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/build + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/build .PHONY : cybershot/fast -home/semtex/samples/common/debugScreen.obj: home/semtex/samples/common/debugScreen.c.obj +home/semtex99/vita/samples/common/debugScreen.obj: home/semtex99/vita/samples/common/debugScreen.c.obj -.PHONY : home/semtex/samples/common/debugScreen.obj +.PHONY : home/semtex99/vita/samples/common/debugScreen.obj # target to build an object file -home/semtex/samples/common/debugScreen.c.obj: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/home/semtex/samples/common/debugScreen.c.obj -.PHONY : home/semtex/samples/common/debugScreen.c.obj +home/semtex99/vita/samples/common/debugScreen.c.obj: + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/home/semtex99/vita/samples/common/debugScreen.c.obj +.PHONY : home/semtex99/vita/samples/common/debugScreen.c.obj -home/semtex/samples/common/debugScreen.i: home/semtex/samples/common/debugScreen.c.i +home/semtex99/vita/samples/common/debugScreen.i: home/semtex99/vita/samples/common/debugScreen.c.i -.PHONY : home/semtex/samples/common/debugScreen.i +.PHONY : home/semtex99/vita/samples/common/debugScreen.i # target to preprocess a source file -home/semtex/samples/common/debugScreen.c.i: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/home/semtex/samples/common/debugScreen.c.i -.PHONY : home/semtex/samples/common/debugScreen.c.i +home/semtex99/vita/samples/common/debugScreen.c.i: + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/home/semtex99/vita/samples/common/debugScreen.c.i +.PHONY : home/semtex99/vita/samples/common/debugScreen.c.i -home/semtex/samples/common/debugScreen.s: home/semtex/samples/common/debugScreen.c.s +home/semtex99/vita/samples/common/debugScreen.s: home/semtex99/vita/samples/common/debugScreen.c.s -.PHONY : home/semtex/samples/common/debugScreen.s +.PHONY : home/semtex99/vita/samples/common/debugScreen.s # target to generate assembly for a file -home/semtex/samples/common/debugScreen.c.s: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/home/semtex/samples/common/debugScreen.c.s -.PHONY : home/semtex/samples/common/debugScreen.c.s +home/semtex99/vita/samples/common/debugScreen.c.s: + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/home/semtex99/vita/samples/common/debugScreen.c.s +.PHONY : home/semtex99/vita/samples/common/debugScreen.c.s src/main.obj: src/main.c.obj @@ -201,7 +182,7 @@ src/main.obj: src/main.c.obj # target to build an object file src/main.c.obj: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/main.c.obj + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/main.c.obj .PHONY : src/main.c.obj src/main.i: src/main.c.i @@ -210,7 +191,7 @@ src/main.i: src/main.c.i # target to preprocess a source file src/main.c.i: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/main.c.i + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/main.c.i .PHONY : src/main.c.i src/main.s: src/main.c.s @@ -219,7 +200,7 @@ src/main.s: src/main.c.s # target to generate assembly for a file src/main.c.s: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/main.c.s + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/main.c.s .PHONY : src/main.c.s src/sprites/sprites.obj: src/sprites/sprites.c.obj @@ -228,7 +209,7 @@ src/sprites/sprites.obj: src/sprites/sprites.c.obj # target to build an object file src/sprites/sprites.c.obj: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/sprites/sprites.c.obj + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/sprites/sprites.c.obj .PHONY : src/sprites/sprites.c.obj src/sprites/sprites.i: src/sprites/sprites.c.i @@ -237,7 +218,7 @@ src/sprites/sprites.i: src/sprites/sprites.c.i # target to preprocess a source file src/sprites/sprites.c.i: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/sprites/sprites.c.i + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/sprites/sprites.c.i .PHONY : src/sprites/sprites.c.i src/sprites/sprites.s: src/sprites/sprites.c.s @@ -246,7 +227,7 @@ src/sprites/sprites.s: src/sprites/sprites.c.s # target to generate assembly for a file src/sprites/sprites.c.s: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/sprites/sprites.c.s + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/sprites/sprites.c.s .PHONY : src/sprites/sprites.c.s src/system/control_input.obj: src/system/control_input.c.obj @@ -255,7 +236,7 @@ src/system/control_input.obj: src/system/control_input.c.obj # target to build an object file src/system/control_input.c.obj: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/control_input.c.obj + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/control_input.c.obj .PHONY : src/system/control_input.c.obj src/system/control_input.i: src/system/control_input.c.i @@ -264,7 +245,7 @@ src/system/control_input.i: src/system/control_input.c.i # target to preprocess a source file src/system/control_input.c.i: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/control_input.c.i + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/control_input.c.i .PHONY : src/system/control_input.c.i src/system/control_input.s: src/system/control_input.c.s @@ -273,7 +254,7 @@ src/system/control_input.s: src/system/control_input.c.s # target to generate assembly for a file src/system/control_input.c.s: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/control_input.c.s + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/control_input.c.s .PHONY : src/system/control_input.c.s src/system/timing.obj: src/system/timing.c.obj @@ -282,7 +263,7 @@ src/system/timing.obj: src/system/timing.c.obj # target to build an object file src/system/timing.c.obj: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/timing.c.obj + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/timing.c.obj .PHONY : src/system/timing.c.obj src/system/timing.i: src/system/timing.c.i @@ -291,7 +272,7 @@ src/system/timing.i: src/system/timing.c.i # target to preprocess a source file src/system/timing.c.i: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/timing.c.i + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/timing.c.i .PHONY : src/system/timing.c.i src/system/timing.s: src/system/timing.c.s @@ -300,7 +281,7 @@ src/system/timing.s: src/system/timing.c.s # target to generate assembly for a file src/system/timing.c.s: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/timing.c.s + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/system/timing.c.s .PHONY : src/system/timing.c.s src/toolbox/drawing.obj: src/toolbox/drawing.c.obj @@ -309,7 +290,7 @@ src/toolbox/drawing.obj: src/toolbox/drawing.c.obj # target to build an object file src/toolbox/drawing.c.obj: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/drawing.c.obj + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/drawing.c.obj .PHONY : src/toolbox/drawing.c.obj src/toolbox/drawing.i: src/toolbox/drawing.c.i @@ -318,7 +299,7 @@ src/toolbox/drawing.i: src/toolbox/drawing.c.i # target to preprocess a source file src/toolbox/drawing.c.i: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/drawing.c.i + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/drawing.c.i .PHONY : src/toolbox/drawing.c.i src/toolbox/drawing.s: src/toolbox/drawing.c.s @@ -327,7 +308,7 @@ src/toolbox/drawing.s: src/toolbox/drawing.c.s # target to generate assembly for a file src/toolbox/drawing.c.s: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/drawing.c.s + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/drawing.c.s .PHONY : src/toolbox/drawing.c.s src/toolbox/toolbox.obj: src/toolbox/toolbox.c.obj @@ -336,7 +317,7 @@ src/toolbox/toolbox.obj: src/toolbox/toolbox.c.obj # target to build an object file src/toolbox/toolbox.c.obj: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/toolbox.c.obj + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/toolbox.c.obj .PHONY : src/toolbox/toolbox.c.obj src/toolbox/toolbox.i: src/toolbox/toolbox.c.i @@ -345,7 +326,7 @@ src/toolbox/toolbox.i: src/toolbox/toolbox.c.i # target to preprocess a source file src/toolbox/toolbox.c.i: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/toolbox.c.i + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/toolbox.c.i .PHONY : src/toolbox/toolbox.c.i src/toolbox/toolbox.s: src/toolbox/toolbox.c.s @@ -354,7 +335,7 @@ src/toolbox/toolbox.s: src/toolbox/toolbox.c.s # target to generate assembly for a file src/toolbox/toolbox.c.s: - $(MAKE) $(MAKESILENT) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/toolbox.c.s + $(MAKE) -f CMakeFiles/cybershot.dir/build.make CMakeFiles/cybershot.dir/src/toolbox/toolbox.c.s .PHONY : src/toolbox/toolbox.c.s # Help Target @@ -363,14 +344,14 @@ help: @echo "... all (the default if no target is provided)" @echo "... clean" @echo "... depend" - @echo "... edit_cache" @echo "... rebuild_cache" - @echo "... cybershot.self" + @echo "... edit_cache" @echo "... cybershot.vpk" + @echo "... cybershot.self" @echo "... cybershot" - @echo "... home/semtex/samples/common/debugScreen.obj" - @echo "... home/semtex/samples/common/debugScreen.i" - @echo "... home/semtex/samples/common/debugScreen.s" + @echo "... home/semtex99/vita/samples/common/debugScreen.obj" + @echo "... home/semtex99/vita/samples/common/debugScreen.i" + @echo "... home/semtex99/vita/samples/common/debugScreen.s" @echo "... src/main.obj" @echo "... src/main.i" @echo "... src/main.s" diff --git a/cmake_install.cmake b/cmake_install.cmake index c4d9445..9630e57 100644 --- a/cmake_install.cmake +++ b/cmake_install.cmake @@ -1,4 +1,4 @@ -# Install script for directory: /home/semtex/samples/cybershot-PSVita +# Install script for directory: /home/semtex99/vita/samples/cybershot-PSVita # Set the install prefix if(NOT DEFINED CMAKE_INSTALL_PREFIX) @@ -32,11 +32,6 @@ if(NOT DEFINED CMAKE_CROSSCOMPILING) set(CMAKE_CROSSCOMPILING "TRUE") endif() -# Set default install directory permissions. -if(NOT DEFINED CMAKE_OBJDUMP) - set(CMAKE_OBJDUMP "/usr/local/vitasdk/bin/arm-vita-eabi-objdump") -endif() - if(CMAKE_INSTALL_COMPONENT) set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") else() @@ -45,5 +40,5 @@ endif() string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT "${CMAKE_INSTALL_MANIFEST_FILES}") -file(WRITE "/home/semtex/samples/cybershot-PSVita/${CMAKE_INSTALL_MANIFEST}" +file(WRITE "/home/semtex99/vita/samples/cybershot-PSVita/${CMAKE_INSTALL_MANIFEST}" "${CMAKE_INSTALL_MANIFEST_CONTENT}") diff --git a/src/main.c b/src/main.c index 30c185a..f0abc74 100644 --- a/src/main.c +++ b/src/main.c @@ -37,7 +37,7 @@ menu windows: |--------| |------------| |-----| |tutorial| |color select| |start| |--------| |------------| |-----| -*/ +*/ #define MENU_WINDOW_TUTORIAL 0 #define MENU_WINDOW_COLOR_SELECT 1 #define MENU_WINDOW_START 2 @@ -76,7 +76,7 @@ vita2d_pvf *pvf; SceUInt64 deltaTime = 0; // delta time in ms SceKernelSysClock sysclock; timing_timer bullet_timer = {0, 250, 0}; // 0 as starting time, 250 ms timeout, not elapsed -timing_timer menu_switch_input_delay_timer = {0, 500, 0}; // 0 as starting time, 100 ms timeout, not elapsed +timing_timer menu_switch_input_delay_timer = {0, 500, 0}; // 0 as starting time, 500 ms timeout, not elapsed timing_timer score_timer = {0, 100, 0}; // timer to update score timing_timer simple_enemy_spawn_timer = {0, 500, 0}; // timer to spawn a new simple enemy timing_timer complex_enemy_spawn_timer = {0, 2000, 0}; // timer to spawn a new complex enemy @@ -97,8 +97,10 @@ uint8_t menu_background_color[3] = {0, 255, 255}; char menu_background_color_index; // 1 or -1, is used to cycle between the colors of the menu menu_window_state menu_active_window; -uint8_t menu_selected_window; // 0 is how to play, 1 is ship color select, 2 is game -uint8_t menu_left_right_pressed; // 0 is none, 1 is left, 2 is right +uint8_t menu_selected_window; // 0 is how to play, 1 is ship color select, 2 is game +uint8_t menu_left_right_pressed; // 0 is none, 1 is left, 2 is right +uint8_t last_menu_left_right_pressed; // what we pressed last update loop +timing_timer menu_selected_window_input_delay_timer = {0, 300, 0}; // 0 as starting time, 300 ms timeout, not elapsed /** * @brief should be called when an unhandlable exception or error occurs. Triggers coredump. @@ -135,8 +137,9 @@ void init_variables() menu_background_color[1] = 255; menu_background_color_index = 1; menu_active_window = NONE; - menu_selected_window = 0; - menu_left_right_pressed = 0; + menu_selected_window = MENU_WINDOW_TUTORIAL; + menu_left_right_pressed = MENU_LEFT_RIGHT_NONE; + last_menu_left_right_pressed = MENU_LEFT_RIGHT_NONE; } // ################################################################ @@ -408,6 +411,9 @@ void update_menu() { timing_update_timer(&menu_switch_input_delay_timer, deltaTime); timing_check_timer_elapsed(&menu_switch_input_delay_timer); + timing_update_timer(&menu_selected_window_input_delay_timer, deltaTime); + timing_check_timer_elapsed(&menu_selected_window_input_delay_timer); + if (menu_background_color[0] == 254 || menu_background_color[0] == 1) { menu_background_color[0] += menu_background_color_index; @@ -430,22 +436,24 @@ void update_menu() player_y = 500; } - if (menu_switch_input_delay_timer.elapsed) + if (menu_selected_window_input_delay_timer.elapsed) { if (menu_left_right_pressed == MENU_LEFT_RIGHT_LEFT) // left { menu_selected_window -= 1; - if (menu_selected_window < MENU_WINDOW_TUTORIAL) + if (menu_selected_window == 255) menu_selected_window = MENU_WINDOW_START; menu_left_right_pressed = MENU_LEFT_RIGHT_NONE; + menu_selected_window_input_delay_timer.elapsed = 0; } if (menu_left_right_pressed == MENU_LEFT_RIGHT_RIGHT) // right { menu_selected_window += 1; - if (menu_selected_window > MENU_WINDOW_START) + if (menu_selected_window == 3) menu_selected_window = MENU_WINDOW_TUTORIAL; menu_left_right_pressed = MENU_LEFT_RIGHT_NONE; + menu_selected_window_input_delay_timer.elapsed = 0; } } } @@ -592,11 +600,13 @@ void update() if (pad.buttons & SCE_CTRL_CROSS) cross_pressed = 1; +//TODO check on button release? if (pad.buttons & SCE_CTRL_LEFT) menu_left_right_pressed = MENU_LEFT_RIGHT_LEFT; if (pad.buttons & SCE_CTRL_RIGHT) menu_left_right_pressed = MENU_LEFT_RIGHT_RIGHT; + ctrl_input_get_leftstick(&pad, &left_stick); // ctrl_input_get_rightstick(&pad, &right_stick); @@ -628,6 +638,7 @@ void update() // ------------------------ DRAW FUNCTIONS ------------------ // ################################################################ + void draw_start() { unsigned int text_color; @@ -649,20 +660,67 @@ void draw_start() vita2d_pgf_draw_text(pgf, 622, 457, COLOR_BLACK, 1.2f, "Press X to start"); } +void draw_menu_window_tutorial(uint8_t sel_window) +{ + if (sel_window == MENU_WINDOW_TUTORIAL) + { + drawing_draw_selected_window_filled(100, 200, 226, 80, "Tutorial", pgf, SECONDARY_BORDER_COLOR); + } + else + { + drawing_draw_window_filled(100, 200, 226, 80, "Tutorial", pgf, SECONDARY_BORDER_COLOR); + } + + vita2d_pgf_draw_text(pgf, 122, 257, COLOR_BLACK, 1.2f, "How to play"); +} + +void draw_menu_window_color_select(uint8_t sel_window) +{ + if (sel_window == MENU_WINDOW_COLOR_SELECT) + { + drawing_draw_selected_window_filled(200, 300, 226, 80, "Make it pretty", pgf, SECONDARY_BORDER_COLOR); + } + else + { + drawing_draw_window_filled(200, 300, 226, 80, "Make it pretty", pgf, SECONDARY_BORDER_COLOR); + } + + vita2d_pgf_draw_text(pgf, 222, 357, COLOR_BLACK, 1.2f, "Ship color select"); +} + +void draw_menu_window_start(uint8_t sel_window) +{ + if (sel_window == MENU_WINDOW_START) + { + drawing_draw_selected_window_filled(600, 400, 226, 80, "Message", pgf, SECONDARY_BORDER_COLOR); + } + else + { + drawing_draw_window_filled(600, 400, 226, 80, "Message", pgf, SECONDARY_BORDER_COLOR); // width: 28 pixels for each character + } + + vita2d_pgf_draw_text(pgf, 622, 457, COLOR_BLACK, 1.2f, "Start"); +} + void draw_menu() { // TODO add windows for tutorial and color select, and make "press x to start" window just a "start" window drawing_draw_window_filled(SCREEN_WIDTH / 2 - 212 / 2, 50, 212, 100, "Window Title", pgf, RGBA8(menu_background_color[0], menu_background_color[1], menu_background_color[2], 255)); vita2d_pgf_draw_text(pgf, SCREEN_WIDTH / 2 - 212 / 2 + 47, 50 + 70, COLOR_BLACK, 2.0, "Menu"); - drawing_draw_window_filled(600, 400, 226, 80, "Message", pgf, SECONDARY_BORDER_COLOR); // width: 28 pixels for each character - vita2d_pgf_draw_text(pgf, 622, 457, COLOR_BLACK, 1.2f, "Press X to start"); - drawing_draw_window_filled(100, 200, 356, 120, "WIP", pgf, RGBA8(255, 0, 0, 255)); // width: 28 pixels for each character - vita2d_pgf_draw_text(pgf, 122, 257, COLOR_BLACK, 1.2f, "Menu will be\nadded later"); + + draw_menu_window_tutorial(menu_selected_window); + draw_menu_window_color_select(menu_selected_window); + draw_menu_window_start(menu_selected_window); + + // drawing_draw_window_filled(100, 200, 356, 120, "WIP", pgf, RGBA8(255, 0, 0, 255)); // width: 28 pixels for each character + char buf[80]; + sprintf(buf, "sel menu %d", menu_selected_window); + vita2d_pgf_draw_text(pgf, 10, 10, COLOR_MAGENTA, 1.2f, buf); //draw warning triangle - drawing_draw_triangle(320, 240, 280, 300, 360, 300, 3, COLOR_BLACK); - drawing_draw_vline(320 - 1.5, 255, 30, 6, COLOR_BLACK); - vita2d_draw_rectangle(320 - 1.5, 290, 6, 6, COLOR_BLACK); + // drawing_draw_triangle(320, 240, 280, 300, 360, 300, 3, COLOR_BLACK); + // drawing_draw_vline(320 - 1.5, 255, 30, 6, COLOR_BLACK); + // vita2d_draw_rectangle(320 - 1.5, 290, 6, 6, COLOR_BLACK); } void draw_game() diff --git a/src/toolbox/drawing.c b/src/toolbox/drawing.c index 693c0b5..cfee864 100644 --- a/src/toolbox/drawing.c +++ b/src/toolbox/drawing.c @@ -27,15 +27,6 @@ void drawing_draw_vline(float x0, float y0, float height, int thiccness, unsigne } } -void drawing_draw_window_clear(float x, float y, float width, float heigth, const char *title_text, vita2d_pgf *pgf) -{ - drawing_draw_window(x,y,width,heigth,title_text,pgf,MAIN_BORDER_COLOR); -} - -void drawing_draw_window_selected(float x, float y, float width, float heigth, const char *title_text, vita2d_pgf *pgf) -{ - drawing_draw_window(x,y,width,heigth,title_text,pgf,SELECTED_BORDER_COLOR); -} void drawing_draw_window(float x, float y, float width, float heigth, const char *title_text, vita2d_pgf *pgf, unsigned int border_color) { @@ -67,6 +58,16 @@ void drawing_draw_window(float x, float y, float width, float heigth, const char vita2d_pgf_draw_text(pgf, x + 10, y + 23, COLOR_MAGENTA, 0.9, title_text); } +void drawing_draw_window_clear(float x, float y, float width, float heigth, const char *title_text, vita2d_pgf *pgf) +{ + drawing_draw_window(x,y,width,heigth,title_text,pgf,MAIN_BORDER_COLOR); +} + +void drawing_draw_window_selected(float x, float y, float width, float heigth, const char *title_text, vita2d_pgf *pgf) +{ + drawing_draw_window(x,y,width,heigth,title_text,pgf,SELECTED_BORDER_COLOR); +} + void drawing_draw_window_filled(float x, float y, float width, float heigth, const char *title_text, vita2d_pgf *pgf, unsigned int color) { drawing_draw_window_clear(x, y, width, heigth, title_text, pgf); diff --git a/src/toolbox/drawing.h b/src/toolbox/drawing.h index d220aaf..e3b5b68 100644 --- a/src/toolbox/drawing.h +++ b/src/toolbox/drawing.h @@ -56,6 +56,19 @@ void drawing_draw_hline(float x0, float y0, float width, int thiccness, unsigned */ void drawing_draw_vline(float x0, float y0, float height, int thiccness, unsigned int color); +/** + * @brief draws a window frame with the specified features + * + * @param x the top left x position of the frame + * @param y the top left y position of the frame + * @param width the width of the frame + * @param heigth the heigth of the frame + * @param title_text the title text to be displayed at the top of the frame + * @param pgf pointer to the pgf font to be used + * @param border_color the color of the border + */ +void drawing_draw_window(float x, float y, float width, float heigth, const char *title_text, vita2d_pgf *pgf, unsigned int border_color); + /** * @brief draws a window frame with the specified features *