2014-12-08 19:32:05 +01:00
|
|
|
#include "rsgamemenu.h"
|
|
|
|
|
|
|
|
#include "rsgame.h"
|
|
|
|
|
|
|
|
#include "rskos.h"
|
|
|
|
|
2014-12-19 18:29:02 +01:00
|
|
|
#include "strings.h"
|
|
|
|
|
2014-12-08 19:32:05 +01:00
|
|
|
PRSFUNC0 menu_actions[] = {
|
|
|
|
/* a */ &menu_action_start,
|
|
|
|
/* b */ &menu_action_exit,
|
2014-12-29 23:59:51 +01:00
|
|
|
/* c */ &menu_action_change_window_scale,
|
2014-12-31 01:32:03 +01:00
|
|
|
/* d */ &menu_action_resume
|
2014-12-08 19:32:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
char window_scale_str[] = "c< 2X >";
|
2014-12-29 23:59:51 +01:00
|
|
|
char level_passed_score_str[] = " 000 ";
|
2014-12-08 19:32:05 +01:00
|
|
|
|
2014-12-19 18:29:02 +01:00
|
|
|
/*
|
|
|
|
First char:
|
|
|
|
- letter a...z means action (a = 0th, b = 1st, c = 2nd, see menu_actions[] above)
|
|
|
|
- number 0...9 means goto menu #0, #1, #2... see menu_titles[] below
|
|
|
|
- space ' ' means no action, menu item is unselectable
|
|
|
|
- empty string "" is now allowed and can cause segfault
|
|
|
|
String from second char is label of menu item
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-12-08 19:32:05 +01:00
|
|
|
char* menu_main_titles[] = {
|
2014-12-19 18:29:02 +01:00
|
|
|
"a"L_START,
|
|
|
|
"1"L_SETTINGS,
|
|
|
|
"2"L_ABOUT,
|
|
|
|
"b"L_QUIT,
|
2014-12-08 19:32:05 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
char* menu_settings_titles[] = {
|
2014-12-19 18:29:02 +01:00
|
|
|
" "L_WINDOW_SCALE,
|
2014-12-08 19:32:05 +01:00
|
|
|
window_scale_str,
|
|
|
|
" ",
|
2014-12-19 18:29:02 +01:00
|
|
|
"0"L_DONE,
|
2014-12-08 19:32:05 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
char* menu_about_titles[] = {
|
2014-12-19 18:29:02 +01:00
|
|
|
" "L_DEVELOPED_BY,
|
|
|
|
" "L_ROMAN_SHUVALOV,
|
2014-12-08 19:32:05 +01:00
|
|
|
" ",
|
2014-12-29 23:59:51 +01:00
|
|
|
"0"L_BACK,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
char* menu_level_passed_titles[] = {
|
|
|
|
" "L_LEVEL_PASSED,
|
|
|
|
" "L_YOUR_SCORE,
|
|
|
|
level_passed_score_str,
|
|
|
|
" ",
|
|
|
|
"0"L_BACK,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
char* menu_game_over_titles[] = {
|
|
|
|
" "L_GAME_OVER,
|
|
|
|
" ",
|
|
|
|
"0"L_BACK,
|
2014-12-08 19:32:05 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2014-12-31 01:32:03 +01:00
|
|
|
char* menu_pause_titles[] = {
|
|
|
|
" "L_PAUSE,
|
|
|
|
" ",
|
|
|
|
"d"L_RESUME,
|
|
|
|
"0"L_EXIT_TO_MAIN_MENU,
|
|
|
|
0
|
|
|
|
};
|
2014-12-29 23:59:51 +01:00
|
|
|
|
|
|
|
|
2014-12-08 19:32:05 +01:00
|
|
|
char **menu_titles[] = {
|
|
|
|
/* 0 */ menu_main_titles,
|
|
|
|
/* 1 */ menu_settings_titles,
|
|
|
|
/* 2 */ menu_about_titles,
|
2014-12-29 23:59:51 +01:00
|
|
|
/* 3 */ menu_level_passed_titles,
|
|
|
|
/* 4 */ menu_game_over_titles,
|
2014-12-31 01:32:03 +01:00
|
|
|
/* 5 */ menu_pause_titles,
|
2014-12-08 19:32:05 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void menu_cursor_down() {
|
|
|
|
int new_index = game.menu_item_index+1;
|
|
|
|
while ( (menu_titles[game.menu_index][new_index]) ) {
|
|
|
|
if ((menu_titles[game.menu_index][new_index][0] != ' ')) {
|
|
|
|
game.menu_item_index = new_index;
|
|
|
|
game_ding(1);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
new_index++;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
void menu_cursor_up() {
|
|
|
|
int new_index = game.menu_item_index-1;
|
|
|
|
while ( new_index+1 ) {
|
|
|
|
if ((menu_titles[game.menu_index][new_index][0] != ' ')) {
|
|
|
|
game.menu_item_index = new_index;
|
|
|
|
game_ding(1);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
new_index--;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
void menu_open(int i) {
|
2014-12-31 01:32:03 +01:00
|
|
|
|
|
|
|
if ( (game.menu_index == MENU_PAUSE) && (i != MENU_PAUSE) ){
|
|
|
|
soundbuf_play( &game.sound_music, SND_MODE_LOOP );
|
|
|
|
};
|
2014-12-30 23:47:04 +01:00
|
|
|
|
2014-12-08 19:32:05 +01:00
|
|
|
game.menu_index = i;
|
|
|
|
|
|
|
|
game.menu_item_index = -1;
|
|
|
|
// (menu_cursor_down without sound)
|
|
|
|
int new_index = game.menu_item_index+1;
|
|
|
|
while ( (menu_titles[game.menu_index][new_index]) ) {
|
|
|
|
if ((menu_titles[game.menu_index][new_index][0] != ' ')) {
|
|
|
|
game.menu_item_index = new_index;
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
new_index++;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
void menu_cursor_click() {
|
|
|
|
|
|
|
|
char c = menu_titles[game.menu_index][game.menu_item_index][0];
|
|
|
|
|
|
|
|
game_ding(0);
|
|
|
|
|
|
|
|
if (c > '9') {
|
|
|
|
// action: call function
|
|
|
|
menu_actions[c - 'a']();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// action: navigate to menu
|
|
|
|
menu_open(c - '0');
|
|
|
|
};
|
|
|
|
|
|
|
|
// DEBUG10f("click: %c \n", c);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
void menu_action_start() {
|
|
|
|
game.status = STATUS_PLAYING;
|
|
|
|
|
2014-12-29 23:59:51 +01:00
|
|
|
game.player_x = GAME_WIDTH/2 - 50;
|
|
|
|
game.player_y = GAME_HEIGHT/2 - 10;
|
|
|
|
|
|
|
|
game.stage = 0;
|
|
|
|
game.stage_timer = 0;
|
|
|
|
|
|
|
|
game.health = GAME_HEALTH_MAX;
|
|
|
|
game.ammo = GAME_AMMO_MAX;
|
|
|
|
|
|
|
|
game.shoot_delay = 0;
|
|
|
|
game.shoot_keypressed = 0;
|
|
|
|
game.shoot_restore_delay = 0;
|
|
|
|
|
|
|
|
game.score = 0;
|
|
|
|
game.flags = 0;
|
|
|
|
|
|
|
|
game.objs_count = 0;
|
2014-12-08 19:32:05 +01:00
|
|
|
|
2014-12-30 19:04:09 +01:00
|
|
|
game.bg_color = COLOR_BLACK;
|
|
|
|
|
2014-12-30 23:47:04 +01:00
|
|
|
soundbuf_stop( &game.sound_music );
|
|
|
|
|
2014-12-08 19:32:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void menu_action_exit() {
|
2014-12-19 18:29:02 +01:00
|
|
|
#ifdef RS_KOS
|
2014-12-08 19:32:05 +01:00
|
|
|
GameTerm();
|
|
|
|
#endif
|
|
|
|
rskos_exit();
|
|
|
|
};
|
|
|
|
|
|
|
|
void menu_action_change_window_scale() {
|
|
|
|
game_change_window_scale(1);
|
|
|
|
};
|
2014-12-31 01:32:03 +01:00
|
|
|
|
|
|
|
void menu_action_resume() {
|
|
|
|
|
|
|
|
game.status = STATUS_PLAYING;
|
|
|
|
|
|
|
|
};
|