Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/RMCP01/module/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ ui/Page.cpp:
.text start:0x8060197C end:0x80602D2C
.data start:0x808BA5C0 end:0x808BA624

ui/Section.o:
.text start:0x80621D0C end:0x80624690
ui/Section.cpp:
.text start:0x80622D08 end:0x80622EC8

ui/SectionAutogens.cpp:
.text start:0x8062C3A4 end:0x8063240C
Expand Down
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ def MatchingFor(*versions):

Object(Matching, "ui/ControlGroup.cpp"),
Object(Matching, "ui/MessageGroup.cpp"),
Object(Matching, "ui/Section.cpp"),
Object(NonMatching, "ui/SectionAutogens.cpp"),
Object(NonMatching, "ui/SectionManager.cpp"),
Object(NonMatching, "ui/Page.cpp"),
Expand Down
48 changes: 47 additions & 1 deletion src/ui/Section.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
#include "Section.hpp"

#include "SectionAutogens.hpp"
#include "Page.hpp"

extern "C" UI::Page* Section_createPage(int pageId);
extern "C" UI::Page* createSystemPage(int pageId, int sectionId);
extern "C" void Page_init(UI::Page* page, int pageId);
extern "C" void Page_activate(UI::Page* page);
extern "C" void SystemPage_init(UI::Page* page);

extern "C" void Section_addPage(UI::Section* section, int pageId) {
section->pages[pageId] = Section_createPage(pageId);
Page_init(section->pages[pageId], pageId);
}

extern "C" void fn_1_1129A0(UI::Section* section, int pageId) {
section->systemPages[pageId] = createSystemPage(pageId, section->sectionId);
if (section->systemPages[pageId] != nullptr) {
SystemPage_init(section->systemPages[pageId]);
}
}

extern "C" void Section_addActivePage(UI::Section* section, int pageId) {
UI::Page* page = section->pages[pageId];
section->activePages[section->activePageCount++] = page;
page->setAnimationDirection(section->_04);
Page_activate(page);
}

extern "C" UI::Page* Section_activatePage(UI::Section* section, int pageId,
int animationDirection) {
UI::Page* page = section->pages[pageId];
section->activePages[section->activePageCount++] = page;
page->setAnimationDirection(animationDirection);
Page_activate(page);
return page;
}

extern "C" int Section_isPageActive(UI::Section* section, UI::Page* page) {
return section->activePageCount >= 1 &&
section->activePages[section->activePageCount - 1] == page;
}

extern "C" UI::Page* Section_getVisiblePage(UI::Section* section) {
if (section->activePageCount < 1) {
return nullptr;
}
return section->activePages[section->activePageCount - 1];
}
42 changes: 42 additions & 0 deletions src/ui/Section.hpp
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
#pragma once

#include <cstddef>

#include <rk_types.h>

namespace UI {

class Page;

// The top-level owner for a UI section's pages. This layout is derived from
// StaticR.rel's Section.o (0x80621D0C--0x80624690). The fields following the
// active page stack have not been named yet, but their exact locations matter
// to every function in this translation unit.
class Section {
public:
s32 sectionId;
u32 _04;
Page* pages[211];
Page* activePages[10];
s32 activePageCount;
Page* systemPages[2];
u8 _388[8];
u8 _390[0x54];
void* allocator;
void* resourceAccessors;
void* layoutThings;
f32 _3f0;
f32 _3f4;
f32 _3f8;
f32 _3fc;
void* _400;
void* _404;
};

static_assert(offsetof(Section, pages) == 0x8);
static_assert(offsetof(Section, activePages) == 0x354);
static_assert(offsetof(Section, activePageCount) == 0x37c);
static_assert(offsetof(Section, systemPages) == 0x380);
static_assert(offsetof(Section, allocator) == 0x3e4);
static_assert(sizeof(Section) == 0x408);

} // namespace UI
4 changes: 2 additions & 2 deletions src/ui/SectionAutogens.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "SectionAutogens.hpp"

void Section_addPages(void* pSection, int sectionId) {
void Section_addPages(UI::Section* pSection, int sectionId) {
switch (sectionId) {
case 6:
Section_addPage(pSection, 0);
Expand Down Expand Up @@ -1587,7 +1587,7 @@ void Section_addPages(void* pSection, int sectionId) {
}
}

void Section_addActivePages(void* section, int sectionId) {
void Section_addActivePages(UI::Section* section, int sectionId) {
switch (sectionId) {
case 6:
Section_addActivePage(section, 0);
Expand Down
6 changes: 4 additions & 2 deletions src/ui/SectionAutogens.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include <rk_types.h>
#include <host_system/RKScene.hpp>

#include "Section.hpp"

extern "C" {
void Section_addActivePage(void*, int);
void Section_addPage(void*, int);
void Section_addActivePage(UI::Section*, int);
void Section_addPage(UI::Section*, int);
}