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 *) =
|
||||
{
|
||||
[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);
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
#include <net.h>
|
||||
#include <packet.h>
|
||||
#include <util.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
enum
|
||||
|
@ -27,8 +29,8 @@ struct gamecfg_menu
|
|||
{
|
||||
char chat_in[PACKET_MAX_MESSAGE_LEN],
|
||||
chat[CHAT_ENTRIES][TOTAL_MESSAGE_LEN];
|
||||
char chat_label[sizeof "Chat (6)"];
|
||||
size_t chat_i, unread_messages;
|
||||
char chat_label[sizeof "Chat (255)"];
|
||||
uint8_t chat_i, unread_messages;
|
||||
struct gui_container bcnt;
|
||||
struct gui_button start, back;
|
||||
struct net_host *host;
|
||||
|
@ -653,7 +655,7 @@ static void on_packet_received(const net_peer peer,
|
|||
m->unread_messages++;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,37 +40,51 @@ int menu_main(struct menu_common *const c)
|
|||
{
|
||||
struct main_menu m = {0};
|
||||
|
||||
gui_container_init(&m.cnt);
|
||||
m.cnt.mode = GUI_CONTAINER_MODE_V;
|
||||
m.cnt.common.hcentered = true;
|
||||
m.cnt.common.vcentered = true;
|
||||
m.cnt.spacing = 4;
|
||||
{
|
||||
struct gui_container *const c = &m.cnt;
|
||||
|
||||
gui_button_init(&m.play, GUI_BUTTON_TYPE_1);
|
||||
m.play.on_pressed = menu_on_pressed;
|
||||
m.play.arg = &m.start;
|
||||
m.play.u.type1.w = 140;
|
||||
m.play.common.hcentered = true;
|
||||
m.play.u.type1.label.text = "Play";
|
||||
gui_add_child(&m.cnt.common, &m.play.common);
|
||||
gui_container_init(c);
|
||||
c->mode = GUI_CONTAINER_MODE_V;
|
||||
c->common.hcentered = true;
|
||||
c->common.vcentered = true;
|
||||
c->spacing = 4;
|
||||
}
|
||||
|
||||
gui_button_init(&m.settings_btn, GUI_BUTTON_TYPE_1);
|
||||
m.settings_btn.on_pressed = menu_on_pressed;
|
||||
m.settings_btn.arg = &m.settings;
|
||||
m.settings_btn.u.type1.w = 140;
|
||||
m.settings_btn.common.hcentered = true;
|
||||
m.settings_btn.u.type1.label.text = "Settings";
|
||||
gui_add_child(&m.cnt.common, &m.settings_btn.common);
|
||||
{
|
||||
struct gui_button *const b = &m.play;
|
||||
|
||||
gui_button_init(b, GUI_BUTTON_TYPE_1);
|
||||
b->on_pressed = menu_on_pressed;
|
||||
b->arg = &m.start;
|
||||
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())
|
||||
{
|
||||
gui_button_init(&m.exit_btn, GUI_BUTTON_TYPE_1);
|
||||
m.exit_btn.arg = &m.exit;
|
||||
m.exit_btn.u.type1.w = 140;
|
||||
m.exit_btn.common.hcentered = true;
|
||||
m.exit_btn.u.type1.label.text = "Exit";
|
||||
m.exit_btn.on_pressed = menu_on_pressed;
|
||||
gui_add_child(&m.cnt.common, &m.exit_btn.common);
|
||||
struct gui_button *const b = &m.exit_btn;
|
||||
|
||||
gui_button_init(b, GUI_BUTTON_TYPE_1);
|
||||
b->arg = &m.exit;
|
||||
b->u.type1.w = 140;
|
||||
b->common.hcentered = true;
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue