mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
UrlWarningOverlay uses new rendering method
This commit is contained in:
parent
086bc1be9f
commit
d374e3f843
82
src/Menus.c
82
src/Menus.c
@ -79,6 +79,11 @@ static void Menu_Back(void* s, int i, struct ButtonWidget* btn, Widget_LeftClick
|
|||||||
Menu_Button(s, i, btn, width, onClick, ANCHOR_CENTRE, ANCHOR_MAX, 0, 25);
|
Menu_Button(s, i, btn, width, onClick, ANCHOR_CENTRE, ANCHOR_MAX, 0, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Menu_MakeBack(struct ButtonWidget* btn, Widget_LeftClick onClick) {
|
||||||
|
int width = Gui_ClassicMenu ? 400 : 200;
|
||||||
|
ButtonWidget_Make(btn, width, onClick, ANCHOR_CENTRE, ANCHOR_MAX, 0, 25);
|
||||||
|
}
|
||||||
|
|
||||||
CC_NOINLINE static void Menu_MakeTitleFont(struct FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_BOLD); }
|
CC_NOINLINE static void Menu_MakeTitleFont(struct FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_BOLD); }
|
||||||
CC_NOINLINE static void Menu_MakeBodyFont(struct FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_NORMAL); }
|
CC_NOINLINE static void Menu_MakeBodyFont(struct FontDesc* font) { Drawer2D_MakeFont(font, 16, FONT_STYLE_NORMAL); }
|
||||||
static void Menu_NullFunc(void* s) { }
|
static void Menu_NullFunc(void* s) { }
|
||||||
@ -386,7 +391,7 @@ static void ListScreen_Init(void* screen) {
|
|||||||
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -155);
|
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -155);
|
||||||
TextWidget_Make(&s->page,
|
TextWidget_Make(&s->page,
|
||||||
ANCHOR_CENTRE, ANCHOR_MAX, 0, 75);
|
ANCHOR_CENTRE, ANCHOR_MAX, 0, 75);
|
||||||
Menu_Back(s, 9, &s->done, s->DoneClick);
|
Menu_MakeBack(&s->done, s->DoneClick);
|
||||||
s->LoadEntries(s);
|
s->LoadEntries(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,17 +429,8 @@ static void ListScreen_ContextRecreated(void* screen) {
|
|||||||
static void ListScreen_BuildMesh(void* screen) {
|
static void ListScreen_BuildMesh(void* screen) {
|
||||||
struct ListScreen* s = (struct ListScreen*)screen;
|
struct ListScreen* s = (struct ListScreen*)screen;
|
||||||
VertexP3fT2fC4b vertices[LIST_MAX_VERTICES];
|
VertexP3fT2fC4b vertices[LIST_MAX_VERTICES];
|
||||||
VertexP3fT2fC4b* ptr = vertices;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < LIST_SCREEN_ITEMS; i++) {
|
Screen_BuildMesh(screen, vertices);
|
||||||
Widget_BuildMesh(&s->btns[i], &ptr);
|
|
||||||
}
|
|
||||||
Widget_BuildMesh(&s->left, &ptr);
|
|
||||||
Widget_BuildMesh(&s->right, &ptr);
|
|
||||||
Widget_BuildMesh(&s->title, &ptr);
|
|
||||||
Widget_BuildMesh(&s->page, &ptr);
|
|
||||||
Widget_BuildMesh(&s->done, &ptr);
|
|
||||||
Gfx_SetDynamicVbData(s->vb, vertices, LIST_MAX_VERTICES);
|
Gfx_SetDynamicVbData(s->vb, vertices, LIST_MAX_VERTICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,12 +1133,8 @@ static void ClassicGenScreen_ContextRecreated(void* screen) {
|
|||||||
static void ClassicGenScreen_BuildMesh(void* screen) {
|
static void ClassicGenScreen_BuildMesh(void* screen) {
|
||||||
struct ClassicGenScreen* s = (struct ClassicGenScreen*)screen;
|
struct ClassicGenScreen* s = (struct ClassicGenScreen*)screen;
|
||||||
VertexP3fT2fC4b vertices[CLASSICGEN_MAX_VERTICES];
|
VertexP3fT2fC4b vertices[CLASSICGEN_MAX_VERTICES];
|
||||||
VertexP3fT2fC4b* ptr = vertices;
|
|
||||||
|
|
||||||
Widget_BuildMesh(&s->btns[0], &ptr);
|
Screen_BuildMesh(screen, vertices);
|
||||||
Widget_BuildMesh(&s->btns[1], &ptr);
|
|
||||||
Widget_BuildMesh(&s->btns[2], &ptr);
|
|
||||||
Widget_BuildMesh(&s->cancel, &ptr);
|
|
||||||
Gfx_SetDynamicVbData(s->vb, vertices, CLASSICGEN_MAX_VERTICES);
|
Gfx_SetDynamicVbData(s->vb, vertices, CLASSICGEN_MAX_VERTICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1159,7 +1151,7 @@ static void ClassicGenScreen_Init(void* screen) {
|
|||||||
ClassicGenScreen_Make(s, 1, -50, ClassicGenScreen_Medium);
|
ClassicGenScreen_Make(s, 1, -50, ClassicGenScreen_Medium);
|
||||||
ClassicGenScreen_Make(s, 2, 0, ClassicGenScreen_Huge);
|
ClassicGenScreen_Make(s, 2, 0, ClassicGenScreen_Huge);
|
||||||
|
|
||||||
Menu_Back(s, 3, &s->cancel, Menu_SwitchPause);
|
Menu_MakeBack(&s->cancel, Menu_SwitchPause);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ScreenVTABLE ClassicGenScreen_VTABLE = {
|
static const struct ScreenVTABLE ClassicGenScreen_VTABLE = {
|
||||||
@ -3108,10 +3100,17 @@ void TexIdsOverlay_Show(void) {
|
|||||||
static struct UrlWarningOverlay {
|
static struct UrlWarningOverlay {
|
||||||
Screen_Body
|
Screen_Body
|
||||||
String url;
|
String url;
|
||||||
struct ButtonWidget buttons[2];
|
struct ButtonWidget btns[2];
|
||||||
struct TextWidget labels[4];
|
struct TextWidget lbls[4];
|
||||||
char _urlBuffer[STRING_SIZE * 4];
|
char _urlBuffer[STRING_SIZE * 4];
|
||||||
} UrlWarningOverlay_Instance;
|
} UrlWarningOverlay;
|
||||||
|
|
||||||
|
static struct Widget* urlwarning_widgets[6] = {
|
||||||
|
(struct Widget*)&UrlWarningOverlay.lbls[0], (struct Widget*)&UrlWarningOverlay.lbls[1],
|
||||||
|
(struct Widget*)&UrlWarningOverlay.lbls[2], (struct Widget*)&UrlWarningOverlay.lbls[3],
|
||||||
|
(struct Widget*)&UrlWarningOverlay.btns[0], (struct Widget*)&UrlWarningOverlay.btns[1]
|
||||||
|
};
|
||||||
|
#define URLWARNING_MAX_VERTICES (4 * TEXTWIDGET_MAX + 2 * BUTTONWIDGET_MAX)
|
||||||
|
|
||||||
static void UrlWarningOverlay_OpenUrl(void* screen, void* b) {
|
static void UrlWarningOverlay_OpenUrl(void* screen, void* b) {
|
||||||
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
||||||
@ -3128,42 +3127,49 @@ static void UrlWarningOverlay_AppendUrl(void* screen, void* b) {
|
|||||||
static void UrlWarningOverlay_ContextRecreated(void* screen) {
|
static void UrlWarningOverlay_ContextRecreated(void* screen) {
|
||||||
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
||||||
struct FontDesc titleFont, textFont;
|
struct FontDesc titleFont, textFont;
|
||||||
|
s->vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_P3FT2FC4B, URLWARNING_MAX_VERTICES);
|
||||||
|
|
||||||
Menu_MakeTitleFont(&titleFont);
|
Menu_MakeTitleFont(&titleFont);
|
||||||
Menu_MakeBodyFont(&textFont);
|
Menu_MakeBodyFont(&textFont);
|
||||||
|
|
||||||
TextWidget_SetConst(&s->labels[0], "&eAre you sure you want to open this link?", &titleFont);
|
TextWidget_SetConst(&s->lbls[0], "&eAre you sure you want to open this link?", &titleFont);
|
||||||
TextWidget_Set(&s->labels[1], &s->url, &textFont);
|
TextWidget_Set(&s->lbls[1], &s->url, &textFont);
|
||||||
TextWidget_SetConst(&s->labels[2], "Be careful - links from strangers may be websites that", &textFont);
|
TextWidget_SetConst(&s->lbls[2], "Be careful - links from strangers may be websites that", &textFont);
|
||||||
TextWidget_SetConst(&s->labels[3], " have viruses, or things you may not want to open/see.", &textFont);
|
TextWidget_SetConst(&s->lbls[3], " have viruses, or things you may not want to open/see.", &textFont);
|
||||||
|
|
||||||
ButtonWidget_SetConst(&s->buttons[0], "Yes", &titleFont);
|
ButtonWidget_SetConst(&s->btns[0], "Yes", &titleFont);
|
||||||
ButtonWidget_SetConst(&s->buttons[1], "No", &titleFont);
|
ButtonWidget_SetConst(&s->btns[1], "No", &titleFont);
|
||||||
Font_Free(&titleFont);
|
Font_Free(&titleFont);
|
||||||
Font_Free(&textFont);
|
Font_Free(&textFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UrlWarningOverlay_BuildMesh(void* screen) { }
|
static void UrlWarningOverlay_BuildMesh(void* screen) {
|
||||||
|
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
||||||
|
VertexP3fT2fC4b vertices[URLWARNING_MAX_VERTICES];
|
||||||
|
|
||||||
|
Screen_BuildMesh(screen, vertices);
|
||||||
|
Gfx_SetDynamicVbData(s->vb, vertices, URLWARNING_MAX_VERTICES);
|
||||||
|
}
|
||||||
|
|
||||||
static void UrlWarningOverlay_Init(void* screen) {
|
static void UrlWarningOverlay_Init(void* screen) {
|
||||||
static struct Widget* widgets[6];
|
|
||||||
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
struct UrlWarningOverlay* s = (struct UrlWarningOverlay*)screen;
|
||||||
s->widgets = widgets;
|
s->widgets = urlwarning_widgets;
|
||||||
s->numWidgets = Array_Elems(widgets);
|
s->numWidgets = Array_Elems(urlwarning_widgets);
|
||||||
|
|
||||||
Overlay_MakeLabels(s, s->labels);
|
Overlay_MakeLabels(s, s->lbls);
|
||||||
Overlay_MakeMainButtons(s, s->buttons);
|
Overlay_MakeMainButtons(s, s->btns);
|
||||||
s->buttons[0].MenuClick = UrlWarningOverlay_OpenUrl;
|
s->btns[0].MenuClick = UrlWarningOverlay_OpenUrl;
|
||||||
s->buttons[1].MenuClick = UrlWarningOverlay_AppendUrl;
|
s->btns[1].MenuClick = UrlWarningOverlay_AppendUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
|
static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
|
||||||
UrlWarningOverlay_Init, MenuScreen_Render, Menu_NullFunc, UrlWarningOverlay_BuildMesh,
|
UrlWarningOverlay_Init, MenuScreen_Render2, Menu_NullFunc, UrlWarningOverlay_BuildMesh,
|
||||||
Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Screen_Layout, Screen_ContextLost, UrlWarningOverlay_ContextRecreated
|
Screen_Layout, Screen_ContextLost, UrlWarningOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
void UrlWarningOverlay_Show(const String* url) {
|
void UrlWarningOverlay_Show(const String* url) {
|
||||||
struct UrlWarningOverlay* s = &UrlWarningOverlay_Instance;
|
struct UrlWarningOverlay* s = &UrlWarningOverlay;
|
||||||
s->grabsInput = true;
|
s->grabsInput = true;
|
||||||
s->closable = true;
|
s->closable = true;
|
||||||
s->VTABLE = &UrlWarningOverlay_VTABLE;
|
s->VTABLE = &UrlWarningOverlay_VTABLE;
|
||||||
|
@ -96,6 +96,18 @@ void Screen_ContextLost(void* screen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Screen_BuildMesh(void* screen, VertexP3fT2fC4b* vertices) {
|
||||||
|
struct Screen* s = (struct Screen*)screen;
|
||||||
|
struct Widget** widgets = s->widgets;
|
||||||
|
VertexP3fT2fC4b** ptr = &vertices;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < s->numWidgets; i++) {
|
||||||
|
if (!widgets[i]) continue;
|
||||||
|
Widget_BuildMesh(widgets[i], ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------HUDScreen--------------------------------------------------------*
|
*--------------------------------------------------------HUDScreen--------------------------------------------------------*
|
||||||
@ -1335,7 +1347,7 @@ static struct Widget* disconnect_widgets[3] = {
|
|||||||
(struct Widget*)&DisconnectScreen.message,
|
(struct Widget*)&DisconnectScreen.message,
|
||||||
(struct Widget*)&DisconnectScreen.reconnect
|
(struct Widget*)&DisconnectScreen.reconnect
|
||||||
};
|
};
|
||||||
#define DISCONNECT_MAX_VERTICES (BUTTONWIDGET_MAX + 2 * TEXTWIDGET_MAX)
|
#define DISCONNECT_MAX_VERTICES (2 * TEXTWIDGET_MAX + BUTTONWIDGET_MAX)
|
||||||
#define DISCONNECT_DELAY_MS 5000
|
#define DISCONNECT_DELAY_MS 5000
|
||||||
|
|
||||||
static void DisconnectScreen_ReconnectMessage(struct DisconnectScreen* s, String* msg) {
|
static void DisconnectScreen_ReconnectMessage(struct DisconnectScreen* s, String* msg) {
|
||||||
@ -1394,11 +1406,8 @@ static void DisconnectScreen_ContextRecreated(void* screen) {
|
|||||||
static void DisconnectScreen_BuildMesh(void* screen) {
|
static void DisconnectScreen_BuildMesh(void* screen) {
|
||||||
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
||||||
VertexP3fT2fC4b vertices[DISCONNECT_MAX_VERTICES];
|
VertexP3fT2fC4b vertices[DISCONNECT_MAX_VERTICES];
|
||||||
VertexP3fT2fC4b* ptr = vertices;
|
|
||||||
|
|
||||||
Widget_BuildMesh(&s->title, &ptr);
|
Screen_BuildMesh(screen, vertices);
|
||||||
Widget_BuildMesh(&s->message, &ptr);
|
|
||||||
Widget_BuildMesh(&s->reconnect, &ptr);
|
|
||||||
Gfx_SetDynamicVbData(s->vb, vertices, DISCONNECT_MAX_VERTICES);
|
Gfx_SetDynamicVbData(s->vb, vertices, DISCONNECT_MAX_VERTICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef CC_SCREENS_H
|
#ifndef CC_SCREENS_H
|
||||||
#define CC_SCREENS_H
|
#define CC_SCREENS_H
|
||||||
#include "String.h"
|
#include "VertexStructs.h"
|
||||||
/* Contains all 2D non-menu screen implementations.
|
/* Contains all 2D non-menu screen implementations.
|
||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
@ -30,6 +30,8 @@ void Screen_Layout(void* screen);
|
|||||||
/* Calls Widget_Free on each widget in the screen. */
|
/* Calls Widget_Free on each widget in the screen. */
|
||||||
/* Also deletes the screen's vb. */
|
/* Also deletes the screen's vb. */
|
||||||
void Screen_ContextLost(void* screen);
|
void Screen_ContextLost(void* screen);
|
||||||
|
/* Calls Widget_BuildMesh on each widget in the screen. */
|
||||||
|
void Screen_BuildMesh(void* screen, VertexP3fT2fC4b* vertices);
|
||||||
|
|
||||||
void InventoryScreen_Show(void);
|
void InventoryScreen_Show(void);
|
||||||
void HUDScreen_Show(void);
|
void HUDScreen_Show(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user