Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions PROJECTS/ROLLER/3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -4624,8 +4624,19 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx)
if (draw_type != 2) {
display_paused();
if (trying_to_exit) {
int iPromptY = (scr_size * 96) >> 6;
int iPromptH = (scr_size * 14) >> 6;

if (iPromptH <= 0)
iPromptH = 1;
frontend_mouse_register_rect(FRONTEND_PAUSE_MOUSE_QUIT_PROMPT_ID,
0, iPromptY,
winw > 0 ? winw : XMAX,
iPromptH);
if ((frames & 0xFu) < 8)
prt_centrecol(rev_vga[1], &language_buffer[6592], 160, 100, 171);
frontend_mouse_draw_hover_box(FRONTEND_PAUSE_MOUSE_QUIT_PROMPT_ID,
0, 0);
}
}
}
Expand Down Expand Up @@ -4659,6 +4670,7 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx)
pQuitMessage = szF10ToQuitGame;
mini_prt_centre(rev_vga[0], pQuitMessage, winw / 2, winh / 2);
mini_prt_centre(rev_vga[0], "ESC TO CANCEL", winw / 2, winh / 2 + 14);
frontend_mouse_draw_hover_box(RACE_MOUSE_QUIT_PROMPT, 0, 0);
scr_size = iSavedScrSize3;
}
}
Expand Down
7 changes: 7 additions & 0 deletions PROJECTS/ROLLER/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#define PREVIEW_H 330
#define CAR_PREVIEW_Y 57
#define TRACK_PREVIEW_Y 5
#define FRONTEND_PAUSE_MOUSE_QUIT_PROMPT_ID 100

typedef struct MenuRenderer MenuRenderer;

