wip3
This commit is contained in:
parent
850ed93367
commit
c5f04adaea
|
@ -81,7 +81,7 @@ void gui_button_init(struct gui_button *const b, const enum gui_button_type t)
|
||||||
static void (*const f[])(struct gui_button *) =
|
static void (*const f[])(struct gui_button *) =
|
||||||
{
|
{
|
||||||
[GUI_BUTTON_TYPE_1] = gui_button_init_type1,
|
[GUI_BUTTON_TYPE_1] = gui_button_init_type1,
|
||||||
[GUI_BUTTON_TYPE_SPRITE] = gui_button_get_dim_sprite
|
[GUI_BUTTON_TYPE_SPRITE] = gui_button_init_sprite
|
||||||
};
|
};
|
||||||
|
|
||||||
f[b->type](b);
|
f[b->type](b);
|
||||||
|
|
|
@ -11,8 +11,10 @@
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#include <packet.h>
|
#include <packet.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -27,8 +29,8 @@ struct gamecfg_menu
|
||||||
{
|
{
|
||||||
char chat_in[PACKET_MAX_MESSAGE_LEN],
|
char chat_in[PACKET_MAX_MESSAGE_LEN],
|
||||||
chat[CHAT_ENTRIES][TOTAL_MESSAGE_LEN];
|
chat[CHAT_ENTRIES][TOTAL_MESSAGE_LEN];
|
||||||
char chat_label[sizeof "Chat (6)"];
|
char chat_label[sizeof "Chat (255)"];
|
||||||
size_t chat_i, unread_messages;
|
uint8_t chat_i, unread_messages;
|
||||||
struct gui_container bcnt;
|
struct gui_container bcnt;
|
||||||
struct gui_button start, back;
|
struct gui_button start, back;
|
||||||
struct net_host *host;
|
struct net_host *host;
|
||||||
|
@ -653,7 +655,7 @@ static void on_packet_received(const net_peer peer,
|
||||||
m->unread_messages++;
|
m->unread_messages++;
|
||||||
|
|
||||||
snprintf(m->chat_label, sizeof m->chat_label,
|
snprintf(m->chat_label, sizeof m->chat_label,
|
||||||
"Chat (%zu)", m->unread_messages);
|
"Chat (%" PRIu8 ")", m->unread_messages);
|
||||||
m->u.page1.chat_page.u.type1.label.text = m->chat_label;
|
m->u.page1.chat_page.u.type1.label.text = m->chat_label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,37 +40,51 @@ int menu_main(struct menu_common *const c)
|
||||||
{
|
{
|
||||||
struct main_menu m = {0};
|
struct main_menu m = {0};
|
||||||
|
|
||||||
gui_container_init(&m.cnt);
|
{
|
||||||
m.cnt.mode = GUI_CONTAINER_MODE_V;
|
struct gui_container *const c = &m.cnt;
|
||||||
m.cnt.common.hcentered = true;
|
|
||||||
m.cnt.common.vcentered = true;
|
|
||||||
m.cnt.spacing = 4;
|
|
||||||
|
|
||||||
gui_button_init(&m.play, GUI_BUTTON_TYPE_1);
|
gui_container_init(c);
|
||||||
m.play.on_pressed = menu_on_pressed;
|
c->mode = GUI_CONTAINER_MODE_V;
|
||||||
m.play.arg = &m.start;
|
c->common.hcentered = true;
|
||||||
m.play.u.type1.w = 140;
|
c->common.vcentered = true;
|
||||||
m.play.common.hcentered = true;
|
c->spacing = 4;
|
||||||
m.play.u.type1.label.text = "Play";
|
}
|
||||||
gui_add_child(&m.cnt.common, &m.play.common);
|
|
||||||
|
|
||||||
gui_button_init(&m.settings_btn, GUI_BUTTON_TYPE_1);
|
{
|
||||||
m.settings_btn.on_pressed = menu_on_pressed;
|
struct gui_button *const b = &m.play;
|
||||||
m.settings_btn.arg = &m.settings;
|
|
||||||
m.settings_btn.u.type1.w = 140;
|
gui_button_init(b, GUI_BUTTON_TYPE_1);
|
||||||
m.settings_btn.common.hcentered = true;
|
b->on_pressed = menu_on_pressed;
|
||||||
m.settings_btn.u.type1.label.text = "Settings";
|
b->arg = &m.start;
|
||||||
gui_add_child(&m.cnt.common, &m.settings_btn.common);
|
b->u.type1.w = 140;
|
||||||
|
b->common.hcentered = true;
|
||||||
|
b->u.type1.label.text = "Play";
|
||||||
|
gui_add_child(&m.cnt.common, &b->common);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct gui_button *const b = &m.settings_btn;
|
||||||
|
|
||||||
|
gui_button_init(b, GUI_BUTTON_TYPE_1);
|
||||||
|
b->on_pressed = menu_on_pressed;
|
||||||
|
b->arg = &m.settings;
|
||||||
|
b->u.type1.w = 140;
|
||||||
|
b->common.hcentered = true;
|
||||||
|
b->u.type1.label.text = "Settings";
|
||||||
|
gui_add_child(&m.cnt.common, &b->common);
|
||||||
|
}
|
||||||
|
|
||||||
if (system_can_exit())
|
if (system_can_exit())
|
||||||
{
|
{
|
||||||
gui_button_init(&m.exit_btn, GUI_BUTTON_TYPE_1);
|
struct gui_button *const b = &m.exit_btn;
|
||||||
m.exit_btn.arg = &m.exit;
|
|
||||||
m.exit_btn.u.type1.w = 140;
|
gui_button_init(b, GUI_BUTTON_TYPE_1);
|
||||||
m.exit_btn.common.hcentered = true;
|
b->arg = &m.exit;
|
||||||
m.exit_btn.u.type1.label.text = "Exit";
|
b->u.type1.w = 140;
|
||||||
m.exit_btn.on_pressed = menu_on_pressed;
|
b->common.hcentered = true;
|
||||||
gui_add_child(&m.cnt.common, &m.exit_btn.common);
|
b->u.type1.label.text = "Exit";
|
||||||
|
b->on_pressed = menu_on_pressed;
|
||||||
|
gui_add_child(&m.cnt.common, &b->common);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!m.start && !m.settings && !c->p.common.exit)
|
while (!m.start && !m.settings && !c->p.common.exit)
|
||||||
|
|
Loading…
Reference in New Issue