From 029a37d87de87ec24577b6d31085247e667d1eb3 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Thu, 10 Feb 2022 20:38:46 -0600 Subject: [PATCH] Start of main menu. --- client/assets/door.png | 3 ++ client/assets/dos.png | 3 ++ client/assets/if.png | 3 ++ client/assets/menu.xcf | 3 ++ client/src/gui/taglist.c | 10 +++- client/src/main.c | 5 +- client/src/menu.c | 107 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 client/assets/door.png create mode 100644 client/assets/dos.png create mode 100644 client/assets/if.png create mode 100644 client/assets/menu.xcf diff --git a/client/assets/door.png b/client/assets/door.png new file mode 100644 index 0000000..d55c4c8 --- /dev/null +++ b/client/assets/door.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fac67f341ffec347d5722fbf9cae810d13666d308d01722f11397e9cd2d65dbf +size 3250 diff --git a/client/assets/dos.png b/client/assets/dos.png new file mode 100644 index 0000000..62fefd7 --- /dev/null +++ b/client/assets/dos.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d009a129322e0ef2c6088f6ccc6249e53c814dea47df7c8f25bc11569cf56ac6 +size 5145 diff --git a/client/assets/if.png b/client/assets/if.png new file mode 100644 index 0000000..121647d --- /dev/null +++ b/client/assets/if.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79e08a0328c8e1d71b24028dacea5d1726c6ad73983b0638e6ec6724d3b4232d +size 3047 diff --git a/client/assets/menu.xcf b/client/assets/menu.xcf new file mode 100644 index 0000000..74ce554 --- /dev/null +++ b/client/assets/menu.xcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a96e8aa41d87c8a7aed6e5ba1236bd8285742fdfdca256a1333bd8b29ce9583f +size 21301 diff --git a/client/src/gui/taglist.c b/client/src/gui/taglist.c index 3b026d3..eeb15e1 100644 --- a/client/src/gui/taglist.c +++ b/client/src/gui/taglist.c @@ -85,6 +85,8 @@ static void tagListWidgetAttributeHandle(void) { char *title; char *filename; RectT pos; + uint8_t hasWidth; + uint8_t hasHeight; widgetCallback click; void *userdata; int32_t valueInt; @@ -120,6 +122,8 @@ static void tagListWidgetAttributeHandle(void) { pos.y = 0; pos.w = 0; pos.h = 0; + hasWidth = 0; + hasHeight = 0; click = NULL; userdata = NULL; hasValue = 0; @@ -184,7 +188,8 @@ static void tagListWidgetAttributeHandle(void) { break; case T_HEIGHT: - pos.h = v; + pos.h = v; + hasHeight = 1; break; case T_INDEX: @@ -239,7 +244,8 @@ static void tagListWidgetAttributeHandle(void) { break; case T_WIDTH: - pos.w = v; + pos.w = v; + hasWidth = 1; break; case T_X: diff --git a/client/src/main.c b/client/src/main.c index 071d145..fde7705 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -292,6 +292,8 @@ static void tableSave(void) { } +void menuShow(void); + int main(int argc, char *argv[]) { if (startup(argc, argv)) return 1; @@ -299,7 +301,8 @@ int main(int argc, char *argv[]) { // Perform "first run" setup tasks or start the client? if (hasValidSettings()) { // We have what we need, start the client. - welcomeShow(); + //welcomeShow(); + menuShow(); } else { // Run the setup. settingsShow(checkSettings); diff --git a/client/src/menu.c b/client/src/menu.c index 597ea66..40d0b3c 100644 --- a/client/src/menu.c +++ b/client/src/menu.c @@ -18,9 +18,116 @@ */ +#include "network.h" +#include "vesa.h" + +#include "taglist.h" +#include "msgbox.h" +#include "window.h" +#include "picture.h" +#include "button.h" + #include "menu.h" +#include "hangup.h" +#include "welcome.h" + + +static void btnLogoffClick(WidgetT *widget); +static void btnOptionsClick(WidgetT *widget); +static void btnMsgBoxLogoff(MsgBoxButtonT button); +static void picDoorClick(WidgetT *widget); +static void setButtons(uint8_t enabled); + + +static WindowT *_winMenu = NULL; +static PictureT *_picDoor = NULL; +static PictureT *_picDOS = NULL; +static PictureT *_picIF = NULL; +static ButtonT *_btnOptions = NULL; +static ButtonT *_btnLogoff = NULL; + + +static void btnLogoffClick(WidgetT *widget) { + (void)widget; + + setButtons(0); + msgBoxTwo("Cancel?", MSGBOX_ICON_QUESTION, "Cancel login?\n \nThis will disconnect you from the server.", "Okay", btnMsgBoxLogoff, "Cancel", btnMsgBoxLogoff); +} + + +static void btnMsgBoxLogoff(MsgBoxButtonT button) { + + if (button == MSGBOX_BUTTON_ONE) { + guiDelete(D(_winMenu)); + // ***TODO*** Need a way to close all other windows. + hangupShow(welcomeShow); + } else { + setButtons(1); + } +} + + + + +static void btnOptionsClick(WidgetT *widget) { + (void)widget; + // ***TODO*** + msgBoxOne("Options", MSGBOX_ICON_MESSAGE, "Yeah, this doesn't do anything yet.", "Okay", NULL); +} void menuShow(void) { + TagItemT uiMenu[] = { + T_START, + T_WINDOW, O(_winMenu), + T_TITLE, P("KangaWorld Main Menu"), + T_X, vbeDisplayWidthGet() - 360, T_Y, vbeDisplayHeightGet() - 285, + T_WIDTH, 350, T_HEIGHT, 275, + + T_PICTURE, O(_picDOS), + T_FILENAME, P("dos.png"), + T_X, 18, T_Y, 18, + T_PICTURE, T_DONE, + + T_PICTURE, O(_picDoor), + T_FILENAME, P("door.png"), + T_X, 18, T_Y, 77, + T_CLICK, P(picDoorClick), + T_PICTURE, T_DONE, + + T_PICTURE, O(_picIF), + T_FILENAME, P("if.png"), + T_X, 18, T_Y, 136, + T_PICTURE, T_DONE, + + T_BUTTON, O(_btnOptions), + T_TITLE, P("Options"), + T_X, 23, T_Y, 202, + T_CLICK, P(btnOptionsClick), + T_BUTTON, T_DONE, + + T_BUTTON, O(_btnLogoff), + T_TITLE, P("Logoff"), + T_X, 245, T_Y, 202, + T_CLICK, P(btnLogoffClick), + T_BUTTON, T_DONE, + + T_WINDOW, T_DONE, + T_END + }; + + tagListRun(uiMenu); +} + + +static void picDoorClick(WidgetT *widget) { + +} + + +static void setButtons(uint8_t enabled) { + // ***TODO*** This should disable the entire dialog instead of just the buttons. Need to finish the Enable GUI code first. + widgetEnableSet(W(_btnOptions), enabled); + widgetEnableSet(W(_btnLogoff), enabled); }