Compare commits

...

8 Commits

Author SHA1 Message Date
Devin AI
9b4f2f1b97 kbdzi: restore per-TU decl-only gating — drop ~TiEventHandler, split tiString/CommandReceiver ordering, out-of-line GUIComponent/GUIManager defs + changeEventHandler home; DOL hash OK
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 21:41:08 +00:00
Devin AI
cb43716639 zkokeyp: non-const param (alias reload), keyTable i*9 decode
- Zi8_81483264 param back to ziGetParam* — store through scratch may alias
  param->maxCandidates, producing base's per-iter lbz reload
- Zi8GetKOcandidates keyTable + keyIndex*9 form reproduces base's i*9
  address grouping (673->664 insns)

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 21:09:54 +00:00
Devin AI
00db0ec068 kbdzi: zi8pud2 u16 byte-pair decode, tiInputForm float-form fixes, MyTiManager global binds
- zi8pud2: (ziU16) casts on PUD byte-pair reads reproduce base's clrlwi idiom
- zkokeyp: drop gate-violating volatile casts (no codegen change)
- tiInputForm: autoScroll lh/2.0f literal fold, calc DegToFIdxF*phase operand
  order, onTiEvent {0,0,0} int-zero CursorPos inits -> all 3 fns identical
- tiString: u16 count + indexed input[i] writes in mode==3 (partial)
- MyTiManager: de-static file-scope singletons -> GLOBAL binds, State::~State
  non-inline -> __vt__State GLOBAL

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 21:04:31 +00:00
Devin AI
5c81a8985b kbdzi: inline-empty ~EventHandler/~TiEventHandler — derived dtor chains match
- ~gui::EventHandler inline-empty: derived deleting-dtors emit no base call
- ~TiEventHandler() {} declared inline-empty: breaks implicit chain weak-emits
- ~GUIInterface() {} restored (implicit broke .data fuzzy scoring)
- tiSignWindow 99.90, tiCandidateBox 99.31, tiCellPhone 99.78 code

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 19:55:22 +00:00
Devin AI
d138b586f2 kbdzi: decl-only virtual refactor — vtable key-fn ordering + weak-fn elimination
- GUIComponent/EventHandler/GUIManager virtuals decl-only, defs in owning TUs
- ~GUIComponent declared first → key fn → __vt__GUIComponent GLOBAL in tiGUIManager.o
- EventHandler defs in tiPcKeyboard.cpp; drops weak-copy excess across leaf
- tiGUIManager whole-unit 100/100; tiPcKeyboard/tiInputForm/tiSignWindow .text fixed

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 19:41:22 +00:00
Devin AI
dcb7a8b033 kbdzi: gate decl-only GUIComponent/EventHandler forms per impl unit; tiInputForm .sdata2 + .data decode; zkokeyp volatile-cast
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 17:22:22 +00:00
Devin AI
b81cb13d11 tiInputForm::create: FindPaneByName probe + inline files[i] member indexing
Base probes root->FindPaneByName(textBox) first (not paneMgr.getPane),
and indexes button.files[i] inline (button+i*4 base, +0x10 offset)
rather than through a file local. 356=356 insns; residual is the
{this,allocator} callee-window rotation and one select-load schedule.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 14:31:02 +00:00
Devin AI
8788e79e50 kbdzi: tiPcKeyboard fns identical + Zi8PrepareMatch size decode
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 14:13:53 +00:00
15 changed files with 393 additions and 167 deletions

View File

