mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
DJUI: started adding options menu
This commit is contained in:
parent
dfef74e727
commit
a3947b3800
9 changed files with 149 additions and 22 deletions
|
@ -3951,6 +3951,7 @@
|
|||
<ClCompile Include="..\src\pc\djui\djui_interactable.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_rect.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_root.c" />
|
||||
|
@ -4378,6 +4379,7 @@
|
|||
<ClInclude Include="..\src\pc\djui\djui_interactable.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_rect.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_root.h" />
|
||||
|
|
|
@ -15204,6 +15204,9 @@
|
|||
<ClCompile Include="..\src\pc\djui\djui_panel_debug.c">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_options.c">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\actors\common0.h">
|
||||
|
@ -16228,5 +16231,8 @@
|
|||
<ClInclude Include="..\src\pc\djui\djui_panel_debug.h">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_options.h">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "djui_panel_debug.h"
|
||||
#include "djui_panel_main.h"
|
||||
#include "djui_panel_options.h"
|
||||
#include "djui_panel_quit.h"
|
||||
|
||||
extern struct DjuiRoot* gDjuiRoot;
|
||||
|
|
|
@ -76,7 +76,7 @@ static f32 sDjuiFontTitleCharWidths[] = {
|
|||
/* : ; < = > ? @ */
|
||||
0.50f, 0.50f, 0.50f, 0.50f, 0.50f, 0.50f, 0.50f,
|
||||
/* A B C D E F G H I J K L M N O P Q R S T U V W X Y Z */
|
||||
0.55f, 0.50f, 0.50f, 0.50f, 0.45f, 0.45f, 0.50f, 0.55f, 0.28f, 0.60f, 0.50f, 0.45f, 0.55f, 0.50f, 0.50f, 0.45f, 0.50f, 0.50f, 0.55f, 0.50f, 0.50f, 0.50f, 0.60f, 0.52f, 0.60f, 0.45f,
|
||||
0.55f, 0.50f, 0.50f, 0.50f, 0.45f, 0.45f, 0.50f, 0.55f, 0.28f, 0.60f, 0.50f, 0.45f, 0.55f, 0.50f, 0.50f, 0.50f, 0.50f, 0.50f, 0.55f, 0.50f, 0.50f, 0.50f, 0.60f, 0.52f, 0.60f, 0.45f,
|
||||
/* [ \ ] ^ _ ` */
|
||||
0.50f, 0.50f, 0.50f, 0.50f, 0.50f, 0.50f,
|
||||
/* a b c d e f g h i j k l m n o p q r s t u v w x y z */
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#include "djui.h"
|
||||
|
||||
ALIGNED8 static u8 texture_title[] = {
|
||||
#include "textures/segment2/custom_title.rgba32.inc.c"
|
||||
};
|
||||
|
||||
struct DjuiRect* gPanelMainMenu = NULL;
|
||||
struct DjuiFlowLayout* sButtonContainer = NULL;
|
||||
struct DjuiText* sTitleText = NULL;
|
||||
struct DjuiText* sVersionText = 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;
|
||||
|
@ -17,8 +13,8 @@ static void djui_panel_main_render_pre(struct DjuiBase* base, bool* skipRender)
|
|||
void djui_panel_main_create(void) {
|
||||
gPanelMainMenu = djui_rect_create(&gDjuiRoot->base);
|
||||
djui_base_set_size_type(&gPanelMainMenu->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&gPanelMainMenu->base, 350.0f + (16 * 2.0f), 1.0f);
|
||||
djui_base_set_color(&gPanelMainMenu->base, 0, 0, 0, 230);
|
||||
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);
|
||||
|
@ -42,6 +38,7 @@ void djui_panel_main_create(void) {
|
|||
struct DjuiButton* button3 = djui_button_create(&sButtonContainer->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");
|
||||
djui_base_set_size_type(&button4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
|
@ -49,7 +46,6 @@ void djui_panel_main_create(void) {
|
|||
button4->base.interactable->on_click = djui_panel_quit_open;
|
||||
}
|
||||
|
||||
//sTitleText = djui_text_create(&gPanelMainMenu->base, "SM64EX\nCOOP");
|
||||
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);
|
||||
|
|
106
src/pc/djui/djui_panel_options.c
Normal file
106
src/pc/djui/djui_panel_options.c
Normal file
|
@ -0,0 +1,106 @@
|
|||
#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 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) {
|
||||
movement += yMove / 10.0f;
|
||||
if (movement >= yMove) {
|
||||
movement = yMove;
|
||||
sOpening = false;
|
||||
djui_base_set_enabled(&sPanelOptions->base, true);
|
||||
}
|
||||
} 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;
|
||||
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);
|
||||
}
|
||||
|
||||
void djui_panel_options_create(void) {
|
||||
sOpening = true;
|
||||
sClosing = false;
|
||||
sPanelOptions = djui_rect_create(&gDjuiRoot->base);
|
||||
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;
|
||||
{
|
||||
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 DjuiButton* button1 = djui_button_create(&sButtonContainer->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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
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(&sButtonContainer->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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void djui_panel_options_open(struct DjuiBase* caller) {
|
||||
djui_base_set_enabled(&gPanelMainMenu->base, false);
|
||||
djui_panel_options_create();
|
||||
}
|
4
src/pc/djui/djui_panel_options.h
Normal file
4
src/pc/djui/djui_panel_options.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
void djui_panel_options_open(struct DjuiBase* caller);
|
|
@ -1,9 +1,9 @@
|
|||
#include "djui.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
|
||||
struct DjuiRect* sPanelQuit = NULL;
|
||||
bool sOpening = false;
|
||||
bool sClosing = false;
|
||||
static struct DjuiRect* sPanelQuit = 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;
|
||||
|
@ -48,7 +48,7 @@ static void djui_panel_quit_create(void) {
|
|||
sClosing = false;
|
||||
sPanelQuit = djui_rect_create(&gDjuiRoot->base);
|
||||
djui_base_set_size_type(&sPanelQuit->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&sPanelQuit->base, 350.0f + (16 * 2.0f), 1.0f);
|
||||
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);
|
||||
|
@ -86,4 +86,4 @@ static void djui_panel_quit_create(void) {
|
|||
void djui_panel_quit_open(struct DjuiBase* caller) {
|
||||
djui_base_set_enabled(&gPanelMainMenu->base, false);
|
||||
djui_panel_quit_create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#include "djui.h"
|
||||
#include "game/segment2.h"
|
||||
|
||||
static u8 sSavedAlpha = 0;
|
||||
static u8 sSavedR = 0;
|
||||
static u8 sSavedG = 0;
|
||||
static u8 sSavedB = 0;
|
||||
static u8 sSavedA = 0;
|
||||
|
||||
////////////////
|
||||
// properties //
|
||||
|
@ -81,7 +84,7 @@ static void djui_text_render_char(struct DjuiText* text, char c) {
|
|||
sTextRenderY += 1.0f / text->fontScale;
|
||||
gDPSetEnvColor(gDisplayListHead++, text->dropShadow.r, text->dropShadow.g, text->dropShadow.b, text->dropShadow.a);
|
||||
djui_text_render_single_char(text, c);
|
||||
gDPSetEnvColor(gDisplayListHead++, base->color.r, base->color.g, base->color.b, base->color.a);
|
||||
gDPSetEnvColor(gDisplayListHead++, sSavedR, sSavedG, sSavedB, sSavedA);
|
||||
sTextRenderX -= 1.0f / text->fontScale;
|
||||
sTextRenderY -= 1.0f / text->fontScale;
|
||||
}
|
||||
|
@ -187,11 +190,16 @@ static int djui_text_render_line_parse_escape(struct DjuiText* text, u16 startIn
|
|||
|
||||
if (parsingColor) {
|
||||
if (colorPieces == 6) {
|
||||
gDPSetEnvColor(gDisplayListHead++, ((color >> 16) & 0xFF), ((color >> 8) & 0xFF), ((color >> 0) & 0xFF), sSavedAlpha);
|
||||
sSavedR = ((color >> 16) & 0xFF);
|
||||
sSavedG = ((color >> 8) & 0xFF);
|
||||
sSavedB = ((color >> 0) & 0xFF);
|
||||
} else if (colorPieces == 8) {
|
||||
gDPSetEnvColor(gDisplayListHead++, ((color >> 24) & 0xFF), ((color >> 16) & 0xFF), ((color >> 8) & 0xFF), ((color >> 0) & 0xFF));
|
||||
sSavedAlpha = ((color << 0) & 0xFF);
|
||||
sSavedR = ((color >> 24) & 0xFF);
|
||||
sSavedG = ((color >> 16) & 0xFF);
|
||||
sSavedB = ((color >> 8) & 0xFF);
|
||||
sSavedA = ((color >> 0) & 0xFF);
|
||||
}
|
||||
gDPSetEnvColor(gDisplayListHead++, sSavedR, sSavedG, sSavedB, sSavedA);
|
||||
}
|
||||
|
||||
return i;
|
||||
|
@ -284,7 +292,10 @@ static void djui_text_render(struct DjuiBase* base) {
|
|||
|
||||
// set color
|
||||
gDPSetEnvColor(gDisplayListHead++, base->color.r, base->color.g, base->color.b, base->color.a);
|
||||
sSavedAlpha = base->color.a;
|
||||
sSavedR = base->color.r;
|
||||
sSavedG = base->color.g;
|
||||
sSavedB = base->color.b;
|
||||
sSavedA = base->color.a;
|
||||
|
||||
// count lines
|
||||
u16 startIndex = 0;
|
||||
|
@ -349,6 +360,7 @@ struct DjuiText* djui_text_create(struct DjuiBase* parent, const char* message)
|
|||
djui_text_set_font_scale(text, text->font->defaultFontScale);
|
||||
djui_text_set_text(text, message);
|
||||
djui_text_set_alignment(text, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||
djui_text_set_drop_shadow(text, 0, 0, 0, 0);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue