# Stage 1.9

- Add AppInit Flags and AppFlags to COntrol some Individual Stuff (Not using default can run into a crash report if things get used that are disabled)
- Create a Test Settings Menu
- Make Some Menu functions Public
- Add ScrollTo Animation
- Make ContainerApi fully public
- Remove an else statement (now need to find a way to not set the pos twice)
-
This commit is contained in:
2025-02-09 21:40:31 +01:00
parent fc8291555e
commit ca26189f52
11 changed files with 207 additions and 60 deletions

View File

@ -41,42 +41,65 @@ void App::Run() {
app_time += dt / 1000.f;
last_time = current;
fps = 1000.f / dt;
PD::TT::Beg("App_MainLoop");
if (!this->MainLoop(dt, app_time)) {
break;
if (runtimeflags & AppFLags_UserLoop) {
PD::TT::Beg("App_MainLoop");
if (!this->MainLoop(dt, app_time)) {
break;
}
PD::TT::End("App_MainLoop");
}
PD::TT::End("App_MainLoop");
PD::TT::Beg("Ovl_Update");
renderer->Layer(90);
overlay_mgr->Update(dt);
/// Messages have their own special Layer
renderer->Layer(93);
msg_mgr->Update(dt);
if (runtimeflags & AppFlags_HandleOverlays &&
SafeInitFlags & AppInitFlags_InitLithium) {
renderer->Layer(90);
overlay_mgr->Update(dt);
}
if (runtimeflags & AppFlags_HandleMessageMgr &&
SafeInitFlags & AppInitFlags_InitLithium) {
/// Messages have their own special Layer
renderer->Layer(93);
msg_mgr->Update(dt);
}
PD::TT::End("Ovl_Update");
renderer->PrepareRender();
renderer->Render(Top);
renderer->Render(Bottom);
renderer->FinalizeRender();
if (runtimeflags & AppFlags_HandleRendering &&
SafeInitFlags & AppInitFlags_InitLithium) {
renderer->PrepareRender();
renderer->Render(Top);
renderer->Render(Bottom);
renderer->FinalizeRender();
}
}
this->Deinit();
this->PostDeinit();
}
void App::PreInit() {
osSetSpeedupEnable(true);
gfxInitDefault();
/// Create a Copy that won't get edit
SafeInitFlags = InitFlags;
osSetSpeedupEnable(InitFlags & AppInitFlags_New3dsMode);
if (InitFlags & AppInitFlags_InitGraphics) {
gfxInitDefault();
if (!(InitFlags & AppInitFlags_InitGraphicsNoC3D)) {
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
}
}
cfguInit();
romfsInit();
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
if (InitFlags & AppInitFlags_MountRomfs) {
romfsInit();
}
input_mgr = Hid::New();
Top = Screen::New(Screen::Top);
Bottom = Screen::New(Screen::Bottom);
renderer = LI::Renderer::New();
renderer->RegisterScreen(false, Top);
renderer->RegisterScreen(true, Bottom);
renderer->OnScreen(Top);
msg_mgr = MessageMgr::New(renderer);
overlay_mgr = OverlayMgr::New(renderer, input_mgr);
if (InitFlags & AppInitFlags_InitLithium) {
Assert(!(InitFlags & AppInitFlags_InitGraphicsNoC3D),
"InitGraphicsNoC3D is not compatible with InitLithium!");
Top = Screen::New(Screen::Top);
Bottom = Screen::New(Screen::Bottom);
renderer = LI::Renderer::New();
renderer->RegisterScreen(false, Top);
renderer->RegisterScreen(true, Bottom);
renderer->OnScreen(Top);
msg_mgr = MessageMgr::New(renderer);
overlay_mgr = OverlayMgr::New(renderer, input_mgr);
}
}
void App::PostDeinit() {
@ -84,9 +107,15 @@ void App::PostDeinit() {
msg_mgr = nullptr;
overlay_mgr = nullptr;
input_mgr = nullptr;
C3D_Fini();
gfxExit();
if (SafeInitFlags & AppInitFlags_InitGraphics) {
if (!(SafeInitFlags & AppInitFlags_InitGraphicsNoC3D)) {
C3D_Fini();
}
gfxExit();
}
cfguExit();
romfsExit();
if (SafeInitFlags & AppInitFlags_MountRomfs) {
romfsExit();
}
}
} // namespace PD

View File

@ -0,0 +1,39 @@
#include <pd/overlays/settings.hpp>
namespace PD {
int SettingsMenu::too = 0;
void SettingsMenu::Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) {
if (!ctx) {
ctx = UI7::Context::New(ren, inp);
ctx->RootLayer(70);
}
flymgr.Update(delta);
if (rem && flymgr.IsFinished()) {
this->Kill();
}
ren->OnScreen(ren->GetScreen(false));
if (ctx->BeginMenu("Palladium - Settings", UI7MenuFlags_CenterTitle)) {
auto m = ctx->GetCurrentMenu();
m->SeparatorText("Library Info");
m->Label(LibInfo::CompiledWith());
m->AfterAlignCenter();
m->Label(LibInfo::CxxVersion());
m->AfterAlignCenter();
m->Label("Version: " + LibInfo::Version() + "[" + LibInfo::Commit() + "]");
m->AfterAlignCenter();
m->Label("Build Time: " + LibInfo::BuildTime());
m->AfterAlignCenter();
ctx->EndMenu();
}
ren->OnScreen(ren->GetScreen(true));
if (ctx->BeginMenu("pdovlssettings", UI7MenuFlags_NoTitlebar)) {
auto m = ctx->GetCurrentMenu();
m->SeparatorText("Settings");
if (m->Button("Exit")) {
this->Rem();
}
ctx->EndMenu();
}
ctx->Update(delta);
}
} // namespace PD

