Rename LScreen->Reposition to more logical LScreen->Layout

This commit is contained in:
UnknownShadow200 2019-08-04 08:49:42 +10:00
parent 6035276344
commit dd7b1c1bca
6 changed files with 36 additions and 46 deletions

View File

@ -822,7 +822,7 @@ static void Music_RunLoop(void) {
char pathBuffer[FILENAME_SIZE]; char pathBuffer[FILENAME_SIZE];
String path; String path;
uint16_t musicFiles[MUSIC_MAX_FILES]; unsigned short musicFiles[MUSIC_MAX_FILES];
String file; String file;
RNGState rnd; RNGState rnd;

View File

@ -281,7 +281,7 @@ static void ChooseModeScreen_Init(struct LScreen* s_) {
LLabel_SetConst(&s->lblTitle, "Choose game mode"); LLabel_SetConst(&s->lblTitle, "Choose game mode");
} }
static void ChooseModeScreen_Reposition(struct LScreen* s_) { static void ChooseModeScreen_Layout(struct LScreen* s_) {
struct ChooseModeScreen* s = (struct ChooseModeScreen*)s_; struct ChooseModeScreen* s = (struct ChooseModeScreen*)s_;
LWidget_SetLocation(&s->lblTitle, ANCHOR_CENTRE, ANCHOR_CENTRE, 10, -135); LWidget_SetLocation(&s->lblTitle, ANCHOR_CENTRE, ANCHOR_CENTRE, 10, -135);
LWidget_SetLocation(&s->seps[0], ANCHOR_CENTRE, ANCHOR_CENTRE, -5, -35); LWidget_SetLocation(&s->seps[0], ANCHOR_CENTRE, ANCHOR_CENTRE, -5, -35);
@ -306,9 +306,9 @@ static void ChooseModeScreen_Reposition(struct LScreen* s_) {
struct LScreen* ChooseModeScreen_MakeInstance(bool firstTime) { struct LScreen* ChooseModeScreen_MakeInstance(bool firstTime) {
struct ChooseModeScreen* s = &ChooseModeScreen_Instance; struct ChooseModeScreen* s = &ChooseModeScreen_Instance;
LScreen_Reset((struct LScreen*)s); LScreen_Reset((struct LScreen*)s);
s->Init = ChooseModeScreen_Init; s->Init = ChooseModeScreen_Init;
s->Reposition = ChooseModeScreen_Reposition; s->Layout = ChooseModeScreen_Layout;
s->firstTime = firstTime; s->firstTime = firstTime;
s->onEnterWidget = (struct LWidget*)&s->btnEnhanced; s->onEnterWidget = (struct LWidget*)&s->btnEnhanced;
return (struct LScreen*)s; return (struct LScreen*)s;
} }
@ -452,7 +452,7 @@ static void ColoursScreen_Init(struct LScreen* s_) {
ColoursScreen_UpdateAll(s); ColoursScreen_UpdateAll(s);
} }
static void ColoursScreen_Reposition(struct LScreen* s_) { static void ColoursScreen_Layout(struct LScreen* s_) {
struct ColoursScreen* s = (struct ColoursScreen*)s_; struct ColoursScreen* s = (struct ColoursScreen*)s_;
int i, y; int i, y;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
@ -480,7 +480,7 @@ struct LScreen* ColoursScreen_MakeInstance(void) {
struct ColoursScreen* s = &ColoursScreen_Instance; struct ColoursScreen* s = &ColoursScreen_Instance;
LScreen_Reset((struct LScreen*)s); LScreen_Reset((struct LScreen*)s);
s->Init = ColoursScreen_Init; s->Init = ColoursScreen_Init;
s->Reposition = ColoursScreen_Reposition; s->Layout = ColoursScreen_Layout;
s->KeyDown = ColoursScreen_KeyDown; s->KeyDown = ColoursScreen_KeyDown;
s->MouseWheel = ColoursScreen_MouseWheel; s->MouseWheel = ColoursScreen_MouseWheel;
return (struct LScreen*)s; return (struct LScreen*)s;
@ -590,7 +590,7 @@ static void DirectConnectScreen_Init(struct LScreen* s_) {
DirectConnectScreen_Load(s); DirectConnectScreen_Load(s);
} }
static void DirectConnectScreen_Reposition(struct LScreen* s_) { static void DirectConnectScreen_Layout(struct LScreen* s_) {
struct DirectConnectScreen* s = (struct DirectConnectScreen*)s_; struct DirectConnectScreen* s = (struct DirectConnectScreen*)s_;
LWidget_SetLocation(&s->iptUsername, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -165, -120); LWidget_SetLocation(&s->iptUsername, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -165, -120);
LWidget_SetLocation(&s->iptAddress, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -165, -75); LWidget_SetLocation(&s->iptAddress, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -165, -75);
@ -605,7 +605,7 @@ struct LScreen* DirectConnectScreen_MakeInstance(void) {
struct DirectConnectScreen* s = &DirectConnectScreen_Instance; struct DirectConnectScreen* s = &DirectConnectScreen_Instance;
LScreen_Reset((struct LScreen*)s); LScreen_Reset((struct LScreen*)s);
s->Init = DirectConnectScreen_Init; s->Init = DirectConnectScreen_Init;
s->Reposition = DirectConnectScreen_Reposition; s->Layout = DirectConnectScreen_Layout;
s->onEnterWidget = (struct LWidget*)&s->btnConnect; s->onEnterWidget = (struct LWidget*)&s->btnConnect;
return (struct LScreen*)s; return (struct LScreen*)s;
} }
@ -749,7 +749,7 @@ static void MainScreen_Init(struct LScreen* s_) {
LInput_SetText(&s->iptPassword, &pass); LInput_SetText(&s->iptPassword, &pass);
} }
static void MainScreen_Reposition(struct LScreen* s_) { static void MainScreen_Layout(struct LScreen* s_) {
struct MainScreen* s = (struct MainScreen*)s_; struct MainScreen* s = (struct MainScreen*)s_;
LWidget_SetLocation(&s->iptUsername, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -140, -120); LWidget_SetLocation(&s->iptUsername, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -140, -120);
LWidget_SetLocation(&s->iptPassword, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -140, -75); LWidget_SetLocation(&s->iptPassword, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -140, -75);
@ -893,9 +893,9 @@ static void MainScreen_Tick(struct LScreen* s_) {
struct LScreen* MainScreen_MakeInstance(void) { struct LScreen* MainScreen_MakeInstance(void) {
struct MainScreen* s = &MainScreen_Instance; struct MainScreen* s = &MainScreen_Instance;
LScreen_Reset((struct LScreen*)s); LScreen_Reset((struct LScreen*)s);
s->Init = MainScreen_Init; s->Init = MainScreen_Init;
s->Tick = MainScreen_Tick; s->Tick = MainScreen_Tick;
s->Reposition = MainScreen_Reposition; s->Layout = MainScreen_Layout;
s->HoverWidget = MainScreen_HoverWidget; s->HoverWidget = MainScreen_HoverWidget;
s->UnhoverWidget = MainScreen_UnhoverWidget; s->UnhoverWidget = MainScreen_UnhoverWidget;
s->onEnterWidget = (struct LWidget*)&s->btnLogin; s->onEnterWidget = (struct LWidget*)&s->btnLogin;
@ -978,7 +978,7 @@ static void ResourcesScreen_Init(struct LScreen* s_) {
s->btnCancel.OnClick = ResourcesScreen_Next; s->btnCancel.OnClick = ResourcesScreen_Next;
} }
static void ResourcesScreen_Reposition(struct LScreen* s_) { static void ResourcesScreen_Layout(struct LScreen* s_) {
struct ResourcesScreen* s = (struct ResourcesScreen*)s_; struct ResourcesScreen* s = (struct ResourcesScreen*)s_;
LWidget_SetLocation(&s->lblLine1, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -50); LWidget_SetLocation(&s->lblLine1, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -50);
@ -1080,10 +1080,10 @@ static void ResourcesScreen_Tick(struct LScreen* s_) {
struct LScreen* ResourcesScreen_MakeInstance(void) { struct LScreen* ResourcesScreen_MakeInstance(void) {
struct ResourcesScreen* s = &ResourcesScreen_Instance; struct ResourcesScreen* s = &ResourcesScreen_Instance;
LScreen_Reset((struct LScreen*)s); LScreen_Reset((struct LScreen*)s);
s->Init = ResourcesScreen_Init; s->Init = ResourcesScreen_Init;
s->Draw = ResourcesScreen_Draw; s->Draw = ResourcesScreen_Draw;
s->Tick = ResourcesScreen_Tick; s->Tick = ResourcesScreen_Tick;
s->Reposition = ResourcesScreen_Reposition; s->Layout = ResourcesScreen_Layout;
s->onEnterWidget = (struct LWidget*)&s->btnYes; s->onEnterWidget = (struct LWidget*)&s->btnYes;
return (struct LScreen*)s; return (struct LScreen*)s;
} }
@ -1236,7 +1236,7 @@ static void ServersScreen_Free(struct LScreen* s_) {
Font_Free(&s->rowFont); Font_Free(&s->rowFont);
} }
static void ServersScreen_Reposition(struct LScreen* s_) { static void ServersScreen_Layout(struct LScreen* s_) {
struct ServersScreen* s = (struct ServersScreen*)s_; struct ServersScreen* s = (struct ServersScreen*)s_;
LWidget_SetLocation(&s->iptSearch, ANCHOR_MIN, ANCHOR_MIN, 10, 10); LWidget_SetLocation(&s->iptSearch, ANCHOR_MIN, ANCHOR_MIN, 10, 10);
LWidget_SetLocation(&s->iptHash, ANCHOR_MIN, ANCHOR_MAX, 10, 10); LWidget_SetLocation(&s->iptHash, ANCHOR_MIN, ANCHOR_MAX, 10, 10);
@ -1282,7 +1282,7 @@ struct LScreen* ServersScreen_MakeInstance(void) {
s->Init = ServersScreen_Init; s->Init = ServersScreen_Init;
s->Tick = ServersScreen_Tick; s->Tick = ServersScreen_Tick;
s->Free = ServersScreen_Free; s->Free = ServersScreen_Free;
s->Reposition = ServersScreen_Reposition; s->Layout = ServersScreen_Layout;
s->MouseWheel = ServersScreen_MouseWheel; s->MouseWheel = ServersScreen_MouseWheel;
s->KeyDown = ServersScreen_KeyDown; s->KeyDown = ServersScreen_KeyDown;
s->MouseUp = ServersScreen_MouseUp; s->MouseUp = ServersScreen_MouseUp;
@ -1327,7 +1327,7 @@ static void SettingsScreen_Init(struct LScreen* s_) {
s->btnBack.OnClick = SwitchToMain; s->btnBack.OnClick = SwitchToMain;
} }
static void SettingsScreen_Reposition(struct LScreen* s_) { static void SettingsScreen_Layout(struct LScreen* s_) {
struct SettingsScreen* s = (struct SettingsScreen*)s_; struct SettingsScreen* s = (struct SettingsScreen*)s_;
LWidget_SetLocation(&s->btnUpdates, ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -120); LWidget_SetLocation(&s->btnUpdates, ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -120);
LWidget_SetLocation(&s->lblUpdates, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -70, -120); LWidget_SetLocation(&s->lblUpdates, ANCHOR_CENTRE_MIN, ANCHOR_CENTRE, -70, -120);
@ -1344,8 +1344,8 @@ static void SettingsScreen_Reposition(struct LScreen* s_) {
struct LScreen* SettingsScreen_MakeInstance(void) { struct LScreen* SettingsScreen_MakeInstance(void) {
struct SettingsScreen* s = &SettingsScreen_Instance; struct SettingsScreen* s = &SettingsScreen_Instance;
LScreen_Reset((struct LScreen*)s); LScreen_Reset((struct LScreen*)s);
s->Init = SettingsScreen_Init; s->Init = SettingsScreen_Init;
s->Reposition = SettingsScreen_Reposition; s->Layout = SettingsScreen_Layout;
return (struct LScreen*)s; return (struct LScreen*)s;
} }
@ -1529,7 +1529,7 @@ static void UpdatesScreen_Init(struct LScreen* s_) {
UpdatesScreen_Format(&s->lblYour, "Your build: ", buildTime); UpdatesScreen_Format(&s->lblYour, "Your build: ", buildTime);
} }
static void UpdatesScreen_Reposition(struct LScreen* s_) { static void UpdatesScreen_Layout(struct LScreen* s_) {
struct UpdatesScreen* s = (struct UpdatesScreen*)s_; struct UpdatesScreen* s = (struct UpdatesScreen*)s_;
LWidget_SetLocation(&s->lblYour, ANCHOR_CENTRE, ANCHOR_CENTRE, -5, -120); LWidget_SetLocation(&s->lblYour, ANCHOR_CENTRE, ANCHOR_CENTRE, -5, -120);
LWidget_SetLocation(&s->seps[0], ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -100); LWidget_SetLocation(&s->seps[0], ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -100);
@ -1569,10 +1569,10 @@ static void UpdatesScreen_Free(struct LScreen* s_) {
struct LScreen* UpdatesScreen_MakeInstance(void) { struct LScreen* UpdatesScreen_MakeInstance(void) {
struct UpdatesScreen* s = &UpdatesScreen_Instance; struct UpdatesScreen* s = &UpdatesScreen_Instance;
LScreen_Reset((struct LScreen*)s); LScreen_Reset((struct LScreen*)s);
s->Init = UpdatesScreen_Init; s->Init = UpdatesScreen_Init;
s->Tick = UpdatesScreen_Tick; s->Tick = UpdatesScreen_Tick;
s->Free = UpdatesScreen_Free; s->Free = UpdatesScreen_Free;
s->Reposition = UpdatesScreen_Reposition; s->Layout = UpdatesScreen_Layout;
return (struct LScreen*)s; return (struct LScreen*)s;
} }
#endif #endif

View File

@ -11,11 +11,11 @@ typedef void (*LScreen_Func)(struct LScreen* s);
typedef void (*LWidget_Func)(struct LScreen* s, struct LWidget* w); typedef void (*LWidget_Func)(struct LScreen* s, struct LWidget* w);
#define LScreen_Layout \ #define LScreen_Layout \
LScreen_Func Init; /* Initialises widgets and other data. */ \ LScreen_Func Init; /* Initialises widgets and other data. */ \
LScreen_Func Free; /* Cleans up all native resources. */ \ LScreen_Func Free; /* Cleans up all native resources. */ \
LScreen_Func Reposition; /* Repositions the widgets in the screen. */ \ LScreen_Func Layout; /* Positions the widgets on the screen. */ \
LScreen_Func Draw; /* Draws all widgets and any other features such as lines/rectangles. */ \ LScreen_Func Draw; /* Draws all widgets and any other features such as lines/rectangles. */ \
LScreen_Func Tick; /* Repeatedly called multiple times every second. */ \ LScreen_Func Tick; /* Repeatedly called multiple times every second. */ \
LScreen_Func OnDisplay; /* Called when framebuffer is about to be displayed. */ \ LScreen_Func OnDisplay; /* Called when framebuffer is about to be displayed. */ \
void (*KeyDown)(struct LScreen* s, Key key, bool wasDown); \ void (*KeyDown)(struct LScreen* s, Key key, bool wasDown); \
void (*KeyPress)(struct LScreen* s, char c); \ void (*KeyPress)(struct LScreen* s, char c); \

View File

@ -34,7 +34,7 @@ void Launcher_SetScreen(struct LScreen* screen) {
Launcher_Screen = screen; Launcher_Screen = screen;
screen->Init(screen); screen->Init(screen);
screen->Reposition(screen); screen->Layout(screen);
/* for hovering over active button etc */ /* for hovering over active button etc */
screen->MouseMove(screen, 0, 0); screen->MouseMove(screen, 0, 0);
@ -107,7 +107,7 @@ static void Launcher_OnResize(void* obj) {
Window_FreeFramebuffer(&Launcher_Framebuffer); Window_FreeFramebuffer(&Launcher_Framebuffer);
Window_AllocFramebuffer(&Launcher_Framebuffer); Window_AllocFramebuffer(&Launcher_Framebuffer);
if (Launcher_Screen) Launcher_Screen->Reposition(Launcher_Screen); if (Launcher_Screen) Launcher_Screen->Layout(Launcher_Screen);
Launcher_Redraw(); Launcher_Redraw();
} }

View File

@ -4,7 +4,6 @@
/* Decodes ogg vorbis audio /* Decodes ogg vorbis audio
Copyright 2014-2019 ClassiCube | Licensed under BSD-3 Copyright 2014-2019 ClassiCube | Licensed under BSD-3
*/ */
struct IGameComponent;
struct Stream; struct Stream;
#define VORBIS_MAX_CHANS 8 #define VORBIS_MAX_CHANS 8
#define VORBIS_MAX_BLOCK_SIZE 8192 #define VORBIS_MAX_BLOCK_SIZE 8192

View File

@ -2896,7 +2896,6 @@ static void JNICALL java_processSurfaceDestroyed(JNIEnv* env, jobject o) {
static void JNICALL java_processSurfaceResized(JNIEnv* env, jobject o, jobject surface) { static void JNICALL java_processSurfaceResized(JNIEnv* env, jobject o, jobject surface) {
Platform_LogConst("WIN - RESIZED"); Platform_LogConst("WIN - RESIZED");
Window_RefreshBounds(); Window_RefreshBounds();
Window_RefreshBounds(); /* TODO: Why does it only work on second try? */
} }
static void JNICALL java_processSurfaceRedrawNeeded(JNIEnv* env, jobject o) { static void JNICALL java_processSurfaceRedrawNeeded(JNIEnv* env, jobject o) {
@ -2941,13 +2940,6 @@ static void JNICALL java_onLostFocus(JNIEnv* env, jobject o) {
Window_Focused = false; Window_Focused = false;
Event_RaiseVoid(&WindowEvents.FocusChanged); Event_RaiseVoid(&WindowEvents.FocusChanged);
/* TODO: Disable rendering? */ /* TODO: Disable rendering? */
}
static void JNICALL java_onConfigChanged(JNIEnv* env, jobject o) {
Platform_LogConst("APP - CONFIG CHANGED");
Window_RefreshBounds();
Window_RefreshBounds(); /* TODO: Why does it only work on second try? */
/* TODO: this one might not even be needed */
} }
static void JNICALL java_onLowMemory(JNIEnv* env, jobject o) { static void JNICALL java_onLowMemory(JNIEnv* env, jobject o) {
@ -2977,7 +2969,6 @@ static const JNINativeMethod methods[19] = {
{ "processOnGotFocus", "()V", java_onGotFocus }, { "processOnGotFocus", "()V", java_onGotFocus },
{ "processOnLostFocus", "()V", java_onLostFocus }, { "processOnLostFocus", "()V", java_onLostFocus },
{ "processOnConfigChanged", "()V", java_onConfigChanged },
{ "processOnLowMemory", "()V", java_onLowMemory } { "processOnLowMemory", "()V", java_onLowMemory }
}; };
@ -2995,7 +2986,7 @@ void Window_Init(void) {
void Window_Create(int width, int height) { void Window_Create(int width, int height) {
Window_Exists = true; Window_Exists = true;
/* actual window creation is done when APP_CMD_INIT_WINDOW is received */ /* actual window creation is done when processSurfaceCreated is called */
} }
void Window_SetTitle(const String* title) { void Window_SetTitle(const String* title) {