typedef struct
{
Expand Down Expand Up @@ -268,6 +271,7 @@ int CheckNames(char *szPlayerName, int iPlayerIdx);
void frontend_mouse_handle_event(const SDL_Event *pEvent);
void frontend_mouse_begin_frame(int iVirtualWidth, int iVirtualHeight);
void frontend_mouse_register_rect(int iId, int iX, int iY, int iWidth, int iHeight);
void frontend_mouse_register_left_menu_row(int iId, int iY);
void frontend_mouse_register_text(int iId, tBlockHeader *pFont, const char *szText,
const char *szMappingTable, int *pCharVOffsets,
int iX, int iY, int iAlignment);
Expand All @@ -280,6 +284,9 @@ void frontend_mouse_register_scaled_text(int iId, tBlockHeader *pFont,
int frontend_mouse_take_hovered_id(void);
int frontend_mouse_peek_hovered_id(void);
int frontend_mouse_peek_clicked_id(void);
void frontend_mouse_draw_hover_box(int iId, int iVirtualWidth,
int iVirtualHeight);
void frontend_mouse_draw_menu_hover_box(MenuRenderer *pRenderer, int iId);
int frontend_mouse_consume_click(void);
int frontend_mouse_consume_click_anywhere(void);
int frontend_mouse_take_wheel_y(void);
Expand Down
68 changes: 62 additions & 6 deletions PROJECTS/ROLLER/frontend_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,55 @@ static int frontend_config_apply_volume_wheel(int iWheelY)

//-------------------------------------------------------------------------------------------------

static void frontend_config_commit_name_edit(void)
{
int iNameChar;
int iDefaultNameIdx;

szFrontendConfigNewNameBuf[iFrontendConfigNameLength] = 0;
iFrontendConfigEditingName = 0;

if (!iFrontendConfigSelectedCar) {
iFrontendConfigState = 0;
return;
}

if ((unsigned int)iFrontendConfigSelectedCar <= 1) {
for (iNameChar = 0; iNameChar < 9; ++iNameChar)
player_names[player1_car][iNameChar] =
szFrontendConfigNewNameBuf[iNameChar];

frontend_config_begin_broadcast_wait(
-669, FRONTEND_CONFIG_BROADCAST_WAIT_CHECK_PLAYER1_NAME_AND_CARS);
return;
}

if (iFrontendConfigSelectedCar == 2) {
for (iNameChar = 0; iNameChar < 9; ++iNameChar)
player_names[player2_car][iNameChar] =
szFrontendConfigNewNameBuf[iNameChar];

waste = CheckNames(player_names[player2_car], player2_car);
check_cars();
return;
}

iDefaultNameIdx = (iFrontendConfigSelectedCar - 3) ^ 1;
for (iNameChar = 0; iNameChar < 9; ++iNameChar)
default_names[iDefaultNameIdx][iNameChar] =
szFrontendConfigNewNameBuf[iNameChar];

if (!default_names[iDefaultNameIdx][0]) {
sprintf(buffer, "comp %i", iFrontendConfigSelectedCar - 2);
name_copy(default_names[iDefaultNameIdx], buffer);
}

frontend_config_begin_broadcast_wait(
-1, FRONTEND_CONFIG_BROADCAST_WAIT_NONE);
}

//-------------------------------------------------------------------------------------------------

static void frontend_config_handle_mouse(void)
{
int iHovered;
Expand Down Expand Up @@ -499,7 +548,7 @@ static void frontend_config_handle_mouse(void)
if (iFrontendConfigEditingName) {
frontend_mouse_take_wheel_y();
if (frontend_mouse_consume_click_anywhere())
frontend_mouse_press_accept();
frontend_config_commit_name_edit();
return;
}

Expand All @@ -519,12 +568,12 @@ static void frontend_config_handle_mouse(void)
return;

iClicked = frontend_mouse_peek_clicked_id();
iSubItem = frontend_config_submenu_item_from_mouse_id(iClicked);
if (iSubItem >= 0)
(void)frontend_config_set_submenu_item(iSubItem);

if (frontend_mouse_consume_click_anywhere())
if (frontend_mouse_consume_click_anywhere()) {
iSubItem = frontend_config_submenu_item_from_mouse_id(iClicked);
if (iSubItem >= 0)
(void)frontend_config_set_submenu_item(iSubItem);
frontend_mouse_press_accept();
}
return;
}

Expand Down Expand Up @@ -850,27 +899,34 @@ void frontend_config_update(void)
font2_ascii, font2_offsets,
sel_posns[0].x + 132,
sel_posns[0].y + 7, 2);
frontend_mouse_register_left_menu_row(0, sel_posns[0].y);
frontend_mouse_register_text(1, front_vga[2], &config_buffer[256],
font2_ascii, font2_offsets,
sel_posns[1].x + 132,
sel_posns[1].y + 7, 2);
frontend_mouse_register_left_menu_row(1, sel_posns[1].y);
frontend_mouse_register_text(3, front_vga[2], &config_buffer[4032],
font2_ascii, font2_offsets,
sel_posns[2].x + 132,
sel_posns[2].y + 7, 2);
frontend_mouse_register_left_menu_row(3, sel_posns[2].y);
frontend_mouse_register_text(4, front_vga[2], &config_buffer[4096],
font2_ascii, font2_offsets,
sel_posns[3].x + 132,
sel_posns[3].y + 7, 2);
frontend_mouse_register_left_menu_row(4, sel_posns[3].y);
frontend_mouse_register_text(5, front_vga[2], &config_buffer[4160],
font2_ascii, font2_offsets,
sel_posns[4].x + 132,
sel_posns[4].y + 7, 2);
frontend_mouse_register_left_menu_row(5, sel_posns[4].y);
if (network_on)
frontend_mouse_register_text(6, front_vga[2], &config_buffer[5568],
font2_ascii, font2_offsets,
sel_posns[5].x + 132,
sel_posns[5].y + 7, 2);
if (network_on)
frontend_mouse_register_left_menu_row(6, sel_posns[5].y);
if (front_vga[6])
frontend_mouse_register_rect(7, 62, 336, front_vga[6][4].iWidth,
front_vga[6][4].iHeight);
Expand Down
66 changes: 57 additions & 9 deletions PROJECTS/ROLLER/frontend_lobby.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ static eFrontendState eLobbyExitTarget;

#define MENU_COLOR_RED 0xE7u

enum {
LOBBY_MOUSE_START = 1
};

static void lobby_draw_frame(void);
static void lobby_begin_exit(eFrontendState eTarget);

Expand Down Expand Up @@ -118,12 +122,22 @@ static void lobby_begin_broadcast_wait(eLobbyBroadcastAction eAction,

//-------------------------------------------------------------------------------------------------

static void lobby_drain_mouse(void)
{
frontend_mouse_take_wheel_y();
(void)frontend_mouse_take_hovered_id();
(void)frontend_mouse_consume_click_anywhere();
}

//-------------------------------------------------------------------------------------------------

static int lobby_update_broadcast_wait(void)
{
if (eLobbyBroadcastActionCurrent == eLOBBY_BROADCAST_NONE)
return 0;

lobby_draw_frame();
lobby_drain_mouse();

if (!network_broadcast_wait_update())
return -1;
Expand Down Expand Up @@ -278,9 +292,13 @@ static void lobby_emit_draw(MenuRenderer *mr)
menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 200, 4, 0x8Fu, 1u, pal_addr);

if (players_waiting == network_on) {
frontend_mouse_register_text(LOBBY_MOUSE_START, front_vga[1],
&language_buffer[4800], font2_ascii,
font2_offsets, 200, 22, 1u);
if ((frames & 0xFu) < 8)
menu_render_text(mr, 1, &language_buffer[4800], font2_ascii, font2_offsets,
200, 22, 0x8Fu, 1u, pal_addr);
frontend_mouse_draw_menu_hover_box(mr, LOBBY_MOUSE_START);
if (time_to_start)
iLobbyActive = 0;
}
Expand Down Expand Up @@ -376,6 +394,7 @@ static void lobby_draw_frame(void)
MenuRenderer *mr = GetMenuRenderer();

menu_render_begin_frame(mr);
frontend_mouse_begin_frame(640, 400);
lobby_emit_draw(mr);
if (iLobbyActive) {
if (!front_fade) {
Expand All @@ -389,6 +408,41 @@ static void lobby_draw_frame(void)

//-------------------------------------------------------------------------------------------------

static int lobby_request_start_race(void)
{
if (players_waiting != network_on || time_to_start)
return 0;

if (g_iNetworkTrackFileCRCMismatch ||
(TrackLoad == TRACK_LOAD_COMMUNITY && g_iCommunityTrackMissing) ||
!community_track_available()) {
sfxsample(SOUND_SAMPLE_BUTTON, 0x8000);
return -1;
}

lobby_begin_broadcast_wait(eLOBBY_BROADCAST_START_RACE, -671, 3);
return -1;
}

//-------------------------------------------------------------------------------------------------

static int lobby_handle_mouse(void)
{
int iClicked;

frontend_mouse_take_wheel_y();
(void)frontend_mouse_take_hovered_id();

iClicked = frontend_mouse_peek_clicked_id();
if (frontend_mouse_consume_click_anywhere() &&
iClicked == LOBBY_MOUSE_START)
return lobby_request_start_race();

return 0;
}

//-------------------------------------------------------------------------------------------------

static void lobby_handle_input(void)
{
unsigned int uiKeyPressed;
Expand All @@ -399,16 +453,8 @@ static void lobby_handle_input(void)
if (!uiKeyPressed)
fatgetch();
} else if (uiKeyPressed <= 0xD) {
if (players_waiting == network_on && !time_to_start) {
if (g_iNetworkTrackFileCRCMismatch ||
(TrackLoad == TRACK_LOAD_COMMUNITY && g_iCommunityTrackMissing) ||
!community_track_available()) {
sfxsample(SOUND_SAMPLE_BUTTON, 0x8000);
return;
}
lobby_begin_broadcast_wait(eLOBBY_BROADCAST_START_RACE, -671, 3);
if (lobby_request_start_race())
return;
}
} else if (uiKeyPressed == 27 && !time_to_start && !restart_net) {
StartPressed = 0;
time_to_start = 0;
Expand Down Expand Up @@ -470,6 +516,8 @@ void frontend_lobby_update(void)

check_cars();
lobby_draw_frame();
if (lobby_handle_mouse())
return;
lobby_handle_input();

if (!iLobbyActive) {
Expand Down
2 changes: 1 addition & 1 deletion PROJECTS/ROLLER/frontend_pause.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//-------------------------------------------------------------------------------------------------

enum {
FRONTEND_PAUSE_MOUSE_QUIT_PROMPT = 100
FRONTEND_PAUSE_MOUSE_QUIT_PROMPT = FRONTEND_PAUSE_MOUSE_QUIT_PROMPT_ID
};

static int frontend_pause_mouse_scale(int iValue)
Expand Down
3 changes: 3 additions & 0 deletions PROJECTS/ROLLER/frontend_screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,8 @@ static void frontend_main_menu_emit_draw(MenuRenderer *mr)
frontend_mouse_register_text(FRONTEND_MAIN_MENU_MOUSE_QUIT_PROMPT,
front_vga[15], &language_buffer[3456],
font1_ascii, font1_offsets, 400, 250, 1);
frontend_mouse_draw_menu_hover_box(mr,
FRONTEND_MAIN_MENU_MOUSE_QUIT_PROMPT);
}
if (g_iNetworkTrackFileCRCMismatch) {
menu_render_text(mr, 15, "TRACK FILE CRC MISMATCH", font1_ascii,
Expand Down Expand Up @@ -1305,6 +1307,7 @@ static void frontend_main_menu_register_text_item(int iItem, const char *szText)
frontend_mouse_register_text(iItem, front_vga[2], szText, font2_ascii,
font2_offsets, sel_posns[iItem].x + 132,
sel_posns[iItem].y + 7, 2);
frontend_mouse_register_left_menu_row(iItem, sel_posns[iItem].y);
}

//-------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions PROJECTS/ROLLER/frontend_select_car.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static void frontend_car_select_register_mouse_items(void)
font2_ascii, font2_offsets,
sel_posns[i].x + 132,
sel_posns[i].y + 7, 2);
frontend_mouse_register_left_menu_row(i, sel_posns[i].y);
}

if (front_vga[6])
Expand Down
2 changes: 2 additions & 0 deletions PROJECTS/ROLLER/frontend_select_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,12 @@ static void frontend_disk_select_draw(void)
font2_ascii, font2_offsets,
sel_posns[0].x + 132,
sel_posns[0].y + 7, 2);
frontend_mouse_register_left_menu_row(0, sel_posns[0].y);
frontend_mouse_register_text(1, front_vga[2], &language_buffer[640],
font2_ascii, font2_offsets,
sel_posns[1].x + 132,
sel_posns[1].y + 7, 2);
frontend_mouse_register_left_menu_row(1, sel_posns[1].y);
if (front_vga[6])
frontend_mouse_register_rect(2, 62, 336, front_vga[6][4].iWidth,
front_vga[6][4].iHeight);
Expand Down
Loading