View File

@ -40,13 +40,12 @@ bool UI7::Menu::Button(const std::string& label) {
u32 id = Strings::FastHash("btn" + label + std::to_string(count_btn++));
Container::Ref r = FindIDObj(id);
if (!r) {
r = ObjectPush(PD::New<UI7::Button>(label, Cursor(), this->back->ren));
r = PD::New<UI7::Button>(label, Cursor(), this->back->ren);
r->SetID(id);
r->Init(main->ren, main, linked_theme);
} else {
ObjectPush(r);
r->SetPos(Cursor());
}
ObjectPush(r);
r->SetPos(Cursor());
CursorMove(r->GetSize());
r->HandleScrolling(scrolling_off, view_area);
if (!r->Skippable()) {
@ -59,13 +58,12 @@ void UI7::Menu::Checkbox(const std::string& label, bool& v) {
u32 id = Strings::FastHash("cbx" + label + std::to_string(count_cbx++));
Container::Ref r = FindIDObj(id);
if (!r) {
r = ObjectPush(PD::New<UI7::Checkbox>(label, Cursor(), v, this->back->ren));
r = PD::New<UI7::Checkbox>(label, Cursor(), v, this->back->ren);
r->SetID(id);
r->Init(main->ren, main, linked_theme);
} else {
ObjectPush(r);
r->SetPos(Cursor());
}
ObjectPush(r);
r->SetPos(Cursor());
CursorMove(r->GetSize());
r->HandleScrolling(scrolling_off, view_area);
}
@ -104,6 +102,10 @@ void UI7::Menu::DebugLabels() {
void UI7::Menu::Update(float delta) {
TT::Scope st("MUPT_" + name);
scroll_anim.Update(delta);
if (!scroll_anim.IsFinished()) {
scrolling_off = scroll_anim;
}
std::vector<int> tbr;
for (int i = 0; i < (int)objects.size(); i++) {
auto& it = objects[i];
@ -146,12 +148,11 @@ void UI7::Menu::CursorMove(const vec2& size) {
void UI7::Menu::PreHandler(UI7MenuFlags flags) {
TT::Scope st("MPRE_" + name);
TT::Beg("MUSR_" + name);
this->back->BaseLayer(30);
this->main->BaseLayer(40);
this->front->BaseLayer(50);
count_btn = 0;
count_cbx = 0;
Cursor(vec2(5, 5));
tbh = 0.f;
CursorInit();
main_area = view_area;
this->flags = flags;
this->scrolling[0] = flags & UI7MenuFlags_HzScrolling;
this->scrolling[1] = flags & UI7MenuFlags_VtScrolling;
@ -173,7 +174,8 @@ void UI7::Menu::PreHandler(UI7MenuFlags flags) {
}
front->AddText(tpos, this->name, linked_theme->Get(UI7Color_Text), tflags,
vec2(view_area.z(), tbh));
Cursor(vec2(5, tbh + 5));
main_area[1] = tbh;
CursorInit();
}
}
@ -229,8 +231,7 @@ void UI7::Menu::PostHandler() {
mouse = vec2();
}
if (inp->IsHeld(inp->Touch)) {
if (!front->ren->InBox(tpos, vec4(view_area[2] - 13, tbh + 5, 8,
view_area[3] - tbh - 10))) {
if (front->ren->InBox(tpos, main_area)) {
if (scrolling_off[1] < max[1] - view_area[3] + 40 &&
scrolling_off[1] > -40) {
/// Cursor Mod

View File

@ -37,12 +37,15 @@ bool UI7::Context::BeginMenu(const ID& id, UI7MenuFlags flags) {
this->current = menu->second;
if (!this->current->BackList()) {
this->current->BackList(DrawList::New(ren));
this->current->BackList()->BaseLayer(root_layer + 30);
}
if (!this->current->MainList()) {
this->current->MainList(DrawList::New(ren));
this->current->MainList()->BaseLayer(root_layer + 40);
}
if (!this->current->FrontList()) {
this->current->FrontList(DrawList::New(ren));
this->current->FrontList()->BaseLayer(root_layer + 50);
}
this->current->ViewArea(this->ren->GetViewport());
this->current->PreHandler(flags);
@ -63,12 +66,12 @@ void UI7::Context::EndMenu() {
void UI7::Context::Update(float delta) {
TT::Scope st("UI7_Update");
Assert(current == nullptr, "Still in a Menu!");
this->back->BaseLayer(10);
this->back->BaseLayer(root_layer + 10);
this->back->Process();
for (auto it : amenus) {
menus[it]->Update(delta);
}
this->front->BaseLayer(60);
this->front->BaseLayer(root_layer + 60);
this->front->Process();
this->amenus.clear();
}