From: Holger Schemel Date: Sun, 18 Oct 2020 00:52:13 +0000 (+0200) Subject: added basic support for user name selection screen (not used yet) X-Git-Tag: 4.2.1.0~45 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=55188fc81fac757089356928ae7ec26f90c4a7d0;p=rocksndiamonds.git added basic support for user name selection screen (not used yet) --- diff --git a/src/events.c b/src/events.c index b4f75948..a5bbf458 100644 --- a/src/events.c +++ b/src/events.c @@ -1752,6 +1752,10 @@ void HandleButton(int mx, int my, int button, int button_nr) HandleTypeName(KSYM_Return); break; + case GAME_MODE_NAMES: + HandleChoosePlayerName(mx, my, 0, 0, button); + break; + case GAME_MODE_LEVELS: HandleChooseLevelSet(mx, my, 0, 0, button); break; @@ -2302,6 +2306,7 @@ void HandleKey(Key key, int key_status) case GAME_MODE_TITLE: case GAME_MODE_MAIN: + case GAME_MODE_NAMES: case GAME_MODE_LEVELS: case GAME_MODE_LEVELNR: case GAME_MODE_SETUP: @@ -2319,6 +2324,8 @@ void HandleKey(Key key, int key_status) HandleTitleScreen(0, 0, 0, 0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_MAIN) HandleMainMenu(0, 0, 0, 0, MB_MENU_CHOICE); + else if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, 0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, 0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_LEVELNR) @@ -2337,6 +2344,8 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_TITLE) HandleTitleScreen(0, 0, 0, 0, MB_MENU_LEAVE); + else if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, 0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, 0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_LEVELNR) @@ -2350,7 +2359,9 @@ void HandleKey(Key key, int key_status) break; case KSYM_Page_Up: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR) HandleChooseLevelNr(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); @@ -2363,7 +2374,9 @@ void HandleKey(Key key, int key_status) break; case KSYM_Page_Down: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR) HandleChooseLevelNr(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); @@ -2594,6 +2607,7 @@ void HandleJoystick(void) { case GAME_MODE_TITLE: case GAME_MODE_MAIN: + case GAME_MODE_NAMES: case GAME_MODE_LEVELS: case GAME_MODE_LEVELNR: case GAME_MODE_SETUP: @@ -2607,6 +2621,8 @@ void HandleJoystick(void) HandleTitleScreen(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_MAIN) HandleMainMenu(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); + else if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0,0,dx,dy,newbutton?MB_MENU_CHOICE:MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0,0,dx,dy,newbutton?MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR) diff --git a/src/libgame/system.h b/src/libgame/system.h index 2011aaac..549d003e 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -761,9 +761,11 @@ #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC #define TREE_TYPE_LEVEL_DIR 3 #define TREE_TYPE_LEVEL_NR 4 +#define TREE_TYPE_PLAYER_NAME 5 +#define TREE_TYPE_PLAYER_TEAM 6 #define NUM_BASE_TREE_TYPES 4 -#define NUM_TREE_TYPES 5 +#define NUM_TREE_TYPES 7 #define INFOTEXT_UNDEFINED "" #define INFOTEXT_GRAPHICS_DIR "Custom Graphics" @@ -771,8 +773,14 @@ #define INFOTEXT_MUSIC_DIR "Custom Music" #define INFOTEXT_LEVEL_DIR "Level Sets" #define INFOTEXT_LEVEL_NR "Levels" - -#define TREE_INFOTEXT(t) ((t) == TREE_TYPE_LEVEL_NR ? \ +#define INFOTEXT_PLAYER_NAME "Player Names" +#define INFOTEXT_PLAYER_TEAM "Player Teams" + +#define TREE_INFOTEXT(t) ((t) == TREE_TYPE_PLAYER_NAME ? \ + INFOTEXT_PLAYER_NAME : \ + (t) == TREE_TYPE_PLAYER_TEAM ? \ + INFOTEXT_PLAYER_TEAM : \ + (t) == TREE_TYPE_LEVEL_NR ? \ INFOTEXT_LEVEL_NR : \ (t) == TREE_TYPE_LEVEL_DIR ? \ INFOTEXT_LEVEL_DIR : \ diff --git a/src/screens.c b/src/screens.c index 040a45c5..95b56934 100644 --- a/src/screens.c +++ b/src/screens.c @@ -248,6 +248,7 @@ static void execSetupTouch(void); static void execSetupArtwork(void); static void HandleChooseTree(int, int, int, int, int, TreeInfo **); +static void DrawChoosePlayerName(void); static void DrawChooseLevelSet(void); static void DrawChooseLevelNr(void); static void DrawInfoScreen(void); @@ -327,6 +328,9 @@ static TreeInfo *transparency_current = NULL; static TreeInfo *grid_sizes[2][2] = { { NULL, NULL }, { NULL, NULL } }; static TreeInfo *grid_size_current[2][2] = { { NULL, NULL }, { NULL, NULL } }; +static TreeInfo *player_name = NULL; +static TreeInfo *player_name_current = NULL; + static TreeInfo *level_number = NULL; static TreeInfo *level_number_current = NULL; @@ -2081,9 +2085,20 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else { - SetGameStatus(GAME_MODE_PSEUDO_TYPENAME); + if (0 && setup.multiple_users) // (not used yet) + { + CloseDoor(DOOR_CLOSE_2); + + SetGameStatus(GAME_MODE_NAMES); - DrawTypeName(); + DrawChoosePlayerName(); + } + else + { + SetGameStatus(GAME_MODE_PSEUDO_TYPENAME); + + DrawTypeName(); + } } } else if (pos == MAIN_CONTROL_LEVELS) @@ -4123,7 +4138,9 @@ static void DrawChooseTree(TreeInfo **ti_ptr) // needed if different viewport properties defined for choosing level (set) ChangeViewportPropertiesIfNeeded(); - if (game_status == GAME_MODE_LEVELNR) + if (game_status == GAME_MODE_NAMES) + SetMainBackgroundImage(IMG_BACKGROUND_NAMES); + else if (game_status == GAME_MODE_LEVELNR) SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR); else if (game_status == GAME_MODE_LEVELS) SetMainBackgroundImage(IMG_BACKGROUND_LEVELS); @@ -4565,6 +4582,65 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } } +void DrawChoosePlayerName(void) +{ + int i; + + FadeMenuSoundsAndMusic(); + + if (player_name != NULL) + { + freeTreeInfo(player_name); + + player_name = NULL; + } + + for (i = 0; i < MAX_PLAYER_NAMES; i++) + { + boolean team_mode = (!network.enabled && setup.team_mode); + int tree_type = (team_mode ? TREE_TYPE_PLAYER_TEAM : TREE_TYPE_PLAYER_NAME); + TreeInfo *ti = newTreeInfo_setDefaults(tree_type); + char identifier[32], name[MAX_PLAYER_NAME_LEN + 1]; + int value = i; + + ti->node_top = &player_name; + ti->sort_priority = 10000 + value; + ti->color = FC_RED; + + if (strEqual(global.user_names[i], EMPTY_PLAYER_NAME)) + ti->color = FC_BLUE; + + snprintf(identifier, sizeof(identifier), "%d", value); + snprintf(name, sizeof(name), "%s", global.user_names[i]); + + setString(&ti->identifier, identifier); + setString(&ti->name, name); + setString(&ti->name_sorting, name); + + pushTreeInfo(&player_name, ti); + } + + // sort player entries by player number + sortTreeInfo(&player_name); + + // set current player entry to selected player entry + player_name_current = + getTreeInfoFromIdentifier(player_name, i_to_a(user.nr)); + + // if that fails, set current player name to first available name + if (player_name_current == NULL) + player_name_current = player_name; + + DrawChooseTree(&player_name_current); + + PlayMenuSoundsAndMusic(); +} + +void HandleChoosePlayerName(int mx, int my, int dx, int dy, int button) +{ + HandleChooseTree(mx, my, dx, dy, button, &player_name_current); +} + void DrawChooseLevelSet(void) { FadeMenuSoundsAndMusic(); @@ -9074,7 +9150,9 @@ static void HandleScreenGadgets(struct GadgetInfo *gi) break; case SCREEN_CTRL_ID_SCROLL_UP: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR) HandleChooseLevelNr(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK); @@ -9085,7 +9163,9 @@ static void HandleScreenGadgets(struct GadgetInfo *gi) break; case SCREEN_CTRL_ID_SCROLL_DOWN: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR) HandleChooseLevelNr(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK); @@ -9096,7 +9176,9 @@ static void HandleScreenGadgets(struct GadgetInfo *gi) break; case SCREEN_CTRL_ID_SCROLL_VERTICAL: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE); else if (game_status == GAME_MODE_LEVELNR) HandleChooseLevelNr(0,0,999,gi->event.item_position,MB_MENU_INITIALIZE); diff --git a/src/screens.h b/src/screens.h index 3cb08c1e..d79745df 100644 --- a/src/screens.h +++ b/src/screens.h @@ -30,6 +30,7 @@ void RedrawSetupScreenAfterScreenRotation(int); void HandleTitleScreen(int, int, int, int, int); void HandleMainMenu(int, int, int, int, int); +void HandleChoosePlayerName(int, int, int, int, int); void HandleChooseLevelSet(int, int, int, int, int); void HandleChooseLevelNr(int, int, int, int, int); void HandleHallOfFame(int, int, int, int, int);