1#include <game/bases/d_2d.hpp>
2#include <game/bases/d_game_com.hpp>
3#include <game/bases/d_font_manager.hpp>
4#include <game/mLib/m_allocator.hpp>
5#include <game/mLib/m_heap.hpp>
6#include <game/mLib/m_mtx.hpp>
7#include <constants/sjis_constants.h>
26 m2d::drawBtween(after, before);
30void DUMMY_ORDERING() {
35 u8 *pOpacity = (u8 *) opacity;
36 pane->SetAlpha(*pOpacity);
37 pane->SetGlbAlpha(*pOpacity);
45d2d::ResAccMult_c::ResAccMult_c() {
49d2d::ResAccMult_c::~ResAccMult_c() {
52void *d2d::ResAccMult_c::getResource(
unsigned long type,
const char *name) {
53 return mInternalAccessor.GetResource(type, name,
nullptr);
56void d2d::ResAccMult_c::creater() {
57 setResAccessor(&mInternalAccessor);
60void *d2d::ResAccMult_c::InternalAccessor::GetResource(ulong type,
const char *name,
size_t *size) {
61 if (type == RES_TYPE_FONT) {
62 return dFontMng_c::getResFontData(name);
64 return nw4r::lyt::ArcResourceAccessor::GetResource(type, name, size);
67nw4r::ut::Font *d2d::ResAccMult_c::InternalAccessor::GetFont(
const char *name) {
68 return dFontMng_c::getFont(dFontMng_c::getResFontIndex(name));
71d2d::ResAccMultLoader_c::ResAccMultLoader_c() : mpResource(nullptr) {}
72d2d::ResAccMultLoader_c::~ResAccMultLoader_c() {}
74bool d2d::ResAccMultLoader_c::requestEx(
const char *name,
int i) {
75 if (mpResource !=
nullptr) {
78 mpResource = mLoader.request(name, i, ms_res_allocator->mpHeap);
79 if (mpResource !=
nullptr) {
80 attach(mpResource,
"arc");
87bool d2d::ResAccMultLoader_c::request(
const char *name) {
88 return requestEx(name, 0);
91bool d2d::ResAccMultLoader_c::remove() {
92 if (mpResource !=
nullptr) {
94 ms_res_allocator->free(mpResource);
97 return mLoader.remove();
100bool d2d::ResAccMultLoader_c::create(EGG::Heap *parent, ulong size) {
101 EGG::Heap *heap = mHeap::createExpHeap(size, parent, D2D_HEAP_NAME, 0x20, mHeap::OPT_4);
102 ms_res_allocator =
new(heap, 4) mAllocator_c();
103 ms_res_allocator->attach(heap, 0x20);
112 if (dGameCom::GetAspectRatio() == EGG::Screen::TV_MODE_16_9) {
122 m2d::Base_c::entry();
130 PSMTXTransApply(mtx, mtx, pos.x, pos.y, pos.z);
153 bool isWide = dGameCom::GetAspectRatio() == EGG::Screen::TV_MODE_16_9;
154 float w_16_9 = EGG::Screen::sTVModeInfo[EGG::Screen::TV_MODE_16_9].width;
155 float w_4_3 = EGG::Screen::sTVModeInfo[EGG::Screen::TV_MODE_4_3].width;
156 float left = isWide ? w_16_9 * rect.left / w_4_3 : rect.left;
157 float right = isWide ? w_16_9 * rect.right / w_4_3 : rect.right;
158 screen.mProjType = EGG::Frustum::PROJ_ORTHO;
159 screen.ResetOrthographic(rect.top, rect.bottom, left, right, near, far);
163 screen.SetProjectionGX();
166 GXGetScissor(&x, &y, &w, &h);
172 GXSetScissor(x, y, w, h);
183 if (
mLayout.GetRootPane() !=
nullptr) {
186 if (resAcc ==
nullptr) {
188 if (resAcc ==
nullptr) {
192 void *lyt = resAcc->getResource(0, name);
193 if (lyt ==
nullptr) {
196 bool res =
mLayout.Build(lyt, &resAcc->mInternalAccessor);
204 return mLayout.GetRootPane()->FindPaneByName(name,
true);
209 if (pane !=
nullptr) {
218 if (pane !=
nullptr) {
227 if (pane !=
nullptr) {
virtual ~Multi_c()
Destroys the layout.
void calcAfter()
Calculates the view rectangle and view matrix after the main calculation.
m2d::Layout_c mLayout
The layout instance.
ScissorMask mScissorMask
The scissor mask for the layout.
virtual void draw()
Draws the layout.
void entry()
Registers the layout to be drawn.
nw4r::lyt::Picture * findPictureByName(const char *name)
Finds a picture pane by name.
virtual void calc()
Applies the view matrix.
nw4r::lyt::DrawInfo mDrawInfo
The parameters for drawing the layout.
u32 mFlags
The flags for the layout.
nw4r::lyt::TextBox * findTextBoxByName(const char *name)
Finds a text box pane by name.
nw4r::lyt::Pane * getRootPane()
Gets the root pane of the layout.
ResAccMult_c * mpResAccessor
The resource accessor for the layout.
void calcBefore()
Calculates an animation step before the main calculation.
nw4r::lyt::Pane * findPaneByName(const char *name)
Finds a pane by name.
Multi_c()
Creates a layout.
virtual bool build(const char *name, ResAccMult_c *resAcc)
Builds the layout from a binary layout file.
mVec2_c mPos
The position of the layout.
nw4r::lyt::Window * findWindowByName(const char *name)
Finds a window pane by name.
An allocator class that wraps an EGG:Allocator .
A two-dimensional floating point vector.
A three-dimensional floating point vector.
void drawAfter()
Draws all registered foreground 2D objects.
void drawBefore()
Draws all registered background 2D objects.
void init()
Initializes the 2D engine.
void draw()
Draws all registered 2D objects.
void drawBtween(u8 after, u8 before)
Draws all registered 2D objects between the after and before draw orders.
int setAlpha_patrolPane_patrol(nw4r::lyt::Pane *pane, void *opacity)
Visitor function for setting the opacity of panes.
void setAlpha(m2d::Simple_c *layout, u8 opacity)
Sets the opacity of an entire layout.