Compare commits
1 Commits
main
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5d8bd95a3 |
@@ -20,6 +20,10 @@ namespace textinput {
|
||||
virtual void moveNigaoeButton() {}
|
||||
};
|
||||
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
class ScrollButton;
|
||||
#endif
|
||||
|
||||
class InputForm : public textinput::InputForm {
|
||||
public:
|
||||
typedef enum EditMode {
|
||||
@@ -44,6 +48,25 @@ namespace textinput {
|
||||
#endif
|
||||
|
||||
~InputForm();
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
virtual void moveCursorUp();
|
||||
virtual void moveCursorDown();
|
||||
virtual void onCommand(INPUT_COMMAND command, void* data);
|
||||
virtual void create(MEMAllocator* allocator, inputform::EditBuffer* editBuffer);
|
||||
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
|
||||
virtual bool updateInput(input::HKBManager& hkbManager);
|
||||
virtual void init();
|
||||
virtual void draw();
|
||||
virtual void calc();
|
||||
virtual void doScroll(Scroll* scroll);
|
||||
virtual u32 calcCursorPos(f32 x, f32 y);
|
||||
virtual void drawCursor(f32 x, f32 y);
|
||||
virtual nw4r::math::VEC2 getScale() const;
|
||||
virtual void preDraw(u32 pos);
|
||||
virtual void doLineFeed();
|
||||
virtual void finishDraw(u32 pos);
|
||||
virtual bool isInScroll();
|
||||
#endif
|
||||
|
||||
virtual void setScroll(f32 scroll);
|
||||
virtual void setAddScroll(f32 scroll, bool up, bool down);
|
||||
@@ -108,7 +131,7 @@ namespace textinput {
|
||||
void setEditScrollDown(bool editScrollDown) { mbEditScrollUp = editScrollDown; }
|
||||
void setCloseWithSend(bool closeWithSend) { mbCloseWithSend = closeWithSend; }
|
||||
|
||||
#ifdef MYTIMANAGER_IMPLEMENTATION
|
||||
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
|
||||
void setEditMode(EditMode editMode);
|
||||
#else
|
||||
void setEditMode(EditMode editMode) { meEditMode = editMode; }
|
||||
@@ -125,12 +148,19 @@ namespace textinput {
|
||||
tistring::Decolated* getSendString() { return mpSendString; }
|
||||
|
||||
private:
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
nw4r::lyt::Pane* mpMemoPane;
|
||||
nw4r::lyt::Pane* mpMemoRootPane;
|
||||
nw4r::lyt::Pane* mpBoundPane;
|
||||
nw4r::lyt::Pane* mpDrawPane;
|
||||
#else
|
||||
#ifdef MYTIMANAGER_IMPLEMENTATION
|
||||
undefined4* unk_0x308;
|
||||
#endif
|
||||
undefined4* unk_0x30C;
|
||||
undefined4* unk_0x310;
|
||||
undefined4* unk_0x314;
|
||||
#endif
|
||||
f32 mfScroll; // 0x318
|
||||
f32 mfScrollFrom; // 0x31C
|
||||
f32 mfScrollTo; // 0x320
|
||||
@@ -142,7 +172,7 @@ namespace textinput {
|
||||
nw4r::lyt::Size mDefaultBoundSize; // 0x358
|
||||
Mtx mDrawMtx; // 0x360
|
||||
Mtx mBoundMtx; // 0x390
|
||||
#ifdef MYTIMANAGER_IMPLEMENTATION
|
||||
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
|
||||
util::Animation mExScrollAnm; // 0x3C0
|
||||
#else
|
||||
u8 /*todo*/ mExScrollAnm[32]; // 0x3C0
|
||||
@@ -156,7 +186,11 @@ namespace textinput {
|
||||
bool mbEditScrollDown; // 0x3EF
|
||||
bool mbCloseWithSend; // 0x3F0
|
||||
u8 padding[3]; // 0x3F1
|
||||
undefined4* mpScrollButton; // 0x3F4
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
ScrollButton* mpScrollButton;
|
||||
#else
|
||||
undefined4* mpScrollButton;
|
||||
#endif
|
||||
bool mbScrollUp; // 0x3F8
|
||||
bool mbScrollDown; // 0x3F9
|
||||
EditMode meEditMode; // 0x3FC
|
||||
|
||||
@@ -190,8 +190,19 @@ namespace textinput {
|
||||
|
||||
virtual void makeUpCursorPos(CursorPos* cursorPos, u32 pos, s32 startLine, s32 endLine);
|
||||
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
protected:
|
||||
void setCursorPos(tistring::Decolated* string, u32 pos);
|
||||
void resetRelation();
|
||||
void calcCursorTimer();
|
||||
#else
|
||||
private:
|
||||
Rect mRect; // 0x120
|
||||
#endif
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
nw4r::ut::Rect mRect;
|
||||
#else
|
||||
Rect mRect;
|
||||
#endif
|
||||
nw4r::math::MTX34 mMtx; // 0x130
|
||||
Destination meDestination; // 0x160
|
||||
tistring::Decolated* mpString; // 0x164
|
||||
@@ -264,11 +275,30 @@ namespace textinput {
|
||||
|
||||
virtual void visibleSeparator(bool flag);
|
||||
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
protected:
|
||||
const void* mpLayoutData;
|
||||
const void* mpLanguageData;
|
||||
const char* mpFontName;
|
||||
bool mbUpVisible;
|
||||
bool mbDownVisible;
|
||||
bool mbRepeat;
|
||||
nw4rmanager::TiEventHandler* mpInputEventHandler;
|
||||
nw4r::ut::ResFont mFont;
|
||||
int mUpRepeat;
|
||||
int mDownRepeat;
|
||||
int mLeftRepeat;
|
||||
int mRightRepeat;
|
||||
int mDeleteRepeat;
|
||||
int mConfirmRepeat;
|
||||
u32 mRepeatButtons;
|
||||
#else
|
||||
private:
|
||||
#ifdef MYTIMANAGER_IMPLEMENTATION
|
||||
u8 unk_0x2C0[0x48];
|
||||
#else
|
||||
u8 unk_0x2C0[0x4C];
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@@ -128,6 +128,11 @@ namespace textinput {
|
||||
|
||||
class AnimPaneGroup {
|
||||
public:
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
AnimPaneGroup(nw4r::lyt::Group* group) : mpGroup(group) {
|
||||
nw4r::ut::List_Init(&mAnmPaneList, offsetof(AnmPane, mGroupLink));
|
||||
}
|
||||
#endif
|
||||
virtual void create() {} // 0x08
|
||||
virtual void init() {} // 0x0C
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace textinput {
|
||||
namespace textdrawer {
|
||||
#ifdef MYTIMANAGER_IMPLEMENTATION
|
||||
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
|
||||
class Base : public nw4r::ut::CharWriter {
|
||||
#else
|
||||
class Base : nw4r::ut::CharWriter {
|
||||
@@ -90,7 +90,14 @@ namespace textinput {
|
||||
private:
|
||||
u8 unk_0x50[0x78];
|
||||
bool mbSecretMode; // 0xC8
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
protected:
|
||||
u8 mDrawState[0x27];
|
||||
f32 mfDrawScrollY;
|
||||
u8 mDrawCacheState[0x14];
|
||||
#else
|
||||
u8 unk_0xCC[0x3C];
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,13 @@ namespace textinput {
|
||||
class CommandSender;
|
||||
class CommandReceiver : public Base {
|
||||
public:
|
||||
#ifdef MYTIINPUTFORM_IMPLEMENTATION
|
||||
struct Scroll {
|
||||
bool absY;
|
||||
f32 x;
|
||||
f32 y;
|
||||
};
|
||||
#endif
|
||||
typedef enum INPUT_COMMAND {
|
||||
INPUT_COMMAND_0 = 0,
|
||||
INPUT_COMMAND_37 = 37,
|
||||
|
||||
796
src/keyboard/MyTiInputForm.cpp
Normal file
796
src/keyboard/MyTiInputForm.cpp
Normal file
@@ -0,0 +1,796 @@
|
||||
#define MYTIINPUTFORM_IMPLEMENTATION
|
||||
#include "keyboard/MyTiInputForm.h"
|
||||
#include "keyboard/tiUtil.h"
|
||||
#include <nw4r/lyt/group.h>
|
||||
#include <nw4r/lyt/material.h>
|
||||
#include <nw4r/lyt/textbox.h>
|
||||
#include <new>
|
||||
|
||||
namespace textinput {
|
||||
namespace inputform {
|
||||
class EventHandler : public nw4rmanager::TiEventHandler {
|
||||
public:
|
||||
EventHandler(textinput::InputForm* form) : mpInputForm(form) {}
|
||||
virtual ~EventHandler() {}
|
||||
virtual void onTiEvent(gui::PaneComponent*, u32, Input*);
|
||||
protected:
|
||||
textinput::InputForm* mpInputForm;
|
||||
};
|
||||
}
|
||||
namespace extend {
|
||||
namespace memo {
|
||||
|
||||
class AnmPane : public nw4rmanager::AnmPane {
|
||||
protected:
|
||||
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
|
||||
: nw4rmanager::AnmPane(pane, observer), meState(0) {}
|
||||
public:
|
||||
virtual ~AnmPane();
|
||||
virtual void init();
|
||||
virtual void changeAnimation(u32 id);
|
||||
virtual u32 getState();
|
||||
virtual u32 getKeyType() const;
|
||||
protected:
|
||||
u32 meState;
|
||||
u32 meKeyType;
|
||||
};
|
||||
|
||||
class WholePane : public AnmPane {
|
||||
public:
|
||||
WholePane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { meKeyType = 0; }
|
||||
virtual ~WholePane() {}
|
||||
virtual void onAnmEvent(AnmPaneEvent event);
|
||||
};
|
||||
|
||||
class NigaoePane : public AnmPane {
|
||||
public:
|
||||
NigaoePane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : AnmPane(pane, observer) { meKeyType = 1; }
|
||||
virtual ~NigaoePane() {}
|
||||
virtual void onAnmEvent(AnmPaneEvent event);
|
||||
};
|
||||
|
||||
class SimpleAnmPane : public nw4rmanager::AnmPane {
|
||||
public:
|
||||
SimpleAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : nw4rmanager::AnmPane(pane, observer) {}
|
||||
virtual ~SimpleAnmPane() {}
|
||||
virtual void init();
|
||||
virtual void changeAnimation(u32 id);
|
||||
};
|
||||
|
||||
class ScrollButton {
|
||||
public:
|
||||
ScrollButton(TiLayout* layout) : muGroup(0), muAnimation(0), mpLayout(layout), mbLeftPressed(false), mbRightPressed(false) {}
|
||||
virtual void create(MEMAllocator*, nw4r::lyt::MultiArcResourceAccessor*);
|
||||
virtual void init();
|
||||
virtual void calc();
|
||||
virtual void changeAnimation(bool left, u32 id);
|
||||
private:
|
||||
u32 muGroup;
|
||||
u32 muAnimation;
|
||||
TiLayout* mpLayout;
|
||||
nw4rmanager::AnimPaneGroup* mGroups[9];
|
||||
bool mbGroupChanged[9];
|
||||
bool mbLeftPressed;
|
||||
bool mbRightPressed;
|
||||
};
|
||||
|
||||
class EventHandler : public inputform::EventHandler {
|
||||
public:
|
||||
EventHandler(InputForm* form) : inputform::EventHandler(form), mpMemoForm(form) {}
|
||||
virtual ~EventHandler() {}
|
||||
virtual void onTiEvent(gui::PaneComponent*, u32, Input*);
|
||||
private:
|
||||
InputForm* mpMemoForm;
|
||||
};
|
||||
|
||||
static const char* scPaneName[] = {
|
||||
"N_Header", "N_Body", "B_Body", "N_Footer", "Nigaoe",
|
||||
"T_Nigaoe", "B_Nigaoe", "T_Letter", "T_TouchLetter"
|
||||
};
|
||||
|
||||
struct AnimationFile {
|
||||
u32 id;
|
||||
char name[64];
|
||||
};
|
||||
static const AnimationFile csAninationFile[] = {
|
||||
{0, "my_Memo_a_normal.brlan"},
|
||||
{1, "my_Memo_a_MailIn.brlan"},
|
||||
{2, "my_Memo_a_MailOut.brlan"},
|
||||
{3, "my_Memo_a_SendOut.brlan"},
|
||||
{4, "my_Memo_a_NigaoeFoucusIn.brlan"},
|
||||
{5, "my_Memo_a_NigaoeFoucusOut.brlan"}
|
||||
};
|
||||
struct PaneAnimations {
|
||||
u32 type;
|
||||
const char* paneName;
|
||||
u32 count;
|
||||
const AnimationFile* animations[12];
|
||||
};
|
||||
static const PaneAnimations csPaneToAnimation[] = {
|
||||
{0, "N_Memo", 4, {&csAninationFile[0], &csAninationFile[1], &csAninationFile[2], &csAninationFile[3]}},
|
||||
{1, "Nigaoe", 2, {&csAninationFile[4], &csAninationFile[5]}}
|
||||
};
|
||||
static const AnimationFile csGroupAninationFile[] = {
|
||||
{0, "my_Memo_a_Off.brlan"},
|
||||
{1, "my_Memo_a_Appear.brlan"},
|
||||
{2, "my_Memo_a_Lost.brlan"},
|
||||
{3, "my_Memo_a_HDActionEnd.brlan"},
|
||||
{4, "my_Memo_a_HDActionStart.brlan"},
|
||||
{5, "my_Memo_a_Loop.brlan"},
|
||||
{6, "my_Memo_a_Select.brlan"},
|
||||
{7, "my_Memo_a_FocusOff.brlan"},
|
||||
{8, "my_Memo_a_FocusOn.brlan"}
|
||||
};
|
||||
struct GroupAnimations {
|
||||
u32 group;
|
||||
u32 animations[3];
|
||||
};
|
||||
static const GroupAnimations csGroupToAnimation[] = {
|
||||
{0, {5, 9, 9}}, {1, {8, 7, 9}}, {2, {8, 7, 9}},
|
||||
{3, {6, 9, 9}}, {4, {6, 9, 9}}, {5, {2, 1, 9}},
|
||||
{6, {2, 1, 9}}, {7, {4, 3, 9}}, {8, {4, 3, 9}}
|
||||
};
|
||||
|
||||
InputForm::~InputForm() {
|
||||
mpSendString->~Decolated();
|
||||
MEMFreeToAllocator(mpAllocator, mpSendString);
|
||||
MEMFreeToAllocator(mpAllocator, mpDefaultNigaoe);
|
||||
}
|
||||
|
||||
void InputForm::setAddScroll(f32 scroll, bool up, bool down) {
|
||||
setScroll(mfScroll + scroll);
|
||||
if (up && !mbScrollUp) {
|
||||
mpScrollButton->changeAnimation(false, 4);
|
||||
} else if (down && !mbScrollDown) {
|
||||
mpScrollButton->changeAnimation(true, 4);
|
||||
}
|
||||
if (!up && mbScrollUp) {
|
||||
mpScrollButton->changeAnimation(false, 3);
|
||||
} else if (!down && mbScrollDown) {
|
||||
mpScrollButton->changeAnimation(true, 3);
|
||||
}
|
||||
mbScrollUp = up;
|
||||
mbScrollDown = down;
|
||||
}
|
||||
|
||||
void InputForm::moveCursorUp() {
|
||||
f32 y = 1.0f + (mfCursorY - getLineHeight());
|
||||
if (y <= 0.0f) {
|
||||
u32 start, end;
|
||||
mpString->getCursorPos(&start, &end);
|
||||
if (start == 0 && end == 0) onSE(sound::SE_CHAR_CURSOR_FIX);
|
||||
else onSE(sound::SE_CHAR_CURSOR);
|
||||
setCursorPos(mpString, 0);
|
||||
} else {
|
||||
setCursorPos(mpString, calcCursorPos(mfCursorX, y - mfScroll));
|
||||
onSE(sound::SE_CHAR_CURSOR);
|
||||
}
|
||||
meScrollFlag = SF_ScrollOn;
|
||||
}
|
||||
|
||||
void InputForm::moveCursorDown() {
|
||||
f32 y = 1.0f + (mfCursorY + getLineHeight());
|
||||
if (y / getLineHeight() >= getLine()) {
|
||||
u32 start, end;
|
||||
mpString->getCursorPos(&start, &end);
|
||||
if (start == mpString->getLength() && end == mpString->getLength()) onSE(sound::SE_CHAR_CURSOR_FIX);
|
||||
else onSE(sound::SE_CHAR_CURSOR);
|
||||
setCursorPos(mpString, mpString->getLength());
|
||||
} else {
|
||||
setCursorPos(mpString, calcCursorPos(mfCursorX, y - mfScroll));
|
||||
onSE(sound::SE_CHAR_CURSOR);
|
||||
}
|
||||
meScrollFlag = SF_ScrollOn;
|
||||
}
|
||||
|
||||
void InputForm::onCommand(INPUT_COMMAND command, void* data) {
|
||||
if (meEditMode == EM_Edit) onCommandOnEditMode(command, data);
|
||||
else if (meEditMode == EM_Disp) onCommandOnDispMode(command, data);
|
||||
else {
|
||||
switch (command) {
|
||||
case 6: case 21: case 29: case 31:
|
||||
textinput::InputForm::onCommand(command, data);
|
||||
break;
|
||||
case 7: case 8: case 9: case 10: case 11: case 12: case 13:
|
||||
case 14: case 15: case 16: case 17: case 18: case 19: case 20:
|
||||
case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 30:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputForm::onCommandOnEditMode(INPUT_COMMAND command, void* data) {
|
||||
switch (command) {
|
||||
case 24:
|
||||
if (!mExScrollAnm.isActive()) {
|
||||
if (static_cast<Scroll*>(data)->y < 0.0f)
|
||||
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll + getLineHeight(), 15.0f, NULL);
|
||||
else
|
||||
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll - getLineHeight(), 15.0f, NULL);
|
||||
onSE(sound::SE_LINE_SCROLL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
textinput::InputForm::onCommand(command, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InputForm::onCommandOnDispMode(INPUT_COMMAND command, void* data) {
|
||||
switch (command) {
|
||||
case 14: {
|
||||
nw4r::math::VEC2 position = getGlobalLeftTopPos();
|
||||
nw4r::math::VEC2* point = static_cast<nw4r::math::VEC2*>(data);
|
||||
int line = (point->y - position.y) / getLineHeight();
|
||||
if (line > getLine() - 1) line = getLine() - 1;
|
||||
if (getLine() > 1 && line >= getLine() - 1) line = getLine() - 2;
|
||||
mfScrollFrom = mfScroll;
|
||||
mfScrollTo = line * getLineHeight();
|
||||
nw4r::math::VEC2 editPoint;
|
||||
editPoint.x = point->x;
|
||||
editPoint.y = point->y - mfScroll;
|
||||
textinput::InputForm::onCommand(static_cast<INPUT_COMMAND>(14), &editPoint);
|
||||
int relationLine = line;
|
||||
struct Relation { int type; int* line; } relation = {0, &relationLine};
|
||||
textinput::InputForm::onCommand(INPUT_COMMAND_37, &relation);
|
||||
mbEdited = true;
|
||||
candidatebox::CandidateBoxCaller::resetCandidate();
|
||||
candidatebox::CandidateBoxCaller::makeEmptyCandidate();
|
||||
break;
|
||||
}
|
||||
case 29: case 31: case 41:
|
||||
textinput::InputForm::onCommand(command, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InputForm::create(MEMAllocator* allocator, inputform::EditBuffer* editBuffer) {
|
||||
textinput::InputForm::create(allocator, editBuffer);
|
||||
void* stringMemory = MEMAllocFromAllocator(allocator, sizeof(tistring::Decolated));
|
||||
mpSendString = new (stringMemory) tistring::Decolated(1024);
|
||||
mpSendString->create(allocator);
|
||||
MEMFreeToAllocator(allocator, mpInputEventHandler);
|
||||
void* handlerMemory = MEMAllocFromAllocator(allocator, sizeof(EventHandler));
|
||||
mpInputEventHandler = new (handlerMemory) EventHandler(this);
|
||||
mpInputEventHandler->setEventObserver(mpEventObserver);
|
||||
mpPaneManager->changeEventHandler(mpInputEventHandler);
|
||||
mpDefaultNigaoe = static_cast<GXTexObj*>(MEMAllocFromAllocator(allocator, sizeof(GXTexObj)));
|
||||
getNigaoePaneMaterial()->GetTexture(mpDefaultNigaoe, 0);
|
||||
setVisible("P_2l_TextBox", true);
|
||||
mpBoundPane = mpLayout->GetRootPane()->FindPaneByName("T_2l_TextBox", true);
|
||||
mDefaultBoundTrans = mpBoundPane->GetTranslate();
|
||||
mDefaultBoundSize = mpBoundPane->GetSize();
|
||||
mpDrawPane = mpLayout->GetRootPane()->FindPaneByName("B_2l_TextBox", true);
|
||||
mpPaneManager->getPaneComponentByPane(mpDrawPane)->setTriggerTarget(false);
|
||||
mDrawRect = mpDrawPane->GetPaneRect(mDrawInfo);
|
||||
mDefaultDrawTrans = mpDrawPane->GetTranslate();
|
||||
mDefaultDrawSize = mpDrawPane->GetSize();
|
||||
mpMemoPane = mpLayout->GetRootPane()->FindPaneByName("N_Memo", true);
|
||||
mpMemoRootPane = mpLayout->GetRootPane()->FindPaneByName("N_MemoRoot", true);
|
||||
setScroll(0.0f);
|
||||
mnLine = 1;
|
||||
mfScrollFrom = 0.0f;
|
||||
mfScrollTo = 0.0f;
|
||||
PSMTXIdentity(mDrawMtx);
|
||||
PSMTXIdentity(mBoundMtx);
|
||||
createAnimation(allocator);
|
||||
void* scrollMemory = MEMAllocFromAllocator(allocator, sizeof(ScrollButton));
|
||||
mpScrollButton = new (scrollMemory) ScrollButton(mpLayout);
|
||||
mpScrollButton->create(allocator, mpMultiArcResourceAccessor);
|
||||
}
|
||||
|
||||
void InputForm::createAnimation(MEMAllocator* allocator) {
|
||||
for (u16 i = 0; i < 2; i++) {
|
||||
const PaneAnimations& entry = csPaneToAnimation[i];
|
||||
AnmPane* pane = NULL;
|
||||
switch (entry.type) {
|
||||
case 0: {
|
||||
void* memory = MEMAllocFromAllocator(allocator, sizeof(WholePane));
|
||||
pane = new (memory) WholePane(getPane(entry.paneName), NULL);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
void* memory = MEMAllocFromAllocator(allocator, sizeof(NigaoePane));
|
||||
pane = new (memory) NigaoePane(getPane(entry.paneName), NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
nw4r::ut::List_Append(&mAnmPanes, pane);
|
||||
for (u16 j = 0; j < entry.count; j++) {
|
||||
const void* resource = mpMultiArcResourceAccessor->GetResource(0, entry.animations[j]->name, NULL);
|
||||
AnimTransformPane* transform = static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
|
||||
pane->addAnimation(allocator, entry.animations[j]->id, transform, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnmPane::~AnmPane() {}
|
||||
|
||||
static const char* csGroupName[] = {
|
||||
"G_ArwRoop", "G_ArwR_Focus", "G_ArwL_Focus", "G_ArwR_Ac", "G_ArwL_Ac",
|
||||
"G_ArwL_End", "G_ArwR_End", "G_ArwL_HDAc", "G_ArwR_HDAc"
|
||||
};
|
||||
|
||||
void ScrollButton::create(MEMAllocator* allocator, nw4r::lyt::MultiArcResourceAccessor* accessor) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
mbGroupChanged[i] = false;
|
||||
nw4r::lyt::Group* group = mpLayout->GetGroupContainer()->FindGroupByName(csGroupName[i]);
|
||||
void* groupMemory = MEMAllocFromAllocator(allocator, sizeof(nw4rmanager::AnimPaneGroup));
|
||||
mGroups[i] = new (groupMemory) nw4rmanager::AnimPaneGroup(group);
|
||||
nw4r::lyt::PaneLinkList& panes = group->GetPaneList();
|
||||
for (nw4r::lyt::PaneLinkList::Iterator it = panes.GetBeginIter(); it != panes.GetEndIter(); ++it) {
|
||||
void* memory = MEMAllocFromAllocator(allocator, sizeof(SimpleAnmPane));
|
||||
SimpleAnmPane* pane = new (memory) SimpleAnmPane(it->mTarget, NULL);
|
||||
for (u16 j = 0; j < 3; j++) {
|
||||
int id = csGroupToAnimation[i].animations[j];
|
||||
if (id != 9) {
|
||||
const void* resource = accessor->GetResource(0, csGroupAninationFile[id].name, NULL);
|
||||
AnimTransformPane* transform = static_cast<AnimTransformPane*>(mpLayout->CreateAnimTransform(resource, accessor));
|
||||
bool loop = false;
|
||||
if (id == 5) loop = true;
|
||||
pane->addAnimation(allocator, id, transform, loop, false);
|
||||
}
|
||||
}
|
||||
mGroups[i]->addAnimPane(pane);
|
||||
}
|
||||
}
|
||||
changeAnimation(true, 5);
|
||||
changeAnimation(false, 5);
|
||||
changeAnimation(true, 2);
|
||||
changeAnimation(false, 2);
|
||||
for (int i = 0; i < 10; i++) calc();
|
||||
}
|
||||
|
||||
void ScrollButton::calc() {
|
||||
for (int i = 0; i < 9; i++) mGroups[i]->calc();
|
||||
}
|
||||
|
||||
void ScrollButton::changeAnimation(bool left, u32 id) {
|
||||
muAnimation = id;
|
||||
if (left) {
|
||||
switch (id) {
|
||||
case 0: muGroup = 0; break;
|
||||
case 1: muGroup = 5; break;
|
||||
case 2: muGroup = 5; break;
|
||||
case 3: if (!mbLeftPressed) return; muGroup = 8; mbLeftPressed = false; break;
|
||||
case 4: if (mbLeftPressed) return; muGroup = 8; mbLeftPressed = true; break;
|
||||
case 5: muGroup = 0; break;
|
||||
case 6: muGroup = 4; break;
|
||||
case 7: muGroup = 2; break;
|
||||
case 8: muGroup = 2; break;
|
||||
}
|
||||
} else {
|
||||
switch (id) {
|
||||
case 0: muGroup = 0; break;
|
||||
case 1: muGroup = 6; break;
|
||||
case 2: muGroup = 6; break;
|
||||
case 3: if (!mbRightPressed) return; muGroup = 7; mbRightPressed = false; break;
|
||||
case 4: if (mbRightPressed) return; muGroup = 7; mbRightPressed = true; break;
|
||||
case 5: muGroup = 0; break;
|
||||
case 6: muGroup = 3; break;
|
||||
case 7: muGroup = 1; break;
|
||||
case 8: muGroup = 1; break;
|
||||
}
|
||||
}
|
||||
mbGroupChanged[muGroup] = true;
|
||||
mGroups[muGroup]->changeAnimation(id);
|
||||
}
|
||||
|
||||
void InputForm::onArrowRPoint() {
|
||||
if (meEditMode == EM_Disp) {
|
||||
mpScrollButton->changeAnimation(false, 8);
|
||||
onSE(sound::SE_BT_TARGETTING);
|
||||
}
|
||||
}
|
||||
void InputForm::onArrowRLeft() {
|
||||
if (meEditMode == EM_Disp) mpScrollButton->changeAnimation(false, 7);
|
||||
}
|
||||
void InputForm::onArrowLPoint() {
|
||||
if (meEditMode == EM_Disp) {
|
||||
mpScrollButton->changeAnimation(true, 8);
|
||||
onSE(sound::SE_BT_TARGETTING);
|
||||
}
|
||||
}
|
||||
void InputForm::onArrowLLeft() {
|
||||
if (meEditMode == EM_Disp) mpScrollButton->changeAnimation(true, 7);
|
||||
}
|
||||
void InputForm::onArrowRTrig() {
|
||||
if (meEditMode == EM_Disp && !mExScrollAnm.isActive()) {
|
||||
mpScrollButton->changeAnimation(false, 6);
|
||||
f32 scroll = mfScroll - 3.0f * getLineHeight();
|
||||
if (scroll <= getScrollMin()) scroll = getScrollMin();
|
||||
mExScrollAnm.startAnm(NULL, mfScroll, scroll, 15.0f, NULL);
|
||||
onSE(sound::SE_LINE_SCROLL);
|
||||
}
|
||||
}
|
||||
void InputForm::onArrowLTrig() {
|
||||
if (meEditMode == EM_Disp && !mExScrollAnm.isActive()) {
|
||||
mpScrollButton->changeAnimation(true, 6);
|
||||
f32 scroll = mfScroll + 3.0f * getLineHeight();
|
||||
if (scroll >= getScrollMax()) scroll = getScrollMax();
|
||||
mExScrollAnm.startAnm(NULL, mfScroll, scroll, 15.0f, NULL);
|
||||
onSE(sound::SE_LINE_SCROLL);
|
||||
}
|
||||
}
|
||||
|
||||
bool InputForm::updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) {
|
||||
if (meEditMode == EM_Disp) {
|
||||
if (hold & 0x400) return textinput::InputForm::updateInput(chan, 0.0f, 0.0f, 0, 0, 0, data);
|
||||
if (trig & 8) mpScrollButton->changeAnimation(false, 4);
|
||||
if (release & 8) mpScrollButton->changeAnimation(false, 3);
|
||||
if (trig & 4) mpScrollButton->changeAnimation(true, 4);
|
||||
if (release & 4) mpScrollButton->changeAnimation(true, 3);
|
||||
if (hold & 8) {
|
||||
if (getScrollMin() <= mfScroll) {
|
||||
setScroll(mfScroll - 3.5f);
|
||||
if (mfScroll <= getScrollMin()) setScroll(getScrollMin());
|
||||
else onSE(sound::SE_MESSAGE_SCROLL);
|
||||
}
|
||||
mpScrollButton->changeAnimation(false, 4);
|
||||
} else mpScrollButton->changeAnimation(false, 3);
|
||||
if (hold & 4) {
|
||||
if (getScrollMax() >= mfScroll) {
|
||||
setScroll(3.5f + mfScroll);
|
||||
if (mfScroll >= getScrollMax()) setScroll(getScrollMax());
|
||||
else onSE(sound::SE_MESSAGE_SCROLL);
|
||||
}
|
||||
mpScrollButton->changeAnimation(true, 4);
|
||||
} else mpScrollButton->changeAnimation(true, 3);
|
||||
}
|
||||
return textinput::InputForm::updateInput(chan, x, y, trig, hold, release, data);
|
||||
}
|
||||
|
||||
bool InputForm::updateInput(input::HKBManager& hkbManager) {
|
||||
return textinput::InputForm::updateInput(hkbManager);
|
||||
}
|
||||
|
||||
void InputForm::init() {
|
||||
if (mpBoundPane != NULL) mCharColor.Set(20, 20, 20, 255);
|
||||
mbUpVisible = false;
|
||||
mbDownVisible = false;
|
||||
searchAnmPane("P_txtScrll_UP")->changeAnimation(7);
|
||||
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(7);
|
||||
mbGoodBye = false;
|
||||
mbEditScrollUp = false;
|
||||
mbEditScrollDown = false;
|
||||
setScroll(0.0f);
|
||||
mfScrollFrom = 0.0f;
|
||||
mfScrollTo = 0.0f;
|
||||
resetRelation();
|
||||
updateCandidateState_();
|
||||
setLineDrawInfo(true, 10);
|
||||
}
|
||||
|
||||
void InputForm::draw() {
|
||||
setProjectionMtx();
|
||||
drawHeader();
|
||||
drawBody();
|
||||
drawFooter();
|
||||
if (meEditMode == EM_Edit) getPane("N_txt_scrl")->Draw(mDrawInfo);
|
||||
inputform::Base::draw();
|
||||
if (meEditMode == EM_Disp) {
|
||||
setProjectionMtx();
|
||||
getPane("N_TopBtn_00")->Animate(0);
|
||||
getPane("N_TopBtn_00")->CalculateMtx(mDrawInfo);
|
||||
getPane("N_TopBtn_00")->Draw(mDrawInfo);
|
||||
}
|
||||
mnLine = getLine();
|
||||
if (mnLine <= 4) mnLine = 4;
|
||||
}
|
||||
|
||||
void InputForm::setScroll(f32 scroll) {
|
||||
mfScroll = scroll;
|
||||
mfDrawScrollY = meEditMode == EM_Edit ? -mfScroll : 0.0f;
|
||||
}
|
||||
|
||||
static nw4r::math::VEC2 transformedOrigin(const nw4r::ut::Rect& rect, const Mtx& matrix) {
|
||||
nw4r::math::VEC3 position;
|
||||
position.x = rect.left;
|
||||
position.y = rect.bottom;
|
||||
position.z = 0.0f;
|
||||
PSMTXMultVec(matrix, reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
|
||||
return nw4r::math::VEC2(position.x, -position.y);
|
||||
}
|
||||
|
||||
void InputForm::calc() {
|
||||
nw4rmanager::Layout::calc();
|
||||
muGlobalAlpha = getLayout()->GetRootPane()->GetAlpha();
|
||||
mpLayout->Animate(0);
|
||||
mpLayout->CalculateMtx(mDrawInfo);
|
||||
mpLayout->GetRootPane()->FindPaneByName("N_Memo", true)->SetTranslate(nw4r::math::VEC2(0.0f, mfScroll));
|
||||
f32 height = mnLine * getLineHeight();
|
||||
f32 drawY = mDefaultDrawTrans.y - (height - mDefaultDrawSize.height) / 2.0f;
|
||||
mpDrawPane->SetSize(nw4r::lyt::Size(mpDrawPane->GetSize().width, height));
|
||||
mpDrawPane->SetTranslate(nw4r::math::VEC2(mDefaultDrawTrans.x, drawY));
|
||||
mpDrawPane->CalculateMtx(mDrawInfo);
|
||||
AdjustPaneMtx(mDrawMtx, mDrawInfo, mpDrawPane->GetGlobalMtx());
|
||||
nw4r::ut::Rect rect;
|
||||
rect = mpDrawPane->GetPaneRect(mDrawInfo);
|
||||
nw4r::math::VEC2 scale(getScale().x, 1.0f);
|
||||
nw4r::math::VEC2 position = transformedOrigin(rect, mDrawMtx);
|
||||
mDrawRect.left = position.x;
|
||||
mDrawRect.bottom = position.y;
|
||||
mDrawRect.right = position.x + scale.x * (rect.right - rect.left);
|
||||
mDrawRect.top = position.y + scale.y * (rect.top - rect.bottom);
|
||||
height = mnLine * getLineHeight();
|
||||
f32 halfHeight = height - mDefaultBoundSize.height;
|
||||
halfHeight *= 0.5f;
|
||||
f32 boundY = mDefaultBoundTrans.y - halfHeight;
|
||||
if (meEditMode == EM_Edit) {
|
||||
height = 2.0f * getLineHeight();
|
||||
boundY = (mDefaultBoundTrans.y - (height - mDefaultBoundSize.height) / 2.0f) - mfScroll;
|
||||
} else mfDrawScrollY = 0.0f;
|
||||
mpBoundPane->SetSize(nw4r::lyt::Size(mpBoundPane->GetSize().width, height));
|
||||
mpBoundPane->SetTranslate(nw4r::math::VEC2(mDefaultBoundTrans.x, boundY));
|
||||
mpBoundPane->CalculateMtx(mDrawInfo);
|
||||
AdjustPaneMtx(mBoundMtx, mDrawInfo, mpBoundPane->GetGlobalMtx());
|
||||
AdjustPaneMtx(mMtx.m, mDrawInfo, mpBoundPane->GetGlobalMtx());
|
||||
mRect = mpBoundPane->GetPaneRect(mDrawInfo);
|
||||
muGlobalAlpha = mpBoundPane->GetAlpha();
|
||||
mExScrollAnm.calc();
|
||||
if (mExScrollAnm.isActive()) {
|
||||
setScroll(mExScrollAnm.getValue());
|
||||
} else if (meEditMode == EM_Edit) {
|
||||
doAutoScroll();
|
||||
if (!mExScrollAnm.isActive()) {
|
||||
f32 halfLine = getLineHeight();
|
||||
halfLine *= 0.5f;
|
||||
if (mfScroll - halfLine > 0.0f) {
|
||||
if (!mbUpVisible) {
|
||||
searchAnmPane("P_txtScrll_UP")->changeAnimation(5);
|
||||
mpPaneManager->getPaneComponentByPane(getPane("B_txtScrll_UP"))->init();
|
||||
}
|
||||
mbUpVisible = true;
|
||||
} else {
|
||||
if (mbUpVisible) searchAnmPane("P_txtScrll_UP")->changeAnimation(6);
|
||||
mbUpVisible = false;
|
||||
}
|
||||
f32 textHeight = getLine() * getLineHeight();
|
||||
f32 lowerHalfLine = getLineHeight();
|
||||
lowerHalfLine *= 0.5f;
|
||||
f32 lowerEdge = mfScroll + height;
|
||||
lowerEdge += lowerHalfLine;
|
||||
if (lowerEdge < textHeight) {
|
||||
if (!mbDownVisible) {
|
||||
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(5);
|
||||
mpPaneManager->getPaneComponentByPane(getPane("B_txtScrll_DOWN"))->init();
|
||||
}
|
||||
mbDownVisible = true;
|
||||
} else {
|
||||
if (mbDownVisible) searchAnmPane("P_txtScrll_DOWN")->changeAnimation(6);
|
||||
mbDownVisible = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mbUpVisible = false;
|
||||
mbDownVisible = false;
|
||||
searchAnmPane("P_txtScrll_UP")->changeAnimation(7);
|
||||
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(7);
|
||||
getPane("N_txt_scrl")->Animate(0);
|
||||
getPane("N_txt_scrl")->CalculateMtx(mDrawInfo);
|
||||
}
|
||||
nw4r::lyt::Pane* scrollPane = getPane("N_txt_scrl");
|
||||
scrollPane->SetTranslate(nw4r::math::VEC2(scrollPane->GetTranslate().x, 0.0f));
|
||||
if (meEditMode == EM_Disp) {
|
||||
mpScrollButton->calc();
|
||||
if (!mbGoodBye) {
|
||||
if (mbEditScrollUp && getScrollMin() >= mfScroll) {
|
||||
mbEditScrollUp = false;
|
||||
mpScrollButton->changeAnimation(false, 2);
|
||||
} else if (!mbEditScrollUp && getScrollMin() < mfScroll) {
|
||||
mbEditScrollUp = true;
|
||||
mpScrollButton->changeAnimation(false, 1);
|
||||
}
|
||||
if (mbEditScrollDown && getScrollMax() <= mfScroll) {
|
||||
mbEditScrollDown = false;
|
||||
mpScrollButton->changeAnimation(true, 2);
|
||||
}
|
||||
if (!mbEditScrollDown && getScrollMax() > mfScroll) {
|
||||
mbEditScrollDown = true;
|
||||
mpScrollButton->changeAnimation(true, 1);
|
||||
}
|
||||
if (mpNigaoeObserver != NULL) mpNigaoeObserver->moveNigaoeButton();
|
||||
}
|
||||
}
|
||||
calcCursorTimer();
|
||||
}
|
||||
|
||||
void InputForm::doAutoScroll() {
|
||||
if (!mExScrollAnm.isActive() && (meScrollFlag == SF_ScrollOn || meScrollFlag == SF_ScrollByBS)) {
|
||||
if (meEditMode == EM_Edit) {
|
||||
f32 lineHeight = getLineHeight();
|
||||
lineHeight *= 0.5f;
|
||||
f32 cursorBottom = mfCursorY + lineHeight;
|
||||
if (mfScroll > cursorBottom) {
|
||||
int lines = (mfScroll - mfCursorY) / getLineHeight();
|
||||
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll - lines * getLineHeight(), 15.0f, NULL);
|
||||
onSE(sound::SE_LINE_SCROLL);
|
||||
}
|
||||
if (mfScroll + 2.0f * getLineHeight() < cursorBottom) {
|
||||
f32 lineHeight = getLineHeight();
|
||||
int lines = static_cast<int>((cursorBottom - (mfScroll + 2.0f * getLineHeight())) / lineHeight) + 1;
|
||||
mExScrollAnm.startAnm(NULL, mfScroll, mfScroll + lines * getLineHeight(), 15.0f, NULL);
|
||||
onSE(sound::SE_LINE_SCROLL);
|
||||
}
|
||||
}
|
||||
meScrollFlag = SF_NoScroll;
|
||||
}
|
||||
}
|
||||
|
||||
void InputForm::beginDraw(const nw4r::ut::Rect&) {
|
||||
if (mDrawRect.left == mDrawRect.right) mDrawRect.right += 0.1f;
|
||||
if (mDrawRect.top == mDrawRect.bottom) mDrawRect.top += 0.1f;
|
||||
textdrawer::Base::beginDraw(mDrawRect);
|
||||
}
|
||||
void InputForm::doScroll(Scroll*) {}
|
||||
|
||||
u32 InputForm::calcCursorPos(f32 x, f32 y) {
|
||||
u32 lines = getLine();
|
||||
if (lines > muLimitRowNum) lines = muLimitRowNum;
|
||||
f32 lineHeight = getLineHeight();
|
||||
f32 cursorY = y + mfScroll;
|
||||
if (cursorY > lines * lineHeight) return inputform::Base::calcCursorPos(x, lines * getLineHeight());
|
||||
return inputform::Base::calcCursorPos(x, cursorY);
|
||||
}
|
||||
void InputForm::drawCursor(f32 x, f32 y) {
|
||||
if (meEditMode != EM_Disp) inputform::Base::drawCursor(x, y);
|
||||
}
|
||||
nw4r::math::VEC2 InputForm::getScale() const {
|
||||
if (mpMemoRootPane == NULL) return nw4r::math::VEC2(1.0f, 1.0f);
|
||||
return mpMemoRootPane->GetScale();
|
||||
}
|
||||
|
||||
void InputForm::drawHeader() {
|
||||
getPane(scPaneName[0])->Draw(mDrawInfo);
|
||||
getPane("Nigaoe")->Draw(mDrawInfo);
|
||||
getPane("T_Nigaoe")->Draw(mDrawInfo);
|
||||
}
|
||||
void InputForm::drawBody() {
|
||||
nw4r::lyt::Pane* body = getPane(scPaneName[1]);
|
||||
f32 y = 0.0f;
|
||||
for (int i = 0; i < mnLine; i++) {
|
||||
body->SetTranslate(nw4r::math::VEC2(0.0f, y));
|
||||
body->CalculateMtx(mDrawInfo);
|
||||
body->Draw(mDrawInfo);
|
||||
y -= body->GetSize().height;
|
||||
}
|
||||
if (!mbEdited) getPane("T_TouchLetter")->Draw(mDrawInfo);
|
||||
}
|
||||
void InputForm::drawFooter() {
|
||||
f32 y = (mnLine - 1) * (-1.0f * getPane(scPaneName[1])->GetSize().height);
|
||||
nw4r::lyt::Pane* footer = getPane(scPaneName[3]);
|
||||
footer->SetTranslate(nw4r::math::VEC2(0.0f, y));
|
||||
footer->CalculateMtx(mDrawInfo);
|
||||
footer->Draw(mDrawInfo);
|
||||
}
|
||||
|
||||
void InputForm::open() {
|
||||
setScroll(0.0f);
|
||||
mfScrollFrom = 0.0f;
|
||||
mfScrollTo = 0.0f;
|
||||
mpLayout->GetRootPane()->SetTranslate(nw4r::math::VEC2(0.0f, 0.0f));
|
||||
searchAnmPane("N_Memo")->changeAnimation(1);
|
||||
searchAnmPane("P_txtScrll_UP")->changeAnimation(7);
|
||||
searchAnmPane("P_txtScrll_DOWN")->changeAnimation(7);
|
||||
}
|
||||
void InputForm::close() {
|
||||
if (!mbCloseWithSend) searchAnmPane("N_Memo")->changeAnimation(2);
|
||||
else searchAnmPane("N_Memo")->changeAnimation(3);
|
||||
if (mbEditScrollUp) {
|
||||
mpScrollButton->changeAnimation(false, 2);
|
||||
mbEditScrollUp = false;
|
||||
}
|
||||
if (mbEditScrollDown) {
|
||||
mpScrollButton->changeAnimation(true, 2);
|
||||
mbEditScrollDown = false;
|
||||
}
|
||||
mbGoodBye = true;
|
||||
}
|
||||
bool InputForm::isWholePaneInAnimation() {
|
||||
return searchAnmPane("N_Memo")->isInAnimation();
|
||||
}
|
||||
void InputForm::setHeaderCaption(const wchar_t* caption) {
|
||||
static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_Header", true))->SetString(caption, 0);
|
||||
}
|
||||
void InputForm::setMiiName(const wchar_t* name) {
|
||||
static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_Nigaoe", true))->SetString(name, 0);
|
||||
}
|
||||
void InputForm::setTouchLetterCaption(const wchar_t* caption) {
|
||||
static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_TouchLetter", true))->SetString(caption, 0);
|
||||
mbEdited = false;
|
||||
}
|
||||
nw4r::lyt::Pane* InputForm::getNigaoePane() {
|
||||
return getPane("Nigaoe");
|
||||
}
|
||||
nw4r::lyt::Material* InputForm::getNigaoePaneMaterial() {
|
||||
return getPane("Nigaoe")->FindMaterialByName("Nigaoe", true);
|
||||
}
|
||||
f32 InputForm::getScrollMin() { return 0.0f; }
|
||||
f32 InputForm::getScrollMax() { return getDrawBoxHeight() - 100.0f; }
|
||||
f32 InputForm::getDrawBoxHeight() { return mnLine * getLineHeight(); }
|
||||
|
||||
void InputForm::onNigaoeButtonTrig() {
|
||||
if (meEditMode == EM_Disp && mpNigaoeObserver != NULL && mpNigaoeObserver->onNigaoeButton()) onSE(sound::SE_DECIDE);
|
||||
}
|
||||
void InputForm::onNigaoeButtonPoint() {
|
||||
if (meEditMode == EM_Disp) {
|
||||
searchAnmPane("Nigaoe")->changeAnimation(4);
|
||||
if (mpNigaoeObserver != NULL) mpNigaoeObserver->pointNigaoeButton();
|
||||
onSE(sound::SE_BT_TARGETTING);
|
||||
}
|
||||
}
|
||||
void InputForm::onNigaoeButtonLeft() {
|
||||
if (meEditMode == EM_Disp) {
|
||||
if (mpNigaoeObserver != NULL) mpNigaoeObserver->leftNigaoeButton();
|
||||
searchAnmPane("Nigaoe")->changeAnimation(5);
|
||||
}
|
||||
}
|
||||
void InputForm::setDefaultNigaoe() {
|
||||
getNigaoePaneMaterial()->SetTexture(0, *mpDefaultNigaoe);
|
||||
}
|
||||
void InputForm::setEditMode(EditMode mode) {
|
||||
meEditMode = mode;
|
||||
switch (mode) {
|
||||
case EM_Disp: getPane("N_txt_scrl")->SetVisible(false); break;
|
||||
case EM_Edit: getPane("N_txt_scrl")->SetVisible(true); break;
|
||||
case EM_Disappear:
|
||||
onCommand(static_cast<INPUT_COMMAND>(6), NULL);
|
||||
candidatebox::CandidateBoxCaller::resetCandidate();
|
||||
candidatebox::CandidateBoxCaller::makeEmptyCandidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
void InputForm::preDraw(u32 pos) {
|
||||
if (meEditMode == EM_Disp) mpSendString->clear();
|
||||
inputform::Base::preDraw(pos);
|
||||
}
|
||||
void InputForm::doLineFeed() {
|
||||
if (meEditMode == EM_Disp) mpSendString->pushBack(L'\n');
|
||||
inputform::Base::doLineFeed();
|
||||
}
|
||||
void InputForm::put(wchar_t ch) {
|
||||
if (meEditMode == EM_Disp) mpSendString->pushBack(ch);
|
||||
textdrawer::Base::put(ch);
|
||||
}
|
||||
void InputForm::finishDraw(u32) {
|
||||
if (meEditMode == EM_Disp) mpSendString->pushBack(0);
|
||||
}
|
||||
void WholePane::onAnmEvent(AnmPaneEvent) {}
|
||||
|
||||
void EventHandler::onTiEvent(gui::PaneComponent* component, u32 event, Input* input) {
|
||||
inputform::EventHandler::onTiEvent(component, event, input);
|
||||
const char* name = component->getPane()->GetName();
|
||||
if (name[0] == 'B') {
|
||||
if (event == 4 && (input->field_0x0C & 0x800)) {
|
||||
if (util::strcmp("B_Nigaoe", name)) mpMemoForm->onNigaoeButtonTrig();
|
||||
if (util::strcmp("B_ArwR", name)) mpMemoForm->onArrowRTrig();
|
||||
if (util::strcmp("B_ArwL", name)) mpMemoForm->onArrowLTrig();
|
||||
}
|
||||
if (event == 0) {
|
||||
if (util::strcmp("B_Nigaoe", name)) mpMemoForm->onNigaoeButtonPoint();
|
||||
if (util::strcmp("B_ArwR", name)) mpMemoForm->onArrowRPoint();
|
||||
if (util::strcmp("B_ArwL", name)) mpMemoForm->onArrowLPoint();
|
||||
}
|
||||
if (event == 1) {
|
||||
if (util::strcmp("B_Nigaoe", name)) mpMemoForm->onNigaoeButtonLeft();
|
||||
if (util::strcmp("B_ArwR", name)) mpMemoForm->onArrowRLeft();
|
||||
if (util::strcmp("B_ArwL", name)) mpMemoForm->onArrowLLeft();
|
||||
}
|
||||
}
|
||||
}
|
||||
void SimpleAnmPane::changeAnimation(u32 id) { nw4rmanager::AnmPane::changeAnimation(id); }
|
||||
void SimpleAnmPane::init() {}
|
||||
void ScrollButton::init() {}
|
||||
u32 AnmPane::getState() { return meState; }
|
||||
void AnmPane::changeAnimation(u32 id) {
|
||||
meState = id;
|
||||
nw4rmanager::AnmPane::changeAnimation(id);
|
||||
}
|
||||
u32 AnmPane::getKeyType() const { return meKeyType; }
|
||||
void AnmPane::init() { meState = 0; }
|
||||
void NigaoePane::onAnmEvent(AnmPaneEvent) {}
|
||||
bool InputForm::isInScroll() { return mExScrollAnm.isActive(); }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
27
tools/decomp-assist/MyTiInputForm.attempts.md
Normal file
27
tools/decomp-assist/MyTiInputForm.attempts.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# MyTiInputForm attempts
|
||||
|
||||
Unit: `src/keyboard/MyTiInputForm`, 4.3U only.
|
||||
|
||||
Implemented all 84 target functions, including the compiler-generated inheritance thunks, in object order. The original `ghidra_decomp.txt` contains no functions from this unit; implementation followed the extracted assembly and sibling headers.
|
||||
|
||||
The initial source had 42 instruction-exact functions. Correcting the guarded base layout with the existing font and six repeat counters brought objdiff to 73 functions. Ordinary string literals and the original animation records produced identical 29-string pools from the first build.
|
||||
|
||||
## Functions that required iteration
|
||||
|
||||
- `onCommandOnDispMode`: initially 143/130 instructions. Keeping the cursor line in a separate scalar until constructing the relation argument, qualifying the candidate calls, and passing command 14 directly reduced this to 130/130. Assigning the edit point fields individually removed the final floating-point scheduling differences. Exact.
|
||||
- `InputForm::create`: initially 229/220 instructions. Removing redundant checks around placement new reduced this to 220/220. Correcting the GUI call to `setTriggerTarget(false)` fixed the last virtual-slot difference. Exact.
|
||||
- `createAnimation`: initially 129/124 instructions with a cached animation pointer. Ordinary placement new reduced this to 123/124. Reloading the animation record through its table entry restored 124/124 with 22 differences. Moving the count variable outside the loop worsened allocation to 49 differences. Keeping the loop bound as `entry.count` and initializing each concrete pane's key type in its constructor produced zero differences. The base constructor is protected; both concrete constructors initialize the key type before use. Exact.
|
||||
- `ScrollButton::create`: initially 160/154 instructions. Ordinary placement new and a signed animation ID corrected allocation checks and comparison instructions. Exact.
|
||||
- `init`: initial fields were at wrong guarded layout offsets. After restoring the repeat fields, separate boolean and float assignments corrected store order; `updateCandidateState_()` corrected the virtual slot. Exact.
|
||||
- `setScroll`: initially 9/10 instructions. Reading the stored scroll field when negating it preserved the original float rounding instruction. Exact.
|
||||
- `calcCursorPos`: initially 69/68 instructions. Computing line height before the adjusted cursor Y removed the extra saved floating-point move. Exact.
|
||||
- `open`: separate scroll-from and scroll-to stores fixed the last two differences. Exact.
|
||||
- `setEditMode`: initially 57/51 instructions. Qualified candidate calls removed the extra virtual dispatch. Exact.
|
||||
- `doAutoScroll`: initially 153/152 instructions. Casting the quotient to int before adding one restored the original conversion order and 152/152 instructions. Multiplication operand reversal and a named half-line value left one difference. Multiplying the line-height temporary in place removed it. Exact.
|
||||
- `calc`: initial 624/629 instructions and a different frame layout. Explicit draw-size/position temporaries and VEC3 construction gave 626/629. A helper returning the transformed origin, with separate coordinate assignments, restored the packed VEC2 return and 629/629. Computing draw Y before setting pane size and expressing half-height separately reduced this to 14 differences. Guarding the rectangle member with its NW4R type and assigning the returned rectangle directly corrected ten stack offsets. Several half-height multiplication temporaries altered allocation without reaching exactness. Dividing the centered height differences by 2 and computing the lower edge in a named scalar removed every remaining difference. Exact: 629/629 instructions, diffs 0.
|
||||
|
||||
## Validation scope
|
||||
|
||||
The unit remains `NonMatching`. All original code functions match; data has separate unresolved differences and no linking claim is made. All shared-header changes are guarded by `MYTIINPUTFORM_IMPLEMENTATION`, defined only in this source file.
|
||||
|
||||
The default gate merge-base is `112e4e1a`, for which the supplied tools have no baseline report. Gates use the available parent snapshot explicitly: `--base 0aca3c76`. No supplied baseline or tool was edited. Regression checks against that snapshot remain zero.
|
||||
Reference in New Issue
Block a user