Add Online Manual and I_OpenURL stuff

This commit is contained in:
AJ Martinez 2024-05-18 21:09:00 -07:00
parent c44790749d
commit 2679e0eae0
5 changed files with 59 additions and 0 deletions

View file

@ -195,5 +195,15 @@ void I_GetCursorPosition(INT32 *x, INT32 *y)
(void)y;
}
boolean I_HasOpenURL()
{
return 0;
}
void I_OpenURL(const char *data)
{
return;
}
#include "../sdl/dosstr.c"

View file

@ -309,6 +309,10 @@ void I_RegisterSysCommands(void);
void I_CursedWindowMovement(int xd, int yd);
boolean I_HasOpenURL(void);
void I_OpenURL(const char *data);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -1213,6 +1213,7 @@ extern struct extrasmenu_s {
typedef enum
{
extras_addons = 0,
extras_manual,
extras_tutorial,
extras_challenges,
extras_statistics,

View file

@ -17,6 +17,7 @@
#include "../f_finale.h"
#include "../k_credits.h"
#include "../m_pw.h"
#include "../i_system.h"
static void M_Credits(INT32 choice)
{
@ -26,6 +27,32 @@ static void M_Credits(INT32 choice)
F_StartCredits();
}
const char *manual_url = "https://kartkrew.org/rr-manual";
static void M_ManualSelect(INT32 choice)
{
if (choice != MA_YES)
return;
I_OpenURL(manual_url);
}
static void M_Manual(INT32 choice)
{
(void)choice;
restoreMenu = currentMenu;
if (I_HasOpenURL())
{
M_StartMessage("Online Manual", "This will open a webpage in your default browser.", M_ManualSelect, MM_YESNO, "Let's go!", "Not now...");
}
else
{
I_ClipboardCopy(manual_url, strlen(manual_url));
M_StartMessage("Online Manual", "A URL has been copied to your clipboard!", NULL, MM_NOTHING, NULL, NULL);
}
}
menuitem_t EXTRAS_Main[] =
{
// The following has NULL strings for text and tooltip.
@ -35,6 +62,9 @@ menuitem_t EXTRAS_Main[] =
{IT_STRING | IT_CALL, NULL, NULL,
NULL, {.routine = M_Addons}, 0, 0},
{IT_STRING | IT_CALL, "Online Manual", "Learn everything there is to know about handling, items, and strategy.",
NULL, {.routine = M_Manual}, 0, 0},
{IT_STRING | IT_CALL, "Tutorial", "Help Dr. Robotnik and Tails test out their new Ring Racers.",
NULL, {.routine = M_LevelSelectInit}, 0, GT_TUTORIAL},

View file

@ -1013,6 +1013,20 @@ I_CursedWindowMovement (int xd, int yd)
SDL_SetWindowPosition(window, window_x + xd, window_y + yd);
}
boolean I_HasOpenURL()
{
#if (SDL_VERSION_ATLEAST(2, 0, 14))
return true;
#else
return false;
#endif
}
void I_OpenURL(const char *data)
{
SDL_OpenURL(data);
}
//
// I_JoyScale
//