mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
cleanup and add comments for Screen
This commit is contained in:
parent
b36e7ccd50
commit
0140608104
10 changed files with 214 additions and 183 deletions
|
@ -10,7 +10,7 @@ struct _BlockEventsList BlockEvents;
|
||||||
struct _WorldEventsList WorldEvents;
|
struct _WorldEventsList WorldEvents;
|
||||||
struct _ChatEventsList ChatEvents;
|
struct _ChatEventsList ChatEvents;
|
||||||
struct _WindowEventsList WindowEvents;
|
struct _WindowEventsList WindowEvents;
|
||||||
struct _KeyEventsList InputEvents;
|
struct _InputEventsList InputEvents;
|
||||||
struct _PointerEventsList PointerEvents;
|
struct _PointerEventsList PointerEvents;
|
||||||
struct _NetEventsList NetEvents;
|
struct _NetEventsList NetEvents;
|
||||||
|
|
||||||
|
@ -105,3 +105,10 @@ void Event_RaiseInput(struct Event_Input* handlers, int key, cc_bool repeating)
|
||||||
handlers->Handlers[i](handlers->Objs[i], key, repeating);
|
handlers->Handlers[i](handlers->Objs[i], key, repeating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Event_RaiseString(struct Event_String* handlers, const String* str) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < handlers->Count; i++) {
|
||||||
|
handlers->Handlers[i](handlers->Objs[i], str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
14
src/Event.h
14
src/Event.h
|
@ -58,6 +58,12 @@ struct Event_Input {
|
||||||
void* Objs[EVENT_MAX_CALLBACKS]; int Count;
|
void* Objs[EVENT_MAX_CALLBACKS]; int Count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*Event_String_Callback)(void* obj, const String* str);
|
||||||
|
struct Event_String {
|
||||||
|
Event_String_Callback Handlers[EVENT_MAX_CALLBACKS];
|
||||||
|
void* Objs[EVENT_MAX_CALLBACKS]; int Count;
|
||||||
|
};
|
||||||
|
|
||||||
/* Registers a callback function for the given event. */
|
/* Registers a callback function for the given event. */
|
||||||
/* NOTE: Trying to register a callback twice or over EVENT_MAX_CALLBACKS callbacks will terminate the game. */
|
/* NOTE: Trying to register a callback twice or over EVENT_MAX_CALLBACKS callbacks will terminate the game. */
|
||||||
CC_API void Event_Register(struct Event_Void* handlers, void* obj, Event_Void_Callback handler);
|
CC_API void Event_Register(struct Event_Void* handlers, void* obj, Event_Void_Callback handler);
|
||||||
|
@ -113,6 +119,11 @@ void Event_RaiseInput(struct Event_Input* handlers, int key, cc_bool repeating);
|
||||||
#define Event_RegisterInput(handlers, obj, handler) Event_RegisterMacro(handlers, obj, handler)
|
#define Event_RegisterInput(handlers, obj, handler) Event_RegisterMacro(handlers, obj, handler)
|
||||||
#define Event_UnregisterInput(handlers, obj, handler) Event_UnregisterMacro(handlers, obj, handler)
|
#define Event_UnregisterInput(handlers, obj, handler) Event_UnregisterMacro(handlers, obj, handler)
|
||||||
|
|
||||||
|
/* Calls all registered callbacks for an event which has a string argument. */
|
||||||
|
void Event_RaiseString(struct Event_String* handlers, const String* str);
|
||||||
|
#define Event_RegisterString(handlers, obj, handler) Event_RegisterMacro(handlers, obj, handler)
|
||||||
|
#define Event_UnregisterString(handlers, obj, handler) Event_UnregisterMacro(handlers, obj, handler)
|
||||||
|
|
||||||
CC_VAR extern struct _EntityEventsList {
|
CC_VAR extern struct _EntityEventsList {
|
||||||
struct Event_Int Added; /* Entity is spawned in the current world */
|
struct Event_Int Added; /* Entity is spawned in the current world */
|
||||||
struct Event_Int Removed; /* Entity is despawned from the current world */
|
struct Event_Int Removed; /* Entity is despawned from the current world */
|
||||||
|
@ -172,11 +183,12 @@ CC_VAR extern struct _WindowEventsList {
|
||||||
struct Event_Void Created; /* Window has been created, Window_Handle is valid now. */
|
struct Event_Void Created; /* Window has been created, Window_Handle is valid now. */
|
||||||
} WindowEvents;
|
} WindowEvents;
|
||||||
|
|
||||||
CC_VAR extern struct _KeyEventsList {
|
CC_VAR extern struct _InputEventsList {
|
||||||
struct Event_Int Press; /* Key input character is typed. Arg is a character */
|
struct Event_Int Press; /* Key input character is typed. Arg is a character */
|
||||||
struct Event_Input Down; /* Key or button is pressed. Arg is a member of Key enumeration */
|
struct Event_Input Down; /* Key or button is pressed. Arg is a member of Key enumeration */
|
||||||
struct Event_Int Up; /* Key or button is released. Arg is a member of Key enumeration */
|
struct Event_Int Up; /* Key or button is released. Arg is a member of Key enumeration */
|
||||||
struct Event_Float Wheel; /* Mouse wheel is moved/scrolled (Arg is wheel delta) */
|
struct Event_Float Wheel; /* Mouse wheel is moved/scrolled (Arg is wheel delta) */
|
||||||
|
struct Event_String TextChanged; /* HTML text input changed */
|
||||||
} InputEvents;
|
} InputEvents;
|
||||||
|
|
||||||
CC_VAR extern struct _PointerEventsList {
|
CC_VAR extern struct _PointerEventsList {
|
||||||
|
|
|
@ -278,7 +278,7 @@ static void Game_OnResize(void* obj) {
|
||||||
Game_UpdateDimensions();
|
Game_UpdateDimensions();
|
||||||
Gfx_OnWindowResize();
|
Gfx_OnWindowResize();
|
||||||
Game_UpdateProjection();
|
Game_UpdateProjection();
|
||||||
Gui_OnResize();
|
Gui_Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Game_OnNewMapCore(void* obj) {
|
static void Game_OnNewMapCore(void* obj) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ void Widget_SetLocation(void* widget, cc_uint8 horAnchor, cc_uint8 verAnchor, in
|
||||||
w->horAnchor = horAnchor; w->verAnchor = verAnchor;
|
w->horAnchor = horAnchor; w->verAnchor = verAnchor;
|
||||||
w->xOffset = Display_ScaleX(xOffset);
|
w->xOffset = Display_ScaleX(xOffset);
|
||||||
w->yOffset = Display_ScaleY(yOffset);
|
w->yOffset = Display_ScaleY(yOffset);
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget_CalcPosition(void* widget) {
|
void Widget_CalcPosition(void* widget) {
|
||||||
|
@ -293,13 +293,13 @@ void Gui_RenderGui(double delta) {
|
||||||
Gfx_Mode3D();
|
Gfx_Mode3D();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui_OnResize(void) {
|
void Gui_Layout(void) {
|
||||||
struct Screen* s;
|
struct Screen* s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < Gui_ScreensCount; i++) {
|
for (i = 0; i < Gui_ScreensCount; i++) {
|
||||||
s = Gui_Screens[i];
|
s = Gui_Screens[i];
|
||||||
s->VTABLE->OnResize(s);
|
s->VTABLE->Layout(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
47
src/Gui.h
47
src/Gui.h
|
@ -36,28 +36,41 @@ extern cc_bool Gui_TabAutocomplete;
|
||||||
extern cc_bool Gui_ShowFPS;
|
extern cc_bool Gui_ShowFPS;
|
||||||
|
|
||||||
struct ScreenVTABLE {
|
struct ScreenVTABLE {
|
||||||
|
/* Initialises persistent state. */
|
||||||
void (*Init)(void* elem);
|
void (*Init)(void* elem);
|
||||||
|
/* Draws this screen and its widgets on screen. */
|
||||||
void (*Render)(void* elem, double delta);
|
void (*Render)(void* elem, double delta);
|
||||||
|
/* Frees/releases persistent state. */
|
||||||
void (*Free)(void* elem);
|
void (*Free)(void* elem);
|
||||||
cc_bool (*HandlesKeyDown)(void* elem, Key key);
|
/* Returns non-zero if an input press is handled. */
|
||||||
cc_bool (*HandlesKeyUp)(void* elem, Key key);
|
int (*HandlesKeyDown)(void* elem, Key key);
|
||||||
cc_bool (*HandlesKeyPress)(void* elem, char keyChar);
|
/* Returns non-zero if an input release is handled. */
|
||||||
cc_bool (*HandlesPointerDown)(void* elem, int id, int x, int y);
|
int (*HandlesKeyUp)(void* elem, Key key);
|
||||||
cc_bool (*HandlesPointerUp)(void* elem, int id, int x, int y);
|
/* Returns non-zero if a key character press is handled. */
|
||||||
cc_bool (*HandlesPointerMove)(void* elem, int id, int x, int y);
|
int (*HandlesKeyPress)(void* elem, char keyChar);
|
||||||
cc_bool (*HandlesMouseScroll)(void* elem, float delta);
|
/* Returns non-zero if a pointer press is handled. */
|
||||||
void (*OnResize)(void* elem);
|
int (*HandlesPointerDown)(void* elem, int id, int x, int y);
|
||||||
Event_Void_Callback ContextLost;
|
/* Returns non-zero if a pointer release is handled. */
|
||||||
Event_Void_Callback ContextRecreated;
|
int (*HandlesPointerUp)(void* elem, int id, int x, int y);
|
||||||
|
/* Returns non-zero if a pointer movement is handled. */
|
||||||
|
int (*HandlesPointerMove)(void* elem, int id, int x, int y);
|
||||||
|
/* Returns non-zero if a mouse wheel scroll is handled. */
|
||||||
|
int (*HandlesMouseScroll)(void* elem, float delta);
|
||||||
|
/* Positions widgets on screen. Typically called on window resize. */
|
||||||
|
void (*Layout)(void* elem);
|
||||||
|
/* Destroys graphics resources. (textures, vertex buffers, etc) */
|
||||||
|
void (*ContextLost)(void* elem);
|
||||||
|
/* Allocates graphics resources. (textures, vertex buffers, etc) */
|
||||||
|
void (*ContextRecreated)(void* elem);
|
||||||
};
|
};
|
||||||
#define Screen_Layout const struct ScreenVTABLE* VTABLE; \
|
#define Screen_Body const struct ScreenVTABLE* VTABLE; \
|
||||||
cc_bool grabsInput; /* Whether this screen grabs input. Causes the cursor to become visible. */ \
|
cc_bool grabsInput; /* Whether this screen grabs input. Causes the cursor to become visible. */ \
|
||||||
cc_bool blocksWorld; /* Whether this screen completely and opaquely covers the game world behind it. */ \
|
cc_bool blocksWorld; /* Whether this screen completely and opaquely covers the game world behind it. */ \
|
||||||
cc_bool closable; /* Whether this screen is automatically closed when pressing Escape */ \
|
cc_bool closable; /* Whether this screen is automatically closed when pressing Escape */ \
|
||||||
struct Widget** widgets; int numWidgets;
|
struct Widget** widgets; int numWidgets;
|
||||||
|
|
||||||
/* Represents a container of widgets and other 2D elements. May cover entire window. */
|
/* Represents a container of widgets and other 2D elements. May cover entire window. */
|
||||||
struct Screen { Screen_Layout };
|
struct Screen { Screen_Body };
|
||||||
|
|
||||||
typedef void (*Widget_LeftClick)(void* screen, void* widget);
|
typedef void (*Widget_LeftClick)(void* screen, void* widget);
|
||||||
struct WidgetVTABLE {
|
struct WidgetVTABLE {
|
||||||
|
@ -71,7 +84,7 @@ struct WidgetVTABLE {
|
||||||
cc_bool (*HandlesPointerUp)(void* elem, int id, int x, int y);
|
cc_bool (*HandlesPointerUp)(void* elem, int id, int x, int y);
|
||||||
cc_bool (*HandlesPointerMove)(void* elem, int id, int x, int y);
|
cc_bool (*HandlesPointerMove)(void* elem, int id, int x, int y);
|
||||||
};
|
};
|
||||||
#define Widget_Layout const struct WidgetVTABLE* VTABLE; \
|
#define Widget_Body const struct WidgetVTABLE* VTABLE; \
|
||||||
int x, y, width, height; /* Top left corner, and dimensions, of this widget */ \
|
int x, y, width, height; /* Top left corner, and dimensions, of this widget */ \
|
||||||
cc_bool active; /* Whether this widget is currently being moused over */ \
|
cc_bool active; /* Whether this widget is currently being moused over */ \
|
||||||
cc_bool disabled; /* Whether widget is prevented from being interacted with */ \
|
cc_bool disabled; /* Whether widget is prevented from being interacted with */ \
|
||||||
|
@ -80,7 +93,7 @@ struct WidgetVTABLE {
|
||||||
Widget_LeftClick MenuClick;
|
Widget_LeftClick MenuClick;
|
||||||
|
|
||||||
/* Represents an individual 2D gui component. */
|
/* Represents an individual 2D gui component. */
|
||||||
struct Widget { Widget_Layout };
|
struct Widget { Widget_Body };
|
||||||
void Widget_SetLocation(void* widget, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset);
|
void Widget_SetLocation(void* widget, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset);
|
||||||
void Widget_CalcPosition(void* widget);
|
void Widget_CalcPosition(void* widget);
|
||||||
/* Resets Widget struct fields to 0/NULL (except VTABLE) */
|
/* Resets Widget struct fields to 0/NULL (except VTABLE) */
|
||||||
|
@ -148,7 +161,7 @@ void Gui_RefreshChat(void);
|
||||||
void Gui_Refresh(struct Screen* s);
|
void Gui_Refresh(struct Screen* s);
|
||||||
|
|
||||||
void Gui_RenderGui(double delta);
|
void Gui_RenderGui(double delta);
|
||||||
void Gui_OnResize(void);
|
void Gui_Layout(void);
|
||||||
|
|
||||||
#define TEXTATLAS_MAX_WIDTHS 16
|
#define TEXTATLAS_MAX_WIDTHS 16
|
||||||
struct TextAtlas {
|
struct TextAtlas {
|
||||||
|
@ -174,6 +187,6 @@ void TextAtlas_AddInt(struct TextAtlas* atlas, int value, VertexP3fT2fC4b** vert
|
||||||
#define Elem_HandlesPointerUp(elem, id, x, y) (elem)->VTABLE->HandlesPointerUp(elem, id, x, y)
|
#define Elem_HandlesPointerUp(elem, id, x, y) (elem)->VTABLE->HandlesPointerUp(elem, id, x, y)
|
||||||
#define Elem_HandlesPointerMove(elem, id, x, y) (elem)->VTABLE->HandlesPointerMove(elem, id, x, y)
|
#define Elem_HandlesPointerMove(elem, id, x, y) (elem)->VTABLE->HandlesPointerMove(elem, id, x, y)
|
||||||
|
|
||||||
#define Widget_Reposition(widget) (widget)->VTABLE->Reposition(widget);
|
#define Widget_Layout(widget) (widget)->VTABLE->Reposition(widget);
|
||||||
#define Elem_TryFree(elem) if ((elem)->VTABLE) { Elem_Free(elem); }
|
#define Elem_TryFree(elem) if ((elem)->VTABLE) { Elem_Free(elem); }
|
||||||
#endif
|
#endif
|
||||||
|
|
125
src/Menus.c
125
src/Menus.c
|
@ -95,14 +95,14 @@ static void Menu_ContextLost(void* screen) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Menu_OnResize(void* screen) {
|
static void Menu_Layout(void* screen) {
|
||||||
struct Screen* s = (struct Screen*)screen;
|
struct Screen* s = (struct Screen*)screen;
|
||||||
struct Widget** widgets = s->widgets;
|
struct Widget** widgets = s->widgets;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < s->numWidgets; i++) {
|
for (i = 0; i < s->numWidgets; i++) {
|
||||||
if (!widgets[i]) continue;
|
if (!widgets[i]) continue;
|
||||||
Widget_Reposition(widgets[i]);
|
Widget_Layout(widgets[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ static int Menu_DoPointerDown(void* screen, int id, int x, int y) {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
static cc_bool Menu_PointerDown(void* screen, int id, int x, int y) {
|
static int Menu_PointerDown(void* screen, int id, int x, int y) {
|
||||||
Menu_DoPointerDown(screen, id, x, y); return true;
|
Menu_DoPointerDown(screen, id, x, y); return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ static int Menu_DoPointerMove(void* screen, int id, int x, int y) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool Menu_PointerMove(void* screen, int id, int x, int y) {
|
static int Menu_PointerMove(void* screen, int id, int x, int y) {
|
||||||
Menu_DoPointerMove(screen, id, x, y); return true;
|
Menu_DoPointerMove(screen, id, x, y); return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ struct ListScreen;
|
||||||
#define LIST_SCREEN_EMPTY "-----"
|
#define LIST_SCREEN_EMPTY "-----"
|
||||||
|
|
||||||
static struct ListScreen {
|
static struct ListScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct ButtonWidget buttons[LIST_SCREEN_ITEMS];
|
struct ButtonWidget buttons[LIST_SCREEN_ITEMS];
|
||||||
struct ButtonWidget left, right, done;
|
struct ButtonWidget left, right, done;
|
||||||
struct FontDesc font;
|
struct FontDesc font;
|
||||||
|
@ -371,7 +371,7 @@ static void ListScreen_Select(struct ListScreen* s, const String* str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool ListScreen_KeyDown(void* screen, Key key) {
|
static int ListScreen_KeyDown(void* screen, Key key) {
|
||||||
struct ListScreen* s = (struct ListScreen*)screen;
|
struct ListScreen* s = (struct ListScreen*)screen;
|
||||||
if (key == KEY_LEFT || key == KEY_PAGEUP) {
|
if (key == KEY_LEFT || key == KEY_PAGEUP) {
|
||||||
ListScreen_PageClick(s, false);
|
ListScreen_PageClick(s, false);
|
||||||
|
@ -381,7 +381,7 @@ static cc_bool ListScreen_KeyDown(void* screen, Key key) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool ListScreen_MouseScroll(void* screen, float delta) {
|
static int ListScreen_MouseScroll(void* screen, float delta) {
|
||||||
struct ListScreen* s = (struct ListScreen*)screen;
|
struct ListScreen* s = (struct ListScreen*)screen;
|
||||||
int steps = Utils_AccumulateWheelDelta(&s->wheelAcc, delta);
|
int steps = Utils_AccumulateWheelDelta(&s->wheelAcc, delta);
|
||||||
|
|
||||||
|
@ -448,9 +448,9 @@ static void ListScreen_ContextRecreated(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE ListScreen_VTABLE = {
|
static const struct ScreenVTABLE ListScreen_VTABLE = {
|
||||||
ListScreen_Init, ListScreen_Render, ListScreen_Free,
|
ListScreen_Init, ListScreen_Render, ListScreen_Free,
|
||||||
ListScreen_KeyDown, Screen_TKey, Screen_TKeyPress,
|
ListScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, ListScreen_MouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, ListScreen_MouseScroll,
|
||||||
Menu_OnResize, ListScreen_ContextLost, ListScreen_ContextRecreated
|
Menu_Layout, ListScreen_ContextLost, ListScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void ListScreen_Show(void) {
|
void ListScreen_Show(void) {
|
||||||
struct ListScreen* s = &ListScreen;
|
struct ListScreen* s = &ListScreen;
|
||||||
|
@ -464,7 +464,7 @@ void ListScreen_Show(void) {
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------MenuScreen-------------------------------------------------------*
|
*--------------------------------------------------------MenuScreen-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static cc_bool MenuScreen_KeyDown(void* screen, Key key) { return key < KEY_F1 || key > KEY_F35; }
|
static int MenuScreen_KeyDown(void* screen, Key key) { return key < KEY_F1 || key > KEY_F35; }
|
||||||
|
|
||||||
static void MenuScreen_Render(void* screen, double delta) {
|
static void MenuScreen_Render(void* screen, double delta) {
|
||||||
Menu_RenderBounds();
|
Menu_RenderBounds();
|
||||||
|
@ -478,7 +478,7 @@ static void MenuScreen_Render(void* screen, double delta) {
|
||||||
*-------------------------------------------------------PauseScreen-------------------------------------------------------*
|
*-------------------------------------------------------PauseScreen-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct PauseScreen {
|
static struct PauseScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
const struct SimpleButtonDesc* descs;
|
const struct SimpleButtonDesc* descs;
|
||||||
struct ButtonWidget buttons[6], quit, back;
|
struct ButtonWidget buttons[6], quit, back;
|
||||||
} PauseScreen_Instance;
|
} PauseScreen_Instance;
|
||||||
|
@ -559,9 +559,9 @@ static void PauseScreen_Free(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE PauseScreen_VTABLE = {
|
static const struct ScreenVTABLE PauseScreen_VTABLE = {
|
||||||
PauseScreen_Init, MenuScreen_Render, PauseScreen_Free,
|
PauseScreen_Init, MenuScreen_Render, PauseScreen_Free,
|
||||||
MenuScreen_KeyDown, Screen_TKey, Screen_TKeyPress,
|
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, Menu_ContextLost, PauseScreen_ContextRecreated
|
Menu_Layout, Menu_ContextLost, PauseScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void PauseScreen_Show(void) {
|
void PauseScreen_Show(void) {
|
||||||
struct PauseScreen* s = &PauseScreen_Instance;
|
struct PauseScreen* s = &PauseScreen_Instance;
|
||||||
|
@ -576,7 +576,7 @@ void PauseScreen_Show(void) {
|
||||||
*--------------------------------------------------OptionsGroupScreen-----------------------------------------------------*
|
*--------------------------------------------------OptionsGroupScreen-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct OptionsGroupScreen {
|
static struct OptionsGroupScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
int selectedI;
|
int selectedI;
|
||||||
struct FontDesc textFont;
|
struct FontDesc textFont;
|
||||||
struct ButtonWidget buttons[7];
|
struct ButtonWidget buttons[7];
|
||||||
|
@ -635,7 +635,6 @@ static void OptionsGroupScreen_ContextRecreated(void* screen) {
|
||||||
static void OptionsGroupScreen_Init(void* screen) {
|
static void OptionsGroupScreen_Init(void* screen) {
|
||||||
static struct Widget* widgets[9];
|
static struct Widget* widgets[9];
|
||||||
struct OptionsGroupScreen* s = (struct OptionsGroupScreen*)screen;
|
struct OptionsGroupScreen* s = (struct OptionsGroupScreen*)screen;
|
||||||
int i;
|
|
||||||
|
|
||||||
Event_RegisterVoid(&UserEvents.HackPermissionsChanged, s, OptionsGroupScreen_CheckHacksAllowed);
|
Event_RegisterVoid(&UserEvents.HackPermissionsChanged, s, OptionsGroupScreen_CheckHacksAllowed);
|
||||||
s->widgets = widgets;
|
s->widgets = widgets;
|
||||||
|
@ -652,7 +651,7 @@ static void OptionsGroupScreen_Free(void* screen) {
|
||||||
Event_UnregisterVoid(&UserEvents.HackPermissionsChanged, s, OptionsGroupScreen_CheckHacksAllowed);
|
Event_UnregisterVoid(&UserEvents.HackPermissionsChanged, s, OptionsGroupScreen_CheckHacksAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool OptionsGroupScreen_PointerMove(void* screen, int id, int x, int y) {
|
static int OptionsGroupScreen_PointerMove(void* screen, int id, int x, int y) {
|
||||||
struct OptionsGroupScreen* s = (struct OptionsGroupScreen*)screen;
|
struct OptionsGroupScreen* s = (struct OptionsGroupScreen*)screen;
|
||||||
int i = Menu_DoPointerMove(s, id, x, y);
|
int i = Menu_DoPointerMove(s, id, x, y);
|
||||||
if (i == -1 || i == s->selectedI) return true;
|
if (i == -1 || i == s->selectedI) return true;
|
||||||
|
@ -665,9 +664,9 @@ static cc_bool OptionsGroupScreen_PointerMove(void* screen, int id, int x, int y
|
||||||
|
|
||||||
static const struct ScreenVTABLE OptionsGroupScreen_VTABLE = {
|
static const struct ScreenVTABLE OptionsGroupScreen_VTABLE = {
|
||||||
OptionsGroupScreen_Init, MenuScreen_Render, OptionsGroupScreen_Free,
|
OptionsGroupScreen_Init, MenuScreen_Render, OptionsGroupScreen_Free,
|
||||||
MenuScreen_KeyDown, Screen_TKey, Screen_TKeyPress,
|
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, OptionsGroupScreen_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, OptionsGroupScreen_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, OptionsGroupScreen_ContextLost, OptionsGroupScreen_ContextRecreated
|
Menu_Layout, OptionsGroupScreen_ContextLost, OptionsGroupScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void OptionsGroupScreen_Show(void) {
|
void OptionsGroupScreen_Show(void) {
|
||||||
struct OptionsGroupScreen* s = &OptionsGroupScreen;
|
struct OptionsGroupScreen* s = &OptionsGroupScreen;
|
||||||
|
@ -682,7 +681,7 @@ void OptionsGroupScreen_Show(void) {
|
||||||
*----------------------------------------------------EditHotkeyScreen-----------------------------------------------------*
|
*----------------------------------------------------EditHotkeyScreen-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct EditHotkeyScreen {
|
static struct EditHotkeyScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct HotkeyData curHotkey, origHotkey;
|
struct HotkeyData curHotkey, origHotkey;
|
||||||
int selectedI;
|
int selectedI;
|
||||||
cc_bool supressNextPress;
|
cc_bool supressNextPress;
|
||||||
|
@ -803,7 +802,7 @@ static void EditHotkeyScreen_Render(void* screen, double delta) {
|
||||||
Gfx_Draw2DFlat(x - 250, y + 45, 500, 2, grey);
|
Gfx_Draw2DFlat(x - 250, y + 45, 500, 2, grey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool EditHotkeyScreen_KeyPress(void* screen, char keyChar) {
|
static int EditHotkeyScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
||||||
if (s->supressNextPress) {
|
if (s->supressNextPress) {
|
||||||
s->supressNextPress = false;
|
s->supressNextPress = false;
|
||||||
|
@ -813,7 +812,7 @@ static cc_bool EditHotkeyScreen_KeyPress(void* screen, char keyChar) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool EditHotkeyScreen_KeyDown(void* screen, Key key) {
|
static int EditHotkeyScreen_KeyDown(void* screen, Key key) {
|
||||||
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
||||||
if (s->selectedI >= 0) {
|
if (s->selectedI >= 0) {
|
||||||
if (s->selectedI == 0) {
|
if (s->selectedI == 0) {
|
||||||
|
@ -888,9 +887,9 @@ static void EditHotkeyScreen_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
|
static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
|
||||||
EditHotkeyScreen_Init, EditHotkeyScreen_Render, Menu_CloseKeyboard,
|
EditHotkeyScreen_Init, EditHotkeyScreen_Render, Menu_CloseKeyboard,
|
||||||
EditHotkeyScreen_KeyDown, Screen_TKey, EditHotkeyScreen_KeyPress,
|
EditHotkeyScreen_KeyDown, Screen_TInput, EditHotkeyScreen_KeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, EditHotkeyScreen_ContextLost, EditHotkeyScreen_ContextRecreated
|
Menu_Layout, EditHotkeyScreen_ContextLost, EditHotkeyScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void EditHotkeyScreen_Show(struct HotkeyData original) {
|
void EditHotkeyScreen_Show(struct HotkeyData original) {
|
||||||
struct EditHotkeyScreen* s = &EditHotkeyScreen_Instance;
|
struct EditHotkeyScreen* s = &EditHotkeyScreen_Instance;
|
||||||
|
@ -907,7 +906,7 @@ void EditHotkeyScreen_Show(struct HotkeyData original) {
|
||||||
*-----------------------------------------------------GenLevelScreen------------------------------------------------------*
|
*-----------------------------------------------------GenLevelScreen------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct GenLevelScreen {
|
static struct GenLevelScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct FontDesc textFont;
|
struct FontDesc textFont;
|
||||||
struct ButtonWidget flatgrass, vanilla, cancel;
|
struct ButtonWidget flatgrass, vanilla, cancel;
|
||||||
struct MenuInputWidget* selected;
|
struct MenuInputWidget* selected;
|
||||||
|
@ -982,19 +981,19 @@ static void GenLevelScreen_Make(struct GenLevelScreen* s, int i, int y, int def)
|
||||||
s->labels[i].col = col;
|
s->labels[i].col = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool GenLevelScreen_KeyDown(void* screen, Key key) {
|
static int GenLevelScreen_KeyDown(void* screen, Key key) {
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
if (s->selected && Elem_HandlesKeyDown(&s->selected->base, key)) return true;
|
if (s->selected && Elem_HandlesKeyDown(&s->selected->base, key)) return true;
|
||||||
return MenuScreen_KeyDown(s, key);
|
return MenuScreen_KeyDown(s, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool GenLevelScreen_KeyPress(void* screen, char keyChar) {
|
static int GenLevelScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
if (s->selected) InputWidget_Append(&s->selected->base, keyChar);
|
if (s->selected) InputWidget_Append(&s->selected->base, keyChar);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool GenLevelScreen_PointerDown(void* screen, int id, int x, int y) {
|
static int GenLevelScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
int i = Menu_DoPointerDown(screen, id, x, y);
|
int i = Menu_DoPointerDown(screen, id, x, y);
|
||||||
if (i == -1 || i >= 4) return true;
|
if (i == -1 || i >= 4) return true;
|
||||||
|
@ -1059,9 +1058,9 @@ static void GenLevelScreen_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE GenLevelScreen_VTABLE = {
|
static const struct ScreenVTABLE GenLevelScreen_VTABLE = {
|
||||||
GenLevelScreen_Init, MenuScreen_Render, Menu_CloseKeyboard,
|
GenLevelScreen_Init, MenuScreen_Render, Menu_CloseKeyboard,
|
||||||
GenLevelScreen_KeyDown, Screen_TKey, GenLevelScreen_KeyPress,
|
GenLevelScreen_KeyDown, Screen_TInput, GenLevelScreen_KeyPress,
|
||||||
GenLevelScreen_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
GenLevelScreen_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, GenLevelScreen_ContextLost, GenLevelScreen_ContextRecreated
|
Menu_Layout, GenLevelScreen_ContextLost, GenLevelScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void GenLevelScreen_Show(void) {
|
void GenLevelScreen_Show(void) {
|
||||||
struct GenLevelScreen* s = &GenLevelScreen_Instance;
|
struct GenLevelScreen* s = &GenLevelScreen_Instance;
|
||||||
|
@ -1076,7 +1075,7 @@ void GenLevelScreen_Show(void) {
|
||||||
*----------------------------------------------------ClassicGenScreen-----------------------------------------------------*
|
*----------------------------------------------------ClassicGenScreen-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct ClassicGenScreen {
|
static struct ClassicGenScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct ButtonWidget buttons[3], cancel;
|
struct ButtonWidget buttons[3], cancel;
|
||||||
} ClassicGenScreen_Instance;
|
} ClassicGenScreen_Instance;
|
||||||
|
|
||||||
|
@ -1124,9 +1123,9 @@ static void ClassicGenScreen_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE ClassicGenScreen_VTABLE = {
|
static const struct ScreenVTABLE ClassicGenScreen_VTABLE = {
|
||||||
ClassicGenScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
ClassicGenScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
||||||
MenuScreen_KeyDown, Screen_TKey, Screen_TKeyPress,
|
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, Menu_ContextLost, ClassicGenScreen_ContextRecreated
|
Menu_Layout, Menu_ContextLost, ClassicGenScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void ClassicGenScreen_Show(void) {
|
void ClassicGenScreen_Show(void) {
|
||||||
struct ClassicGenScreen* s = &ClassicGenScreen_Instance;
|
struct ClassicGenScreen* s = &ClassicGenScreen_Instance;
|
||||||
|
@ -1141,7 +1140,7 @@ void ClassicGenScreen_Show(void) {
|
||||||
*----------------------------------------------------SaveLevelScreen------------------------------------------------------*
|
*----------------------------------------------------SaveLevelScreen------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct SaveLevelScreen {
|
static struct SaveLevelScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct FontDesc titleFont, textFont;
|
struct FontDesc titleFont, textFont;
|
||||||
struct ButtonWidget save, alt, cancel;
|
struct ButtonWidget save, alt, cancel;
|
||||||
struct MenuInputWidget input;
|
struct MenuInputWidget input;
|
||||||
|
@ -1314,14 +1313,14 @@ static void SaveLevelScreen_Render(void* screen, double delta) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool SaveLevelScreen_KeyPress(void* screen, char keyChar) {
|
static int SaveLevelScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
||||||
SaveLevelScreen_RemoveOverwrites(s);
|
SaveLevelScreen_RemoveOverwrites(s);
|
||||||
InputWidget_Append(&s->input.base, keyChar);
|
InputWidget_Append(&s->input.base, keyChar);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool SaveLevelScreen_KeyDown(void* screen, Key key) {
|
static int SaveLevelScreen_KeyDown(void* screen, Key key) {
|
||||||
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
||||||
if (Elem_HandlesKeyDown(&s->input.base, key)) {
|
if (Elem_HandlesKeyDown(&s->input.base, key)) {
|
||||||
SaveLevelScreen_RemoveOverwrites(s);
|
SaveLevelScreen_RemoveOverwrites(s);
|
||||||
|
@ -1387,9 +1386,9 @@ static void SaveLevelScreen_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE SaveLevelScreen_VTABLE = {
|
static const struct ScreenVTABLE SaveLevelScreen_VTABLE = {
|
||||||
SaveLevelScreen_Init, SaveLevelScreen_Render, Menu_CloseKeyboard,
|
SaveLevelScreen_Init, SaveLevelScreen_Render, Menu_CloseKeyboard,
|
||||||
SaveLevelScreen_KeyDown, Screen_TKey, SaveLevelScreen_KeyPress,
|
SaveLevelScreen_KeyDown, Screen_TInput, SaveLevelScreen_KeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, SaveLevelScreen_ContextLost, SaveLevelScreen_ContextRecreated
|
Menu_Layout, SaveLevelScreen_ContextLost, SaveLevelScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void SaveLevelScreen_Show(void) {
|
void SaveLevelScreen_Show(void) {
|
||||||
struct SaveLevelScreen* s = &SaveLevelScreen_Instance;
|
struct SaveLevelScreen* s = &SaveLevelScreen_Instance;
|
||||||
|
@ -1613,7 +1612,7 @@ struct KeyBindingsScreen;
|
||||||
typedef void (*InitKeyBindings)(struct KeyBindingsScreen* s);
|
typedef void (*InitKeyBindings)(struct KeyBindingsScreen* s);
|
||||||
|
|
||||||
static struct KeyBindingsScreen {
|
static struct KeyBindingsScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
int curI, bindsCount;
|
int curI, bindsCount;
|
||||||
const char* const* descs;
|
const char* const* descs;
|
||||||
const cc_uint8* binds;
|
const cc_uint8* binds;
|
||||||
|
@ -1647,7 +1646,7 @@ static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) {
|
||||||
if (old >= 0) KeyBindingsScreen_Update(s, old);
|
if (old >= 0) KeyBindingsScreen_Update(s, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool KeyBindingsScreen_KeyDown(void* screen, Key key) {
|
static int KeyBindingsScreen_KeyDown(void* screen, Key key) {
|
||||||
struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen;
|
struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen;
|
||||||
KeyBind bind;
|
KeyBind bind;
|
||||||
int idx;
|
int idx;
|
||||||
|
@ -1735,9 +1734,9 @@ static void KeyBindingsScreen_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE KeyBindingsScreen_VTABLE = {
|
static const struct ScreenVTABLE KeyBindingsScreen_VTABLE = {
|
||||||
KeyBindingsScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
KeyBindingsScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
||||||
KeyBindingsScreen_KeyDown, Screen_TKey, Screen_TKeyPress,
|
KeyBindingsScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, KeyBindingsScreen_ContextLost, KeyBindingsScreen_ContextRecreated
|
Menu_Layout, KeyBindingsScreen_ContextLost, KeyBindingsScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
static void KeyBindingsScreen_Show(int bindsCount, const cc_uint8* binds, const char* const* descs, InitKeyBindings doInit) {
|
static void KeyBindingsScreen_Show(int bindsCount, const cc_uint8* binds, const char* const* descs, InitKeyBindings doInit) {
|
||||||
struct KeyBindingsScreen* s = &KeyBindingsScreen_Instance;
|
struct KeyBindingsScreen* s = &KeyBindingsScreen_Instance;
|
||||||
|
@ -1858,7 +1857,7 @@ typedef void (*InitMenuOptions)(struct MenuOptionsScreen* s);
|
||||||
#define MENUOPTIONS_CORE_WIDGETS 4 /* back + 3 input */
|
#define MENUOPTIONS_CORE_WIDGETS 4 /* back + 3 input */
|
||||||
|
|
||||||
static struct MenuOptionsScreen {
|
static struct MenuOptionsScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct MenuInputDesc* descs;
|
struct MenuInputDesc* descs;
|
||||||
const char** descriptions;
|
const char** descriptions;
|
||||||
int activeI, selectedI, descriptionsCount;
|
int activeI, selectedI, descriptionsCount;
|
||||||
|
@ -1914,7 +1913,7 @@ CC_NOINLINE static void MenuOptionsScreen_FreeExtHelp(struct MenuOptionsScreen*
|
||||||
|
|
||||||
static void MenuOptionsScreen_RepositionExtHelp(struct MenuOptionsScreen* s) {
|
static void MenuOptionsScreen_RepositionExtHelp(struct MenuOptionsScreen* s) {
|
||||||
s->extHelp.xOffset = Window_Width / 2 - s->extHelp.width / 2;
|
s->extHelp.xOffset = Window_Width / 2 - s->extHelp.width / 2;
|
||||||
Widget_Reposition(&s->extHelp);
|
Widget_Layout(&s->extHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String MenuOptionsScreen_GetDesc(void* obj, int i) {
|
static String MenuOptionsScreen_GetDesc(void* obj, int i) {
|
||||||
|
@ -1975,13 +1974,13 @@ static void MenuOptionsScreen_EnterInput(struct MenuOptionsScreen* s) {
|
||||||
s->activeI = -1;
|
s->activeI = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool MenuOptionsScreen_KeyPress(void* screen, char keyChar) {
|
static int MenuOptionsScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
if (s->activeI >= 0) InputWidget_Append(&s->input.base, keyChar);
|
if (s->activeI >= 0) InputWidget_Append(&s->input.base, keyChar);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool MenuOptionsScreen_KeyDown(void* screen, Key key) {
|
static int MenuOptionsScreen_KeyDown(void* screen, Key key) {
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
if (s->activeI >= 0) {
|
if (s->activeI >= 0) {
|
||||||
if (Elem_HandlesKeyDown(&s->input.base, key)) return true;
|
if (Elem_HandlesKeyDown(&s->input.base, key)) return true;
|
||||||
|
@ -1993,7 +1992,7 @@ static cc_bool MenuOptionsScreen_KeyDown(void* screen, Key key) {
|
||||||
return MenuScreen_KeyDown(s, key);
|
return MenuScreen_KeyDown(s, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool MenuOptionsScreen_PointerMove(void* screen, int id, int x, int y) {
|
static int MenuOptionsScreen_PointerMove(void* screen, int id, int x, int y) {
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
int i = Menu_DoPointerMove(s, id, x, y);
|
int i = Menu_DoPointerMove(s, id, x, y);
|
||||||
if (i == -1 || i == s->selectedI) return true;
|
if (i == -1 || i == s->selectedI) return true;
|
||||||
|
@ -2149,9 +2148,9 @@ static void MenuOptionsScreen_Free(void* screen) {
|
||||||
if (s->activeI >= 0) Window_CloseKeyboard();
|
if (s->activeI >= 0) Window_CloseKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MenuOptionsScreen_OnResize(void* screen) {
|
static void MenuOptionsScreen_Layout(void* screen) {
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
Menu_OnResize(s);
|
Menu_Layout(s);
|
||||||
MenuOptionsScreen_RepositionExtHelp(s);
|
MenuOptionsScreen_RepositionExtHelp(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2182,9 +2181,9 @@ static void MenuOptionsScreen_ContextRecreated(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE MenuOptionsScreen_VTABLE = {
|
static const struct ScreenVTABLE MenuOptionsScreen_VTABLE = {
|
||||||
MenuOptionsScreen_Init, MenuOptionsScreen_Render, MenuOptionsScreen_Free,
|
MenuOptionsScreen_Init, MenuOptionsScreen_Render, MenuOptionsScreen_Free,
|
||||||
MenuOptionsScreen_KeyDown, Screen_TKey, MenuOptionsScreen_KeyPress,
|
MenuOptionsScreen_KeyDown, Screen_TInput, MenuOptionsScreen_KeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, MenuOptionsScreen_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, MenuOptionsScreen_PointerMove, Screen_TMouseScroll,
|
||||||
MenuOptionsScreen_OnResize, MenuOptionsScreen_ContextLost, MenuOptionsScreen_ContextRecreated
|
MenuOptionsScreen_Layout, MenuOptionsScreen_ContextLost, MenuOptionsScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void MenuOptionsScreen_Show(struct MenuInputDesc* descs, const char** descriptions, int descsCount, InitMenuOptions init) {
|
void MenuOptionsScreen_Show(struct MenuInputDesc* descs, const char** descriptions, int descsCount, InitMenuOptions init) {
|
||||||
struct MenuOptionsScreen* s = &MenuOptionsScreen_Instance;
|
struct MenuOptionsScreen* s = &MenuOptionsScreen_Instance;
|
||||||
|
@ -2878,7 +2877,7 @@ static cc_bool WarningOverlay_IsAlways(void* screen, void* w) { return Menu_Inde
|
||||||
#define TEXID_OVERLAY_VERTICES_COUNT (TEXID_OVERLAY_MAX_PER_PAGE * 4)
|
#define TEXID_OVERLAY_VERTICES_COUNT (TEXID_OVERLAY_MAX_PER_PAGE * 4)
|
||||||
|
|
||||||
static struct TexIdsOverlay {
|
static struct TexIdsOverlay {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
GfxResourceID dynamicVb;
|
GfxResourceID dynamicVb;
|
||||||
int xOffset, yOffset, tileSize, baseTexLoc;
|
int xOffset, yOffset, tileSize, baseTexLoc;
|
||||||
struct TextAtlas idAtlas;
|
struct TextAtlas idAtlas;
|
||||||
|
@ -3012,7 +3011,7 @@ static void TexIdsOverlay_Render(void* screen, double delta) {
|
||||||
Gfx_SetTexturing(false);
|
Gfx_SetTexturing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool TexIdsOverlay_KeyDown(void* screen, Key key) {
|
static int TexIdsOverlay_KeyDown(void* screen, Key key) {
|
||||||
struct Screen* s = (struct Screen*)screen;
|
struct Screen* s = (struct Screen*)screen;
|
||||||
if (key == KeyBinds[KEYBIND_IDOVERLAY]) { Gui_Remove(s); return true; }
|
if (key == KeyBinds[KEYBIND_IDOVERLAY]) { Gui_Remove(s); return true; }
|
||||||
return false;
|
return false;
|
||||||
|
@ -3020,9 +3019,9 @@ static cc_bool TexIdsOverlay_KeyDown(void* screen, Key key) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE TexIdsOverlay_VTABLE = {
|
static const struct ScreenVTABLE TexIdsOverlay_VTABLE = {
|
||||||
TexIdsOverlay_Init, TexIdsOverlay_Render, Menu_NullFunc,
|
TexIdsOverlay_Init, TexIdsOverlay_Render, Menu_NullFunc,
|
||||||
TexIdsOverlay_KeyDown, Screen_FKey, Screen_FKeyPress,
|
TexIdsOverlay_KeyDown, Screen_FInput, Screen_FKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, TexIdsOverlay_ContextLost, TexIdsOverlay_ContextRecreated
|
Menu_Layout, TexIdsOverlay_ContextLost, TexIdsOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
void TexIdsOverlay_Show(void) {
|
void TexIdsOverlay_Show(void) {
|
||||||
struct TexIdsOverlay* s = &TexIdsOverlay_Instance;
|
struct TexIdsOverlay* s = &TexIdsOverlay_Instance;
|
||||||
|
@ -3037,7 +3036,7 @@ void TexIdsOverlay_Show(void) {
|
||||||
*----------------------------------------------------UrlWarningOverlay----------------------------------------------------*
|
*----------------------------------------------------UrlWarningOverlay----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct UrlWarningOverlay {
|
static struct UrlWarningOverlay {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
String url;
|
String url;
|
||||||
struct ButtonWidget buttons[2];
|
struct ButtonWidget buttons[2];
|
||||||
struct TextWidget labels[4];
|
struct TextWidget labels[4];
|
||||||
|
@ -3087,9 +3086,9 @@ static void UrlWarningOverlay_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
|
static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
|
||||||
UrlWarningOverlay_Init, MenuScreen_Render, Menu_NullFunc,
|
UrlWarningOverlay_Init, MenuScreen_Render, Menu_NullFunc,
|
||||||
Screen_TKey, Screen_TKey, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, Menu_ContextLost, UrlWarningOverlay_ContextRecreated
|
Menu_Layout, Menu_ContextLost, UrlWarningOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
void UrlWarningOverlay_Show(const String* url) {
|
void UrlWarningOverlay_Show(const String* url) {
|
||||||
struct UrlWarningOverlay* s = &UrlWarningOverlay_Instance;
|
struct UrlWarningOverlay* s = &UrlWarningOverlay_Instance;
|
||||||
|
@ -3107,7 +3106,7 @@ void UrlWarningOverlay_Show(const String* url) {
|
||||||
*-----------------------------------------------------TexPackOverlay------------------------------------------------------*
|
*-----------------------------------------------------TexPackOverlay------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct TexPackOverlay {
|
static struct TexPackOverlay {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
cc_bool deny, alwaysDeny;
|
cc_bool deny, alwaysDeny;
|
||||||
cc_uint32 contentLength;
|
cc_uint32 contentLength;
|
||||||
String url, identifier;
|
String url, identifier;
|
||||||
|
@ -3236,9 +3235,9 @@ static void TexPackOverlay_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE TexPackOverlay_VTABLE = {
|
static const struct ScreenVTABLE TexPackOverlay_VTABLE = {
|
||||||
TexPackOverlay_Init, TexPackOverlay_Render, Menu_NullFunc,
|
TexPackOverlay_Init, TexPackOverlay_Render, Menu_NullFunc,
|
||||||
Screen_TKey, Screen_TKey, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, TexPackOverlay_ContextLost, TexPackOverlay_ContextRecreated
|
Menu_Layout, TexPackOverlay_ContextLost, TexPackOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
void TexPackOverlay_Show(const String* url) {
|
void TexPackOverlay_Show(const String* url) {
|
||||||
struct TexPackOverlay* s = &TexPackOverlay_Instance;
|
struct TexPackOverlay* s = &TexPackOverlay_Instance;
|
||||||
|
@ -3260,7 +3259,7 @@ void TexPackOverlay_Show(const String* url) {
|
||||||
*----------------------------------------------------UrlWarningOverlay----------------------------------------------------*
|
*----------------------------------------------------UrlWarningOverlay----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct TouchMoreOverlay {
|
static struct TouchMoreOverlay {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct ButtonWidget buttons[8];
|
struct ButtonWidget buttons[8];
|
||||||
} TouchMoreOverlay_Instance;
|
} TouchMoreOverlay_Instance;
|
||||||
|
|
||||||
|
@ -3319,9 +3318,9 @@ static void TouchMoreOverlay_Init(void* screen) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE TouchMoreOverlay_VTABLE = {
|
static const struct ScreenVTABLE TouchMoreOverlay_VTABLE = {
|
||||||
TouchMoreOverlay_Init, MenuScreen_Render, Menu_NullFunc,
|
TouchMoreOverlay_Init, MenuScreen_Render, Menu_NullFunc,
|
||||||
Screen_TKey, Screen_TKey, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_OnResize, Menu_ContextLost, TouchMoreOverlay_ContextRecreated
|
Menu_Layout, Menu_ContextLost, TouchMoreOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
void TouchMoreOverlay_Show(void) {
|
void TouchMoreOverlay_Show(void) {
|
||||||
struct TouchMoreOverlay* s = &TouchMoreOverlay_Instance;
|
struct TouchMoreOverlay* s = &TouchMoreOverlay_Instance;
|
||||||
|
|
132
src/Screens.c
132
src/Screens.c
|
@ -24,17 +24,17 @@
|
||||||
#define CHAT_MAX_BOTTOMRIGHT Array_Elems(Chat_BottomRight)
|
#define CHAT_MAX_BOTTOMRIGHT Array_Elems(Chat_BottomRight)
|
||||||
#define CHAT_MAX_CLIENTSTATUS Array_Elems(Chat_ClientStatus)
|
#define CHAT_MAX_CLIENTSTATUS Array_Elems(Chat_ClientStatus)
|
||||||
|
|
||||||
cc_bool Screen_FKey(void* s, int key) { return false; }
|
int Screen_FInput(void* s, int key) { return false; }
|
||||||
cc_bool Screen_FKeyPress(void* s, char keyChar) { return false; }
|
int Screen_FKeyPress(void* s, char keyChar) { return false; }
|
||||||
cc_bool Screen_FMouseScroll(void* s, float delta) { return false; }
|
int Screen_FMouseScroll(void* s, float delta) { return false; }
|
||||||
cc_bool Screen_FPointer(void* s, int id, int x, int y) { return false; }
|
int Screen_FPointer(void* s, int id, int x, int y) { return false; }
|
||||||
cc_bool Screen_FPointerMove(void* s, int id, int x, int y) { return false; }
|
int Screen_FPointerMove(void* s, int id, int x, int y) { return false; }
|
||||||
|
|
||||||
cc_bool Screen_TKeyPress(void* s, char keyChar) { return true; }
|
int Screen_TInput(void* s, int key) { return true; }
|
||||||
cc_bool Screen_TKey(void* s, int key) { return true; }
|
int Screen_TKeyPress(void* s, char keyChar) { return true; }
|
||||||
cc_bool Screen_TMouseScroll(void* s, float delta) { return true; }
|
int Screen_TMouseScroll(void* s, float delta) { return true; }
|
||||||
cc_bool Screen_TPointer(void* s, int id, int x, int y) { return true; }
|
int Screen_TPointer(void* s, int id, int x, int y) { return true; }
|
||||||
cc_bool Screen_TPointerMove(void* s, int id, int x, int y) { return true; }
|
int Screen_TPointerMove(void* s, int id, int x, int y) { return true; }
|
||||||
static void Screen_NullFunc(void* screen) { }
|
static void Screen_NullFunc(void* screen) { }
|
||||||
|
|
||||||
CC_NOINLINE static cc_bool IsOnlyHudActive(void) {
|
CC_NOINLINE static cc_bool IsOnlyHudActive(void) {
|
||||||
|
@ -53,7 +53,7 @@ CC_NOINLINE static cc_bool IsOnlyHudActive(void) {
|
||||||
*--------------------------------------------------------HUDScreen--------------------------------------------------------*
|
*--------------------------------------------------------HUDScreen--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct HUDScreen {
|
static struct HUDScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct FontDesc font;
|
struct FontDesc font;
|
||||||
struct TextWidget line1, line2;
|
struct TextWidget line1, line2;
|
||||||
struct TextAtlas posAtlas;
|
struct TextAtlas posAtlas;
|
||||||
|
@ -198,8 +198,8 @@ static void HUDScreen_ContextRecreated(void* screen) {
|
||||||
line1->yOffset = s->posAtlas.tex.Y;
|
line1->yOffset = s->posAtlas.tex.Y;
|
||||||
TextWidget_SetConst(line2, "0.30", &s->font);
|
TextWidget_SetConst(line2, "0.30", &s->font);
|
||||||
|
|
||||||
Widget_Reposition(line1);
|
Widget_Layout(line1);
|
||||||
Widget_Reposition(line2);
|
Widget_Layout(line2);
|
||||||
} else {
|
} else {
|
||||||
HUDScreen_UpdateHackState(s);
|
HUDScreen_UpdateHackState(s);
|
||||||
}
|
}
|
||||||
|
@ -225,8 +225,8 @@ static void HUDScreen_Render(void* screen, double delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ScreenVTABLE HUDScreen_VTABLE = {
|
static const struct ScreenVTABLE HUDScreen_VTABLE = {
|
||||||
Screen_NullFunc, HUDScreen_Render, Screen_NullFunc,
|
Screen_NullFunc, HUDScreen_Render, Screen_NullFunc,
|
||||||
Screen_FKey, Screen_FKey, Screen_FKeyPress,
|
Screen_FInput, Screen_FInput, Screen_FKeyPress,
|
||||||
Screen_FPointer, Screen_FPointer, Screen_FPointerMove, Screen_FMouseScroll,
|
Screen_FPointer, Screen_FPointer, Screen_FPointerMove, Screen_FMouseScroll,
|
||||||
Screen_NullFunc, HUDScreen_ContextLost, HUDScreen_ContextRecreated
|
Screen_NullFunc, HUDScreen_ContextLost, HUDScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
|
@ -242,7 +242,7 @@ void HUDScreen_Show(void) {
|
||||||
*--------------------------------------------------------ChatScreen-------------------------------------------------------*
|
*--------------------------------------------------------ChatScreen-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct ChatScreen {
|
static struct ChatScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct HotbarWidget hotbar;
|
struct HotbarWidget hotbar;
|
||||||
/* player list state */
|
/* player list state */
|
||||||
struct PlayerListWidget playerList;
|
struct PlayerListWidget playerList;
|
||||||
|
@ -272,13 +272,13 @@ static void ChatScreen_UpdateChatYOffsets(struct ChatScreen* s) {
|
||||||
y = min(s->input.base.y, s->hotbar.y);
|
y = min(s->input.base.y, s->hotbar.y);
|
||||||
y -= s->input.base.yOffset; /* add some padding */
|
y -= s->input.base.yOffset; /* add some padding */
|
||||||
s->altText.yOffset = Window_Height - y;
|
s->altText.yOffset = Window_Height - y;
|
||||||
Widget_Reposition(&s->altText);
|
Widget_Layout(&s->altText);
|
||||||
|
|
||||||
pad = s->altText.active ? 5 : 10;
|
pad = s->altText.active ? 5 : 10;
|
||||||
s->clientStatus.yOffset = Window_Height - s->altText.y + pad;
|
s->clientStatus.yOffset = Window_Height - s->altText.y + pad;
|
||||||
Widget_Reposition(&s->clientStatus);
|
Widget_Layout(&s->clientStatus);
|
||||||
s->chat.yOffset = s->clientStatus.yOffset + s->clientStatus.height;
|
s->chat.yOffset = s->clientStatus.yOffset + s->clientStatus.height;
|
||||||
Widget_Reposition(&s->chat);
|
Widget_Layout(&s->chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String ChatScreen_GetChat(void* obj, int i) {
|
static String ChatScreen_GetChat(void* obj, int i) {
|
||||||
|
@ -586,7 +586,7 @@ static void ChatScreen_RemakePlayerList(struct ChatScreen* s) {
|
||||||
cc_bool classic = Gui_ClassicTabList || !Server.SupportsExtPlayerList;
|
cc_bool classic = Gui_ClassicTabList || !Server.SupportsExtPlayerList;
|
||||||
PlayerListWidget_Create(&s->playerList, &s->playerFont, classic);
|
PlayerListWidget_Create(&s->playerList, &s->playerFont, classic);
|
||||||
s->showingList = true;
|
s->showingList = true;
|
||||||
Widget_Reposition(&s->playerList);
|
Widget_Layout(&s->playerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChatScreen_ContextRecreated(void* screen) {
|
static void ChatScreen_ContextRecreated(void* screen) {
|
||||||
|
@ -596,21 +596,21 @@ static void ChatScreen_ContextRecreated(void* screen) {
|
||||||
ChatScreen_ChatUpdateFont(s);
|
ChatScreen_ChatUpdateFont(s);
|
||||||
|
|
||||||
ChatScreen_Redraw(s);
|
ChatScreen_Redraw(s);
|
||||||
Widget_Reposition(&s->hotbar);
|
Widget_Layout(&s->hotbar);
|
||||||
ChatScreen_ChatUpdateLayout(s);
|
ChatScreen_ChatUpdateLayout(s);
|
||||||
if (s->showingList) ChatScreen_RemakePlayerList(s);
|
if (s->showingList) ChatScreen_RemakePlayerList(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChatScreen_OnResize(void* screen) {
|
static void ChatScreen_Layout(void* screen) {
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
Widget_Reposition(&s->hotbar);
|
Widget_Layout(&s->hotbar);
|
||||||
|
|
||||||
if (ChatScreen_ChatUpdateFont(s)) ChatScreen_Redraw(s);
|
if (ChatScreen_ChatUpdateFont(s)) ChatScreen_Redraw(s);
|
||||||
ChatScreen_ChatUpdateLayout(s);
|
ChatScreen_ChatUpdateLayout(s);
|
||||||
if (s->showingList) Widget_Reposition(&s->playerList);
|
if (s->showingList) Widget_Layout(&s->playerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool ChatScreen_KeyPress(void* screen, char keyChar) {
|
static int ChatScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
if (!s->grabsInput) return false;
|
if (!s->grabsInput) return false;
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ static cc_bool ChatScreen_KeyPress(void* screen, char keyChar) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool ChatScreen_KeyDown(void* screen, Key key) {
|
static int ChatScreen_KeyDown(void* screen, Key key) {
|
||||||
static const String slash = String_FromConst("/");
|
static const String slash = String_FromConst("/");
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
Key playerListKey = KeyBinds[KEYBIND_PLAYER_LIST];
|
Key playerListKey = KeyBinds[KEYBIND_PLAYER_LIST];
|
||||||
|
@ -671,7 +671,7 @@ static cc_bool ChatScreen_KeyDown(void* screen, Key key) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool ChatScreen_KeyUp(void* screen, Key key) {
|
static int ChatScreen_KeyUp(void* screen, Key key) {
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
if (key == KeyBinds[KEYBIND_PLAYER_LIST] && s->showingList) {
|
if (key == KeyBinds[KEYBIND_PLAYER_LIST] && s->showingList) {
|
||||||
s->showingList = false;
|
s->showingList = false;
|
||||||
|
@ -693,7 +693,7 @@ static cc_bool ChatScreen_KeyUp(void* screen, Key key) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool ChatScreen_MouseScroll(void* screen, float delta) {
|
static int ChatScreen_MouseScroll(void* screen, float delta) {
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
int steps;
|
int steps;
|
||||||
if (!s->grabsInput) return false;
|
if (!s->grabsInput) return false;
|
||||||
|
@ -703,7 +703,7 @@ static cc_bool ChatScreen_MouseScroll(void* screen, float delta) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool ChatScreen_PointerDown(void* screen, int id, int x, int y) {
|
static int ChatScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
String text; char textBuffer[STRING_SIZE * 4];
|
String text; char textBuffer[STRING_SIZE * 4];
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
int height, chatY;
|
int height, chatY;
|
||||||
|
@ -814,8 +814,8 @@ static void ChatScreen_Free(void* screen) {
|
||||||
static const struct ScreenVTABLE ChatScreen_VTABLE = {
|
static const struct ScreenVTABLE ChatScreen_VTABLE = {
|
||||||
ChatScreen_Init, ChatScreen_Render, ChatScreen_Free,
|
ChatScreen_Init, ChatScreen_Render, ChatScreen_Free,
|
||||||
ChatScreen_KeyDown, ChatScreen_KeyUp, ChatScreen_KeyPress,
|
ChatScreen_KeyDown, ChatScreen_KeyUp, ChatScreen_KeyPress,
|
||||||
ChatScreen_PointerDown, Screen_FPointer, Screen_FPointerMove, ChatScreen_MouseScroll,
|
ChatScreen_PointerDown, Screen_FPointer, Screen_FPointerMove, ChatScreen_MouseScroll,
|
||||||
ChatScreen_OnResize, ChatScreen_ContextLost, ChatScreen_ContextRecreated
|
ChatScreen_Layout, ChatScreen_ContextLost, ChatScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void ChatScreen_Show(void) {
|
void ChatScreen_Show(void) {
|
||||||
struct ChatScreen* s = &ChatScreen_Instance;
|
struct ChatScreen* s = &ChatScreen_Instance;
|
||||||
|
@ -866,7 +866,7 @@ struct Widget* ChatScreen_GetHotbar(void) {
|
||||||
*-----------------------------------------------------InventoryScreen-----------------------------------------------------*
|
*-----------------------------------------------------InventoryScreen-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct InventoryScreen {
|
static struct InventoryScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct FontDesc font;
|
struct FontDesc font;
|
||||||
struct TableWidget table;
|
struct TableWidget table;
|
||||||
cc_bool releasedInv, deferredSelect;
|
cc_bool releasedInv, deferredSelect;
|
||||||
|
@ -924,9 +924,9 @@ static void InventoryScreen_Render(void* screen, double delta) {
|
||||||
Elem_Render(&s->table, delta);
|
Elem_Render(&s->table, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InventoryScreen_OnResize(void* screen) {
|
static void InventoryScreen_Layout(void* screen) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
Widget_Reposition(&s->table);
|
Widget_Layout(&s->table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InventoryScreen_Free(void* screen) {
|
static void InventoryScreen_Free(void* screen) {
|
||||||
|
@ -935,7 +935,7 @@ static void InventoryScreen_Free(void* screen) {
|
||||||
Event_UnregisterVoid(&BlockEvents.BlockDefChanged, s, InventoryScreen_OnBlockChanged);
|
Event_UnregisterVoid(&BlockEvents.BlockDefChanged, s, InventoryScreen_OnBlockChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InventoryScreen_KeyDown(void* screen, Key key) {
|
static int InventoryScreen_KeyDown(void* screen, Key key) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
struct TableWidget* table = &s->table;
|
struct TableWidget* table = &s->table;
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ static cc_bool InventoryScreen_KeyDown(void* screen, Key key) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InventoryScreen_KeyUp(void* screen, Key key) {
|
static int InventoryScreen_KeyUp(void* screen, Key key) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
struct ChatScreen* hud;
|
struct ChatScreen* hud;
|
||||||
|
|
||||||
|
@ -964,7 +964,7 @@ static cc_bool InventoryScreen_KeyUp(void* screen, Key key) {
|
||||||
return Elem_HandlesKeyUp(&hud->hotbar, key);
|
return Elem_HandlesKeyUp(&hud->hotbar, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InventoryScreen_PointerDown(void* screen, int id, int x, int y) {
|
static int InventoryScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
struct TableWidget* table = &s->table;
|
struct TableWidget* table = &s->table;
|
||||||
struct ChatScreen* hud = (struct ChatScreen*)Gui_Chat;
|
struct ChatScreen* hud = (struct ChatScreen*)Gui_Chat;
|
||||||
|
@ -981,17 +981,17 @@ static cc_bool InventoryScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InventoryScreen_PointerUp(void* screen, int id, int x, int y) {
|
static int InventoryScreen_PointerUp(void* screen, int id, int x, int y) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
return Elem_HandlesPointerUp(&s->table, id, x, y);
|
return Elem_HandlesPointerUp(&s->table, id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InventoryScreen_PointerMove(void* screen, int id, int x, int y) {
|
static int InventoryScreen_PointerMove(void* screen, int id, int x, int y) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
return Elem_HandlesPointerMove(&s->table, id, x, y);
|
return Elem_HandlesPointerMove(&s->table, id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InventoryScreen_MouseScroll(void* screen, float delta) {
|
static int InventoryScreen_MouseScroll(void* screen, float delta) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
|
|
||||||
cc_bool hotbar = Key_IsAltPressed() || Key_IsControlPressed() || Key_IsShiftPressed();
|
cc_bool hotbar = Key_IsAltPressed() || Key_IsControlPressed() || Key_IsShiftPressed();
|
||||||
|
@ -1003,7 +1003,7 @@ static const struct ScreenVTABLE InventoryScreen_VTABLE = {
|
||||||
InventoryScreen_Init, InventoryScreen_Render, InventoryScreen_Free,
|
InventoryScreen_Init, InventoryScreen_Render, InventoryScreen_Free,
|
||||||
InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress,
|
InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress,
|
||||||
InventoryScreen_PointerDown, InventoryScreen_PointerUp, InventoryScreen_PointerMove, InventoryScreen_MouseScroll,
|
InventoryScreen_PointerDown, InventoryScreen_PointerUp, InventoryScreen_PointerMove, InventoryScreen_MouseScroll,
|
||||||
InventoryScreen_OnResize, InventoryScreen_ContextLost, InventoryScreen_ContextRecreated
|
InventoryScreen_Layout, InventoryScreen_ContextLost, InventoryScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void InventoryScreen_Show(void) {
|
void InventoryScreen_Show(void) {
|
||||||
struct InventoryScreen* s = &InventoryScreen_Instance;
|
struct InventoryScreen* s = &InventoryScreen_Instance;
|
||||||
|
@ -1019,7 +1019,7 @@ void InventoryScreen_Show(void) {
|
||||||
*------------------------------------------------------LoadingScreen------------------------------------------------------*
|
*------------------------------------------------------LoadingScreen------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct LoadingScreen {
|
static struct LoadingScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
struct FontDesc font;
|
struct FontDesc font;
|
||||||
float progress;
|
float progress;
|
||||||
|
|
||||||
|
@ -1043,11 +1043,11 @@ static void LoadingScreen_MapLoading(void* screen, float progress) {
|
||||||
s->progress = progress;
|
s->progress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadingScreen_OnResize(void* screen) {
|
static void LoadingScreen_Layout(void* screen) {
|
||||||
struct LoadingScreen* s = (struct LoadingScreen*)screen;
|
struct LoadingScreen* s = (struct LoadingScreen*)screen;
|
||||||
if (!s->title.VTABLE) return;
|
if (!s->title.VTABLE) return;
|
||||||
Widget_Reposition(&s->title);
|
Widget_Layout(&s->title);
|
||||||
Widget_Reposition(&s->message);
|
Widget_Layout(&s->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadingScreen_ContextLost(void* screen) {
|
static void LoadingScreen_ContextLost(void* screen) {
|
||||||
|
@ -1166,9 +1166,9 @@ CC_NOINLINE static void LoadingScreen_ShowCommon(const String* title, const Stri
|
||||||
|
|
||||||
static const struct ScreenVTABLE LoadingScreen_VTABLE = {
|
static const struct ScreenVTABLE LoadingScreen_VTABLE = {
|
||||||
LoadingScreen_Init, LoadingScreen_Render, LoadingScreen_Free,
|
LoadingScreen_Init, LoadingScreen_Render, LoadingScreen_Free,
|
||||||
Screen_TKey, Screen_TKey, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
||||||
Screen_TPointer, Screen_TPointer, Screen_TPointerMove, Screen_TMouseScroll,
|
Screen_TPointer, Screen_TPointer, Screen_TPointerMove, Screen_TMouseScroll,
|
||||||
LoadingScreen_OnResize, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void LoadingScreen_Show(const String* title, const String* message) {
|
void LoadingScreen_Show(const String* title, const String* message) {
|
||||||
LoadingScreen_Instance.VTABLE = &LoadingScreen_VTABLE;
|
LoadingScreen_Instance.VTABLE = &LoadingScreen_VTABLE;
|
||||||
|
@ -1236,9 +1236,9 @@ static void GeneratingScreen_Render(void* screen, double delta) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE GeneratingScreen_VTABLE = {
|
static const struct ScreenVTABLE GeneratingScreen_VTABLE = {
|
||||||
GeneratingScreen_Init, GeneratingScreen_Render, LoadingScreen_Free,
|
GeneratingScreen_Init, GeneratingScreen_Render, LoadingScreen_Free,
|
||||||
Screen_TKey, Screen_TKey, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
||||||
Screen_TPointer, Screen_TPointer, Screen_FPointerMove, Screen_TMouseScroll,
|
Screen_TPointer, Screen_TPointer, Screen_FPointerMove, Screen_TMouseScroll,
|
||||||
LoadingScreen_OnResize, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void GeneratingScreen_Show(void) {
|
void GeneratingScreen_Show(void) {
|
||||||
static const String title = String_FromConst("Generating level");
|
static const String title = String_FromConst("Generating level");
|
||||||
|
@ -1253,7 +1253,7 @@ void GeneratingScreen_Show(void) {
|
||||||
*----------------------------------------------------DisconnectScreen-----------------------------------------------------*
|
*----------------------------------------------------DisconnectScreen-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static struct DisconnectScreen {
|
static struct DisconnectScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
TimeMS initTime;
|
TimeMS initTime;
|
||||||
cc_bool canReconnect, lastActive;
|
cc_bool canReconnect, lastActive;
|
||||||
int lastSecsLeft;
|
int lastSecsLeft;
|
||||||
|
@ -1356,17 +1356,17 @@ static void DisconnectScreen_Render(void* screen, double delta) {
|
||||||
|
|
||||||
static void DisconnectScreen_Free(void* screen) { Game_SetFpsLimit(Game_FpsLimit); }
|
static void DisconnectScreen_Free(void* screen) { Game_SetFpsLimit(Game_FpsLimit); }
|
||||||
|
|
||||||
static void DisconnectScreen_OnResize(void* screen) {
|
static void DisconnectScreen_Layout(void* screen) {
|
||||||
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
||||||
if (!s->title.VTABLE) return;
|
if (!s->title.VTABLE) return;
|
||||||
Widget_Reposition(&s->title);
|
Widget_Layout(&s->title);
|
||||||
Widget_Reposition(&s->message);
|
Widget_Layout(&s->message);
|
||||||
Widget_Reposition(&s->reconnect);
|
Widget_Layout(&s->reconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool DisconnectScreen_KeyDown(void* s, Key key) { return key < KEY_F1 || key > KEY_F35; }
|
static int DisconnectScreen_KeyDown(void* s, Key key) { return key < KEY_F1 || key > KEY_F35; }
|
||||||
|
|
||||||
static cc_bool DisconnectScreen_PointerDown(void* screen, int id, int x, int y) {
|
static int DisconnectScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
||||||
struct ButtonWidget* w = &s->reconnect;
|
struct ButtonWidget* w = &s->reconnect;
|
||||||
|
|
||||||
|
@ -1378,7 +1378,7 @@ static cc_bool DisconnectScreen_PointerDown(void* screen, int id, int x, int y)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool DisconnectScreen_PointerMove(void* screen, int idx, int x, int y) {
|
static int DisconnectScreen_PointerMove(void* screen, int idx, int x, int y) {
|
||||||
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
||||||
struct ButtonWidget* w = &s->reconnect;
|
struct ButtonWidget* w = &s->reconnect;
|
||||||
|
|
||||||
|
@ -1388,9 +1388,9 @@ static cc_bool DisconnectScreen_PointerMove(void* screen, int idx, int x, int y)
|
||||||
|
|
||||||
static const struct ScreenVTABLE DisconnectScreen_VTABLE = {
|
static const struct ScreenVTABLE DisconnectScreen_VTABLE = {
|
||||||
DisconnectScreen_Init, DisconnectScreen_Render, DisconnectScreen_Free,
|
DisconnectScreen_Init, DisconnectScreen_Render, DisconnectScreen_Free,
|
||||||
DisconnectScreen_KeyDown, Screen_TKey, Screen_TKeyPress,
|
DisconnectScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
||||||
DisconnectScreen_PointerDown, Screen_TPointer, DisconnectScreen_PointerMove, Screen_TMouseScroll,
|
DisconnectScreen_PointerDown, Screen_TPointer, DisconnectScreen_PointerMove, Screen_TMouseScroll,
|
||||||
DisconnectScreen_OnResize, DisconnectScreen_ContextLost, DisconnectScreen_ContextRecreated
|
DisconnectScreen_Layout, DisconnectScreen_ContextLost, DisconnectScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void DisconnectScreen_Show(const String* title, const String* message) {
|
void DisconnectScreen_Show(const String* title, const String* message) {
|
||||||
static const String kick = String_FromConst("Kicked ");
|
static const String kick = String_FromConst("Kicked ");
|
||||||
|
@ -1423,7 +1423,7 @@ void DisconnectScreen_Show(const String* title, const String* message) {
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
static struct TouchScreen {
|
static struct TouchScreen {
|
||||||
Screen_Layout
|
Screen_Body
|
||||||
int numButtons, layout;
|
int numButtons, layout;
|
||||||
cc_uint8 binds[10];
|
cc_uint8 binds[10];
|
||||||
struct FontDesc font;
|
struct FontDesc font;
|
||||||
|
@ -1524,15 +1524,15 @@ static void TouchScreen_Render(void* screen, double delta) {
|
||||||
if (i != s->layout) Gui_Refresh(s);
|
if (i != s->layout) Gui_Refresh(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TouchScreen_OnResize(void* screen) {
|
static void TouchScreen_Layout(void* screen) {
|
||||||
struct TouchScreen* s = (struct TouchScreen*)screen;
|
struct TouchScreen* s = (struct TouchScreen*)screen;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < s->numButtons; i++) {
|
for (i = 0; i < s->numButtons; i++) {
|
||||||
Widget_Reposition(&s->buttons[i]);
|
Widget_Layout(&s->buttons[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool TouchScreen_PointerDown(void* screen, int id, int x, int y) {
|
static int TouchScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
struct TouchScreen* s = (struct TouchScreen*)screen;
|
struct TouchScreen* s = (struct TouchScreen*)screen;
|
||||||
int i;
|
int i;
|
||||||
//Chat_Add1("POINTER DOWN: %i", &id);
|
//Chat_Add1("POINTER DOWN: %i", &id);
|
||||||
|
@ -1551,7 +1551,7 @@ static cc_bool TouchScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool TouchScreen_PointerUp(void* screen, int id, int x, int y) {
|
static int TouchScreen_PointerUp(void* screen, int id, int x, int y) {
|
||||||
struct TouchScreen* s = (struct TouchScreen*)screen;
|
struct TouchScreen* s = (struct TouchScreen*)screen;
|
||||||
int i;
|
int i;
|
||||||
//Chat_Add1("POINTER UP: %i", &id);
|
//Chat_Add1("POINTER UP: %i", &id);
|
||||||
|
@ -1570,9 +1570,9 @@ static cc_bool TouchScreen_PointerUp(void* screen, int id, int x, int y) {
|
||||||
|
|
||||||
static const struct ScreenVTABLE TouchScreen_VTABLE = {
|
static const struct ScreenVTABLE TouchScreen_VTABLE = {
|
||||||
Screen_NullFunc, TouchScreen_Render, Screen_NullFunc,
|
Screen_NullFunc, TouchScreen_Render, Screen_NullFunc,
|
||||||
Screen_FKey, Screen_FKey, Screen_FKeyPress,
|
Screen_FInput, Screen_FInput, Screen_FKeyPress,
|
||||||
TouchScreen_PointerDown, TouchScreen_PointerUp, Screen_FPointerMove, Screen_FMouseScroll,
|
TouchScreen_PointerDown, TouchScreen_PointerUp, Screen_FPointerMove, Screen_FMouseScroll,
|
||||||
TouchScreen_OnResize, TouchScreen_ContextLost, TouchScreen_ContextRecreated
|
TouchScreen_Layout, TouchScreen_ContextLost, TouchScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void TouchScreen_Show(void) {
|
void TouchScreen_Show(void) {
|
||||||
struct TouchScreen* s = &TouchScreen_Instance;
|
struct TouchScreen* s = &TouchScreen_Instance;
|
||||||
|
|
|
@ -8,18 +8,18 @@ struct Screen;
|
||||||
struct Widget;
|
struct Widget;
|
||||||
|
|
||||||
/* These always return false */
|
/* These always return false */
|
||||||
cc_bool Screen_FKey(void* s, int key);
|
int Screen_FInput(void* s, int key);
|
||||||
cc_bool Screen_FKeyPress(void* s, char keyChar);
|
int Screen_FKeyPress(void* s, char keyChar);
|
||||||
cc_bool Screen_FMouseScroll(void* s, float delta);
|
int Screen_FMouseScroll(void* s, float delta);
|
||||||
cc_bool Screen_FPointer(void* s, int id, int x, int y);
|
int Screen_FPointer(void* s, int id, int x, int y);
|
||||||
cc_bool Screen_FPointerMove(void* s, int id, int x, int y);
|
int Screen_FPointerMove(void* s, int id, int x, int y);
|
||||||
|
|
||||||
/* These always return true */
|
/* These always return true */
|
||||||
cc_bool Screen_TKeyPress(void* s, char keyChar);
|
int Screen_TInput(void* s, int key);
|
||||||
cc_bool Screen_TKey(void* s, int key);
|
int Screen_TKeyPress(void* s, char keyChar);
|
||||||
cc_bool Screen_TMouseScroll(void* s, float delta);
|
int Screen_TMouseScroll(void* s, float delta);
|
||||||
cc_bool Screen_TPointer(void* s, int id, int x, int y);
|
int Screen_TPointer(void* s, int id, int x, int y);
|
||||||
cc_bool Screen_TPointerMove(void* s, int id, int x, int y);
|
int Screen_TPointerMove(void* s, int id, int x, int y);
|
||||||
|
|
||||||
void InventoryScreen_Show(void);
|
void InventoryScreen_Show(void);
|
||||||
void HUDScreen_Show(void);
|
void HUDScreen_Show(void);
|
||||||
|
|
|
@ -70,7 +70,7 @@ void TextWidget_Set(struct TextWidget* w, const String* text, struct FontDesc* f
|
||||||
}
|
}
|
||||||
|
|
||||||
w->width = w->tex.Width; w->height = w->tex.Height;
|
w->width = w->tex.Width; w->height = w->tex.Height;
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWidget_SetConst(struct TextWidget* w, const char* text, struct FontDesc* font) {
|
void TextWidget_SetConst(struct TextWidget* w, const char* text, struct FontDesc* font) {
|
||||||
|
@ -171,7 +171,7 @@ void ButtonWidget_Set(struct ButtonWidget* w, const String* text, struct FontDes
|
||||||
|
|
||||||
w->width = max(w->tex.Width, w->minWidth);
|
w->width = max(w->tex.Width, w->minWidth);
|
||||||
w->height = max(w->tex.Height, btnMinHeight);
|
w->height = max(w->tex.Height, btnMinHeight);
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, struct FontDesc* font) {
|
void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, struct FontDesc* font) {
|
||||||
|
@ -590,7 +590,7 @@ void TableWidget_RecreateBlocks(struct TableWidget* w) {
|
||||||
}
|
}
|
||||||
|
|
||||||
w->rowsCount = Math_CeilDiv(w->blocksCount, w->blocksPerRow);
|
w->rowsCount = Math_CeilDiv(w->blocksCount, w->blocksPerRow);
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TableWidget_Render(void* widget, double delta) {
|
static void TableWidget_Render(void* widget, double delta) {
|
||||||
|
@ -951,7 +951,7 @@ static void InputWidget_OnPressedEnter(void* widget) {
|
||||||
InputWidget_Clear(w);
|
InputWidget_Clear(w);
|
||||||
w->height = w->lineHeight;
|
w->height = w->lineHeight;
|
||||||
/* TODO get rid of this awful hack.. */
|
/* TODO get rid of this awful hack.. */
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputWidget_Clear(struct InputWidget* w) {
|
void InputWidget_Clear(struct InputWidget* w) {
|
||||||
|
@ -1388,7 +1388,7 @@ static void MenuInputWidget_RemakeTexture(void* widget) {
|
||||||
Drawer2D_Make2DTexture(tex, &bmp, adjSize);
|
Drawer2D_Make2DTexture(tex, &bmp, adjSize);
|
||||||
Mem_Free(bmp.Scan0);
|
Mem_Free(bmp.Scan0);
|
||||||
|
|
||||||
Widget_Reposition(&w->base);
|
Widget_Layout(&w->base);
|
||||||
tex->X = w->base.x; tex->Y = w->base.y;
|
tex->X = w->base.x; tex->Y = w->base.y;
|
||||||
if (size.Height < w->minHeight) {
|
if (size.Height < w->minHeight) {
|
||||||
tex->Y += w->minHeight / 2 - size.Height / 2;
|
tex->Y += w->minHeight / 2 - size.Height / 2;
|
||||||
|
@ -1501,7 +1501,7 @@ static void ChatInputWidget_RemakeTexture(void* widget) {
|
||||||
|
|
||||||
w->width = size.Width;
|
w->width = size.Width;
|
||||||
w->height = size.Height;
|
w->height = size.Height;
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
w->inputTex.X = w->x + w->padding;
|
w->inputTex.X = w->x + w->padding;
|
||||||
w->inputTex.Y = w->y;
|
w->inputTex.Y = w->y;
|
||||||
}
|
}
|
||||||
|
@ -1956,7 +1956,7 @@ static void PlayerListWidget_SortEntries(struct PlayerListWidget* w) {
|
||||||
|
|
||||||
static void PlayerListWidget_SortAndReposition(struct PlayerListWidget* w) {
|
static void PlayerListWidget_SortAndReposition(struct PlayerListWidget* w) {
|
||||||
PlayerListWidget_SortEntries(w);
|
PlayerListWidget_SortEntries(w);
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerListWidget_Add(struct PlayerListWidget* w, int id) {
|
void PlayerListWidget_Add(struct PlayerListWidget* w, int id) {
|
||||||
|
@ -2006,7 +2006,7 @@ static void PlayerListWidget_Render(void* widget, double delta) {
|
||||||
|
|
||||||
Gfx_SetTexturing(true);
|
Gfx_SetTexturing(true);
|
||||||
title->yOffset = w->y - offset + 5;
|
title->yOffset = w->y - offset + 5;
|
||||||
Widget_Reposition(title);
|
Widget_Layout(title);
|
||||||
Elem_Render(title, delta);
|
Elem_Render(title, delta);
|
||||||
grabbed = Gui_GetInputGrab();
|
grabbed = Gui_GetInputGrab();
|
||||||
|
|
||||||
|
@ -2386,7 +2386,7 @@ void TextGroupWidget_Redraw(struct TextGroupWidget* w, int index) {
|
||||||
|
|
||||||
tex.X = Gui_CalcPos(w->horAnchor, w->xOffset, tex.Width, Window_Width);
|
tex.X = Gui_CalcPos(w->horAnchor, w->xOffset, tex.Width, Window_Width);
|
||||||
w->textures[index] = tex;
|
w->textures[index] = tex;
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextGroupWidget_RedrawAllWithCol(struct TextGroupWidget* group, char col) {
|
void TextGroupWidget_RedrawAllWithCol(struct TextGroupWidget* group, char col) {
|
||||||
|
@ -2418,7 +2418,7 @@ void TextGroupWidget_SetFont(struct TextGroupWidget* w, struct FontDesc* font) {
|
||||||
w->textures[i].Height = w->collapsible[i] ? 0 : height;
|
w->textures[i].Height = w->collapsible[i] ? 0 : height;
|
||||||
}
|
}
|
||||||
w->font = font;
|
w->font = font;
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TextGroupWidget_Render(void* widget, double delta) {
|
static void TextGroupWidget_Render(void* widget, double delta) {
|
||||||
|
@ -2638,7 +2638,7 @@ void SpecialInputWidget_Redraw(struct SpecialInputWidget* w) {
|
||||||
SpecialInputWidget_Make(w, &w->tabs[w->selectedIndex]);
|
SpecialInputWidget_Make(w, &w->tabs[w->selectedIndex]);
|
||||||
w->width = w->tex.Width;
|
w->width = w->tex.Width;
|
||||||
w->pendingRedraw = false;
|
w->pendingRedraw = false;
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpecialInputWidget_Render(void* widget, double delta) {
|
static void SpecialInputWidget_Render(void* widget, double delta) {
|
||||||
|
@ -2683,7 +2683,7 @@ void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w) {
|
||||||
void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, cc_bool active) {
|
void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, cc_bool active) {
|
||||||
w->active = active;
|
w->active = active;
|
||||||
if (active && w->pendingRedraw) SpecialInputWidget_Redraw(w);
|
if (active && w->pendingRedraw) SpecialInputWidget_Redraw(w);
|
||||||
Widget_Reposition(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct WidgetVTABLE SpecialInputWidget_VTABLE = {
|
static const struct WidgetVTABLE SpecialInputWidget_VTABLE = {
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct FontDesc;
|
||||||
|
|
||||||
/* A text label. */
|
/* A text label. */
|
||||||
struct TextWidget {
|
struct TextWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
struct Texture tex;
|
struct Texture tex;
|
||||||
PackedCol col;
|
PackedCol col;
|
||||||
};
|
};
|
||||||
|
@ -28,7 +28,7 @@ typedef void (*Button_Get)(String* raw);
|
||||||
typedef void (*Button_Set)(const String* raw);
|
typedef void (*Button_Set)(const String* raw);
|
||||||
/* A labelled button that can be clicked on. */
|
/* A labelled button that can be clicked on. */
|
||||||
struct ButtonWidget {
|
struct ButtonWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
struct Texture tex;
|
struct Texture tex;
|
||||||
int minWidth;
|
int minWidth;
|
||||||
const char* optName;
|
const char* optName;
|
||||||
|
@ -45,7 +45,7 @@ CC_NOINLINE void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text,
|
||||||
|
|
||||||
/* Clickable and draggable scrollbar. */
|
/* Clickable and draggable scrollbar. */
|
||||||
struct ScrollbarWidget {
|
struct ScrollbarWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
int totalRows, topRow;
|
int totalRows, topRow;
|
||||||
float scrollingAcc;
|
float scrollingAcc;
|
||||||
int dragOffset;
|
int dragOffset;
|
||||||
|
@ -56,7 +56,7 @@ CC_NOINLINE void ScrollbarWidget_Create(struct ScrollbarWidget* w);
|
||||||
|
|
||||||
/* A row of blocks with a background. */
|
/* A row of blocks with a background. */
|
||||||
struct HotbarWidget {
|
struct HotbarWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
struct Texture selTex, backTex;
|
struct Texture selTex, backTex;
|
||||||
float barHeight, selBlockSize, elemSize;
|
float barHeight, selBlockSize, elemSize;
|
||||||
float barXOffset, borderSize;
|
float barXOffset, borderSize;
|
||||||
|
@ -69,7 +69,7 @@ CC_NOINLINE void HotbarWidget_Create(struct HotbarWidget* w);
|
||||||
|
|
||||||
/* A table of blocks. */
|
/* A table of blocks. */
|
||||||
struct TableWidget {
|
struct TableWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
int blocksCount, blocksPerRow, rowsCount;
|
int blocksCount, blocksPerRow, rowsCount;
|
||||||
int lastCreatedIndex;
|
int lastCreatedIndex;
|
||||||
struct FontDesc* font;
|
struct FontDesc* font;
|
||||||
|
@ -97,7 +97,7 @@ CC_NOINLINE void TableWidget_Recreate(struct TableWidget* w);
|
||||||
#define INPUTWIDGET_MAX_LINES 3
|
#define INPUTWIDGET_MAX_LINES 3
|
||||||
#define INPUTWIDGET_LEN STRING_SIZE
|
#define INPUTWIDGET_LEN STRING_SIZE
|
||||||
struct InputWidget {
|
struct InputWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
struct FontDesc* font;
|
struct FontDesc* font;
|
||||||
int (*GetMaxLines)(void);
|
int (*GetMaxLines)(void);
|
||||||
void (*RemakeTexture)(void* elem); /* Remakes the raw texture containing all the chat lines. Also updates dimensions. */
|
void (*RemakeTexture)(void* elem); /* Remakes the raw texture containing all the chat lines. Also updates dimensions. */
|
||||||
|
@ -202,7 +202,7 @@ typedef String (*TextGroupWidget_Get)(void* obj, int i);
|
||||||
|
|
||||||
/* A group of text labels. */
|
/* A group of text labels. */
|
||||||
struct TextGroupWidget {
|
struct TextGroupWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
int lines, defaultHeight;
|
int lines, defaultHeight;
|
||||||
struct FontDesc* font;
|
struct FontDesc* font;
|
||||||
/* Whether a line has zero height when that line has no text in it. */
|
/* Whether a line has zero height when that line has no text in it. */
|
||||||
|
@ -237,7 +237,7 @@ static String TextGroupWidget_UNSAFE_Get(struct TextGroupWidget* w, int i) { ret
|
||||||
|
|
||||||
|
|
||||||
struct PlayerListWidget {
|
struct PlayerListWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
struct FontDesc* font;
|
struct FontDesc* font;
|
||||||
int namesCount, elementOffset;
|
int namesCount, elementOffset;
|
||||||
cc_bool classic;
|
cc_bool classic;
|
||||||
|
@ -264,7 +264,7 @@ struct SpecialInputTab {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SpecialInputWidget {
|
struct SpecialInputWidget {
|
||||||
Widget_Layout
|
Widget_Body
|
||||||
int elementWidth, elementHeight;
|
int elementWidth, elementHeight;
|
||||||
int selectedIndex;
|
int selectedIndex;
|
||||||
cc_bool pendingRedraw;
|
cc_bool pendingRedraw;
|
||||||
|
|
Loading…
Reference in a new issue