mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
DJUI: Wrote active panel system
This commit is contained in:
parent
5131665be2
commit
05c32ea73e
16 changed files with 278 additions and 161 deletions
|
@ -3950,10 +3950,12 @@
|
|||
<ClCompile Include="..\src\pc\djui\djui_gfx.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_image.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_interactable.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_debug.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_main.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_options.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_quit.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_sound.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_rect.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_root.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_text.c" />
|
||||
|
@ -4380,10 +4382,12 @@
|
|||
<ClInclude Include="..\src\pc\djui\djui_gfx.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_image.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_interactable.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_debug.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_main.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_options.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_quit.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_sound.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_rect.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_root.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_text.h" />
|
||||
|
|
|
@ -15213,6 +15213,12 @@
|
|||
<ClCompile Include="..\src\pc\djui\djui_three_panel.c">
|
||||
<Filter>Source Files\src\pc\djui\component</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_sound.c">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel.c">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\actors\common0.h">
|
||||
|
@ -16246,5 +16252,11 @@
|
|||
<ClInclude Include="..\src\pc\djui\djui_three_panel.h">
|
||||
<Filter>Source Files\src\pc\djui\component</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_sound.h">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel.h">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,2 +1,3 @@
|
|||
#!/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'
|
||||
|
|
|
@ -9,7 +9,7 @@ struct DjuiFlowLayout* buttonContainer;
|
|||
static void djui_init(void) {
|
||||
gDjuiRoot = djui_root_create();
|
||||
|
||||
djui_panel_main_create();
|
||||
djui_panel_main_create(NULL);
|
||||
//djui_panel_debug_create();
|
||||
djui_cursor_create();
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ void djui_render(void) {
|
|||
sSavedDisplayListHead = gDisplayListHead;
|
||||
create_dl_ortho_matrix();
|
||||
|
||||
djui_panel_update();
|
||||
|
||||
djui_base_render(&gDjuiRoot->base);
|
||||
|
||||
djui_cursor_update();
|
||||
|
|
|
@ -23,9 +23,11 @@
|
|||
#include "djui_button.h"
|
||||
#include "djui_flow_layout.h"
|
||||
|
||||
#include "djui_panel.h"
|
||||
#include "djui_panel_debug.h"
|
||||
#include "djui_panel_main.h"
|
||||
#include "djui_panel_options.h"
|
||||
#include "djui_panel_sound.h"
|
||||
#include "djui_panel_quit.h"
|
||||
|
||||
extern struct DjuiRoot* gDjuiRoot;
|
||||
|
|
|
@ -106,8 +106,10 @@ void djui_cursor_update(void) {
|
|||
if (sCursorMouseControlled) {
|
||||
sCursorX = mouse_window_x;
|
||||
sCursorY = mouse_window_y;
|
||||
} else if (sInputControlledBase != NULL) {
|
||||
} else {
|
||||
if (sInputControlledBase != NULL) {
|
||||
djui_cursor_base_hover_location(sInputControlledBase, &sCursorX, &sCursorY);
|
||||
}
|
||||
f32 dist = sqrtf(powf(mouse_window_x - sSavedMouseX, 2) + powf(mouse_window_y - sSavedMouseY, 2));
|
||||
if (dist > 5) {
|
||||
sCursorMouseControlled = true;
|
||||
|
|
111
src/pc/djui/djui_panel.c
Normal file
111
src/pc/djui/djui_panel.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
#include "djui.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
|
||||
struct DjuiPanel {
|
||||
struct DjuiBase* base;
|
||||
struct DjuiPanel* parent;
|
||||
struct DjuiBase* defaultElementBase;
|
||||
};
|
||||
|
||||
static struct DjuiPanel* sPanelList = NULL;
|
||||
static struct DjuiPanel* sPanelRemoving = NULL;
|
||||
static f32 sMoveAmount = 0;
|
||||
|
||||
void djui_panel_add(struct DjuiBase* caller, struct DjuiBase* panelBase, struct DjuiBase* defaultElementBase) {
|
||||
bool firstPanel = (sPanelList == NULL);
|
||||
|
||||
// remember element that triggered this panel add
|
||||
if (sPanelList != NULL) {
|
||||
sPanelList->defaultElementBase = caller;
|
||||
}
|
||||
|
||||
// allocate panel
|
||||
struct DjuiPanel* panel = malloc(sizeof(struct DjuiPanel));
|
||||
panel->parent = sPanelList;
|
||||
panel->base = panelBase;
|
||||
panel->defaultElementBase = defaultElementBase;
|
||||
sPanelList = panel;
|
||||
|
||||
// deselect cursor input
|
||||
djui_cursor_input_controlled_center(NULL);
|
||||
|
||||
// hide new panel off screen initially
|
||||
djui_base_set_location(panelBase, 0, -gDjuiRoot->base.height.value);
|
||||
|
||||
// disable panels
|
||||
djui_base_set_enabled(panel->base, false);
|
||||
if (panel->parent != NULL) {
|
||||
djui_base_set_enabled(panel->parent->base, false);
|
||||
}
|
||||
|
||||
// reset move amount
|
||||
sMoveAmount = 0;
|
||||
|
||||
if (firstPanel) {
|
||||
djui_base_set_location(panelBase, 0, 0);
|
||||
djui_cursor_input_controlled_center(panel->defaultElementBase);
|
||||
djui_base_set_enabled(panel->base, true);
|
||||
}
|
||||
}
|
||||
|
||||
void djui_panel_back(void) {
|
||||
if (sPanelList == NULL) { return; }
|
||||
if (sPanelList->parent == NULL) { return; }
|
||||
|
||||
// deselect cursor input
|
||||
djui_cursor_input_controlled_center(NULL);
|
||||
|
||||
// remember which panel to remove
|
||||
sPanelRemoving = sPanelList;
|
||||
|
||||
// disable old active
|
||||
djui_base_set_enabled(sPanelRemoving->base, false);
|
||||
|
||||
// set the previous active
|
||||
sPanelList = sPanelList->parent;
|
||||
|
||||
// reset move amount
|
||||
sMoveAmount = 0;
|
||||
|
||||
// set new active as visible
|
||||
djui_base_set_visible(sPanelList->base, true);
|
||||
}
|
||||
|
||||
void djui_panel_update(void) {
|
||||
if (sPanelList == NULL) { return; }
|
||||
if (sPanelList->base == NULL) { return; }
|
||||
if (sPanelList->base->elem.height == 0) { return; }
|
||||
|
||||
struct DjuiBase* activeBase = sPanelList->base;
|
||||
struct DjuiBase* parentBase = (sPanelList->parent == NULL) ? NULL : sPanelList->parent->base;
|
||||
struct DjuiBase* removingBase = (sPanelRemoving == NULL) ? NULL : sPanelRemoving->base;
|
||||
|
||||
float moveMax = activeBase->elem.height;
|
||||
if (sMoveAmount >= moveMax) { return; }
|
||||
|
||||
sMoveAmount += moveMax / 10.0f;
|
||||
if (sMoveAmount >= moveMax) {
|
||||
sMoveAmount = moveMax;
|
||||
if (parentBase != NULL) {
|
||||
djui_base_set_visible(parentBase, false);
|
||||
}
|
||||
djui_base_set_enabled(activeBase, true);
|
||||
djui_cursor_input_controlled_center(sPanelList->defaultElementBase);
|
||||
|
||||
if (removingBase != NULL) {
|
||||
djui_base_destroy(removingBase);
|
||||
free(sPanelRemoving);
|
||||
sPanelRemoving = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (removingBase != NULL) {
|
||||
activeBase->y.value = moveMax - moveMax * smoothstep(0, moveMax, sMoveAmount);
|
||||
if (sPanelRemoving != NULL) {
|
||||
removingBase->y.value = activeBase->y.value - removingBase->elem.height;
|
||||
}
|
||||
} else if (parentBase != NULL) {
|
||||
activeBase->y.value = moveMax * smoothstep(0, moveMax, sMoveAmount) - moveMax;
|
||||
parentBase->y.value = activeBase->y.value + moveMax;
|
||||
}
|
||||
}
|
6
src/pc/djui/djui_panel.h
Normal file
6
src/pc/djui/djui_panel.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
void djui_panel_add(struct DjuiBase* caller, struct DjuiBase* panelBase, struct DjuiBase* defaultElementBase);
|
||||
void djui_panel_back(void);
|
||||
void djui_panel_update(void);
|
|
@ -1,35 +1,35 @@
|
|||
#include "djui.h"
|
||||
|
||||
struct DjuiThreePanel* gPanelMainMenu = NULL;
|
||||
|
||||
void djui_panel_main_create(void) {
|
||||
void djui_panel_main_create(struct DjuiBase* caller) {
|
||||
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);
|
||||
djui_base_set_border_color(&gPanelMainMenu->base, 0, 0, 0, 200);
|
||||
djui_base_set_border_width(&gPanelMainMenu->base, 8);
|
||||
djui_base_set_padding(&gPanelMainMenu->base, 16, 16, 16, 16);
|
||||
struct DjuiButton* buttonHost = NULL;
|
||||
|
||||
struct DjuiThreePanel* panel = djui_three_panel_create(&gDjuiRoot->base, 128, bodyHeight, 32);
|
||||
djui_base_set_size_type(&panel->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&panel->base, 340.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&panel->base, 0, 0, 0, 240);
|
||||
djui_base_set_border_color(&panel->base, 0, 0, 0, 200);
|
||||
djui_base_set_border_width(&panel->base, 8);
|
||||
djui_base_set_padding(&panel->base, 16, 16, 16, 16);
|
||||
{
|
||||
struct DjuiText* header = djui_text_create(&gPanelMainMenu->base, "\\#ff0800\\SM\\#1be700\\64\\#00b3ff\\EX\n\\#ffef00\\COOP");
|
||||
struct DjuiText* header = djui_text_create(&panel->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);
|
||||
struct DjuiFlowLayout* body = djui_flow_layout_create(&panel->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(&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);
|
||||
buttonHost = djui_button_create(&body->base, "Host");
|
||||
djui_base_set_size_type(&buttonHost->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&buttonHost->base, 1.0f, 64);
|
||||
djui_cursor_input_controlled_center(&buttonHost->base);
|
||||
|
||||
struct DjuiButton* button2 = djui_button_create(&body->base, "Join");
|
||||
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
|
@ -38,19 +38,20 @@ void djui_panel_main_create(void) {
|
|||
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;
|
||||
button3->base.interactable->on_click = djui_panel_options_create;
|
||||
|
||||
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;
|
||||
button4->base.interactable->on_click = djui_panel_quit_create;
|
||||
}
|
||||
|
||||
struct DjuiText* footer = djui_text_create(&gPanelMainMenu->base, "version - unst 5");
|
||||
djui_base_set_alignment(&footer->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
|
||||
struct DjuiText* footer = djui_text_create(&panel->base, "version - unst 5");
|
||||
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);
|
||||
}
|
||||
|
||||
djui_panel_add(caller, &panel->base, &buttonHost->base);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
extern struct DjuiThreePanel* gPanelMainMenu;
|
||||
|
||||
void djui_panel_main_create(void);
|
||||
void djui_panel_main_create(struct DjuiBase* caller);
|
||||
|
|
|
@ -1,66 +1,24 @@
|
|||
#include "djui.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
|
||||
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) {
|
||||
float yMove = gPanelMainMenu->base.elem.height;
|
||||
static float movement = 0;
|
||||
if (sOpening) {
|
||||
movement += yMove / 10.0f;
|
||||
if (movement >= yMove) {
|
||||
movement = yMove;
|
||||
sOpening = false;
|
||||
djui_base_set_enabled(&sPanelOptions->base, true);
|
||||
djui_cursor_input_controlled_center(&sButtonBack->base);
|
||||
}
|
||||
} else if (sClosing) {
|
||||
movement -= yMove / 10.0f;
|
||||
if (movement <= 0) {
|
||||
movement = 0;
|
||||
sClosing = false;
|
||||
djui_base_destroy(&sPanelOptions->base);
|
||||
sPanelOptions = NULL;
|
||||
*skipRender = true;
|
||||
djui_base_set_enabled(&gPanelMainMenu->base, true);
|
||||
gPanelMainMenu->base.y.value = 0;
|
||||
djui_cursor_input_controlled_center(sCaller);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
movement = yMove;
|
||||
}
|
||||
|
||||
gPanelMainMenu->base.y.value = yMove * smoothstep(0, yMove, movement);
|
||||
sPanelOptions->base.y.value = gPanelMainMenu->base.elem.y - sPanelOptions->base.elem.height;
|
||||
}
|
||||
|
||||
static void djui_panel_options_back(struct DjuiBase* base) {
|
||||
sClosing = true;
|
||||
djui_base_set_enabled(&sPanelOptions->base, false);
|
||||
djui_cursor_input_controlled_center(NULL);
|
||||
djui_panel_back();
|
||||
}
|
||||
|
||||
void djui_panel_options_create(void) {
|
||||
void djui_panel_options_create(struct DjuiBase* caller) {
|
||||
f32 bodyHeight = 64 * 6 + 16 * 5;
|
||||
sOpening = true;
|
||||
sClosing = false;
|
||||
|
||||
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);
|
||||
djui_base_set_border_color(&sPanelOptions->base, 0, 0, 0, 200);
|
||||
djui_base_set_border_width(&sPanelOptions->base, 8);
|
||||
djui_base_set_padding(&sPanelOptions->base, 16, 16, 16, 16);
|
||||
sPanelOptions->base.on_render_pre = djui_panel_options_render_pre;
|
||||
struct DjuiButton* buttonPlayer = NULL;
|
||||
|
||||
struct DjuiThreePanel* panel = djui_three_panel_create(&gDjuiRoot->base, 64, bodyHeight, 0);
|
||||
djui_base_set_size_type(&panel->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&panel->base, 340.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&panel->base, 0, 0, 0, 240);
|
||||
djui_base_set_border_color(&panel->base, 0, 0, 0, 200);
|
||||
djui_base_set_border_width(&panel->base, 8);
|
||||
djui_base_set_padding(&panel->base, 16, 16, 16, 16);
|
||||
{
|
||||
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);
|
||||
struct DjuiText* header = djui_text_create(&panel->base, "\\#ff0800\\O\\#1be700\\P\\#00b3ff\\T\\#ffef00\\I\\#ff0800\\O\\#1be700\\N\\#00b3ff\\S");
|
||||
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);
|
||||
|
@ -68,7 +26,7 @@ void djui_panel_options_create(void) {
|
|||
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);
|
||||
struct DjuiFlowLayout* body = djui_flow_layout_create(&panel->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);
|
||||
|
@ -76,9 +34,9 @@ void djui_panel_options_create(void) {
|
|||
djui_flow_layout_set_margin(body, 16);
|
||||
djui_flow_layout_set_flow_direction(body, DJUI_FLOW_DIR_DOWN);
|
||||
{
|
||||
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);
|
||||
buttonPlayer = djui_button_create(&body->base, "Player");
|
||||
djui_base_set_size_type(&buttonPlayer->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&buttonPlayer->base, 1.0f, 64);
|
||||
|
||||
struct DjuiButton* button2 = djui_button_create(&body->base, "Camera");
|
||||
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
|
@ -95,18 +53,14 @@ void djui_panel_options_create(void) {
|
|||
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);
|
||||
button5->base.interactable->on_click = djui_panel_sound_create;
|
||||
|
||||
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;
|
||||
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
|
||||
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button6->base, 1.0f, 64);
|
||||
button6->base.interactable->on_click = djui_panel_options_back;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void djui_panel_options_open(struct DjuiBase* caller) {
|
||||
sCaller = caller;
|
||||
djui_cursor_input_controlled_center(NULL);
|
||||
djui_base_set_enabled(&gPanelMainMenu->base, false);
|
||||
djui_panel_options_create();
|
||||
djui_panel_add(caller, &panel->base, &buttonPlayer->base);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
void djui_panel_options_open(struct DjuiBase* caller);
|
||||
void djui_panel_options_create(struct DjuiBase* caller);
|
||||
|
|
|
@ -1,70 +1,29 @@
|
|||
#include "djui.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
|
||||
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) {
|
||||
float yMove = gPanelMainMenu->base.elem.height;
|
||||
static float movement = 0;
|
||||
if (sOpening) {
|
||||
movement += yMove / 10.0f;
|
||||
if (movement >= yMove) {
|
||||
movement = yMove;
|
||||
sOpening = false;
|
||||
djui_base_set_enabled(&sPanelQuit->base, true);
|
||||
djui_cursor_input_controlled_center(&sButtonNo->base);
|
||||
}
|
||||
} else if (sClosing) {
|
||||
movement -= yMove / 10.0f;
|
||||
if (movement <= 0) {
|
||||
movement = 0;
|
||||
sClosing = false;
|
||||
djui_base_destroy(&sPanelQuit->base);
|
||||
sPanelQuit = NULL;
|
||||
*skipRender = true;
|
||||
djui_base_set_enabled(&gPanelMainMenu->base, true);
|
||||
gPanelMainMenu->base.y.value = 0;
|
||||
djui_cursor_input_controlled_center(sCaller);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
movement = yMove;
|
||||
}
|
||||
gPanelMainMenu->base.y.value = -yMove * smoothstep(0, yMove, movement);
|
||||
sPanelQuit->base.y.value = gPanelMainMenu->base.elem.y + gPanelMainMenu->base.elem.height;
|
||||
}
|
||||
|
||||
static void djui_panel_quit_yes(struct DjuiBase* base) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void djui_panel_quit_no(struct DjuiBase* base) {
|
||||
sClosing = true;
|
||||
djui_base_set_enabled(&sPanelQuit->base, false);
|
||||
djui_cursor_input_controlled_center(NULL);
|
||||
djui_panel_back();
|
||||
}
|
||||
|
||||
static void djui_panel_quit_create(void) {
|
||||
void djui_panel_quit_create(struct DjuiBase* caller) {
|
||||
f32 bodyHeight = 64 * 3 + 16 * 2;
|
||||
sOpening = true;
|
||||
sClosing = false;
|
||||
|
||||
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);
|
||||
djui_base_set_border_color(&sPanelQuit->base, 0, 0, 0, 200);
|
||||
djui_base_set_border_width(&sPanelQuit->base, 8);
|
||||
djui_base_set_padding(&sPanelQuit->base, 16, 16, 16, 16);
|
||||
djui_base_set_enabled(&sPanelQuit->base, false);
|
||||
sPanelQuit->base.on_render_pre = djui_panel_quit_render_pre;
|
||||
struct DjuiButton* buttonNo = NULL;
|
||||
|
||||
struct DjuiThreePanel* panel = djui_three_panel_create(&gDjuiRoot->base, 64, bodyHeight, 0);
|
||||
djui_base_set_size_type(&panel->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&panel->base, 340.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&panel->base, 0, 0, 0, 230);
|
||||
djui_base_set_border_color(&panel->base, 0, 0, 0, 200);
|
||||
djui_base_set_border_width(&panel->base, 8);
|
||||
djui_base_set_padding(&panel->base, 16, 16, 16, 16);
|
||||
djui_base_set_enabled(&panel->base, false);
|
||||
{
|
||||
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);
|
||||
struct DjuiText* header = djui_text_create(&panel->base, "\\#ff0800\\Q\\#1be700\\U\\#00b3ff\\I\\#ffef00\\T");
|
||||
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);
|
||||
|
@ -72,7 +31,7 @@ static void djui_panel_quit_create(void) {
|
|||
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);
|
||||
struct DjuiFlowLayout* body = djui_flow_layout_create(&panel->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);
|
||||
|
@ -91,17 +50,12 @@ static void djui_panel_quit_create(void) {
|
|||
djui_base_set_size(&button1->base, 1.0f, 64);
|
||||
button1->base.interactable->on_click = djui_panel_quit_yes;
|
||||
|
||||
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;
|
||||
buttonNo = djui_button_create(&body->base, "No");
|
||||
djui_base_set_size_type(&buttonNo->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&buttonNo->base, 1.0f, 64);
|
||||
buttonNo->base.interactable->on_click = djui_panel_quit_no;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void djui_panel_quit_open(struct DjuiBase* caller) {
|
||||
sCaller = caller;
|
||||
djui_cursor_input_controlled_center(NULL);
|
||||
djui_base_set_enabled(&gPanelMainMenu->base, false);
|
||||
djui_panel_quit_create();
|
||||
djui_panel_add(caller, &panel->base, &buttonNo->base);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
void djui_panel_quit_open(struct DjuiBase* caller);
|
||||
void djui_panel_quit_create(struct DjuiBase* caller);
|
||||
|
||||
|
|
65
src/pc/djui/djui_panel_sound.c
Normal file
65
src/pc/djui/djui_panel_sound.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include "djui.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
|
||||
static void djui_panel_sound_back(struct DjuiBase* base) {
|
||||
djui_panel_back();
|
||||
}
|
||||
|
||||
void djui_panel_sound_create(struct DjuiBase* caller) {
|
||||
f32 bodyHeight = 64 * 6 + 16 * 5;
|
||||
|
||||
struct DjuiButton* button1 = NULL;
|
||||
|
||||
struct DjuiThreePanel* panel = djui_three_panel_create(&gDjuiRoot->base, 64, bodyHeight, 0);
|
||||
djui_base_set_size_type(&panel->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&panel->base, 340.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&panel->base, 0, 0, 0, 240);
|
||||
djui_base_set_border_color(&panel->base, 0, 0, 0, 200);
|
||||
djui_base_set_border_width(&panel->base, 8);
|
||||
djui_base_set_padding(&panel->base, 16, 16, 16, 16);
|
||||
{
|
||||
struct DjuiText* header = djui_text_create(&panel->base, "\\#ff0800\\S\\#1be700\\O\\#00b3ff\\U\\#ffef00\\N\\#ff0800\\D");
|
||||
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(&panel->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);
|
||||
{
|
||||
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(&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(&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(&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(&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);
|
||||
|
||||
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
|
||||
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button6->base, 1.0f, 64);
|
||||
button6->base.interactable->on_click = djui_panel_sound_back;
|
||||
}
|
||||
}
|
||||
|
||||
djui_panel_add(caller, &panel->base, &button1->base);
|
||||
}
|
4
src/pc/djui/djui_panel_sound.h
Normal file
4
src/pc/djui/djui_panel_sound.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
void djui_panel_sound_create(struct DjuiBase* caller);
|
Loading…
Reference in a new issue