diff options
| author | robojumper <robojumper@gmail.com> | 2025-03-31 03:34:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-30 21:34:21 -0400 |
| commit | daadae488119c7a8cd28548e5d502abdafbf68e0 (patch) | |
| tree | baf3b22d728e066b639e8ae967aba305ef41f9d4 /src | |
| parent | e85a989271d9445d4c4e1da41dfb6d90cb0652aa (diff) | |
Link d2d (#145)
Diffstat (limited to 'src')
| -rw-r--r-- | src/d/lyt/d2d.cpp | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/src/d/lyt/d2d.cpp b/src/d/lyt/d2d.cpp index d33c741e..4a550e83 100644 --- a/src/d/lyt/d2d.cpp +++ b/src/d/lyt/d2d.cpp @@ -1,15 +1,15 @@ #include "d/lyt/d2d.h" #include "d/d_font_manager.h" +#include "d/d_textunk.h" #include "d/lyt/d_textbox.h" #include "d/lyt/d_window.h" #include "egg/gfx/eggScreen.h" #include "nw4r/lyt/lyt_bounding.h" #include "nw4r/lyt/lyt_group.h" +#include "nw4r/lyt/lyt_pane.h" #include "nw4r/lyt/lyt_picture.h" -#include "nw4r/lyt/lyt_textBox.h" #include "nw4r/lyt/lyt_utils.h" -#include "nw4r/lyt/lyt_window.h" #include "sized_string.h" using namespace nw4r::lyt; @@ -200,15 +200,15 @@ void Multi_c::calcAfter() { extern "C" bool NeedsScreenAdjustment(); -// Largerly copied from m2d::Simple_c::draw +// Largely copied from m2d::Simple_c::draw void Multi_c::draw() { nw4r::ut::Rect r = mLayout.GetLayoutRect(); f32 near = 0.0f; f32 far = 500.0f; EGG::Screen s; bool needsAdjust = NeedsScreenAdjustment(); - f32 f1 = EGG::Screen::GetSizeXMax(EGG::Screen::TV_MODE_UNK_3); - f32 f2 = EGG::Screen::GetSizeXMax(EGG::Screen::TV_MODE_16_9); + f32 f1 = EGG::Screen::GetSizeXMax(EGG::Screen::TV_MODE_16_9); + f32 f2 = EGG::Screen::GetSizeXMax(EGG::Screen::TV_MODE_4_3); f32 left = needsAdjust ? f1 * r.left / f2 : r.left; f32 right = needsAdjust ? f1 * r.right / f2 : r.right; @@ -445,8 +445,6 @@ extern "C" const char *fn_801B2600(const char *); extern "C" void fn_800AF930(dTextBox_c *, const char *); extern "C" void fn_800B0F40(dTextBox_c *); -// NOTE: This function uses `textBox->GetTranslateX1()` as a general placeholder to figure -// out the details first. In reality these are all different functions! void LytBase_c::setProperties(nw4r::lyt::Pane *pane, f32 posX, f32 posY, f32 scale, f32 spaceX, f32 spaceY) { if (pane->GetName()[0] != 'T') { return; @@ -475,41 +473,40 @@ void LytBase_c::setProperties(nw4r::lyt::Pane *pane, f32 posX, f32 posY, f32 sca } nw4r::math::VEC3 t2 = textBox->GetTranslate(); - t2.x += textBox->GetTranslateX1(); - t2.y += textBox->GetTranslateX1(); + t2.x += UnkTextThing::getFn800B2030(); + t2.y += UnkTextThing::getFn800B2040(); textBox->SetTranslate(t2); if (scale != -9999.0f) { const nw4r::ut::Font *f = textBox->GetFont(); if (f != nullptr) { - // VEC2 internally copied via GPRs here, should be FPRs - textBox->SetScale(scale * 0.01f); + scale *= 0.01f; + textBox->SetScale(scale); } } else { const nw4r::ut::Font *f = textBox->GetFont(); if (f != nullptr) { - // VEC2 internally copied via GPRs here, should be FPRs - textBox->SetScale(textBox->GetTranslateX1()); + textBox->SetScale(UnkTextThing::getFn800B1FD0()); } } - f32 f4 = 0.0f; f32 f6 = 0.0f; + f32 f4 = 0.0f; if (spaceX != -9999.0f) { textBox->SetCharSpace(spaceX); } else { - f6 = textBox->GetTranslateX1(); + f6 = UnkTextThing::getFn800B2010(); } if (spaceY != -9999.0f) { textBox->SetLineSpace(spaceY); } else { - f4 = textBox->GetTranslateX1(); + f4 = UnkTextThing::getFn800B1FF0(); } - textBox->SetCharSpace(f6 + textBox->GetCharSpace() + textBox->GetTranslateX1()); - textBox->SetLineSpace(f4 + textBox->GetLineSpace() + textBox->GetTranslateX1()); + textBox->SetCharSpace(textBox->GetCharSpace() + UnkTextThing::getFn800B2020() + f6); + textBox->SetLineSpace(textBox->GetLineSpace() + UnkTextThing::getFn800B2000() + f4); fn_800AB930(textBox); } @@ -595,7 +592,7 @@ bool LytBase_c::fn_800ABB80(dTextBox_c *textbox1, dTextBox_c *textbox2, int arg) bool LytBase_c::fn_800ABCE0( const nw4r::lyt::res::ExtUserData *userDatum, dTextBox_c *textbox1, dTextBox_c *textbox2, int arg ) { - int userDatInt = userDatum->GetInt(); + s32 userDatInt = userDatum->GetInt(); SizedString<0x40> str1; SizedString<0x40> str2; @@ -605,11 +602,9 @@ bool LytBase_c::fn_800ABCE0( if (arg != -1) { userDatInt = arg; } - str2.sprintf(":%02d", userDatInt); - // TODO this operator is not behaving correctly here - there's - // an additional null check, and the source string address is - // computed twice via stack instead of once. - str1 += str2; + SizedString<0x40> &fmt = str2; + fmt.sprintf(":%02d", userDatInt); + str1.append(fmt); } const char *text = LMS_GetTextByLabel(getMsbtInfo(), str1); @@ -693,17 +688,15 @@ extern "C" void fn_800AF840(dTextBox_c *textbox1, MsbtInfo *, const char *, int bool LytBase_c::fn_800AC1AC( const nw4r::lyt::res::ExtUserData *userDatum, dTextBox_c *textbox1, dTextBox_c *textbox2, int arg, void *unk ) { - int userDatInt = userDatum->GetInt(); + s32 userDatInt = userDatum->GetInt(); SizedString<0x40> str1; SizedString<0x40> str2; str1 = textbox2->GetName(); if (userDatInt != 0) { - str2.sprintf(":%02d", 0); - // TODO this operator is not behaving correctly here - there's - // an additional null check, and the source string address is - // computed twice via stack instead of once. - str1 += str2; + SizedString<0x40> &fmt = str2; + fmt.sprintf(":%02d", 0); + str1.append(fmt); } fn_800AF840(textbox1, getMsbtInfo(), str1, arg, unk); @@ -754,18 +747,17 @@ bool hasSameBaseName(const char *left, const char *right) { char *sRef = "ref"; void dSubPane::linkMeters(nw4r::lyt::Group *group, d2d::SubPaneList *meterGroup) { - // single regswap - nw4r::ut::LinkList<d2d::SubPaneListNode, 0>::Iterator beginIt = meterGroup->GetBeginIter(); - nw4r::ut::LinkList<d2d::SubPaneListNode, 0>::Iterator endIt = meterGroup->GetEndIter(); + SubPaneList::Iterator beginIt = meterGroup->GetBeginIter(); + SubPaneList::Iterator endIt = meterGroup->GetEndIter(); + + nw4r::lyt::PaneList::Iterator paneEndIt = group->GetPaneList()->GetEndIter(); - for (nw4r::lyt::PaneList::Iterator paneIt = group->GetPaneList()->GetBeginIter(); - paneIt != group->GetPaneList()->GetEndIter(); ++paneIt) { + for (nw4r::lyt::PaneList::Iterator paneIt = group->GetPaneList()->GetBeginIter(); paneIt != paneEndIt; ++paneIt) { nw4r::lyt::Pane *pane = paneIt->mTarget; - int num = pane->GetExtUserDataNum(); - if (num != 0) { + if (pane->GetExtUserDataNum()) { const nw4r::lyt::res::ExtUserData *dat = pane->FindExtUserDataByName(sRef); if (dat != nullptr && dat->GetType() == nw4r::lyt::res::TYPE_STRING) { - for (nw4r::ut::LinkList<d2d::SubPaneListNode, 0>::Iterator it = beginIt; it != endIt; ++it) { + for (SubPaneList::Iterator it = beginIt; it != endIt; ++it) { d2d::dSubPane *meter = it->mpLytPane; if (!meter->LytMeter0x24()) { if (hasSameBaseName(dat->GetString(), meter->getName())) { @@ -895,6 +887,12 @@ void AnmGroupBase_c::setBackward() { mpFrameCtrl->setBackward(); } +void pushToEnd(nw4r::lyt::Pane *pane) { + nw4r::lyt::Pane *parent = pane->GetParent(); + parent->RemoveChild(pane); + parent->AppendChild(pane); +} + bool AnmGroups::init( d2d::AnmGroup_c *pGroups, const LytBrlanMapping *mappings, u32 num, m2d::ResAccIf_c *acc, d2d::Layout_c *layout ) { |