@@ -48,6 +48,15 @@ namespace textinput {
public:
virtual ~GUIInterface() {} // 0x08
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual void create(); // 0x0C
virtual void init(); // 0x10
virtual void calc(); // 0x14
virtual void draw(Mtx& mtx); // 0x18
virtual void draw(); // 0x1C
#else
virtual void create() {} // 0x0C
virtual void init() {} // 0x10
@@ -55,6 +64,7 @@ namespace textinput {
virtual void draw(Mtx& mtx) {} // 0x18
virtual void draw() {} // 0x1C
#endif
};
class EventHandler {
@@ -70,12 +80,23 @@ namespace textinput {
EventHandler() : muLatestEventCtrlNo(0) {}
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual ~EventHandler(); // 0x08
#else
virtual ~EventHandler() {} // 0x08
#endif
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_IMPLEMENTATION) || defined(TI_CELLPHONE_IMPLEMENTATION)
virtual void onEvent(GUIComponent& comp, u32 event, void* data); // 0x0C
virtual void setLatestEventCtrlNo(int ctrlNo); // 0x10
virtual int getLatestEventCtrlNo(); // 0x14
#else
virtual void onEvent(GUIComponent& comp, u32 event, void* data) {} // 0x0C
virtual void setLatestEventCtrlNo(int ctrlNo) { muLatestEventCtrlNo = ctrlNo; } // 0x10
virtual int getLatestEventCtrlNo() { return muLatestEventCtrlNo; } // 0x14
#endif
protected:
int muLatestEventCtrlNo; // 0x04
@@ -92,8 +113,14 @@ namespace textinput {
EVENT_RELEASE
};
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual void init();
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual ~GUIComponent(); // 0x08
#else
virtual ~GUIComponent() {} // 0x08
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIGUIMANAGER_IMPLEMENTATION)
virtual void init(); // 0x10
#else
virtual void init() { // 0x10
for (int i = 0; i < GUI_POINTS_MAX; i++) {
@@ -109,14 +136,27 @@ namespace textinput {
: GUIInterface(), mbInitialize(false), mDraggingButton(0xFFFF), mID(id), mbTriggerTarget(false), mpManager(NULL), mpListener(NULL) {
init();
}
virtual ~GUIComponent() {} // 0x08
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual u32 getID(); // 0x20
virtual bool isPointed(int point); // 0x24
#else
virtual u32 getID() { return mID; } // 0x20
virtual bool isPointed(int point) { return mbPointed[point]; } // 0x24
#endif
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIGUIMANAGER_IMPLEMENTATION)
virtual bool isDragging(int point); // 0x28
#else
virtual bool isDragging(int point) { return mbDragging[point]; } // 0x28
#endif
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual void setPointed(int point, bool bEnable); // 0x2C
#else
virtual void setPointed(int point, bool bEnable) { mbPointed[point] = bEnable; } // 0x2C
#endif
void onEvent(u32 event, void* data) {
if (mpListener) {
@@ -124,6 +164,21 @@ namespace textinput {
}
}
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual void onPointIn(int point); // 0x30
virtual void onPointOut(int point); // 0x34
virtual void onDrag(f32 x, f32 y);
virtual void onMove(int point, f32 x, f32 y); // 0x38
virtual void onTrig(int point, u32 trig, Vec& dragPos);
virtual void setDraggingButton(u32 dragBtn); // 0x3C
virtual u32 updatePointer(const GUIPointer& pointer); // 0x40
virtual u32 updatePointer(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release); // 0x44
virtual bool isTriggerTarget(); // 0x48
#else
virtual void onPointIn(int point) { mFlightDuration[point] = 0; } // 0x30
virtual void onPointOut(int point) { mFlightDuration[point] = 0; } // 0x34
@@ -146,15 +201,32 @@ namespace textinput {
}
virtual bool isTriggerTarget() { return mbTriggerTarget; } // 0x48
#endif
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIGUIMANAGER_IMPLEMENTATION)
virtual void setTriggerTarget(bool bEnable); // 0x4C
#else
virtual void setTriggerTarget(bool bEnable) { mbTriggerTarget = bEnable; } // 0x4C
#endif
void setParentManager(GUIManager* manager) { mpManager = manager; }
GUIManager* getParentManager() { return mpManager; }
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual bool isVisible(); // 0x50
#else
virtual bool isVisible() { return true; } // 0x50
#endif
virtual u16 getFlightDuration(int point) { return mFlightDuration[point]; } // 0x54
#if defined(TI_CANDIDATEBOX_IMPLEMENTATION) || defined(TIGUIMANAGER_IMPLEMENTATION)
virtual u16 getFlightDuration(int point); // 0x54
#else
virtual u16 getFlightDuration(int point) { return mFlightDuration[point]; } // 0x54
#endif
#if defined(TI_CELLPHONE_IMPLEMENTATION) || defined(TIGUIMANAGER_IMPLEMENTATION)
virtual void setFlightDuration(int point, u16 flightDir); // 0x58
#else
virtual void setFlightDuration(int point, u16 flightDir) { mFlightDuration[point] = flightDir; } // 0x58
#endif
virtual bool contain(f32 x, f32 y) = 0; // 0x5C
@@ -200,9 +272,16 @@ namespace textinput {
virtual GUIComponent* getComponent(u32 id); // 0x24
virtual GUIComponent* getComponent(u32 id) const; // 0x28
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual bool update(int point, const KPADStatus* kpad, f32, f32, void* data); // 0x2C
#else
virtual bool update(int point, const KPADStatus* kpad, f32, f32, void* data) { return false; } // 0x2C
#endif
virtual bool update(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x30
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual void onEvent(GUIComponent& comp, u32 event, int point, void* data); // 0x34
#else
virtual void onEvent(GUIComponent& comp, u32 event, int point, void* data) { // 0x34
if (mpEventHandler) {
mpEventHandler->setLatestEventCtrlNo(point);
@@ -210,17 +289,26 @@ namespace textinput {
}
comp.onEvent(event, data);
}
#endif
virtual void setAllComponentTriggerTarget(bool bEnable); // 0x38
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual void setEventHandler(EventHandler* eventHandler); // 0x3C
#else
virtual void setEventHandler(EventHandler* eventHandler) { // 0x3C
mpEventHandler = eventHandler;
}
#endif
#if defined(TIGUIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
virtual EventHandler* changeEventHandler(EventHandler* eventHandler); // 0x40
#else
virtual EventHandler* changeEventHandler(EventHandler* eventHandler) { // 0x40
EventHandler* prevHandler = mpEventHandler;
mpEventHandler = eventHandler;
return prevHandler;
}
#endif
virtual void setDraggingButton(u32 dragBtn); // 0x44
@@ -259,8 +347,13 @@ namespace textinput {
virtual PaneComponent* getPaneComponentByPane(nw4r::lyt::Pane* pane); // 0x4C
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual const nw4r::lyt::DrawInfo* getDrawInfo(); // 0x50
virtual void setDrawInfo(const nw4r::lyt::DrawInfo* drawInfo); // 0x54
#else
virtual const nw4r::lyt::DrawInfo* getDrawInfo() { return mpDrawInfo; } // 0x50
virtual void setDrawInfo(const nw4r::lyt::DrawInfo* drawInfo) { mpDrawInfo = drawInfo; } // 0x54
#endif
virtual void setAllBoundingBoxComponentTriggerTarget(bool bEnable); // 0x58
void walkInChildren(nw4r::lyt::PaneList& paneList);
@@ -302,7 +395,11 @@ namespace textinput {
virtual bool contain(f32 x, f32 y); // 0x5C
#ifdef TIGUIMANAGER_IMPLEMENTATION
virtual void setPane(nw4r::lyt::Pane* pane); // 0x60
#else
virtual void setPane(nw4r::lyt::Pane* pane) { mpPane = pane; } // 0x60
#endif
nw4r::lyt::Pane* getPane() { return mpPane; }
nw4r::lyt::TextBox* getTextPane() { return static_cast<nw4r::lyt::TextBox*>(mpPane); }

View File

@@ -66,6 +66,9 @@ public:
virtual void startToInput();
virtual void movePrevSignWindow();
virtual void moveNextSignWindow();
#ifdef TISIGNWINDOW_IMPLEMENTATION
virtual void vt_0x10C() = 0;
#endif
bool mbActive;
bool mbInput;

View File

@@ -84,12 +84,20 @@ namespace textinput {
Decolated(u16 maxLen) : StringBase(maxLen), field_0x18(0), field_0x1C(0), field_0x20(0), field_0x24(0) { initKanaConverter(); }
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Decolated();
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
virtual void clear();
virtual void set(const wchar_t* string);
virtual void setLength(u16 length);
#elif defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
virtual void setLength(u16 length);
virtual void clear();
virtual ~Decolated();
virtual void set(const wchar_t* string);
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
void setTranslateMode(TranslateMode mode);
TranslateMode getTranslateMode() const { return static_cast<TranslateMode>(mTranslateMode); }
void inputString(const wchar_t* string, TranslateMode mode);

View File

@@ -57,7 +57,7 @@ namespace textinput {
#ifdef TI_CELLPHONE_IMPLEMENTATION
struct ChangePredictMode;
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIMANAGER_IMPLEMENTATION
CommandReceiver() { clearSender(); }
virtual ~CommandReceiver();
#endif
@@ -79,6 +79,10 @@ namespace textinput {
virtual void clearSender();
virtual void onCommand(INPUT_COMMAND command, void* data);
virtual void addSender(CommandSender* cmdSend);
#ifdef TIINPUTFORM_IMPLEMENTATION
CommandReceiver() { clearSender(); }
virtual ~CommandReceiver();
#endif
private:
nw4r::ut::List mSenderList; // 0x04

View File

@@ -88,8 +88,8 @@ ziU32 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
Zi8LogError(0x4F6, __zi8_work_data);
return 0;
}
ZI_WORK->unk_0x314 = section->count[0] * 0x100 + section->count[1];
ZI_WORK->unk_0x310 = (ziU32)table + section->offset[0] * 0x100 + section->offset[1];
ZI_WORK->unk_0x314 = (ziU16)section->count[0] * 0x100 + (ziU16)section->count[1];
ZI_WORK->unk_0x310 = (ziU32)table + ((ziU16)section->offset[0] << 8) + (ziU16)section->offset[1];
ZI_WORK->unk_0x318 = 0;
}
for (;;) {

View File

@@ -61,7 +61,7 @@ void Zi8_81483118(ziGetParam* param, ziU8* output) {
}
}
ziU32 Zi8_81483264(const ziGetParam* param ZI_NEED_WORK) {
ziU32 Zi8_81483264(ziGetParam* param ZI_NEED_WORK) {
ziU8 i;
if (param->scratch == ZI8_NULL) {
@@ -140,7 +140,8 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
j = 0;
filter.candidateIndex = 0;
matched = 0;
filter.keys.bytes[4] = filter.keys.firstWord = 0;
filter.keys.firstWord = 0;
filter.keys.bytes[4] = 0;
Zi8LogError(0x64, ZI_WORK);
if (param->elementCount == 0) {
if (*remaining >= *count) {
@@ -315,10 +316,10 @@ ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount != 0) {
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) {
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 3) << 16 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childHigh << 8);
((((ZiKoreanKeyEntry*)(keyTable + search.keyIndex * 9))->keyBytes[4] & 8) != 0)) {
search.wordOffset = ((ZiKoreanKeyEntry*)(keyTable + search.keyIndex * 9))->childLow |
((((ZiKoreanKeyEntry*)(keyTable + search.keyIndex * 9))->keyBytes[4] & 3) << 16 |
((ZiKoreanKeyEntry*)(keyTable + search.keyIndex * 9))->childHigh << 8);
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
wordNode = search.wordTable + search.wordOffset;
@@ -342,8 +343,8 @@ match_word:
}
if (search.remainingLetters == 0) {
search.keyIndex = ((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1];
search.character = (ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterLow);
search.character = (ziU16)((ziU16)((ZiKoreanKeyEntry*)(keyTable + search.keyIndex * 9))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(keyTable + search.keyIndex * 9))->characterLow);
if (param->wordCharCount == 1) {
if (search.keyIndex == search.previousIndex) {
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
@@ -453,7 +454,7 @@ search_table:
do {
for (search.tableIndex = 0; search.tableIndex < search.tableCount; search.tableIndex = search.tableIndex + 1) {
search.matches = ZI8_TRUE;
search.entry = (ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable);
search.entry = (ZiKoreanKeyEntry*)(keyTable + search.tableIndex * 9);
search.keyByte = 0;
if (1 < param->elementCount) {
for (search.keyByte = 0;
@@ -490,8 +491,8 @@ search_table:
if (++search.resultCount >= (ziS32)options->maxCount) return options->maxCount;
} else {
param->candidates[search.candidateCount++] =
(ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterLow);
(ziU16)((ziU16)((ZiKoreanKeyEntry*)(keyTable + search.tableIndex * 9))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(keyTable + search.tableIndex * 9))->characterLow);
if (++param->letters >= param->maxCandidates) return param->letters;
}
}

View File

@@ -43,6 +43,7 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
stroke = 0;
contextMask = 0x20;
Zi8Memset(match,0,0x1ee);
index = 0;
nibbles = 0;
elementIndex = 0;
elementCount = request->elementCount;
@@ -61,6 +62,7 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
match->comp = element = request->elements[0];
if (Zi8IsComponent(element,__zi8_work_data) != 0) {
elementIndex++;
nibbles = 1;
buffers.component = (ziU8*)Zi8GetTableAddress(1,2,__zi8_work_data);
buffers.componentIndex = (ziU8*)Zi8GetTableAddress(1,6,__zi8_work_data);
buffers.componentIndex += (element - 0xef10) * 2;

View File

@@ -283,6 +283,12 @@ void InputForm::create(MEMAllocator* allocator, inputform::EditBuffer* editBuffe
mpScrollButton->create(allocator, mpMultiArcResourceAccessor);
}
gui::EventHandler* gui::GUIManager::changeEventHandler(gui::EventHandler* eventHandler) {
EventHandler* prevHandler = mpEventHandler;
mpEventHandler = eventHandler;
return prevHandler;
}
void InputForm::createAnimation(MEMAllocator* allocator) {
for (u16 i = 0; i < 2; i++) {
const PaneAnimations& entry = csPaneToAnimation[i];

View File

@@ -7,6 +7,7 @@
#include <new>
namespace textinput {
namespace extend {
namespace memo {
@@ -112,19 +113,19 @@ namespace textinput {
namespace extend {
namespace memo {
static DispMemoState sDispMemoState;
static EditMemoState sEditMemoState;
static AppearMemoState sAppearMemoState;
static DisappearMemoState sDisappearMemoState;
DispMemoState sDispMemoState;
EditMemoState sEditMemoState;
AppearMemoState sAppearMemoState;
DisappearMemoState sDisappearMemoState;
struct MemoPosition {
f32 x;
f32 y;
};
static MemoPosition sHiddenMemoPosition = {-200.0f, 0.0f};
static MemoPosition sAppearingMemoPosition = {0.0f, 255.0f};
static MemoPosition sLetterMemoPosition = {0.0f, 145.0f};
MemoPosition sHiddenMemoPosition = {-200.0f, 0.0f};
MemoPosition sAppearingMemoPosition = {0.0f, 255.0f};
MemoPosition sLetterMemoPosition = {0.0f, 145.0f};
Manager::~Manager() {
if (mpDefaultPCKeyboard != NULL) {
@@ -1227,7 +1228,7 @@ Manager::StateType EditMemoState::getStateType() {
return Manager::ST_Visible;
}
inline State::~State() {}
State::~State() {}
Manager::StateType AppearMemoState::getStateType() {
return Manager::ST_Appearing;
@@ -1239,6 +1240,9 @@ Manager::StateType DispMemoState::getStateType() {
return Manager::ST_Hidden;
}
extern const f32 sZeroScale;
const f32 sZeroScale = 0.0f;
}
}
}

View File

@@ -407,20 +407,21 @@ namespace textinput {
for (u16 i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
pane = NULL;
const PaneToAnimation& p = scCandidatePaneData.panes[i];
const char* paneName = p.paneName;
switch (p.type) {
case KT_ScrollButton: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(CandidateScrollAnmPane));
pane = new (pBtnBuf) CandidateScrollAnmPane(getPane(p.paneName), NULL);
pane = new (pBtnBuf) CandidateScrollAnmPane(getPane(paneName), NULL);
break;
}
case KT_CandidateText: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(CandidateTextAnmPane));
pane = new (pBtnBuf) CandidateTextAnmPane(getPane(p.paneName), NULL);
pane = new (pBtnBuf) CandidateTextAnmPane(getPane(paneName), NULL);
break;
}
case KT_OnOffButton: {
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(OnOffAnmPane));
pane = new (pBtnBuf) OnOffAnmPane(getPane(p.paneName), &mOnOffButton);
pane = new (pBtnBuf) OnOffAnmPane(getPane(paneName), &mOnOffButton);
break;
}
@@ -1783,4 +1784,8 @@ namespace textinput {
}
} // namespace candidatebox
namespace gui {
u16 GUIComponent::getFlightDuration(int point) { return mFlightDuration[point]; }
}
} // namespace textinput

View File

@@ -1434,4 +1434,8 @@ namespace textinput {
}
}
namespace gui {
void GUIComponent::setFlightDuration(int point, u16 flightDir) { mFlightDuration[point] = flightDir; }
}
}

View File

@@ -1,3 +1,4 @@
#define TIGUIMANAGER_IMPLEMENTATION
#include "keyboard/tiGUIManager.h"
#include "keyboard/tiUtil.h"
@@ -88,6 +89,20 @@ namespace textinput {
return event;
}
bool GUIComponent::isVisible() { return true; }
bool GUIComponent::isPointed(int point) { return mbPointed[point]; }
void GUIComponent::onMove(int point, f32 x, f32 y) { mFlightDuration[point]++; }
void GUIComponent::setPointed(int point, bool bEnable) { mbPointed[point] = bEnable; }
void GUIComponent::onPointIn(int point) { mFlightDuration[point] = 0; }
void GUIComponent::onPointOut(int point) { mFlightDuration[point] = 0; }
void GUIComponent::onDrag(f32 x, f32 y) {}
GUIManager::~GUIManager() {
IDToComponent* p = static_cast<IDToComponent*>(nw4r::ut::List_GetFirst(&mComponents));
while (p != NULL) {
@@ -125,6 +140,8 @@ namespace textinput {
}
}
u32 GUIComponent::getID() { return mID; }
GUIComponent* GUIManager::getComponent(u32 id) {
IDToComponent* p = static_cast<IDToComponent*>(nw4r::ut::List_GetNth(&mComponents, (u16)id));
return p->mpComponent;
@@ -192,6 +209,29 @@ namespace textinput {
return touched;
}
u32 GUIComponent::updatePointer(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release) {
GUIPointer pointer(point, x, y, hold, trig, release);
return updatePointerImpl(pointer);
}
void GUIManager::onEvent(GUIComponent& comp, u32 event, int point, void* data) {
if (mpEventHandler) {
mpEventHandler->setLatestEventCtrlNo(point);
mpEventHandler->onEvent(comp, event, data);
}
comp.onEvent(event, data);
}
bool GUIComponent::isTriggerTarget() { return mbTriggerTarget; }
void GUIComponent::onTrig(int point, u32 trig, Vec& dragPos) {
if (trig & mDraggingButton) {
mDraggingPos[point] = dragPos;
mbDragging[point] = true;
mFlightDuration[point] = 0;
}
}
void GUIManager::calc() {
for (IDToComponent* p = static_cast<IDToComponent*>(nw4r::ut::List_GetFirst(&mComponents)); p != NULL;
p = static_cast<IDToComponent*>(nw4r::ut::List_GetNext(&mComponents, p))) {
@@ -220,6 +260,8 @@ namespace textinput {
}
}
void GUIComponent::setDraggingButton(u32 dragBtn) { mDraggingButton = dragBtn; }
PaneManager::~PaneManager() {
PaneToComponent* p = static_cast<PaneToComponent*>(nw4r::ut::List_GetFirst(&mPaneComponents));
while (p) {
@@ -243,6 +285,8 @@ namespace textinput {
PaneComponent::~PaneComponent() {}
GUIComponent::~GUIComponent() {}
void PaneManager::createLayoutScene(const nw4r::lyt::Layout& layout) {
mIDCounter = 0;
walkInChildren(layout.GetRootPane()->GetChildList());
@@ -288,6 +332,8 @@ namespace textinput {
addComponent(pComponent);
}
void PaneComponent::setPane(nw4r::lyt::Pane* pane) { mpPane = pane; }
PaneComponent* PaneManager::searchPaneComponent(const char* name) {
for (u32 i = 0; i < nw4r::ut::List_GetSize(&mPaneComponents); i++) {
PaneToComponent* p = static_cast<PaneToComponent*>(nw4r::ut::List_GetNth(&mPaneComponents, (u16)i));
@@ -346,6 +392,8 @@ namespace textinput {
}
}
const nw4r::lyt::DrawInfo* PaneManager::getDrawInfo() { return mpDrawInfo; }
#pragma push
#pragma section sconst_type ".sdata2"
extern "C" const f32 scGuiZeroF = 0.0f;
@@ -489,5 +537,11 @@ namespace textinput {
}
return true;
}
u32 GUIComponent::updatePointer(const GUIPointer& pointer) { return updatePointerImpl(pointer); }
void GUIManager::setEventHandler(EventHandler* eventHandler) { mpEventHandler = eventHandler; }
bool GUIManager::update(int point, const KPADStatus* kpad, f32 x, f32 y, void* data) { return false; }
} // namespace gui
} // namespace textinput

View File

@@ -155,6 +155,30 @@ extern "C" const char scN_KOR[];
extern "C" const char scN_CHN[];
#pragma pop
extern "C" const f32 scInputFormZeroF;
extern "C" const f32 scInputForm640F;
extern "C" const f64 scInputFormF32ConvertMagic;
extern "C" const f32 scInputFormOneF;
extern "C" const f32 scInputFormHalfF;
extern "C" const f32 scInputFormDegToFIdxF;
extern "C" const f32 scInputForm150F;
extern "C" const f32 scInputForm30F;
extern "C" const f32 scInputForm50F;
extern "C" const f32 scInputForm10F;
extern "C" const f32 scInputForm52F;
extern "C" const f32 scInputFormTwoF;
extern "C" const f32 scInputForm140F;
extern "C" const f32 scInputForm90F;
extern "C" const f32 scInputForm253F;
extern "C" const f32 scInputForm20F;
extern "C" const u8 scInputFormColorRU8;
extern "C" const u8 scInputFormColorGU8;
extern "C" const u8 scInputFormColorBU8;
extern "C" const u8 scInputFormColorAU8;
extern "C" const f32 scInputForm255F;
extern "C" const f32 scInputForm127F;
extern "C" const f32 scInputForm14592F;
extern "C" const f64 scInputFormF64ConvertMagic;
extern "C" const f32 scInputForm15F;
extern "C" void _savegpr_20();
extern "C" void _restgpr_20();
extern "C" void _savegpr_27();
@@ -386,31 +410,6 @@ extern "C" const wchar_t pppURLCheck[2][10] = {L"http://", L"https://"};
#pragma pop
extern "C" const f32 scInputFormZeroF = 0.0f;
extern "C" const f32 scInputForm640F = 640.0f;
extern "C" const f64 scInputFormF32ConvertMagic = 4503601774854144.0;
extern "C" const f32 scInputFormOneF = 1.0f;
extern "C" const f32 scInputFormHalfF = 0.5f;
extern "C" const f32 scInputFormDegToFIdxF = 0.7111111f;
extern "C" const f32 scInputForm150F = 150.0f;
extern "C" const f32 scInputForm30F = 30.0f;
extern "C" const f32 scInputForm50F = 50.0f;
extern "C" const f32 scInputForm10F = 10.0f;
extern "C" const f32 scInputForm52F = 52.0f;
extern "C" const f32 scInputFormTwoF = 2.0f;
extern "C" const f32 scInputForm140F = 140.0f;
extern "C" const f32 scInputForm90F = 90.0f;
extern "C" const f32 scInputForm253F = 253.0f;
extern "C" const f32 scInputForm20F = 20.0f;
extern "C" const u8 scInputFormColorRU8 = 0xff;
extern "C" const u8 scInputFormColorGU8 = 0x32;
extern "C" const u8 scInputFormColorBU8 = 0x32;
extern "C" const u8 scInputFormColorAU8 = 0;
extern "C" const f32 scInputForm255F = 255.0f;
extern "C" const f32 scInputForm127F = 127.0f;
extern "C" const f32 scInputForm14592F = 14592.0f;
extern "C" const f64 scInputFormF64ConvertMagic = 4503599627370496.0;
extern "C" const f32 scInputForm15F = 15.0f;
f32 sfColorPhase;
bool mbHyphen = true;
@@ -1169,7 +1168,7 @@ void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
setVisible("N_2line", true);
mpPaneManager->setAllComponentTriggerTarget(false);
mpPaneManager->setAllBoundingBoxComponentTriggerTarget(true);
nw4r::lyt::Pane* pane = getPane(static_cast<const LanguagePaneData*>(mpLanguageData)->textBox);
nw4r::lyt::Pane* pane = mpLayout->GetRootPane()->FindPaneByName(static_cast<const LanguagePaneData*>(mpLanguageData)->textBox, true);
if (!pane) pane = mpLayout->GetRootPane()->FindPaneByName(getLanguageTextPane() ? static_cast<const LanguagePaneData*>(mpLanguageData)->textBox : "T_2l_TextBox", true);
mpPaneManager->getPaneComponentByPane(pane)->setTriggerTarget(true);
for (u32 buttonIndex = 0; buttonIndex < 2; ++buttonIndex) {
@@ -1183,15 +1182,13 @@ void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
}
}
nw4r::ut::List_Append(&mAnmPanes, animationPane);
u32 count;
const char* bindingName = button.bindingName;
count = button.count;
u32 count = button.count;
for (u16 animationIndex = 0; animationIndex < count; ++animationIndex) {
const InputFormAnimationFile* file = button.files[animationIndex];
void* resource = mpMultiArcResourceAccessor->GetResource(0, file->fileName, NULL);
void* resource = mpMultiArcResourceAccessor->GetResource(0, button.files[animationIndex]->fileName, NULL);
AnimTransformPane* transform = static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
if (!bindingName) animationPane->addAnimation(allocator, file->id, transform, false, true);
else animationPane->forceAddAnimation(allocator, file->id, transform, bindingName, false, true);
if (!bindingName) animationPane->addAnimation(allocator, button.files[animationIndex]->id, transform, false, true);
else animationPane->forceAddAnimation(allocator, button.files[animationIndex]->id, transform, bindingName, false, true);
}
}
init();
@@ -1236,7 +1233,7 @@ void LayoutByNW4R::calc() {
if (getPane(separator)) setVisible(static_cast<const LanguagePaneData*>(mpLanguageData)->separator, mbRepeat);
else setVisible("N_separateBarAll", mbRepeat);
if (!mScrollAnm.isActive()) {
if (0.0f > mfScrollY) up = true;
if (inputform::scInputFormZeroF > mfScrollY) up = true;
if (mfMinScrollY < mfScrollY) down = true;
if (mbUpVisible != up) {
mbUpVisible = up;
@@ -1354,12 +1351,12 @@ void EventHandler::onTiEvent(gui::PaneComponent* component, u32 event, Input* in
util::replaceChar(animationName, 17, name, 0, 'P');
if (event == 4 && (input->trigger & 0x800) && !mpInputForm->isInScroll()) {
if (mpInputForm->isAbleToUp() && util::strcmp("P_txtScrll_UP", animationName)) {
textdrawer::Base::CursorPos movement = {0, 0.0f, 0.0f};
textdrawer::Base::CursorPos movement = {0, 0, 0};
movement.fCursorY = mpInputForm->getLineHeight();
mpInputForm->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(24), &movement);
mpInputForm->searchAnmPane(animationName)->onAnmEvent(nw4rmanager::AnmPane::PE_0);
} else if (mpInputForm->isAbleToDown() && util::strcmp("P_txtScrll_DOWN", animationName)) {
textdrawer::Base::CursorPos movement = {0, 0.0f, 0.0f};
textdrawer::Base::CursorPos movement = {0, 0, 0};
movement.fCursorY = -mpInputForm->getLineHeight();
mpInputForm->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(24), &movement);
mpInputForm->searchAnmPane(animationName)->onAnmEvent(nw4rmanager::AnmPane::PE_0);
@@ -1370,7 +1367,7 @@ void EventHandler::onTiEvent(gui::PaneComponent* component, u32 event, Input* in
if (component->isDragging(input->controller)) {
u32 duration = mpInputForm->getFlightDuration(input->controller, name);
if (duration >= 60 && duration % 20 == 0) {
textdrawer::Base::CursorPos movement = {0, 0.0f, 0.0f};
textdrawer::Base::CursorPos movement = {0, 0, 0};
movement.fCursorY = mpInputForm->getLineHeight();
mpInputForm->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(24), &movement);
mpInputForm->searchAnmPane(animationName)->onAnmEvent(nw4rmanager::AnmPane::PE_0);
@@ -1380,7 +1377,7 @@ void EventHandler::onTiEvent(gui::PaneComponent* component, u32 event, Input* in
if (component->isDragging(input->controller)) {
u32 duration = mpInputForm->getFlightDuration(input->controller, name);
if (duration >= 60 && duration % 20 == 0) {
textdrawer::Base::CursorPos movement = {0, 0.0f, 0.0f};
textdrawer::Base::CursorPos movement = {0, 0, 0};
movement.fCursorY = -mpInputForm->getLineHeight();
mpInputForm->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(24), &movement);
mpInputForm->searchAnmPane(animationName)->onAnmEvent(nw4rmanager::AnmPane::PE_0);
@@ -1524,14 +1521,14 @@ void Base::autoScroll() {
if (mScrollAnm.isActive()) return;
if (u32(meScrollFlag - SF_ScrollOn) > 1) return;
f32 cursorY = mfCursorY + getLineHeight() / 2.0f;
if (cursorY < 0.0f) {
s32 lines = s32(cursorY / getLineHeight() - 1.0f);
mScrollAnm.startAnm(mfScrollY, mfScrollY - lines * getLineHeight(), 15.0f, NULL, NULL);
if (cursorY < inputform::scInputFormZeroF) {
s32 lines = s32(cursorY / getLineHeight() - inputform::scInputFormOneF);
mScrollAnm.startAnm(mfScrollY, mfScrollY - lines * getLineHeight(), inputform::scInputForm15F, NULL, NULL);
onSE(static_cast<sound::SE>(11));
}
if (cursorY >= (mRect.top - mRect.bottom) * getScale().y) {
s32 lines = s32((cursorY - (mRect.top - mRect.bottom) * getScale().y) / getLineHeight()) + 1;
mScrollAnm.startAnm(mfScrollY, mfScrollY - lines * getLineHeight(), 15.0f, NULL, NULL);
mScrollAnm.startAnm(mfScrollY, mfScrollY - lines * getLineHeight(), inputform::scInputForm15F, NULL, NULL);
onSE(static_cast<sound::SE>(11));
}
meScrollFlag = SF_NoScroll;
@@ -1543,7 +1540,7 @@ void textinput::util::Animation::startAnm(f32 start, f32 end, f32 duration, Anim
mfStartPoint = start;
mfEndPoint = end;
mfAnimationTime = duration;
mfCurrentFrame = 0.0f;
mfCurrentFrame = inputform::scInputFormZeroF;
mbInAnimation = true;
mpAnimObserver = observer;
mpData = data;
@@ -1571,12 +1568,12 @@ inline void DeadKeyStream::init() {
void Base::init() {
meInputMode = IM_Direct;
mfCursorX = 0.0f;
mfCursorY = 0.0f;
mfScrollX = 0.0f;
mfScrollY = 0.0f;
mfSustainTimer = 0.0f;
mfCursorTimer = 0.0f;
mfCursorX = scInputFormZeroF;
mfCursorY = scInputFormZeroF;
mfScrollX = scInputFormZeroF;
mfScrollY = scInputFormZeroF;
mfSustainTimer = scInputFormZeroF;
mfCursorTimer = scInputFormZeroF;
muGlobalAlpha = 255;
mDKStream.init();
SetFixedWidth(GetFont()->GetWidth());
@@ -1767,16 +1764,16 @@ void Base::updateCandidateState_() {
void Base::moveCursorUp() {
f32 y = mfCursorY;
if (-(mfCursorY - mfScrollY) >= 0.0f) {
if (-(mfCursorY - mfScrollY) >= scInputFormZeroF) {
u32 start, end;
mpString->getCursorPos(&start, &end);
if (start == 0 && end == 0) onSE(static_cast<sound::SE>(6));
else onSE(static_cast<sound::SE>(5));
mpString->setCursorPos(0);
} else {
y = mfCursorY >= 0.0f ? mfCursorY : 0.0f;
y = mfCursorY >= scInputFormZeroF ? mfCursorY : scInputFormZeroF;
f32 lineHeight = getLineHeight();
f32 targetY = 1.0f + (y - lineHeight);
f32 targetY = scInputFormOneF + (y - lineHeight);
u32 position = calcCursorPos(mfCursorX, targetY);
mpString->setCursorPos(position);
onSE(static_cast<sound::SE>(5));
@@ -1794,7 +1791,7 @@ void Base::moveCursorDown() {
} else {
f32 lineHeight = getLineHeight();
f32 y = mfCursorY + lineHeight;
mpString->setCursorPos(calcCursorPos(mfCursorX, 1.0f + y));
mpString->setCursorPos(calcCursorPos(mfCursorX, scInputFormOneF + y));
onSE(static_cast<sound::SE>(5));
}
meScrollFlag = SF_ScrollOn;
@@ -2419,8 +2416,8 @@ void Base::onPressRight() {
meScrollFlag = SF_ScrollOn;
}
inline f32 nextColorPhase(f32 phase) { phase += 2.0f; return phase; }
inline f32 colorSine(f32 phase) { return nw4r::math::SinFIdx(phase * 0.7111111f); }
inline f32 nextColorPhase(f32 phase) { phase += scInputFormTwoF; return phase; }
inline f32 colorSine(f32 phase) { return nw4r::math::SinFIdx(inputform::scInputFormDegToFIdxF * phase); }
void Base::calc() {
if (mScrollAnm.isActive()) {
f32 scroll = mScrollAnm.getValue();
@@ -2428,28 +2425,28 @@ void Base::calc() {
mfDrawScrollY = mfScrollY;
}
if (!mScrollAnm.isActive()) autoScroll();
if (!mpString->isOnSustain()) mfSustainTimer = 1.0f + mfSustainTimer;
if (!mpString->isOnSustain()) mfSustainTimer = inputform::scInputFormOneF + mfSustainTimer;
mScrollAnm.calc();
f32 wave = colorSine(sfColorPhase);
mSelectedColor.r = 2;
mSelectedColor.g = 90;
mSelectedColor.b = 253;
mSelectedColor.a = static_cast<u8>(150.0f + 30.0f * wave);
mSelectedColor.a = static_cast<u8>(inputform::scInputForm150F + inputform::scInputForm30F * wave);
if (mpString->isOnSustain()) {
mSelectedColor.r = 52;
mSelectedColor.g = 140;
mSelectedColor.b = 253;
mSelectedColor.a = static_cast<u8>(50.0f + 10.0f * wave);
} else if (mfSustainTimer <= 50.0f) {
mSelectedColor.r = static_cast<u8>(util::hermiteInterporation(mfSustainTimer, 0.0f, 52.0f, 0.0f, 50.0f, 2.0f, 0.0f));
mSelectedColor.g = static_cast<u8>(util::hermiteInterporation(mfSustainTimer, 0.0f, 140.0f, 0.0f, 50.0f, 90.0f, 0.0f));
u8 blue = static_cast<u8>(util::hermiteInterporation(mfSustainTimer, 0.0f, 253.0f, 0.0f, 50.0f, 253.0f, 0.0f));
mSelectedColor.a = static_cast<u8>(inputform::scInputForm50F + inputform::scInputForm10F * wave);
} else if (mfSustainTimer <= inputform::scInputForm50F) {
mSelectedColor.r = static_cast<u8>(util::hermiteInterporation(mfSustainTimer, inputform::scInputFormZeroF, inputform::scInputForm52F, inputform::scInputFormZeroF, inputform::scInputForm50F, inputform::scInputFormTwoF, inputform::scInputFormZeroF));
mSelectedColor.g = static_cast<u8>(util::hermiteInterporation(mfSustainTimer, inputform::scInputFormZeroF, inputform::scInputForm140F, inputform::scInputFormZeroF, inputform::scInputForm50F, inputform::scInputForm90F, inputform::scInputFormZeroF));
u8 blue = static_cast<u8>(util::hermiteInterporation(mfSustainTimer, inputform::scInputFormZeroF, inputform::scInputForm253F, inputform::scInputFormZeroF, inputform::scInputForm50F, inputform::scInputForm253F, inputform::scInputFormZeroF));
f32 phase = sfColorPhase;
f32 angle = phase * 0.7111111f;
f32 angle = inputform::scInputFormDegToFIdxF * phase;
mSelectedColor.b = blue;
wave = nw4r::math::SinFIdx(angle);
f32 alpha = util::hermiteInterporation(mfSustainTimer, 0.0f, 50.0f, 0.0f, 50.0f, 150.0f, 0.0f);
mSelectedColor.a = static_cast<u8>(alpha + 20.0f * wave);
f32 alpha = util::hermiteInterporation(mfSustainTimer, inputform::scInputFormZeroF, inputform::scInputForm50F, inputform::scInputFormZeroF, inputform::scInputForm50F, inputform::scInputForm150F, inputform::scInputFormZeroF);
mSelectedColor.a = static_cast<u8>(alpha + inputform::scInputForm20F * wave);
}
u32 cursorTimer = muCursorTimer + 8;
f32 phase = sfColorPhase;
@@ -2465,9 +2462,9 @@ Base::~Base() {}
Base::Base(Manager* manager) : CommandReceiver(), textdrawer::Base(), candidatebox::CandidateBoxCaller(),
mpString(NULL), mpUnfixString(NULL), mpZiString(NULL), meInputMode(IM_Direct), mePredictMode(PM_USEn),
mbPredictOn(false), mbDoWordWrap(true), mbRightWithSpace(true), mfCursorX(0.0f), mfCursorY(0.0f),
mfScrollX(0.0f), mfScrollY(0.0f), mScrollAnm(), mfSustainTimer(0.0f), meScrollFlag(SF_NoScroll),
muWordWrapCounter(0), muLimitStringLength(1024), muLimitRowNum(9999), mfCursorTimer(0.0f), muGlobalAlpha(255),
mbPredictOn(false), mbDoWordWrap(true), mbRightWithSpace(true), mfCursorX(inputform::scInputFormZeroF), mfCursorY(inputform::scInputFormZeroF),
mfScrollX(inputform::scInputFormZeroF), mfScrollY(inputform::scInputFormZeroF), mScrollAnm(), mfSustainTimer(inputform::scInputFormZeroF), meScrollFlag(SF_NoScroll),
muWordWrapCounter(0), muLimitStringLength(1024), muLimitRowNum(9999), mfCursorTimer(inputform::scInputFormZeroF), muGlobalAlpha(255),
mCharColor(0xffffffff), mpAllocator(NULL), mpManager(manager), mDKStream(), meLanguage(USA),
mbZuSelected(false), mbCursorSelected(false), mriManager(muLimitStringLength), mpCursorLine(NULL),
mCursorLinePos(0), mbLineDraw(true), muSpecifyLineDrawCount(0), muCursorTimer(0) {
@@ -2598,7 +2595,7 @@ namespace inputform {
}
f32 textinput::util::Animation::getValue() {
return hermiteInterporation(mfCurrentFrame, 0.0f, mfStartPoint, 0.0f, mfAnimationTime, mfEndPoint, 0.0f);
return hermiteInterporation(mfCurrentFrame, inputform::scInputFormZeroF, mfStartPoint, inputform::scInputFormZeroF, mfAnimationTime, mfEndPoint, inputform::scInputFormZeroF);
}
namespace inputform {
@@ -2648,7 +2645,7 @@ namespace inputform {
void textinput::util::Animation::calc() {
if (mbInAnimation) {
if (mfCurrentFrame < mfAnimationTime) {
mfCurrentFrame = 1.0f + mfCurrentFrame;
mfCurrentFrame = inputform::scInputFormOneF + mfCurrentFrame;
} else {
if (mbInAnimation && mpAnimObserver) {
mpAnimObserver->onAnmEvent(AnimObserver::AE_1, mpData);
@@ -2836,9 +2833,9 @@ void gui::GUIComponent::init() {
if (mbInitialize) return;
for (int point = 0; point < GUI_POINTS_MAX; ++point) {
mbPointed[point] = false;
mDraggingPos[point].x = 0.0f;
mDraggingPos[point].y = 0.0f;
mDraggingPos[point].z = 0.0f;
mDraggingPos[point].x = inputform::scInputFormZeroF;
mDraggingPos[point].y = inputform::scInputFormZeroF;
mDraggingPos[point].z = inputform::scInputFormZeroF;
mbDragging[point] = false;
mFlightDuration[point] = 0;
}
@@ -2952,10 +2949,10 @@ u32 Base::isOverRowLimit(u32 limit, const wchar_t* string) {
mpString->getCursorPos(&cursorStart, &cursorEnd);
for (;;) {
DrawInfo info;
info.rect.left = 0.0f;
info.rect.top = 0.0f;
info.rect.right = 0.0f;
info.rect.bottom = 0.0f;
info.rect.left = scInputFormZeroF;
info.rect.top = scInputFormZeroF;
info.rect.right = scInputFormZeroF;
info.rect.bottom = scInputFormZeroF;
kana = false;
if (meLanguage == KR && !kanaHandled && cursorStart == pos) {
kanaHandled = true;
@@ -3043,10 +3040,10 @@ bool Base::onCursor(CursorPos* cursor) {
}
if (*predicted == 0xFFFE) SetTextColor(csZiStringColorLeft);
DrawInfo glyph;
glyph.rect.left = 0.0f;
glyph.rect.top = 0.0f;
glyph.rect.right = 0.0f;
glyph.rect.bottom = 0.0f;
glyph.rect.left = scInputFormZeroF;
glyph.rect.top = scInputFormZeroF;
glyph.rect.right = scInputFormZeroF;
glyph.rect.bottom = scInputFormZeroF;
glyph.character = *predicted;
calcRect(glyph);
f32 width = glyph.rect.GetWidth();
@@ -3062,10 +3059,10 @@ bool Base::onCursor(CursorPos* cursor) {
}
if (meDestination == DST_JP && candidate) {
DrawInfo glyph;
glyph.rect.left = 0.0f;
glyph.rect.top = 0.0f;
glyph.rect.right = 0.0f;
glyph.rect.bottom = 0.0f;
glyph.rect.left = scInputFormZeroF;
glyph.rect.top = scInputFormZeroF;
glyph.rect.right = scInputFormZeroF;
glyph.rect.bottom = scInputFormZeroF;
glyph.character = candidate;
calcRect(glyph);
f32 left = glyph.rect.left + GetCursorX();
@@ -3073,7 +3070,7 @@ bool Base::onCursor(CursorPos* cursor) {
f32 right = glyph.rect.right + GetCursorX();
f32 bottomEdge = GetCursorY() + GetFontHeight();
candidateBackground.a = muGlobalAlpha;
debug::drawBox_(left, top, right, bottomEdge, 0.0f, 1.0f, candidateBackground);
debug::drawBox_(left, top, right, bottomEdge, scInputFormZeroF, scInputFormOneF, candidateBackground);
SetupGX();
SetTextColor(mCharColor);
switch (candidate) {
@@ -3081,19 +3078,19 @@ bool Base::onCursor(CursorPos* cursor) {
case 0x3000: {
DrawInfo space;
DrawInfo marker;
space.rect.left = 0.0f;
space.rect.top = 0.0f;
space.rect.right = 0.0f;
space.rect.bottom = 0.0f;
marker.rect.left = 0.0f;
marker.rect.top = 0.0f;
marker.rect.right = 0.0f;
marker.rect.bottom = 0.0f;
space.rect.left = scInputFormZeroF;
space.rect.top = scInputFormZeroF;
space.rect.right = scInputFormZeroF;
space.rect.bottom = scInputFormZeroF;
marker.rect.left = scInputFormZeroF;
marker.rect.top = scInputFormZeroF;
marker.rect.right = scInputFormZeroF;
marker.rect.bottom = scInputFormZeroF;
space.character = candidate;
marker.character = 0xE057;
calcRect(space);
calcRect(marker);
f32 offset = ((space.rect.GetWidth() - marker.rect.GetWidth()) / 2.0f) * getScale().x;
f32 offset = ((space.rect.GetWidth() - marker.rect.GetWidth()) / scInputFormTwoF) * getScale().x;
MoveCursorX(offset);
Print(0xE057);
MoveCursorX(offset);
@@ -3121,10 +3118,10 @@ bool Base::onCursor(CursorPos* cursor) {
wchar_t character = *kana;
if (mbPredictOn) character = util::HankakuToZenkaku(character);
DrawInfo glyph;
glyph.rect.left = 0.0f;
glyph.rect.top = 0.0f;
glyph.rect.right = 0.0f;
glyph.rect.bottom = 0.0f;
glyph.rect.left = scInputFormZeroF;
glyph.rect.top = scInputFormZeroF;
glyph.rect.right = scInputFormZeroF;
glyph.rect.bottom = scInputFormZeroF;
glyph.character = character;
calcRect(glyph);
if (meLanguage == JP) {
@@ -3133,7 +3130,7 @@ bool Base::onCursor(CursorPos* cursor) {
f32 right = glyph.rect.right + GetCursorX();
f32 bottomEdge = GetCursorY() + GetFontHeight();
kanaBackground.a = muGlobalAlpha;
debug::drawBox_(left, top, right, bottomEdge, 0.0f, 1.0f, kanaBackground);
debug::drawBox_(left, top, right, bottomEdge, scInputFormZeroF, scInputFormOneF, kanaBackground);
SetupGX();
mCharColor.a = muGlobalAlpha;
SetTextColor(mCharColor);
@@ -3162,7 +3159,7 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
const wchar_t* string = mpString->getWCString();
if (!*string) return 0;
cursorX = getScale().x;
lineTop = 0.0f;
lineTop = scInputFormZeroF;
lineBottom = lineTop;
nw4r::math::VEC2 scale = getScale();
u32 pos = 0;
@@ -3170,10 +3167,10 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
mbHyphen = false;
while (*string) {
DrawInfo info;
info.rect.left = 0.0f;
info.rect.top = 0.0f;
info.rect.right = 0.0f;
info.rect.bottom = 0.0f;
info.rect.left = scInputFormZeroF;
info.rect.top = scInputFormZeroF;
info.rect.right = scInputFormZeroF;
info.rect.bottom = scInputFormZeroF;
info.character = *string;
calcRect(info);
lineBottom = lineTop + scale.y * (info.rect.bottom - info.rect.top);
@@ -3204,7 +3201,7 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
if (!string[1] && localY >= lineTop && localY <= lineBottom) return pos + 1;
} else {
if (x >= cursorX && x < right && localY >= lineTop && localY < lineBottom) {
if (cursorX + 0.5f * (right - cursorX) > x) return pos;
if (cursorX + scInputFormHalfF * (right - cursorX) > x) return pos;
return pos + 1;
}
cursorX += scale.x * (info.rect.right - info.rect.left);
@@ -3213,17 +3210,17 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
++pos;
if (!*string && localY >= lineTop && localY <= lineBottom) return pos;
}
if (lineTop + (lineBottom - lineTop) * 0.5f <= localY) {
return Base::calcCursorPos(x, 1.0f + lineTop + mfScrollY);
if (lineTop + (lineBottom - lineTop) * scInputFormHalfF <= localY) {
return Base::calcCursorPos(x, scInputFormOneF + lineTop + mfScrollY);
}
return Base::calcCursorPos(x, 1.0f);
return Base::calcCursorPos(x, scInputFormOneF);
}
nw4r::math::VEC2 Base::getGlobalLeftTopPos() const {
nw4r::math::VEC3 position;
position.x = mRect.left;
position.y = mRect.bottom;
position.z = 0.0f;
position.z = scInputFormZeroF;
PSMTXMultVec(mMtx, position, position);
return nw4r::math::VEC2(position.x, -position.y);
}
@@ -3266,7 +3263,7 @@ bool Base::doWordWrap(const wchar_t* string, u32 pos, f32 width) {
}
}
f32 stringWidth = 0.0f;
f32 stringWidth = inputform::scInputFormZeroF;
f32 zero = stringWidth;
u32 index;
u32 hyphenPos;
@@ -3281,10 +3278,10 @@ bool Base::doWordWrap(const wchar_t* string, u32 pos, f32 width) {
break;
}
WordWrapDrawInfo drawInfo;
drawInfo.left = 0.0f;
drawInfo.top = 0.0f;
drawInfo.right = 0.0f;
drawInfo.bottom = 0.0f;
drawInfo.left = inputform::scInputFormZeroF;
drawInfo.top = inputform::scInputFormZeroF;
drawInfo.right = inputform::scInputFormZeroF;
drawInfo.bottom = inputform::scInputFormZeroF;
drawInfo.character = *stringPtr;
calcRect(reinterpret_cast<DrawInfo&>(drawInfo));
characterWrap = false;
@@ -3356,8 +3353,8 @@ bool Base::isOverLine(const DrawInfo& drawInfo) {
void Base::drawFixString(u32 position) {
CursorPos cursor;
cursor.fCursorX = 0.0f;
cursor.fCursorY = 0.0f;
cursor.fCursorX = inputform::scInputFormZeroF;
cursor.fCursorY = inputform::scInputFormZeroF;
cursor.uCursorPos = position;
mCharColor.a = muGlobalAlpha;
SetTextColor(mCharColor);
@@ -3370,7 +3367,7 @@ void Base::drawFixString(u32 position) {
void Base::draw() {
SetCursor(getScale().x, mfScrollY);
nw4r::math::VEC2 scale = getScale();
nw4r::ut::Rect clip(0.0f, 0.0f, 0.0f, 0.0f);
nw4r::ut::Rect clip(inputform::scInputFormZeroF, inputform::scInputFormZeroF, inputform::scInputFormZeroF, inputform::scInputFormZeroF);
nw4r::math::VEC2 origin = getGlobalLeftTopPos();
clip.left = origin.x;
clip.bottom = origin.y;
@@ -3383,14 +3380,14 @@ void Base::draw() {
}
void Base::drawCursor(f32 x, f32 y) {
f32 opacity = static_cast<u32>(muGlobalAlpha) / 255.0f;
f32 opacity = static_cast<u32>(muGlobalAlpha) / inputform::scInputForm255F;
mfCursorX = x;
mfCursorY = y;
GXColor color = {scInputFormColorRU8, scInputFormColorGU8, scInputFormColorBU8, scInputFormColorAU8};
f32 pulse = nw4r::math::SinFIdx(0.7111111f * muCursorTimer);
color.a = static_cast<s32>(opacity * (127.0f + 127.0f * pulse));
GXColor color = {inputform::scInputFormColorRU8, inputform::scInputFormColorGU8, inputform::scInputFormColorBU8, inputform::scInputFormColorAU8};
f32 pulse = nw4r::math::SinFIdx(inputform::scInputFormDegToFIdxF * muCursorTimer);
color.a = static_cast<s32>(opacity * (inputform::scInputForm127F + inputform::scInputForm127F * pulse));
f32 width = mfViewWidth - mfViewX;
debug::drawLine_(mfCursorX, 2.0f + mfCursorY, mfCursorX, (mfCursorY + GetFontHeight()) - 2.0f, 0.0f, static_cast<u8>(14592.0f / width), color);
debug::drawLine_(mfCursorX, inputform::scInputFormTwoF + mfCursorY, mfCursorX, (mfCursorY + GetFontHeight()) - inputform::scInputFormTwoF, inputform::scInputFormZeroF, static_cast<u8>(inputform::scInputForm14592F / width), color);
}
void Base::doScroll(Scroll* scroll) {
@@ -3401,7 +3398,7 @@ void Base::doScroll(Scroll* scroll) {
mfDrawScrollY = mfScrollY;
} else {
mfScrollX += scroll->x;
mScrollAnm.startAnm(mfScrollY, mfScrollY + scroll->y, 15.0f, NULL, NULL);
mScrollAnm.startAnm(mfScrollY, mfScrollY + scroll->y, inputform::scInputForm15F, NULL, NULL);
}
onSE(static_cast<sound::SE>(11));
}
@@ -3423,7 +3420,7 @@ void Base::doBeforeDrawProcess(const wchar_t* string, u32 position, const DrawIn
f32 top = info.rect.top + GetCursorY();
f32 right = info.rect.right + GetCursorX();
f32 bottom = info.rect.bottom + GetCursorY();
debug::drawBox_(left, top, right, bottom, 0.0f, 1.0f, mSelectedColor);
debug::drawBox_(left, top, right, bottom, inputform::scInputFormZeroF, inputform::scInputFormOneF, mSelectedColor);
}
}
@@ -3564,7 +3561,7 @@ void Base::setPredictMode(PredictMode predictMode) {
}
nw4r::math::VEC2 Base::getScale() const {
return nw4r::math::VEC2(1.0f, 1.0f);
return nw4r::math::VEC2(inputform::scInputFormOneF, inputform::scInputFormOneF);
}
bool LayoutByNW4R::isAbleToUp() {
@@ -3589,10 +3586,10 @@ bool LayoutByNW4R::updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 r
nw4r::math::VEC2 point;
point.x = x;
point.y = y;
if (-y < getGlobalLeftTopPos().y + (mRect.top - mRect.bottom) / 2.0f) {
point.y = getGlobalLeftTopPos().y - 1.0f;
if (-y < getGlobalLeftTopPos().y + (mRect.top - mRect.bottom) / inputform::scInputFormTwoF) {
point.y = getGlobalLeftTopPos().y - inputform::scInputFormOneF;
} else {
point.y = 1.0f + ((mRect.top - mRect.bottom) + getGlobalLeftTopPos().y);
point.y = inputform::scInputFormOneF + ((mRect.top - mRect.bottom) + getGlobalLeftTopPos().y);
}
onCommand(static_cast<INPUT_COMMAND>(16), &point);
}
@@ -3693,3 +3690,29 @@ u32 Base::getDrawCacheStartPos() const {
}
}
}
extern "C" const f32 scInputFormZeroF = 0.0f;
extern "C" const f32 scInputForm640F = 640.0f;
extern "C" const f64 scInputFormF32ConvertMagic = 4503601774854144.0;
extern "C" const f32 scInputFormOneF = 1.0f;
extern "C" const f32 scInputFormHalfF = 0.5f;
extern "C" const f32 scInputFormDegToFIdxF = 0.7111111f;
extern "C" const f32 scInputForm150F = 150.0f;
extern "C" const f32 scInputForm30F = 30.0f;
extern "C" const f32 scInputForm50F = 50.0f;
extern "C" const f32 scInputForm10F = 10.0f;
extern "C" const f32 scInputForm52F = 52.0f;
extern "C" const f32 scInputFormTwoF = 2.0f;
extern "C" const f32 scInputForm140F = 140.0f;
extern "C" const f32 scInputForm90F = 90.0f;
extern "C" const f32 scInputForm253F = 253.0f;
extern "C" const f32 scInputForm20F = 20.0f;
extern "C" const u8 scInputFormColorRU8 = 0xff;
extern "C" const u8 scInputFormColorGU8 = 0x32;
extern "C" const u8 scInputFormColorBU8 = 0x32;
extern "C" const u8 scInputFormColorAU8 = 0;
extern "C" const f32 scInputForm255F = 255.0f;
extern "C" const f32 scInputForm127F = 127.0f;
extern "C" const f32 scInputForm14592F = 14592.0f;
extern "C" const f64 scInputFormF64ConvertMagic = 4503599627370496.0;
extern "C" const f32 scInputForm15F = 15.0f;

View File

@@ -19,7 +19,7 @@ namespace textinput {
extern SelectorPosition chinesePosition;
extern SelectorPosition koreanPosition;
static const wchar_t* PREDICT_CAPTIONS[] = {L"", L"", L"Eng", L"Fra", L"Esp", L"EN", L"DE", L"FR", L"ES", L"IT", L"NL", L"CN", L"KR"};
static const wchar_t* PREDICT_CAPTIONS[] = {L"\0\0\0", L"\0\0\0", L"Eng", L"Fra", L"Esp", L"EN", L"DE", L"FR", L"ES", L"IT", L"NL", L"CN", L"KR"};
static const GridKey csGridKeyboard[] = {
{"P_Gkey_00", {0xe0, 0x21, 0x0, 0x0}}, {"P_Gkey_01", {0xe1, 0x3f, 0x3042, 0x30a2}},
@@ -1500,7 +1500,8 @@ namespace textinput {
}
inline u32 FindControlKey(const Base::KeyState& state, char* paneName) {
for (u16 i = 0; i < 23; i++) {
u16 i;
for (i = 0; i < 23; i++) {
if (util::strcmp(state.data->controls[i].paneName, paneName))
return state.data->controls[i].key;
}
@@ -1610,7 +1611,7 @@ namespace textinput {
}
void Base::setTranslateMode(TranslateMode mode) {
u32 keyMode = mode;
u32 keyMode;
switch (mode) {
case TM_Direct:
keyMode = 0;
@@ -2688,7 +2689,7 @@ namespace textinput {
if (name[0] == 'B') {
char animationName[17];
util::replaceChar(animationName, sizeof(animationName), name, 0, 'P');
if (strncmp(name + 5, "Chng", 4) == 0 || strncmp(name + 7, "Chng", 4) == 0 || strncmp(name + 7, "prdc", 4) == 0) {
if (strncmp(name + 5, "Chng", 4) == 0 || strncmp(name + 7, "Chng", 4) == 0 || strncmp(name + 7, "prdc\0\0\0", 4) == 0) {
util::replaceChar(animationName, sizeof(animationName), name, 0, 'W');
}
nw4rmanager::AnmPane* animation = mpKeyboard->searchAnmPane(animationName);
@@ -3201,4 +3202,13 @@ namespace textinput {
}
}
namespace gui {
bool GUIComponent::isDragging(int point) { return mbDragging[point]; }
void GUIComponent::setTriggerTarget(bool bEnable) { mbTriggerTarget = bEnable; }
void EventHandler::onEvent(GUIComponent& comp, u32 event, void* data) {}
void EventHandler::setLatestEventCtrlNo(int ctrlNo) { muLatestEventCtrlNo = ctrlNo; }
int EventHandler::getLatestEventCtrlNo() { return muLatestEventCtrlNo; }
}
}

View File

@@ -14,7 +14,9 @@ void KPRSetMode(KPRQueue*, u32);
namespace textinput {
namespace tistring {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
Decolated::~Decolated() {}
#endif
void StringBase::create(MEMAllocator* allocator) {
mpAllocator = allocator;
mpszString = static_cast<wchar_t*>(MEMAllocFromAllocator(allocator, muMaxLength << 1));
@@ -150,6 +152,7 @@ void Decolated::inputChar(wchar_t ch) {
input[1] = 0;
input[0] = 0;
u16 count;
u32 i;
if (static_cast<u32>(mTranslateMode) - 1 > 1) {
goto nonKana;
}
@@ -165,17 +168,19 @@ void Decolated::inputChar(wchar_t ch) {
ch = util::toWLower(ch);
count = KPRPutChar(&mKanaStream.mQueue, ch) & 0xff;
}
for (u32 inputIndex = 0; (inputIndex & 0xff) < count; inputIndex++) {
input[static_cast<u8>(inputIndex)] = KPRGetChar(&mKanaStream.mQueue);
for (i = 0; (i & 0xff) < count; i++) {
input[static_cast<u8>(i)] = KPRGetChar(&mKanaStream.mQueue);
}
KPRLookAhead(&mKanaStream.mQueue, mKanaStream.mOutput, 5);
goto inputReady;
}
nonKana:
if (mTranslateMode == 3) {
input[0] = ch;
input[1] = 0;
count = 1;
i = 0;
input[i] = 0;
input[i++] = ch;
input[i] = 0;
count = i;
mKanaStream.mOutput[0] = 0;
} else {
count = 1;