mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
DJUI: Added 'Three Panel' component
This commit is contained in:
parent
56a6532d9c
commit
5131665be2
13 changed files with 238 additions and 100 deletions
|
@ -3957,6 +3957,7 @@
|
|||
<ClCompile Include="..\src\pc\djui\djui_rect.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_root.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_text.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_three_panel.c" />
|
||||
<ClCompile Include="..\src\pc\fs\dirtree.c" />
|
||||
<ClCompile Include="..\src\pc\fs\fs.c" />
|
||||
<ClCompile Include="..\src\pc\fs\fs_packtype_dir.c" />
|
||||
|
@ -4386,6 +4387,7 @@
|
|||
<ClInclude Include="..\src\pc\djui\djui_rect.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_root.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_text.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_three_panel.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_types.h" />
|
||||
<ClInclude Include="..\src\pc\network\branch.h" />
|
||||
<ClInclude Include="..\src\pc\network\discord\activity.h" />
|
||||
|
|
|
@ -15210,6 +15210,9 @@
|
|||
<ClCompile Include="..\src\pc\djui\djui_cursor.c">
|
||||
<Filter>Source Files\src\pc\djui\component</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pc\djui\djui_three_panel.c">
|
||||
<Filter>Source Files\src\pc\djui\component</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\actors\common0.h">
|
||||
|
@ -16240,5 +16243,8 @@
|
|||
<ClInclude Include="..\src\pc\djui\djui_cursor.h">
|
||||
<Filter>Source Files\src\pc\djui\component</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pc\djui\djui_three_panel.h">
|
||||
<Filter>Source Files\src\pc\djui\component</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash
|
||||
make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 && winpty cgdb ./build/us_pc/sm64.us.f3dex2e.exe -ex 'break debug_breakpoint_here'
|
||||
make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 && winpty cgdb ./build/us_pc/sm64.us.f3dex2e.exe -ex 'break debug_breakpoint_here' -ex 'run --server 27015 --configfile sm64config_server.txt'
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "djui_rect.h"
|
||||
#include "djui_text.h"
|
||||
#include "djui_image.h"
|
||||
#include "djui_three_panel.h"
|
||||
|
||||
#include "djui_button.h"
|
||||
#include "djui_flow_layout.h"
|
||||
|
|
|
@ -154,7 +154,11 @@ void djui_base_compute(struct DjuiBase* base) {
|
|||
comp->width = width;
|
||||
comp->height = height;
|
||||
|
||||
base->elem = base->comp;
|
||||
struct DjuiBaseRect* elem = &base->elem;
|
||||
elem->x = x;
|
||||
elem->y = y;
|
||||
elem->width = width;
|
||||
elem->height = height;
|
||||
|
||||
djui_base_clip(base);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ static f32 djui_font_title_char_width(char c) {
|
|||
|
||||
static const struct DjuiFont sDjuiFontTitle = {
|
||||
.charWidth = 1.0f,
|
||||
.charHeight = 1.0f,
|
||||
.charHeight = 0.9f,
|
||||
.lineHeight = 0.7f,
|
||||
.defaultFontScale = 64.0f,
|
||||
.rotatedUV = false,
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
#include "djui.h"
|
||||
|
||||
struct DjuiRect* gPanelMainMenu = NULL;
|
||||
static struct DjuiFlowLayout* sButtonContainer = NULL;
|
||||
static struct DjuiText* sTitleText = NULL;
|
||||
static struct DjuiText* sVersionText = NULL;
|
||||
|
||||
static void djui_panel_main_render_pre(struct DjuiBase* base, bool* skipRender) {
|
||||
sTitleText->base.height.value = sButtonContainer->base.clip.y - gPanelMainMenu->base.comp.y;
|
||||
sVersionText->base.height.value = sTitleText->base.height.value;
|
||||
}
|
||||
struct DjuiThreePanel* gPanelMainMenu = NULL;
|
||||
|
||||
void djui_panel_main_create(void) {
|
||||
gPanelMainMenu = djui_rect_create(&gDjuiRoot->base);
|
||||
f32 bodyHeight = 64 * 4 + 16 * 3;
|
||||
|
||||
gPanelMainMenu = djui_three_panel_create(&gDjuiRoot->base, 128, bodyHeight, 32);
|
||||
djui_base_set_size_type(&gPanelMainMenu->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&gPanelMainMenu->base, 340.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&gPanelMainMenu->base, 0, 0, 0, 240);
|
||||
|
@ -19,49 +13,44 @@ void djui_panel_main_create(void) {
|
|||
djui_base_set_border_width(&gPanelMainMenu->base, 8);
|
||||
djui_base_set_padding(&gPanelMainMenu->base, 16, 16, 16, 16);
|
||||
{
|
||||
sButtonContainer = djui_flow_layout_create(&gPanelMainMenu->base);
|
||||
djui_base_set_alignment(&sButtonContainer->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_base_set_size_type(&sButtonContainer->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sButtonContainer->base, 1.0f, 64 * 4 + 16 * 3);
|
||||
djui_base_set_color(&sButtonContainer->base, 0, 0, 0, 0);
|
||||
djui_flow_layout_set_margin(sButtonContainer, 16);
|
||||
djui_flow_layout_set_flow_direction(sButtonContainer, DJUI_FLOW_DIR_DOWN);
|
||||
struct DjuiText* header = djui_text_create(&gPanelMainMenu->base, "\\#ff0800\\SM\\#1be700\\64\\#00b3ff\\EX\n\\#ffef00\\COOP");
|
||||
djui_base_set_color(&header->base, 255, 8, 0, 255);
|
||||
djui_text_set_font(header, &gDjuiFonts[1]);
|
||||
djui_text_set_font_scale(header, gDjuiFonts[1].defaultFontScale);
|
||||
djui_text_set_alignment(header, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
|
||||
struct DjuiFlowLayout* body = djui_flow_layout_create(&gPanelMainMenu->base);
|
||||
djui_base_set_size_type(&body->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&body->base, 1.0f, bodyHeight);
|
||||
djui_base_set_color(&body->base, 0, 0, 0, 0);
|
||||
djui_flow_layout_set_margin(body, 16);
|
||||
djui_flow_layout_set_flow_direction(body, DJUI_FLOW_DIR_DOWN);
|
||||
{
|
||||
struct DjuiButton* button1 = djui_button_create(&sButtonContainer->base, "Host");
|
||||
struct DjuiButton* button1 = djui_button_create(&body->base, "Host");
|
||||
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button1->base, 1.0f, 64);
|
||||
djui_cursor_input_controlled_center(&button1->base);
|
||||
|
||||
struct DjuiButton* button2 = djui_button_create(&sButtonContainer->base, "Join");
|
||||
struct DjuiButton* button2 = djui_button_create(&body->base, "Join");
|
||||
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button2->base, 1.0f, 64);
|
||||
|
||||
struct DjuiButton* button3 = djui_button_create(&sButtonContainer->base, "Options");
|
||||
struct DjuiButton* button3 = djui_button_create(&body->base, "Options");
|
||||
djui_base_set_size_type(&button3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button3->base, 1.0f, 64);
|
||||
button3->base.interactable->on_click = djui_panel_options_open;
|
||||
|
||||
struct DjuiButton* button4 = djui_button_create(&sButtonContainer->base, "Quit");
|
||||
struct DjuiButton* button4 = djui_button_create(&body->base, "Quit");
|
||||
djui_base_set_size_type(&button4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button4->base, 1.0f, 64);
|
||||
button4->base.interactable->on_click = djui_panel_quit_open;
|
||||
}
|
||||
|
||||
sTitleText = djui_text_create(&gPanelMainMenu->base, "\\#ff0800\\SM\\#1be700\\64\\#00b3ff\\EX\n\\#ffef00\\COOP");
|
||||
djui_base_set_alignment(&sTitleText->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
||||
djui_base_set_size_type(&sTitleText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sTitleText->base, 1.0f, 1.0f);
|
||||
djui_base_set_color(&sTitleText->base, 255, 8, 0, 255);
|
||||
djui_text_set_alignment(sTitleText, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_text_set_font(sTitleText, &gDjuiFonts[1]);
|
||||
djui_text_set_font_scale(sTitleText, gDjuiFonts[1].defaultFontScale);
|
||||
sTitleText->base.on_render_pre = djui_panel_main_render_pre;
|
||||
|
||||
sVersionText = djui_text_create(&gPanelMainMenu->base, "version - unst 5");
|
||||
djui_base_set_alignment(&sVersionText->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
|
||||
djui_base_set_size_type(&sVersionText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sVersionText->base, 1.0f, 1.0f);
|
||||
djui_base_set_color(&sVersionText->base, 50, 50, 50, 255);
|
||||
djui_text_set_alignment(sVersionText, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
struct DjuiText* footer = djui_text_create(&gPanelMainMenu->base, "version - unst 5");
|
||||
djui_base_set_alignment(&footer->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
|
||||
djui_base_set_size_type(&footer->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&footer->base, 1.0f, 1.0f);
|
||||
djui_base_set_color(&footer->base, 50, 50, 50, 255);
|
||||
djui_text_set_alignment(footer, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
extern struct DjuiRect* gPanelMainMenu;
|
||||
extern struct DjuiThreePanel* gPanelMainMenu;
|
||||
|
||||
void djui_panel_main_create(void);
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
#include "djui.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
|
||||
static struct DjuiRect* sPanelOptions = NULL;
|
||||
static struct DjuiFlowLayout* sButtonContainer = NULL;
|
||||
static struct DjuiText* sTitleText = NULL;
|
||||
static struct DjuiThreePanel* sPanelOptions = NULL;
|
||||
static struct DjuiButton* sButtonBack = NULL;
|
||||
static struct DjuiBase* sCaller = NULL;
|
||||
static bool sOpening = false;
|
||||
static bool sClosing = false;
|
||||
|
||||
static void djui_panel_options_render_pre(struct DjuiBase* base, bool* skipRender) {
|
||||
sTitleText->base.height.value = sButtonContainer->base.clip.y - sPanelOptions->base.comp.y;
|
||||
|
||||
float yMove = gPanelMainMenu->base.elem.height;
|
||||
static float movement = 0;
|
||||
if (sOpening) {
|
||||
|
@ -50,9 +46,11 @@ static void djui_panel_options_back(struct DjuiBase* base) {
|
|||
}
|
||||
|
||||
void djui_panel_options_create(void) {
|
||||
f32 bodyHeight = 64 * 6 + 16 * 5;
|
||||
sOpening = true;
|
||||
sClosing = false;
|
||||
sPanelOptions = djui_rect_create(&gDjuiRoot->base);
|
||||
|
||||
sPanelOptions = djui_three_panel_create(&gDjuiRoot->base, 64, bodyHeight, 0);
|
||||
djui_base_set_size_type(&sPanelOptions->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&sPanelOptions->base, 340.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&sPanelOptions->base, 0, 0, 0, 240);
|
||||
|
@ -61,48 +59,48 @@ void djui_panel_options_create(void) {
|
|||
djui_base_set_padding(&sPanelOptions->base, 16, 16, 16, 16);
|
||||
sPanelOptions->base.on_render_pre = djui_panel_options_render_pre;
|
||||
{
|
||||
sButtonContainer = djui_flow_layout_create(&sPanelOptions->base);
|
||||
djui_base_set_alignment(&sButtonContainer->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_base_set_size_type(&sButtonContainer->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sButtonContainer->base, 1.0f, 64 * 6 + 16 * 5);
|
||||
djui_base_set_color(&sButtonContainer->base, 0, 0, 0, 0);
|
||||
djui_flow_layout_set_margin(sButtonContainer, 16);
|
||||
djui_flow_layout_set_flow_direction(sButtonContainer, DJUI_FLOW_DIR_DOWN);
|
||||
struct DjuiText* header = djui_text_create(&sPanelOptions->base, "\\#ff0800\\O\\#1be700\\P\\#00b3ff\\T\\#ffef00\\I\\#ff0800\\O\\#1be700\\N\\#00b3ff\\S");
|
||||
djui_base_set_alignment(&header->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
||||
djui_base_set_size_type(&header->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&header->base, 1.0f, 1.0f);
|
||||
djui_base_set_color(&header->base, 255, 8, 0, 255);
|
||||
djui_text_set_alignment(header, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_text_set_font(header, &gDjuiFonts[1]);
|
||||
djui_text_set_font_scale(header, gDjuiFonts[1].defaultFontScale);
|
||||
|
||||
struct DjuiFlowLayout* body = djui_flow_layout_create(&sPanelOptions->base);
|
||||
djui_base_set_alignment(&body->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_base_set_size_type(&body->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&body->base, 1.0f, bodyHeight);
|
||||
djui_base_set_color(&body->base, 0, 0, 0, 0);
|
||||
djui_flow_layout_set_margin(body, 16);
|
||||
djui_flow_layout_set_flow_direction(body, DJUI_FLOW_DIR_DOWN);
|
||||
{
|
||||
struct DjuiButton* button1 = djui_button_create(&sButtonContainer->base, "Player");
|
||||
struct DjuiButton* button1 = djui_button_create(&body->base, "Player");
|
||||
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button1->base, 1.0f, 64);
|
||||
|
||||
struct DjuiButton* button2 = djui_button_create(&sButtonContainer->base, "Camera");
|
||||
struct DjuiButton* button2 = djui_button_create(&body->base, "Camera");
|
||||
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button2->base, 1.0f, 64);
|
||||
|
||||
struct DjuiButton* button3 = djui_button_create(&sButtonContainer->base, "Controls");
|
||||
struct DjuiButton* button3 = djui_button_create(&body->base, "Controls");
|
||||
djui_base_set_size_type(&button3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button3->base, 1.0f, 64);
|
||||
|
||||
struct DjuiButton* button4 = djui_button_create(&sButtonContainer->base, "Display");
|
||||
struct DjuiButton* button4 = djui_button_create(&body->base, "Display");
|
||||
djui_base_set_size_type(&button4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button4->base, 1.0f, 64);
|
||||
|
||||
struct DjuiButton* button5 = djui_button_create(&sButtonContainer->base, "Sound");
|
||||
struct DjuiButton* button5 = djui_button_create(&body->base, "Sound");
|
||||
djui_base_set_size_type(&button5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button5->base, 1.0f, 64);
|
||||
|
||||
sButtonBack = djui_button_create(&sButtonContainer->base, "Back");
|
||||
sButtonBack = djui_button_create(&body->base, "Back");
|
||||
djui_base_set_size_type(&sButtonBack->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sButtonBack->base, 1.0f, 64);
|
||||
sButtonBack->base.interactable->on_click = djui_panel_options_back;
|
||||
}
|
||||
|
||||
sTitleText = djui_text_create(&sPanelOptions->base, "\\#ff0800\\O\\#1be700\\P\\#00b3ff\\T\\#ffef00\\I\\#ff0800\\O\\#1be700\\N\\#00b3ff\\S");
|
||||
djui_base_set_alignment(&sTitleText->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
||||
djui_base_set_size_type(&sTitleText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sTitleText->base, 1.0f, 1.0f);
|
||||
djui_base_set_color(&sTitleText->base, 255, 8, 0, 255);
|
||||
djui_text_set_alignment(sTitleText, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_text_set_font(sTitleText, &gDjuiFonts[1]);
|
||||
djui_text_set_font_scale(sTitleText, gDjuiFonts[1].defaultFontScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
#include "djui.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
|
||||
static struct DjuiRect* sPanelQuit = NULL;
|
||||
static struct DjuiFlowLayout* sButtonContainer = NULL;
|
||||
static struct DjuiText* sTitleText = NULL;
|
||||
static struct DjuiThreePanel* sPanelQuit = NULL;
|
||||
static struct DjuiButton* sButtonNo = NULL;
|
||||
static struct DjuiBase* sCaller = NULL;
|
||||
static bool sOpening = false;
|
||||
static bool sClosing = false;
|
||||
|
||||
static void djui_panel_quit_render_pre(struct DjuiBase* base, bool* skipRender) {
|
||||
sTitleText->base.height.value = sButtonContainer->base.clip.y - sPanelQuit->base.comp.y;
|
||||
|
||||
float yMove = gPanelMainMenu->base.elem.height;
|
||||
static float movement = 0;
|
||||
if (sOpening) {
|
||||
|
@ -53,9 +49,11 @@ static void djui_panel_quit_no(struct DjuiBase* base) {
|
|||
}
|
||||
|
||||
static void djui_panel_quit_create(void) {
|
||||
f32 bodyHeight = 64 * 3 + 16 * 2;
|
||||
sOpening = true;
|
||||
sClosing = false;
|
||||
sPanelQuit = djui_rect_create(&gDjuiRoot->base);
|
||||
|
||||
sPanelQuit = djui_three_panel_create(&gDjuiRoot->base, 64, bodyHeight, 0);
|
||||
djui_base_set_size_type(&sPanelQuit->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&sPanelQuit->base, 340.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&sPanelQuit->base, 0, 0, 0, 230);
|
||||
|
@ -65,39 +63,39 @@ static void djui_panel_quit_create(void) {
|
|||
djui_base_set_enabled(&sPanelQuit->base, false);
|
||||
sPanelQuit->base.on_render_pre = djui_panel_quit_render_pre;
|
||||
{
|
||||
sButtonContainer = djui_flow_layout_create(&sPanelQuit->base);
|
||||
djui_base_set_alignment(&sButtonContainer->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_base_set_size_type(&sButtonContainer->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sButtonContainer->base, 1.0f, 64 * 3 + 16 * 2);
|
||||
djui_base_set_color(&sButtonContainer->base, 0, 0, 0, 0);
|
||||
djui_flow_layout_set_margin(sButtonContainer, 16);
|
||||
djui_flow_layout_set_flow_direction(sButtonContainer, DJUI_FLOW_DIR_DOWN);
|
||||
struct DjuiText* header = djui_text_create(&sPanelQuit->base, "\\#ff0800\\Q\\#1be700\\U\\#00b3ff\\I\\#ffef00\\T");
|
||||
djui_base_set_alignment(&header->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
||||
djui_base_set_size_type(&header->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&header->base, 1.0f, 1.0f);
|
||||
djui_base_set_color(&header->base, 255, 8, 0, 255);
|
||||
djui_text_set_alignment(header, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_text_set_font(header, &gDjuiFonts[1]);
|
||||
djui_text_set_font_scale(header, gDjuiFonts[1].defaultFontScale);
|
||||
|
||||
struct DjuiFlowLayout* body = djui_flow_layout_create(&sPanelQuit->base);
|
||||
djui_base_set_alignment(&body->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_base_set_size_type(&body->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&body->base, 1.0f, bodyHeight);
|
||||
djui_base_set_color(&body->base, 0, 0, 0, 0);
|
||||
djui_flow_layout_set_margin(body, 16);
|
||||
djui_flow_layout_set_flow_direction(body, DJUI_FLOW_DIR_DOWN);
|
||||
{
|
||||
struct DjuiText* text = djui_text_create(&sButtonContainer->base, "Are you sure you want to quit?");
|
||||
struct DjuiText* text = djui_text_create(&body->base, "Are you sure you want to quit?");
|
||||
djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&text->base, 1.0f, 64);
|
||||
djui_base_set_color(&text->base, 200, 200, 200, 255);
|
||||
djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
|
||||
struct DjuiButton* button1 = djui_button_create(&sButtonContainer->base, "Yes");
|
||||
struct DjuiButton* button1 = djui_button_create(&body->base, "Yes");
|
||||
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button1->base, 1.0f, 64);
|
||||
button1->base.interactable->on_click = djui_panel_quit_yes;
|
||||
|
||||
sButtonNo = djui_button_create(&sButtonContainer->base, "No");
|
||||
sButtonNo = djui_button_create(&body->base, "No");
|
||||
djui_base_set_size_type(&sButtonNo->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sButtonNo->base, 1.0f, 64);
|
||||
sButtonNo->base.interactable->on_click = djui_panel_quit_no;
|
||||
}
|
||||
|
||||
sTitleText = djui_text_create(&sPanelQuit->base, "\\#ff0800\\Q\\#1be700\\U\\#00b3ff\\I\\#ffef00\\T");
|
||||
djui_base_set_alignment(&sTitleText->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
||||
djui_base_set_size_type(&sTitleText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&sTitleText->base, 1.0f, 1.0f);
|
||||
djui_base_set_color(&sTitleText->base, 255, 8, 0, 255);
|
||||
djui_text_set_alignment(sTitleText, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_text_set_font(sTitleText, &gDjuiFonts[1]);
|
||||
djui_text_set_font_scale(sTitleText, gDjuiFonts[1].defaultFontScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,9 +113,9 @@ static void djui_text_read_line(struct DjuiText* text, u16* index, f32* lineWidt
|
|||
*lineWidth = 0;
|
||||
char lastC = '\0';
|
||||
|
||||
f32 ellipsesWidth = gDialogCharWidths[0x3F] * 3.0f;
|
||||
/*f32 ellipsesWidth = gDialogCharWidths[0x3F] * 3.0f;
|
||||
u16 lastSafeEllipsesIndex = *index;
|
||||
u16 lastSafeEllipsesLineWidth = *lineWidth + ellipsesWidth;
|
||||
u16 lastSafeEllipsesLineWidth = *lineWidth + ellipsesWidth;*/
|
||||
|
||||
bool skipping = false;
|
||||
while (message[*index] != '\0') {
|
||||
|
@ -152,21 +152,21 @@ static void djui_text_read_line(struct DjuiText* text, u16* index, f32* lineWidt
|
|||
*lineWidth += charWidth;
|
||||
|
||||
// check for safe ellipses index
|
||||
if (onLastLine && ((*lineWidth + ellipsesWidth) < maxLineWidth)) {
|
||||
/*if (onLastLine && ((*lineWidth + ellipsesWidth) < maxLineWidth)) {
|
||||
lastSafeEllipsesIndex = *index;
|
||||
lastSafeEllipsesLineWidth = *lineWidth + ellipsesWidth;
|
||||
}
|
||||
}*/
|
||||
|
||||
*index = *index + 1;
|
||||
lastC = c;
|
||||
}
|
||||
|
||||
// check to see if we should replace the end of the last line with ellipses
|
||||
if (onLastLine && message[*index] != '\0') {
|
||||
/*if (onLastLine && message[*index] != '\0') {
|
||||
*index = lastSafeEllipsesIndex;
|
||||
*lineWidth = lastSafeEllipsesLineWidth;
|
||||
*ellipses = true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
static int djui_text_render_line_parse_escape(struct DjuiText* text, u16 startIndex, u16 endIndex) {
|
||||
|
|
121
src/pc/djui/djui_three_panel.c
Normal file
121
src/pc/djui/djui_three_panel.c
Normal file
|
@ -0,0 +1,121 @@
|
|||
#include "djui.h"
|
||||
|
||||
|
||||
void djui_three_panel_set_min_header_size_type(struct DjuiThreePanel* threePanel, enum DjuiScreenValueType minHeaderSizeType) {
|
||||
threePanel->minHeaderSize.type = minHeaderSizeType;
|
||||
}
|
||||
|
||||
void djui_three_panel_set_min_header_size(struct DjuiThreePanel* threePanel, f32 minHeaderSize) {
|
||||
threePanel->minHeaderSize.value = minHeaderSize;
|
||||
}
|
||||
|
||||
void djui_three_panel_set_body_size_type(struct DjuiThreePanel* threePanel, enum DjuiScreenValueType bodySizeType) {
|
||||
threePanel->bodySize.type = bodySizeType;
|
||||
}
|
||||
|
||||
void djui_three_panel_set_body_size(struct DjuiThreePanel* threePanel, f32 bodySize) {
|
||||
threePanel->bodySize.value = bodySize;
|
||||
}
|
||||
|
||||
void djui_three_panel_set_min_footer_size_type(struct DjuiThreePanel* threePanel, enum DjuiScreenValueType minFooterSizeType) {
|
||||
threePanel->minFooterSize.type = minFooterSizeType;
|
||||
}
|
||||
|
||||
void djui_three_panel_set_min_footer_size(struct DjuiThreePanel* threePanel, f32 minFooterSize) {
|
||||
threePanel->minFooterSize.value = minFooterSize;
|
||||
}
|
||||
|
||||
////////////
|
||||
// events //
|
||||
////////////
|
||||
|
||||
void djui_three_panel_render(struct DjuiBase* base) {
|
||||
struct DjuiThreePanel* threePanel = (struct DjuiThreePanel*)base;
|
||||
|
||||
struct DjuiBase* children[3] = { NULL };
|
||||
struct DjuiBaseChild* child = base->child;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (child == NULL || child->base == NULL) { break; }
|
||||
children[i] = child->base;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
struct DjuiBase* head = children[0];
|
||||
struct DjuiBase* body = children[1];
|
||||
struct DjuiBase* foot = children[2];
|
||||
|
||||
if (body == NULL) { return; }
|
||||
|
||||
struct DjuiBaseRect* parentComp = &base->comp;
|
||||
f32 tPad = (base->padding.top.type == DJUI_SVT_RELATIVE) ? parentComp->height * base->padding.top.value : base->padding.top.value;
|
||||
f32 bPad = (base->padding.bottom.type == DJUI_SVT_RELATIVE) ? parentComp->height * base->padding.bottom.value : base->padding.bottom.value;
|
||||
|
||||
f32 myHeight = base->comp.height - tPad - bPad;
|
||||
f32 minHeaderSize = (threePanel->minHeaderSize.type == DJUI_SVT_RELATIVE) ? base->comp.height * threePanel->minHeaderSize.value : threePanel->minHeaderSize.value;
|
||||
f32 minFooterSize = (threePanel->minFooterSize.type == DJUI_SVT_RELATIVE) ? base->comp.height * threePanel->minFooterSize.value : threePanel->minFooterSize.value;
|
||||
f32 largestMinSize = fmax(minHeaderSize, minFooterSize);
|
||||
|
||||
f32 headerSize = minHeaderSize;
|
||||
f32 bodySize = (threePanel->bodySize.type == DJUI_SVT_RELATIVE) ? base->comp.height * threePanel->bodySize.value : threePanel->bodySize.value;
|
||||
f32 footerSize = minFooterSize;
|
||||
|
||||
if (minHeaderSize + minFooterSize >= myHeight) {
|
||||
bodySize = 0;
|
||||
headerSize = myHeight * (minHeaderSize / (minHeaderSize + minFooterSize));
|
||||
footerSize = myHeight * (minFooterSize / (minHeaderSize + minFooterSize));
|
||||
} else if (minHeaderSize + bodySize + minFooterSize >= myHeight) {
|
||||
bodySize = myHeight - headerSize - footerSize;
|
||||
} else if (largestMinSize * 2.0f + bodySize >= myHeight) {
|
||||
if (minHeaderSize > minFooterSize) {
|
||||
footerSize = myHeight - headerSize - bodySize;
|
||||
} else {
|
||||
headerSize = myHeight - footerSize - bodySize;
|
||||
}
|
||||
} else {
|
||||
headerSize = (myHeight - bodySize) / 2.0f;
|
||||
footerSize = (myHeight - bodySize) / 2.0f;
|
||||
}
|
||||
|
||||
if (head != NULL) {
|
||||
djui_base_set_location_type(head, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_location(head, 0, 0);
|
||||
djui_base_set_size_type(head, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(head, 1.0f, headerSize);
|
||||
djui_base_set_alignment(head, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||
}
|
||||
|
||||
if (body != NULL) {
|
||||
djui_base_set_location_type(body, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_location(body, 0, headerSize);
|
||||
djui_base_set_size_type(body, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(body, 1.0f, bodySize);
|
||||
djui_base_set_alignment(body, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||
}
|
||||
|
||||
if (foot != NULL) {
|
||||
djui_base_set_location_type(foot, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_location(foot, 0, headerSize + bodySize);
|
||||
djui_base_set_size_type(foot, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(foot, 1.0f, footerSize);
|
||||
djui_base_set_alignment(foot, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||
}
|
||||
|
||||
djui_rect_render(base);
|
||||
}
|
||||
|
||||
static void djui_three_panel_destroy(struct DjuiBase* base) {
|
||||
struct DjuiThreePanel* threePanel = (struct DjuiThreePanel*)base;
|
||||
free(threePanel);
|
||||
}
|
||||
|
||||
struct DjuiThreePanel* djui_three_panel_create(struct DjuiBase* parent, f32 minHeaderSize, f32 bodySize, f32 minFooterSize) {
|
||||
struct DjuiThreePanel* threePanel = malloc(sizeof(struct DjuiThreePanel));
|
||||
struct DjuiBase* base = &threePanel->base;
|
||||
|
||||
djui_base_init(parent, base, djui_three_panel_render, djui_three_panel_destroy);
|
||||
djui_three_panel_set_min_header_size(threePanel, minHeaderSize);
|
||||
djui_three_panel_set_body_size(threePanel, bodySize);
|
||||
djui_three_panel_set_min_footer_size(threePanel, minFooterSize);
|
||||
|
||||
return threePanel;
|
||||
}
|
19
src/pc/djui/djui_three_panel.h
Normal file
19
src/pc/djui/djui_three_panel.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
#pragma pack(1)
|
||||
struct DjuiThreePanel {
|
||||
struct DjuiBase base;
|
||||
struct DjuiScreenValue minHeaderSize;
|
||||
struct DjuiScreenValue bodySize;
|
||||
struct DjuiScreenValue minFooterSize;
|
||||
};
|
||||
|
||||
void djui_three_panel_set_min_header_size_type(struct DjuiThreePanel* threePanel, enum DjuiScreenValueType minHeaderSizeType);
|
||||
void djui_three_panel_set_min_header_size(struct DjuiThreePanel* threePanel, f32 minHeaderSize);
|
||||
void djui_three_panel_set_body_size_type(struct DjuiThreePanel* threePanel, enum DjuiScreenValueType bodySizeType);
|
||||
void djui_three_panel_set_body_size(struct DjuiThreePanel* threePanel, f32 bodySize);
|
||||
void djui_three_panel_set_min_footer_size_type(struct DjuiThreePanel* threePanel, enum DjuiScreenValueType minFooterSizeType);
|
||||
void djui_three_panel_set_min_footer_size(struct DjuiThreePanel* threePanel, f32 minFooterSize);
|
||||
|
||||
struct DjuiThreePanel* djui_three_panel_create(struct DjuiBase* parent, f32 minHeaderSize, f32 bodySize, f32 minFooterSize);
|
Loading…
Reference in a new issue