diff --git a/config/43U/symbols.txt b/config/43U/symbols.txt index 44359545..2ab7fbb1 100644 --- a/config/43U/symbols.txt +++ b/config/43U/symbols.txt @@ -13835,8 +13835,8 @@ scAnmTable__10homebutton = .rodata:0x8160F378; // type:object size:0x60 scope:lo scGroupAnmTable__10homebutton = .rodata:0x8160F3D8; // type:object size:0x250 scope:local data:4byte __DVDErrorMessage = .rodata:0x8160F628; // type:object size:0x28 lbl_8160F650 = .rodata:0x8160F650; // type:object size:0x16 data:2byte -lbl_8160F668 = .rodata:0x8160F668; // type:object size:0xB data:byte -lbl_8160F673 = .rodata:0x8160F673; // type:object size:0xC data:byte +specials$18760 = .rodata:0x8160F668; // type:object size:0xB data:byte +@19145 = .rodata:0x8160F673; // type:object size:0xC data:byte lbl_8160F67F = .rodata:0x8160F67F; // type:object size:0xD data:byte lbl_8160F690 = .rodata:0x8160F690; // type:object size:0x18 data:2byte scAnmFrame__Q23ipl5scene = .rodata:0x8160F6A8; // type:object size:0x20 scope:local @@ -15435,26 +15435,46 @@ __vt__Q33ipl5scene7Address = .data:0x81647B70; // type:object size:0x120 @11177 = .data:0x81647D9A; // type:object size:0xF scope:local data:string __vt__Q33ipl5scene18AddressAddSelEvent = .data:0x81647DAC; // type:object size:0x18 __vt__Q33ipl5scene13AddressAddSel = .data:0x81647DC4; // type:object size:0x88 -lbl_81647EE0 = .data:0x81647EE0; // type:object size:0xD data:string -lbl_81647EED = .data:0x81647EED; // type:object size:0xD data:string -lbl_81647EFA = .data:0x81647EFA; // type:object size:0xD data:string -lbl_81647F07 = .data:0x81647F07; // type:object size:0xE data:string -lbl_81647F15 = .data:0x81647F15; // type:object size:0xC data:string -lbl_81647F24 = .data:0x81647F24; // type:object size:0x14 -lbl_81647F38 = .data:0x81647F38; // type:object size:0xE data:string -lbl_81647F46 = .data:0x81647F46; // type:object size:0x83 -lbl_81647FC9 = .data:0x81647FC9; // type:object size:0xC data:string -lbl_81647FD5 = .data:0x81647FD5; // type:object size:0x128 -lbl_816480FD = .data:0x816480FD; // type:object size:0xE data:string -lbl_8164810B = .data:0x8164810B; // type:object size:0x1F5 -jumptable_81648300 = .data:0x81648300; // type:object size:0xC0 scope:local -jumptable_816483C0 = .data:0x816483C0; // type:object size:0xC0 scope:local -lbl_8164848D = .data:0x8164848D; // type:object size:0x16 data:string -lbl_816484A3 = .data:0x816484A3; // type:object size:0xF data:string -jumptable_816484B4 = .data:0x816484B4; // type:object size:0x44 scope:local -jumptable_81648508 = .data:0x81648508; // type:object size:0x58 scope:local -jumptable_81648560 = .data:0x81648560; // type:object size:0x8C scope:local -lbl_816485EC = .data:0x816485EC; // type:object size:0xC data:wstring +@16959 = .data:0x81647EE0; // type:object size:0xD data:string +@16960 = .data:0x81647EED; // type:object size:0xD data:string +@16961 = .data:0x81647EFA; // type:object size:0xD data:string +@16962 = .data:0x81647F07; // type:object size:0xE data:string +@16963 = .data:0x81647F15; // type:object size:0xC data:string +sButtonPaneNames = .data:0x81647F24; // type:object size:0x14 +@16964 = .data:0x81647F38; // type:object size:0xE data:string +@23886 = .data:0x81647F46; // type:object size:0xC data:string +@24207 = .data:0x81647F52; // type:object size:0x12 data:string +@24208 = .data:0x81647F64; // type:object size:0x1C data:string +@24209 = .data:0x81647F80; // type:object size:0xF data:string +@24210 = .data:0x81647F8F; // type:object size:0x19 data:string +@24211 = .data:0x81647FA8; // type:object size:0xB data:string +@24212 = .data:0x81647FB3; // type:object size:0xB data:string +@24213 = .data:0x81647FBE; // type:object size:0xB data:string +@24214 = .data:0x81647FC9; // type:object size:0xC data:string +@24215 = .data:0x81647FD5; // type:object size:0xE data:string +@24216 = .data:0x81647FE3; // type:object size:0x1A data:string +@24217 = .data:0x81647FFD; // type:object size:0x1A data:string +@24218 = .data:0x81648017; // type:object size:0x1D data:string +@24219 = .data:0x81648034; // type:object size:0x1E data:string +@24220 = .data:0x81648052; // type:object size:0xC data:string +@24221 = .data:0x8164805E; // type:object size:0x22 data:string +@24222 = .data:0x81648080; // type:object size:0x9 data:string +@24223 = .data:0x81648089; // type:object size:0x23 data:string +@24224 = .data:0x816480AC; // type:object size:0x1C data:string +@24225 = .data:0x816480C8; // type:object size:0xD data:string +@24226 = .data:0x816480D5; // type:object size:0xD data:string +@24227 = .data:0x816480E2; // type:object size:0xD data:string +@24228 = .data:0x816480EF; // type:object size:0xE data:string +@24229 = .data:0x816480FD; // type:object size:0xE data:string +@24231 = .data:0x8164810B; // type:object size:0x1F5 +@25188 = .data:0x81648300; // type:object size:0xC0 scope:local +@25187 = .data:0x816483C0; // type:object size:0xC0 scope:local +@25711 = .data:0x8164848D; // type:object size:0x16 data:string +@25835 = .data:0x816484A3; // type:object size:0xF data:string +@25838 = .data:0x816484B4; // type:object size:0x44 scope:local +@26007 = .data:0x81648508; // type:object size:0x58 scope:local +@26006 = .data:0x81648560; // type:object size:0x8C scope:local +@26030 = .data:0x816485EC; // type:object size:0xC data:wstring __vt__Q33ipl5scene17AddressInputEvent = .data:0x816485F8; // type:object size:0x18 __vt__Q33ipl5scene16AddressEditEvent = .data:0x81648610; // type:object size:0x18 __vt__Q33ipl5scene11AddressEdit = .data:0x81648628; // type:object size:0x120 @@ -21691,7 +21711,7 @@ lbl_816965C4 = .sdata:0x816965C4; // type:object size:0x6 data:string lbl_816965CA = .sdata:0x816965CA; // type:object size:0x4 smButtonName__Q33ipl5scene13AddressAddSel = .sdata:0x816965D0; // type:object size:0x8 @10971 = .sdata:0x816965D8; // type:object size:0x4 scope:local data:string -lbl_816965E0 = .sdata:0x816965E0; // type:object size:0x4 data:4byte +sInputPaneName = .sdata:0x816965E0; // type:object size:0x4 data:4byte lbl_816965E4 = .sdata:0x816965E4; // type:object size:0x4 data:string lbl_816965E8 = .sdata:0x816965E8; // type:object size:0x2 lbl_816965EA = .sdata:0x816965EA; // type:object size:0x6 data:string diff --git a/include/keyboard/tiManager.h b/include/keyboard/tiManager.h index 9e24205a..c18b8c29 100644 --- a/include/keyboard/tiManager.h +++ b/include/keyboard/tiManager.h @@ -67,6 +67,9 @@ namespace textinput { virtual void setAspectRatio(bool b4x3); virtual void setSecretInputMode(bool secretInputMode) { mpInputForm->setSecretModeOn(secretInputMode); } +#ifdef IPL_ADDRESS_EDIT_CPP + void enableKSXFilter(bool compatibleFilter); +#endif virtual void setDefaultPredictionJP(int num, const char** predicts); virtual void setFixedPredictionJP(int num, const char** predicts); diff --git a/include/math/iplMathTypes.h b/include/math/iplMathTypes.h index f1425545..0e6f9bd6 100644 --- a/include/math/iplMathTypes.h +++ b/include/math/iplMathTypes.h @@ -91,11 +91,15 @@ namespace ipl { y = r.y; z = 0.0f; } +#ifdef IPL_ADDRESS_EDIT_CPP + VEC3(f32 fx, f32 fy, f32 fz); +#else VEC3(f32 fx, f32 fy, f32 fz) { x = fx; y = fy; z = fz; } +#endif VEC3& operator+=(const VEC3& rhs) { VEC3Add(this, this, &rhs); diff --git a/include/scene/address/iplAddress.h b/include/scene/address/iplAddress.h index 8e767e17..8dea5df6 100644 --- a/include/scene/address/iplAddress.h +++ b/include/scene/address/iplAddress.h @@ -258,6 +258,9 @@ namespace ipl { static const math::VEC2 smcPageOffset; friend class AddressEvent; +#ifdef IPL_ADDRESS_EDIT_CPP + friend class AddressEdit; +#endif }; class AddressEvent : public ::gui::EventHandler { diff --git a/include/scene/address/iplAddressEdit.h b/include/scene/address/iplAddressEdit.h index 9bd7fb13..501c89bf 100644 --- a/include/scene/address/iplAddressEdit.h +++ b/include/scene/address/iplAddressEdit.h @@ -2,22 +2,125 @@ #define IPL_SCENE_ADDRESS_EDIT_H #include "iplSceneHeader.h" +#include "scene/button/iplButton.h" + +#include +#include namespace ipl { + namespace nigaoe { + class Object; + } + namespace scene { - FADER_SCENE_CLASS(AddressEdit) { + class AddressEditEvent; + class AddressInputEvent; + class FriendListCache; + + FADER_SCENE_CLASS(AddressEdit), public ButtonEventHandlerBase { public: AddressEdit(EGG::Heap * heap, int friendCode); + virtual ~AddressEdit(); + + virtual void prepare(); + virtual void create(); + virtual void draw(); + + virtual void initCalcNormal(); + virtual void initCalcFadeout(); + virtual void calcCommonAfter(); + + virtual FaderSceneCommand calcFadein(); + virtual FaderSceneCommand calcNormal(); + virtual FaderSceneCommand calcFadeout(); + virtual void onEventDerived(u32 compId, u32 event, const controller::Interface* con); void stt_msg_code_add(); void stt_msg_code_edit(); void stt_msg_parental(); void stt_msg_nwc24_error(); + void reset_gui(); + void start_point_event(const char* paneName, controller::Interface* controller); + void start_left_event(const char* paneName); + void start_trig_event(const char* paneName); + void start_ipt_point_event(const char* paneName, int channel); + void start_ipt_left_event(const char* paneName, int channel); + void start_ipt_trig_event(const char* paneName, int channel); + int get_button_no(const char*); + void add_friendinfo(); + void delete_friendinfo(); + void set_textbox(nw4r::lyt::Pane*, const wchar_t*); + void setDefaultTitleText(const wchar_t*, bool); + static void wiiid_utf16(u64, wchar_t*); + static void nigaoe_create_callback_add(ipl::nigaoe::Object*, void*); + static void nigaoe_create_callback_edit(ipl::nigaoe::Object*, void*); + void set_err_msg(wchar_t*, u32, NWC24Err); + void get_friendinfo(); + static u64 utf16_wiiid(const wchar_t*); + void stt_add_code_fadein(); + void stt_add_code_fadeout(); + void stt_add_code_input(); + void stt_add_code_normal(); + void stt_add_confirm_fadein(); + void stt_add_confirm_fadeout(); + void stt_add_confirm_normal(); + void stt_add_mii_fadein(); + void stt_add_mii_fadeout(); + void stt_add_mii_input(); + void stt_add_mii_normal(); + void stt_add_name_fadein(); + void stt_add_name_fadeout(); + void stt_add_name_input(); + void stt_add_name_normal(); + void stt_ipt_input(); + void stt_ipt_normal(); + void stt_ipt_wait_fadein(); + void stt_ipt_wait_fadeout(); + void stt_msg_add_rlt(); + void stt_msg_code_invalid(); + void stt_msg_del_rlt(); + void stt_msg_dup_email(); + void stt_msg_dup_wii_no(); + void stt_msg_my_wii_no(); + void stt_msg_net(); + void stt_msg_no_established(); + void stt_msg_no_mii(); + void stt_msg_no_mii_add(); + void stt_msg_wc(); + void stt_select_mii(); + void stt_wait_btn_fadein(); + void stt_wait_btn_fadeout(); + void stt_wait_del_msg_fadein(); + void stt_wait_del_msg_fadeout(); + void stt_wait_del_msg_fadeout_to_rlt(); + void stt_wait_delete(); + void stt_wait_decide_anm_add(); + void stt_wait_parental(); + void stt_wait_parental_dst(); + void stt_wait_parental_dst_wc(); + void stt_wait_parental_wc(); + void stt_normal(); + void stt_wait_decide_anm(); + void update_friendinfo(); + void requestSceneChange(int sceneId, void* args) { reserveSceneChange(sceneId, args); } + u32 getPreviousScene() const { return getPrevSceneID(); } + EGG::Heap* getHeap() { return getSceneHeap(); } + ::gui::Manager* getGuiManager() { return mpManager; } class String { public: void clear(); const wchar_t* getDispCodeLong() const; + void setName(const wchar_t* value); + void setEMail(const wchar_t* value); + void setWiiNo(const wchar_t* value); + + wchar_t mValue[0x102]; + wchar_t mName[0x0c]; + wchar_t mDisplayText[0x102]; + bool mbValidMail; + bool mbNameNotEmpty; + bool mbHasWiiNo; }; enum { @@ -25,8 +128,28 @@ namespace ipl { SCENE_ADD_EMAIL, }; - private: - u8 unk_0x58[0x498]; + int mState; + layout::Object* mpCodeLayout; + AddressEditEvent* mpEditEvent; + gui::PaneManager* mpEditGui; + layout::Object* mpNameLayout; + AddressInputEvent* mpInputEvent; + gui::PaneManager* mpInputGui; + layout::Object* mpBackgroundLayout; + int mMode; + int mSelectedButton; + int mSubState; + s32 mPointCount[5]; + u32 mSelectedFriend; + TextBalloon* mpBalloon; + nand::LayoutFile* mpBalloonFile; + String mString; + AddressEdit* mpCallbackOwner; + bool mbParentalOK; + nigaoe::Object* mpNigaoe; + RFLCreateID mCreateID; + int mNigaoeState; + FriendListCache* mpFriendCache; }; } // namespace scene } // namespace ipl diff --git a/include/system/iplKeyboard.h b/include/system/iplKeyboard.h index aa8c6df7..717d309d 100644 --- a/include/system/iplKeyboard.h +++ b/include/system/iplKeyboard.h @@ -54,6 +54,9 @@ namespace ipl { const wchar_t* wcString; // 0x04 u32 stringLimit; // 0x08 u32 rowLimit; // 0x0C +#ifdef IPL_ADDRESS_EDIT_CPP + KeyboardSetting(KeyboardType keyboardType, const wchar_t* value, u32 limit, u32 rows); +#endif } KeyboardSetting; typedef struct State { diff --git a/src/scene/address/iplAddressEdit.cpp b/src/scene/address/iplAddressEdit.cpp index 6971ad2b..791c5145 100644 --- a/src/scene/address/iplAddressEdit.cpp +++ b/src/scene/address/iplAddressEdit.cpp @@ -1,6 +1,18 @@ +#define IPL_ADDRESS_EDIT_CPP #include "scene/address/iplAddressEdit.h" +#include "scene/address/iplAddress.h" +#include "scene/board/iplBoard.h" +#include "scene/faceSelect/iplFaceSelect.h" +#include "scene/parentalDialog/iplParentalDialog.h" +#include "scene/iplSceneManager.h" +#include "layout/iplGuiManager.h" +#include "scene/textBalloon/iplBalloon.h" +#include "sound/iplSound.h" #include "system/iplSystem.h" +#include "system/iplNigaoe.h" +#include "scene/setting/iplNCDSetting.h" +#include "utility/iplCharacterCode.h" #include #include @@ -23,284 +35,125 @@ enum { static ChkHostNameError CheckHostName(const char* hostName, u32 hostNameLength); -u64 s_addressEditDataPool[269] = { - 0x425f6372645f6274, - 0x6e5f303000425f63, - 0x72645f62746e5f31, - 0x3000425f6372645f, - 0x62746e5f31310042, - 0x5f6d69695f69636f, - 0x6e5f303000425f63, - 0x6172645f62657461, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x425f6372645f6564, - 0x67695f3030006261, - 0x6c6c6f6f6e2e6173, - 0x680074685f416472, - 0x6573735f622e6272, - 0x6c79740074685f41, - 0x64726573735f625f, - 0x636172645f737472, - 0x742e62726c616e00, - 0x636172645f737472, - 0x745f666e73680074, - 0x685f416472657373, - 0x5f625f62746e5f69, - 0x6e2e62726c616e00, - 0x6372645f62746e5f, - 0x3030006372645f62, - 0x746e5f3130006372, - 0x645f62746e5f3131, - 0x006d69695f69636f, - 0x6e5f303000545f66, - 0x726e645f6372645f, - 0x30300074685f4164, - 0x726573735f625f62, - 0x746e5f7073682e62, - 0x726c616e0074685f, - 0x4164726573735f62, - 0x5f62746e5f6f7574, - 0x2e62726c616e0074, - 0x685f416472657373, - 0x5f625f62746e5f73, - 0x636c5f696e2e6272, - 0x6c616e0074685f41, - 0x64726573735f625f, - 0x62746e5f73636c5f, - 0x6f75742e62726c61, - 0x6e006372645f6274, - 0x6e5f677279007468, - 0x5f4164726573735f, - 0x625f636172645f6d, - 0x73675f616c705f69, - 0x6e2e62726c616e00, - 0x636172645f6d7367, - 0x0074685f41647265, - 0x73735f625f636172, - 0x645f6d73675f616c, - 0x705f6f75742e6272, - 0x6c616e0074685f41, - 0x64726573735f625f, - 0x636172645f666e73, - 0x682e62726c616e00, - 0x545f6372645f6274, - 0x6e5f303000545f63, - 0x72645f62746e5f31, - 0x3000545f6372645f, - 0x62746e5f31310054, - 0x5f6372645f62746e, - 0x5f67727900545f63, - 0x6172645f6d73675f, - 0x303000545f6e616d, - 0x655f30300074685f, - 0x4164726573735f63, - 0x2e62726c79740074, - 0x685f416472657373, - 0x5f635f636172645f, - 0x737472742e62726c, - 0x616e00475f636172, - 0x645f737472745f66, - 0x6e73680074685f41, - 0x64726573735f635f, - 0x7175657374696f6e, - 0x5f616c705f696e2e, - 0x62726c616e00475f, - 0x7175657374696f6e, - 0x5f30300074685f41, - 0x64726573735f635f, - 0x6e616d655f616c70, - 0x5f696e2e62726c61, - 0x6e00475f6e616d65, - 0x5f30300074685f41, - 0x64726573735f635f, - 0x6d73675f616c705f, - 0x696e2e62726c616e, - 0x00475f6d73675f30, - 0x300074685f416472, - 0x6573735f635f6d69, - 0x695f616c705f696e, - 0x2e62726c616e0074, - 0x685f416472657373, - 0x5f635f7175657374, - 0x696f6e5f616c705f, - 0x6f75742e62726c61, - 0x6e0074685f416472, - 0x6573735f635f6e61, - 0x6d655f616c705f6f, - 0x75742e62726c616e, - 0x0074685f41647265, - 0x73735f635f6d7367, - 0x5f616c705f6f7574, - 0x2e62726c616e0074, - 0x685f416472657373, - 0x5f635f6d69695f61, - 0x6c705f6f75742e62, - 0x726c616e0074685f, - 0x4164726573735f63, - 0x5f636172645f666e, - 0x73682e62726c616e, - 0x006d795f4261636b, - 0x5f612e62726c7974, - 0x006d795f4261636b, - 0x5f615f4170656172, - 0x2e62726c616e0050, - 0x6963747572655f30, - 0x30006d795f426163, - 0x6b5f615f4c6f7374, - 0x2e62726c616e0054, - 0x5f7175657374696f, - 0x6e5f303000545f6d, - 0x73675f3030006d79, - 0x5f49706c546f7042, - 0x616c6c6f6f6e5f61, - 0x2e62726c79740000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x545f6d69695f6d73, - 0x675f303000574950, - 0x4c5f53455f42545f, - 0x5441524745545449, - 0x4e47005749504c5f, - 0x53455f4445434944, - 0x4500000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x5749504c5f53455f, - 0x43414e43454c0000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000250030, - 0x00360064000a0000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, +static const char* sButtonPaneNames[5] = { + "B_crd_btn_00", "B_crd_btn_10", "B_crd_btn_11", "B_mii_icon_00", "B_card_beta" }; -extern "C" char lbl_81647EE0; +static const char* sInputPaneName = "B_crd_edgi_00"; + +namespace ipl { + namespace scene { + class AddressEditEvent : public ::gui::EventHandler { + public: + AddressEditEvent(AddressEdit* parent) : mpParent(parent) {} + + virtual void onEvent(u32 componentId, u32 event, void* data); + + private: + AddressEdit* mpParent; + }; + + class AddressInputEvent : public ::gui::EventHandler { + public: + AddressInputEvent(AddressEdit* parent) : mpParent(parent) {} + + virtual void onEvent(u32 componentId, u32 event, void* data); + + private: + AddressEdit* mpParent; + }; + } +} + +extern "C" u8 __vt__Q33ipl5scene11AddressEdit[]; +extern "C" void __dl__FPv(void*); + +ipl::keyboard::Manager::KeyboardSetting::KeyboardSetting( + ipl::keyboard::Manager::KeyboardType keyboardType, const wchar_t* value, u32 limit, u32 rows) { + type = keyboardType; + wcString = value; + stringLimit = limit; + rowLimit = rows; +} + +ipl::scene::AddressEdit::AddressEdit(EGG::Heap* heap, int friendCode) + : FaderSceneBase(heap), ButtonEventHandlerBase() { + mMode = friendCode; + mSelectedButton = -1; + mSubState = -1; + mSelectedFriend = 0; + mpCallbackOwner = this; + mString.clear(); + mbParentalOK = false; + mpNigaoe = NULL; + mNigaoeState = 0; + setSceneParentFlags(3); + for (int i = 0; i < 5; ++i) { + mPointCount[i] = 0; + } + for (int i = 0; i < 8; ++i) { + mCreateID.data[i] = 0; + } +} + +ipl::scene::AddressEdit::~AddressEdit() { + if (mpNigaoe != NULL) { + delete mpNigaoe; + } +} + +void ipl::scene::AddressEdit::stt_msg_code_add() { + if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { + mState = 0x22; + } +} + +void ipl::scene::AddressEdit::stt_msg_code_edit() { + if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { + mState = 0; + } +} + +void ipl::scene::AddressEdit::stt_msg_parental() { + if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { + mState = 0; + } +} + +void ipl::scene::AddressEdit::stt_msg_nwc24_error() { + if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { + mState = 0; + } +} + +void ipl::scene::AddressEdit::reset_gui() { + mpEditGui->init(); + mpInputGui->init(); + for (s32 i = 0; i < 5; ++i) { + if (mPointCount[i] > 0) { + ipl::layout::Animator* animator = mpCodeLayout->getAnim(i + 0xb); + animator->initFrame(); + animator->restart(); + } + mPointCount[i] = 0; + } +} + + +extern "C" u8 __vt__Q33ipl5scene16AddressEditEvent[]; +extern "C" u8 __vt__Q33ipl5scene17AddressInputEvent[]; +extern "C" void* __nw__FUl(u32); +extern "C" BOOL RFLSearchOfficialData(const RFLCreateID*, u16*); + +extern "C" NWC24FriendInfo sFriendInfo__Q23ipl5scene; extern "C" char smArg__Q23ipl6System; extern "C" const char* smButtonName__Q33ipl5scene6Button[]; extern "C" void readLayoutAsync__Q33ipl4nand7ManagerFPQ23EGG4HeapPCcb(); extern "C" void List_GetNth__Q24nw4r2utFPCQ34nw4r2ut4ListUs(); extern "C" void getScene__Q33ipl5scene7ManagerFi(); +extern "C" void UTF16ToANSI__Q33ipl7utility13CharacterCodeFPUcPCwl(); +extern "C" void reset_friend__Q33ipl5scene7AddressFv(); +extern "C" void callBtn1__Q23ipl12DialogWindowFUlUl(); extern "C" void setEventHandler__Q33ipl5scene6ButtonFPQ23gui12EventHandlerPQ23gui12EventHandler(); extern "C" void calc__Q33ipl5scene11TextBalloonFv(); extern "C" void calc__Q33ipl6layout6ObjectFv(); @@ -310,71 +163,195 @@ extern "C" void update__Q33ipl3gui11PaneManagerFv(); extern "C" void setOrtho__Q33ipl7utility8GraphicsFUl(); extern "C" void draw__Q33ipl6layout6ObjectFv(); extern "C" void draw__Q33ipl5scene11TextBalloonFv(); -extern "C" void callBtn1__Q23ipl12DialogWindowFUlUl(); + + + + + + + + + + +int ipl::scene::AddressEdit::get_button_no(const char*); extern "C" void callS2Btn2__Q23ipl12DialogWindowFUlUlb(); extern "C" void reserveText__Q33ipl5scene6ButtonFiUl(); extern "C" void reserveAnm__Q33ipl5scene6ButtonFi(); extern "C" void initFrame__Q33ipl7utility15FrameControllerFv(); extern "C" void getMessage__Q33ipl7message7MessageCFUl(); extern "C" void del__Q33ipl5scene15FriendListCacheFUl(); -extern "C" void reset_friend__Q33ipl5scene7AddressFv(); + + + + + + + + +extern "C" NWC24Err NWC24CheckPublicMailAddr_(const char*); extern "C" void __div2u(); extern "C" void __mod2u(); -extern "C" void UTF16ToANSI__Q33ipl7utility13CharacterCodeFPUcPCwl(); +extern "C" u64 utf16_wiiid__Q33ipl5scene11AddressEditFPCw(const wchar_t*); extern "C" void isValidId__Q33ipl5scene15FriendListCacheFRCUx(); extern "C" void isDupId__Q33ipl5scene15FriendListCacheFRCUx(); extern "C" void isDupMail__Q33ipl5scene15FriendListCacheFPCc(); -extern "C" u64 utf16_wiiid__Q33ipl5scene11AddressEditFPCw(const wchar_t*); + + + extern "C" void _savegpr_29(); extern "C" void _restgpr_29(); extern "C" void _savegpr_23(); -extern "C" void _savegpr_29(); extern "C" void _savegpr_27(); extern "C" void _restgpr_23(); -extern "C" void _restgpr_29(); extern "C" void _restgpr_27(); -void ipl::scene::AddressEdit::stt_msg_code_add() { - if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { - *reinterpret_cast(reinterpret_cast(this) + 0x64) = 0x22; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +void ipl::scene::AddressEdit::stt_msg_no_established() { + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + reset_gui(); + mState = 0; + break; + default: + break; } } -void ipl::scene::AddressEdit::stt_msg_code_edit() { - if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { - *reinterpret_cast(reinterpret_cast(this) + 0x64) = 0; +void ipl::scene::AddressEdit::stt_msg_code_invalid() { + ipl::System::getScene(5); + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + mState = 0x11; + break; + default: + break; } } -void ipl::scene::AddressEdit::stt_msg_parental() { - if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { - *reinterpret_cast(reinterpret_cast(this) + 0x64) = 0; +void ipl::scene::AddressEdit::stt_msg_dup_wii_no() { + ipl::System::getScene(5); + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + mState = 0x11; + break; + default: + break; } } -void ipl::scene::AddressEdit::stt_msg_nwc24_error() { - if (System::getDialog()->getLastResult() == DialogWindow::RESULT_BUTTON) { - *reinterpret_cast(reinterpret_cast(this) + 0x64) = 0; +void ipl::scene::AddressEdit::stt_msg_dup_email() { + ipl::System::getScene(5); + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + mState = 0x11; + break; + default: + break; } } -extern "C" asm void __ct__Q43ipl8keyboard7Manager15KeyboardSettingFQ43ipl8keyboard7Manager12KeyboardTypePCwUlUl() { - nofralloc - stw r4, 0(r3) - stw r5, 4(r3) - stw r6, 8(r3) - stw r7, 0xc(r3) - blr +void ipl::scene::AddressEdit::stt_msg_my_wii_no() { + ipl::System::getScene(5); + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + mState = 0x11; + break; + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_msg_no_mii_add() { + ipl::System::getScene(5); + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + mState = 0x1d; + break; + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_msg_add_rlt() { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + button->reserveAnm(0xf); + mState = 0x30; + break; + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_add_code_normal() { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + if (button->isActive()) { + button->update(); + } + if (mState == 0x11) { + mpInputGui->update(); + } +} + +void ipl::scene::AddressEdit::stt_add_name_normal() { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + if (button->isActive()) { + button->update(); + } + if (mState == 0x19) { + mpInputGui->update(); + } } const wchar_t* ipl::scene::AddressEdit::String::getDispCodeLong() const { - if (reinterpret_cast(this)[0x422] == 0) { + if (!mbHasWiiNo) { return; } - return reinterpret_cast(reinterpret_cast(this) + 0x21c); + return mDisplayText; } -extern "C" asm void getName__Q33ipl6nigaoe6ObjectCFv() { +extern "C" asm const wchar_t* getName__Q33ipl6nigaoe6ObjectCFv(void*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -402,15 +379,33 @@ extern "C" asm void getInputForm__Q29textinput7ManagerFv() { } void ipl::scene::AddressEdit::String::clear() { - memset(this, 0, 0x204); - memset(reinterpret_cast(this) + 0x204, 0, 0x18); - memset(reinterpret_cast(this) + 0x21c, 0, 0x204); - reinterpret_cast(this)[0x420] = 0; - reinterpret_cast(this)[0x421] = 0; - reinterpret_cast(this)[0x422] = 0; + memset(mValue, 0, sizeof(mValue)); + memset(mName, 0, sizeof(mName)); + memset(mDisplayText, 0, sizeof(mDisplayText)); + mbValidMail = false; + mbNameNotEmpty = false; + mbHasWiiNo = false; } -extern "C" asm void setWiiNo__Q43ipl5scene11AddressEdit6StringFPCw() { +void ipl::scene::AddressEdit::String::setEMail(const wchar_t* value) { + mbHasWiiNo = false; + memset(mValue, 0, sizeof(mValue)); + wcsncpy(mValue, value, 0xff); + u32 length = wcslen(value); + memset(mDisplayText, 0, sizeof(mDisplayText)); + if (length > 0x10) { + wcsncpy(mDisplayText, value, 0xe); + wcscpy(mDisplayText + 0xe, L"..."); + } else { + wcscpy(mDisplayText, value); + } + u8 address[0x100]; + memset(address, 0, sizeof(address)); + ipl::utility::CharacterCode::UTF16ToANSI(address, value, sizeof(address)); + mbValidMail = !NWC24CheckPublicMailAddr_(reinterpret_cast(address)); +} + +extern "C" asm void setWiiNo__Q43ipl5scene11AddressEdit6StringFPCw(void*, const wchar_t*) { nofralloc stwu r1, -0x20(r1) mflr r0 @@ -491,7 +486,7 @@ setWiiNo_L4: blr } -extern "C" asm void isDupCode__Q43ipl5scene11AddressEdit6StringCFv() { +extern "C" asm int isDupCode__Q43ipl5scene11AddressEdit6StringCFv(void*) { nofralloc stwu r1, -0x120(r1) mflr r0 @@ -530,7 +525,7 @@ isDupCode_L2: blr } -extern "C" asm void isMyCode__Q43ipl5scene11AddressEdit6StringCFv() { +extern "C" asm int isMyCode__Q43ipl5scene11AddressEdit6StringCFv(void*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -562,27 +557,946 @@ isMyCode_L2: blr } -extern "C" asm void prepare__Q33ipl5scene11AddressEditFv() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - lis r4, smArg__Q23ipl6System@ha - lis r5, lbl_81647EE0@ha - stw r0, 0x14(r1) - addi r4, r4, smArg__Q23ipl6System@l - addi r5, r5, lbl_81647EE0@l - li r6, 0 - stw r31, 0xc(r1) - mr r31, r3 - lwz r3, 0x6c(r4) - lwz r4, 0x24(r31) - bl readLayoutAsync__Q33ipl4nand7ManagerFPQ23EGG4HeapPCcb - stw r3, 0xac(r31) - lwz r31, 0xc(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr +void ipl::scene::AddressEdit::prepare() { + mpBalloonFile = ipl::System::getNandManager()->readLayoutAsync( + getSceneHeap(), "balloon.ash", false); +} + +void ipl::scene::AddressEdit::create() { + + ipl::layout::Object* bLayout; + ipl::scene::Board* board = static_cast(ipl::System::getScene(4)); + ipl::nand::LayoutFile* boardFile = board->getLayoutFile(); + + bLayout = reinterpret_cast(__nw__FUl(0x580)); + if (bLayout != NULL) { + bLayout = new (bLayout) ipl::layout::Object(getHeap(), boardFile, "arc", "th_Adress_b.brlyt"); + } + bLayout->bindToGroup("th_Adress_b_card_strt.brlan", "card_strt_fnsh", false, true); + bLayout->bindToGroup("th_Adress_b_btn_in.brlan", "crd_btn_00", false, true); + bLayout->bindToGroup("th_Adress_b_btn_in.brlan", "crd_btn_10", false, false); + bLayout->bindToGroup("th_Adress_b_btn_in.brlan", "crd_btn_11", false, false); + bLayout->bindToGroup("th_Adress_b_btn_in.brlan", "mii_icon_00", false, false); + bLayout->bind("th_Adress_b_btn_in.brlan", "T_frnd_crd_00", false, false); + bLayout->bindToGroup("th_Adress_b_btn_psh.brlan", "crd_btn_00", false, false); + bLayout->bindToGroup("th_Adress_b_btn_psh.brlan", "crd_btn_10", false, false); + bLayout->bindToGroup("th_Adress_b_btn_psh.brlan", "crd_btn_11", false, false); + bLayout->bindToGroup("th_Adress_b_btn_psh.brlan", "mii_icon_00", false, false); + bLayout->bind("th_Adress_b_btn_psh.brlan", "T_frnd_crd_00", false, false); + bLayout->bindToGroup("th_Adress_b_btn_out.brlan", "crd_btn_00", false, false); + bLayout->bindToGroup("th_Adress_b_btn_out.brlan", "crd_btn_10", false, true); + bLayout->bindToGroup("th_Adress_b_btn_out.brlan", "crd_btn_11", false, true); + bLayout->bindToGroup("th_Adress_b_btn_out.brlan", "mii_icon_00", false, true); + bLayout->bind("th_Adress_b_btn_out.brlan", "T_frnd_crd_00", false, true); + bLayout->bindToGroup("th_Adress_b_btn_scl_in.brlan", "crd_btn_00", false, false); + bLayout->bindToGroup("th_Adress_b_btn_scl_in.brlan", "crd_btn_10", false, false); + bLayout->bindToGroup("th_Adress_b_btn_scl_in.brlan", "crd_btn_11", false, false); + bLayout->bindToGroup("th_Adress_b_btn_scl_in.brlan", "mii_icon_00", false, false); + bLayout->bind("th_Adress_b_btn_scl_in.brlan", "T_frnd_crd_00", false, false); + bLayout->bindToGroup("th_Adress_b_btn_scl_out.brlan", "crd_btn_00", false, true); + bLayout->bindToGroup("th_Adress_b_btn_scl_out.brlan", "crd_btn_10", false, true); + bLayout->bindToGroup("th_Adress_b_btn_scl_out.brlan", "crd_btn_11", false, true); + bLayout->bindToGroup("th_Adress_b_btn_scl_out.brlan", "mii_icon_00", false, true); + bLayout->bind("th_Adress_b_btn_scl_out.brlan", "T_frnd_crd_00", false, true); + bLayout->bindToGroup("th_Adress_b_btn_scl_in.brlan", "crd_btn_gry", false, true); + bLayout->bindToGroup("th_Adress_b_btn_scl_out.brlan", "crd_btn_gry", false, false); + bLayout->bindToGroup("th_Adress_b_card_msg_alp_in.brlan", "card_msg", false, true); + bLayout->bindToGroup("th_Adress_b_card_msg_alp_out.brlan", "card_msg", false, false); + bLayout->bindToGroup("th_Adress_b_card_fnsh.brlan", "card_strt_fnsh", false, false); + bLayout->finishBinding(); + + ipl::scene::AddressEditEvent* editEvent = static_cast(__nw__FUl(sizeof(ipl::scene::AddressEditEvent))); + if (editEvent != NULL) { + new (editEvent) ipl::scene::AddressEditEvent(this); + } + void* editManagerMemory = __nw__FUl(0x34); + ipl::gui::PaneManager* editManager = reinterpret_cast(editManagerMemory); + if (editManagerMemory != NULL) { + editManager = new (editManagerMemory) ipl::gui::PaneManager(static_cast< ::gui::EventHandler*>(editEvent), bLayout->getDrawInfo(), NULL, NULL, false); + } + editManager->setupScene(bLayout); + editManager->setAllComponentTriggerTarget(false); + for (s32 i = 0; i < 5; i++) { + const char* paneName = sButtonPaneNames[i]; + nw4r::lyt::Pane* pane = bLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(paneName, true); + editManager->setTriggerTarget(pane, true); + } + mpCodeLayout = bLayout; + mpEditEvent = editEvent; + mpEditGui = editManager; + + nw4r::lyt::Pane* textPane = bLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_crd_btn_00", true); + set_textbox(textPane, ipl::System::getMessage(0x2a)); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_crd_btn_10", true); + set_textbox(textPane, ipl::System::getMessage(0x2b)); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_crd_btn_11", true); + set_textbox(textPane, ipl::System::getMessage(0x2f)); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_crd_btn_gry", true); + set_textbox(textPane, ipl::System::getMessage(0x2a)); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_card_msg_00", true); + set_textbox(textPane, L""); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(textPane, L""); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true); + set_textbox(textPane, L""); + + ipl::layout::Object* cLayout = reinterpret_cast(__nw__FUl(0x580)); + if (cLayout != NULL) { + cLayout = new (cLayout) ipl::layout::Object(getHeap(), boardFile, "arc", "th_Adress_c.brlyt"); + } + cLayout->bindToGroup("th_Adress_c_card_strt.brlan", "G_card_strt_fnsh", false, true); + cLayout->bindToGroup("th_Adress_c_question_alp_in.brlan", "G_question_00", false, true); + cLayout->bindToGroup("th_Adress_c_name_alp_in.brlan", "G_name_00", false, true); + cLayout->bindToGroup("th_Adress_c_msg_alp_in.brlan", "G_msg_00", false, true); + cLayout->bindToGroup("th_Adress_c_mii_alp_in.brlan", "G_mii", false, true); + cLayout->bindToGroup("th_Adress_c_question_alp_out.brlan", "G_question_00", false, false); + cLayout->bindToGroup("th_Adress_c_name_alp_out.brlan", "G_name_00", false, false); + cLayout->bindToGroup("th_Adress_c_msg_alp_out.brlan", "G_msg_00", false, false); + cLayout->bindToGroup("th_Adress_c_mii_alp_out.brlan", "G_mii", false, false); + cLayout->bindToGroup("th_Adress_c_card_fnsh.brlan", "G_card_strt_fnsh", false, false); + cLayout->finishBinding(); + + ipl::scene::AddressInputEvent* inputEvent = static_cast(__nw__FUl(sizeof(ipl::scene::AddressInputEvent))); + if (inputEvent != NULL) { + new (inputEvent) ipl::scene::AddressInputEvent(this); + } + void* inputManagerMemory = __nw__FUl(0x34); + ipl::gui::PaneManager* inputManager = reinterpret_cast(inputManagerMemory); + if (inputManagerMemory != NULL) { + inputManager = new (inputManagerMemory) ipl::gui::PaneManager(static_cast< ::gui::EventHandler*>(inputEvent), cLayout->getDrawInfo(), NULL, NULL, false); + } + inputManager->setupScene(cLayout); + inputManager->setAllComponentTriggerTarget(false); + textPane = cLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(sInputPaneName, true); + inputManager->setTriggerTarget(textPane, true); + mpNameLayout = cLayout; + mpInputEvent = inputEvent; + mpInputGui = inputManager; + + ipl::layout::Object* background = reinterpret_cast(__nw__FUl(0x580)); + if (background != NULL) { + background = new (background) ipl::layout::Object(getHeap(), boardFile, "arc", "my_Back_a.brlyt"); + } + mpBackgroundLayout = background; + background->bind("my_Back_a_Apear.brlan", "Picture_00", false, true); + (mpBackgroundLayout) + ->bind("my_Back_a_Lost.brlan", "Picture_00", false, false); + (mpBackgroundLayout)->finishBinding(); + (mpBackgroundLayout) + ->getAnim(0)->initAnmFrame(); + + mString.clear(); + memset(&sFriendInfo__Q23ipl5scene, 0, sizeof(sFriendInfo__Q23ipl5scene)); + mpNigaoe = 0; + mNigaoeState = 0; + ipl::scene::SceneObj* addressScene = ipl::System::getScene(0x14); + ipl::scene::Address* address = static_cast(addressScene); + mpFriendCache = address->getFriendCache(); + + s32 mode = mMode; + ipl::layout::Animator* animator; + switch (mode) { + case 0: { + mSelectedFriend = address->getChosenFriendIndex(); + get_friendinfo(); + u32 friendIndex = mSelectedFriend; + if (mpFriendCache->getInfo(friendIndex).attr.status == 2) { + (mpCodeLayout)->getAnim(0x15)->initAnmFrame(); + (mpCodeLayout)->getAnim(0x1a)->initAnmFrame(); + } else { + (mpCodeLayout)->getAnim(0x10)->initAnmFrame(); + (mpCodeLayout)->getAnim(0x1b)->initAnmFrame(); + } + animator = (mpCodeLayout)->getAnim(0); + animator->initFrame(); + const wchar_t* friendText = mString.mName; + animator->restart(); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(textPane, friendText); + textPane = (mpCodeLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true); + set_textbox(textPane, mString.mDisplayText); + mState = 0; + break; + } + case 1: { + animator = (mpNameLayout)->getAnim(0); + animator->initFrame(); + animator->restart(); + animator = (mpNameLayout)->getAnim(1); + animator->initFrame(); + animator->restart(); + animator = (mpNameLayout)->getAnim(3); + animator->initFrame(); + animator->restart(); + (mpCodeLayout)->getAnim(0x1a)->initAnmFrame(); + (mpCodeLayout)->getAnim(0x10)->initAnmFrame(); + textPane = (mpNameLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_question_00", true); + set_textbox(textPane, ipl::System::getMessage(0x31)); + textPane = (mpNameLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_msg_00", true); + set_textbox(textPane, ipl::System::getMessage(0x47)); + mState = 0x10; + break; + } + case 2: { + animator = (mpNameLayout)->getAnim(0); + animator->initFrame(); + animator->restart(); + animator = (mpNameLayout)->getAnim(1); + animator->initFrame(); + animator->restart(); + animator = (mpNameLayout)->getAnim(3); + animator->initFrame(); + animator->restart(); + (mpCodeLayout)->getAnim(0x1a)->initAnmFrame(); + (mpCodeLayout)->getAnim(0x10)->initAnmFrame(); + textPane = (mpNameLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_question_00", true); + set_textbox(textPane, ipl::System::getMessage(0x3f)); + textPane = (mpNameLayout) + ->getNW4RLyt()->GetRootPane()->FindPaneByName("T_msg_00", true); + set_textbox(textPane, ipl::System::getMessage(0x48)); + mState = 0x10; + break; + } + default: + break; + } + +create_mode_done: + + s16 miiIndex[2]; + if (RFLSearchOfficialData(&mCreateID, + reinterpret_cast(miiIndex))) { + ipl::System::getMiiManager()->create(ipl::System::getMem2App(), 0x4c, 0x4c, miiIndex[0], + ipl::scene::AddressEdit::nigaoe_create_callback_edit, this); + mNigaoeState = 1; + } + + ipl::System::getKeyboard()->init(); + + ipl::scene::TextBalloon* balloon = reinterpret_cast(__nw__FUl(0x3c)); + if (balloon != NULL) { + f32 balloonWidth = 30.0f; + f32 balloonHeight = 120.0f; + EGG::Heap* heap = getHeap(); + ipl::math::VEC3 position(0.0f, 0.0f, 0.0f); + balloon = new (balloon) ipl::scene::TextBalloon(heap, mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt", position, balloonHeight, balloonWidth); + } + mpBalloon = balloon; +} + +void ipl::scene::AddressEdit::stt_wait_decide_anm() { + bool complete = true; + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + for (s32 i = 0; i < 5; ++i) { + u16 index = static_cast(mSelectedButton + 6); + complete = complete && !mpCodeLayout->getAnim(index)->isPlaying(); + } + if (!complete) { + return; + } + + switch (mSelectedButton) { + case 2: { + u32 friendIndex = mSelectedFriend; + ipl::layout::Animator* animator; + if (mpFriendCache->getInfo(friendIndex).attr.status == 2) { + animator = mpCodeLayout->getAnim(0x15); + } else { + animator = mpCodeLayout->getAnim(0x1b); + } + animator->initFrame(); + animator->restart(); + animator = mpCodeLayout->getAnim(0x16); + animator->initFrame(); + animator->restart(); + animator = mpCodeLayout->getAnim(0x17); + animator->initFrame(); + animator->restart(); + button->reserveAnm(0xc); + mState = 3; + mpBalloon->fadeoutForce(); + reset_gui(); + break; + } + case 1: { + button->reserveAnm(0xc); + button->reserveText(1, 0x2e); + button->reserveAnm(0xf); + ipl::layout::Animator* animator = mpNameLayout->getAnim(0); + animator->initFrame(); + animator->restart(); + animator = mpNameLayout->getAnim(1); + animator->initFrame(); + animator->restart(); + animator = mpNameLayout->getAnim(2); + animator->initFrame(); + animator->restart(); + mpNameLayout->getAnim(3)->initAnmFrame(); + animator = mpBackgroundLayout->getAnim(0); + animator->initFrame(); + animator->restart(); + nw4r::lyt::Pane* textPane = mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_question_00", true); + set_textbox(textPane, ipl::System::getMessage(0x32)); + textPane = mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(textPane, mString.mName); + textPane = mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_msg_00", true); + set_textbox(textPane, ipl::System::getMessage(0x49)); + mpBalloon->fadeoutForce(); + reset_gui(); + mState = 0xc; + break; + } + case 3: { + if (mNigaoeState != 1) { + mNigaoeState = 0; + if (RFLGetAvailableOfficialDataNum() != 0) { + button->reserveAnm(0xc); + button->reserveAnm(0xb); + createChildScene(0x1c, this, 0, reinterpret_cast(1)); + mState = 0xb; + } else { + ipl::System::getDialog()->callBtn1(0x17c, 0x2e); + mState = 0xa; + } + mpBalloon->fadeoutForce(); + } + break; + } + case 0: { + SCParentalControlsInfo parentalInfo; + BOOL parentalResult = SCGetParentalControl(&parentalInfo); + if (!ipl::ncd::NCDSetting::getConnectEnableFlag()) { + button->animation(0x1d); + ipl::System::getDialog()->callBtn2(0x144, 0x146, 0x25, false); + mState = 0x27; + } else if ((SCGetWCFlags() & 1) == 0) { + button->animation(0x1d); + ipl::System::getDialog()->callBtn2(0x17e, 0x146, 0x25, false); + mState = 0x2a; + } else if (parentalResult != 0 && (parentalInfo.enable & 0x80) != 0 && + (SCGetNetContentRestrictions() & 2) != 0) { + button->animation(0x1d); + ipl::System::getDialog()->callBtn1(0x14c, 0x2e); + mState = 0x2d; + } else { + s32 friendError = mpFriendCache->check(); + if (friendError == NWC24_ERR_NETWORK || + mpFriendCache->getLastErr() == NWC24_ERR_SERVER || + mpFriendCache->getLastErr() == NWC24_ERR_FULL) { + wchar_t errorMessage[0x400]; + wchar_t* errorMessagePointer = errorMessage - 1; + for (s32 i = 0; i < 0x200; i++) { + errorMessagePointer[1] = 0; + errorMessagePointer += 2; + *errorMessagePointer = 0; + } + set_err_msg(errorMessage, 0x400, + static_cast(mpFriendCache->getLastErr())); + ipl::System::getDialog()->callBtn1(errorMessage, 0x2e); + button->animation(0x1d); + mState = 0x2e; + } else { + button->reserveAnm(0xc); + button->reserveText(1, 0x27); + button->reserveText(0, 0x4f); + button->reserveAnm(0xf); + requestSceneChange(0xb, reinterpret_cast(1)); + ipl::layout::Animator* animator = mpCodeLayout->getAnim(0x1e); + animator->initFrame(); + animator->restart(); + mState = 0x30; + } + } + mpBalloon->fadeoutForce(); + reset_gui(); + break; + } + case 4: { + ipl::System::getDialog()->callBtn1(mString.getDispCodeLong(), 0x2e); + mpBalloon->fadeoutForce(); + reset_gui(); + mState = 9; + break; + } + default: + mState = 0; + break; + } +} + +void ipl::scene::AddressEdit::stt_wait_delete() { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + switch (ipl::System::getDialog()->getLastResult()) { + case 2: { + delete_friendinfo(); + ipl::layout::Animator* animator = mpCodeLayout->getAnim(0x1d); + animator->initFrame(); + animator->restart(); + mState = 6; + break; + } + case 1: { + button->reserveAnm(0xb); + ipl::layout::Animator* animator = mpCodeLayout->getAnim(0x1d); + animator->initFrame(); + animator->restart(); + mState = 5; + break; + } + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_add_confirm_fadein() { + if (!mpCodeLayout->getAnim(0)->isPlaying()) { + mState = 0x22; + } +} + +void ipl::scene::AddressEdit::stt_add_name_fadein() { + if (!mpNameLayout->getAnim(1)->isPlaying() && + !mpNameLayout->getAnim(3)->isPlaying() && + !mpNameLayout->getAnim(2)->isPlaying()) { + mState = 0x19; + } +} + +void ipl::scene::AddressEdit::stt_add_mii_fadein() { + if (!mpNameLayout->getAnim(1)->isPlaying() && + !mpNameLayout->getAnim(4)->isPlaying() && + !mpNameLayout->getAnim(0)->isPlaying()) { + mState = 0x1d; + } +} + +void ipl::scene::AddressEdit::stt_add_code_fadein() { + if (!mpNameLayout->getAnim(0)->isPlaying() && + !mpNameLayout->getAnim(1)->isPlaying() && + !mpNameLayout->getAnim(3)->isPlaying() && + !mpNameLayout->getAnim(4)->isPlaying() && + !mpNameLayout->getAnim(2)->isPlaying()) { + mState = 0x11; + } +} + +void ipl::scene::AddressEdit::stt_add_name_input() { + ipl::keyboard::Manager::State* state = ipl::System::getKeyboard()->getState(); + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + s32 keyboardType = state->iplType; + if (keyboardType == 3) { + goto state_disappearing; + } + if (keyboardType >= 3) { + goto state_at_or_after_disappearing; + } + if (keyboardType >= 2) { + goto done; + } + if (keyboardType >= 0) { + goto state_hidden; + } + goto done; + +state_at_or_after_disappearing: + if (keyboardType >= 5) { + goto done; + } + goto state_visible; + +state_disappearing: { + bool nameWasEmpty = mString.mName[0] == 0; + if (state->pressOK) { + mString.setName(state->wcString); + nw4r::lyt::Pane* pane = mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_name_00", true); + set_textbox(pane, mString.mName); + } + if (mString.mName[0] == 0) { + if (!nameWasEmpty) { + ipl::layout::Animator* animator = mpNameLayout->getAnim(6); + animator->initFrame(); + animator->restart(); + animator = mpNameLayout->getAnim(3); + animator->initFrame(); + animator->restart(); + } + button->reserveAnm(0xb); + } else { + if (nameWasEmpty) { + ipl::layout::Animator* animator = mpNameLayout->getAnim(2); + animator->initFrame(); + animator->restart(); + animator = mpNameLayout->getAnim(7); + animator->initFrame(); + animator->restart(); + } + if (mString.mbNameNotEmpty) { + button->reserveText(1, 0x2e); + button->reserveAnm(0xf); + } else { + button->reserveAnm(0xb); + } + } + } + goto done; + +state_visible: { + mState = 0x19; + if (static_cast(ipl::System::getRegion()) == 6) { + ipl::System::getKeyboard()->baseMgr()->enableKSXFilter(false); + } + } + goto done; + +state_hidden: + setDefaultTitleText(NULL, ipl::System::getKeyboard()->baseMgr()->isVacancy()); + +done: + return; +} + +void ipl::scene::AddressEdit::stt_add_mii_normal() { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + if (button->isActive()) { + button->update(); + } + if (mState == 0x1d) { + mpInputGui->update(); + } +} + +void ipl::scene::AddressEdit::stt_add_mii_input() { + ipl::scene::Base* child = getChild(); + if (child != NULL) { + ipl::scene::FaceSelect* faceSelect = static_cast(child); + s32 faceId = faceSelect->getSelectedFaceId(); + if (faceId >= 0 && ipl::System::getMiiManager()->isAvalable(faceId) && + mNigaoeState == 0) { + RFLAdditionalInfo additionalInfo; + RFLGetAdditionalInfo(&additionalInfo, RFLDataSource_Official, NULL, faceId); + if (!RFLiIsSameID(&mCreateID, &additionalInfo.createID)) { + mCreateID = additionalInfo.createID; + ipl::System::getMiiManager()->create(ipl::System::getMem2App(), 0x4c, 0x4c, faceId, + ipl::scene::AddressEdit::nigaoe_create_callback_add, + this); + mNigaoeState = 1; + mpInputGui->init(); + mpBalloon->fadeoutForce(); + } + } + } + + if (getChild() == NULL && + ipl::System::getSceneManager()->getReservedScene() == NULL) { + static_cast(ipl::System::getScene(5))->setEventHandler(static_cast< ::gui::EventHandler*>(this), NULL); + mState = 0x1d; + mNigaoeState = 0; + } +} + +void ipl::scene::AddressEdit::stt_add_mii_fadeout() { + if (mpNameLayout->getAnim(9)->isPlaying() || + mpNameLayout->getAnim(5)->isPlaying() || + mpNameLayout->getAnim(8)->isPlaying()) { + return; + } + + if (mSubState == 5) { + ipl::layout::Animator* animator = mpNameLayout->getAnim(1); + animator->initFrame(); + animator->restart(); + animator = mpNameLayout->getAnim(2); + animator->initFrame(); + animator->restart(); + + nw4r::lyt::Pane* pane = + mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_question_00", true); + set_textbox(pane, ipl::System::getMessage(0x32)); + pane = mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(pane, mString.mName); + pane = mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_msg_00", true); + set_textbox(pane, ipl::System::getMessage(0x49)); + mState = 0x18; + return; + } + + if (mSubState == 7) { + ipl::layout::Animator* animator = mpCodeLayout->getAnim(0); + animator->initFrame(); + animator->restart(); + mpCodeLayout->getAnim(0x10)->initAnmFrame(); + mpCodeLayout->getAnim(0x11)->initAnmFrame(); + mpCodeLayout->getAnim(0x12)->initAnmFrame(); + animator = mpCodeLayout->getAnim(0x1c); + animator->initFrame(); + animator->restart(); + + nw4r::lyt::Pane* pane = + mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_card_msg_00", true); + set_textbox(pane, ipl::System::getMessage(0x44)); + pane = mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(pane, mString.mName); + pane = mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true); + set_textbox(pane, mString.mDisplayText); + mState = 0x21; + } +} + +void ipl::scene::AddressEdit::stt_ipt_wait_fadeout() { + if (!mpNameLayout->getAnim(5)->isPlaying() && + !mpNameLayout->getAnim(7)->isPlaying() && + !mpNameLayout->getAnim(6)->isPlaying() && + !mpNameLayout->getAnim(8)->isPlaying() && + !mpNameLayout->getAnim(9)->isPlaying() && + !mpBackgroundLayout->getAnim(1)->isPlaying()) { + mState = 0; + } +} + +void ipl::scene::AddressEdit::stt_wait_del_msg_fadeout() { + if (!mpCodeLayout->getAnim(0x1d)->isPlaying()) { + u32 friendIndex = mSelectedFriend; + u32 status = mpFriendCache->getInfo(friendIndex).attr.status; + ipl::layout::Animator* animator; + if (status == 2) { + animator = mpCodeLayout->getAnim(0x10); + } else { + animator = mpCodeLayout->getAnim(0x1a); + } + animator->initFrame(); + animator->restart(); + animator = mpCodeLayout->getAnim(0x11); + animator->initFrame(); + animator->restart(); + animator = mpCodeLayout->getAnim(0x12); + animator->initFrame(); + animator->restart(); + mState = 2; + } +} + +void ipl::scene::AddressEdit::stt_msg_no_mii() { + switch (ipl::System::getDialog()->getLastResult()) { + case 1: + mpEditGui->init(); + for (u32 i = 0; i < 5; ++i) { + mPointCount[i] = 0; + } + mState = 0; + break; + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_add_confirm_fadeout() { + if (!mpCodeLayout->getAnim(0x1e)->isPlaying()) { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + switch (mSubState) { + case 5: { + ipl::layout::Animator* animator = mpNameLayout->getAnim(0); + animator->initFrame(); + animator->restart(); + mState = 0x1c; + break; + } + case 7: + add_friendinfo(); + button->reserveText(1, 0x29); + static_cast(ipl::System::getScene(0x14))->reset_friend(); + ipl::System::getDialog()->callBtn1(0x4a, 0x2e); + mState = 0x26; + break; + default: + break; + } + } +} + +void ipl::scene::AddressEdit::stt_wait_decide_anm_add() { + bool complete = true; + for (s32 i = 0; i < 5; ++i) { + u16 index = static_cast(mSelectedButton + 6); + complete = (complete & !mpCodeLayout->getAnim(index)->isPlaying()) != 0; + } + if (complete) { + switch (mSelectedButton) { + case 4: + mpEditGui->init(); + ipl::System::getDialog()->callBtn1(mString.getDispCodeLong(), 0x2e); + mState = 0x25; + break; + default: + break; + } + } +} + +void ipl::scene::AddressEdit::stt_add_confirm_normal() { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + if (button->isActive()) { + button->update(); + } + if (mState == 0x22) { + mpEditGui->update(); + } +} + +void ipl::scene::AddressEdit::stt_wait_parental() { + ipl::scene::ParentalDialog* parental = + static_cast(ipl::System::getScene(0x1b)); + if (parental != NULL) { + switch (parental->getResult()) { + case 1: + mbParentalOK = true; + mState = 0x29; + break; + case 2: + case 3: + mbParentalOK = false; + mState = 0x29; + break; + default: + break; + } + } +} + +void ipl::scene::AddressEdit::stt_wait_parental_wc() { + ipl::scene::ParentalDialog* parental = + static_cast(ipl::System::getScene(0x1b)); + if (parental != NULL) { + switch (parental->getResult()) { + case 1: + mbParentalOK = true; + mState = 0x2c; + break; + case 2: + case 3: + mbParentalOK = false; + mState = 0x2c; + break; + default: + break; + } + } +} + +void ipl::scene::AddressEdit::stt_wait_parental_dst() { + if (getChild() == NULL) { + if (mbParentalOK) { + ipl::System::getFader()->fadeOut(); + reserveAllSceneDestruction(0x12, reinterpret_cast(1)); + mState = 0x30; + } else { + static_cast(ipl::System::getScene(5))->animation(0xb); + static_cast(ipl::System::getScene(5))->setEventHandler(static_cast< ::gui::EventHandler*>(this), NULL); + mState = 0; + } + } +} + +void ipl::scene::AddressEdit::stt_wait_parental_dst_wc() { + if (getChild() == NULL) { + if (mbParentalOK) { + ipl::System::getFader()->fadeOut(); + reserveAllSceneDestruction(0x12, reinterpret_cast(4)); + mState = 0x30; + } else { + static_cast(ipl::System::getScene(5))->animation(0xb); + static_cast(ipl::System::getScene(5))->setEventHandler(static_cast< ::gui::EventHandler*>(this), NULL); + mState = 0; + } + } +} + +void ipl::scene::AddressEdit::stt_msg_net() { + switch (ipl::System::getDialog()->getLastResult()) { + case 2: + mState = 0; + break; + case 1: { + SCParentalControlsInfo info; + if (SCGetParentalControl(&info) && (info.enable & SC_PARENTAL_FLAG_ENABLED)) { + static_cast(ipl::System::getScene(5))->setEventHandler(NULL, NULL); + static_cast(ipl::System::getScene(5))->animation(0xc); + createChildScene(0x1b, this, NULL, reinterpret_cast(1)); + mbParentalOK = false; + mState = 0x28; + } else { + ipl::System::getFader()->fadeOut(); + reserveAllSceneDestruction(0x12, reinterpret_cast(1)); + mState = 0x30; + } + break; + } + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_msg_wc() { + switch (ipl::System::getDialog()->getLastResult()) { + case 2: + mState = 0; + break; + case 1: { + SCParentalControlsInfo info; + if (SCGetParentalControl(&info) && (info.enable & SC_PARENTAL_FLAG_ENABLED)) { + static_cast(ipl::System::getScene(5))->setEventHandler(NULL, NULL); + static_cast(ipl::System::getScene(5))->animation(0xc); + createChildScene(0x1b, this, NULL, reinterpret_cast(1)); + mbParentalOK = false; + mState = 0x2b; + } else { + ipl::System::getFader()->fadeOut(); + reserveAllSceneDestruction(0x12, reinterpret_cast(4)); + mState = 0x30; + } + break; + } + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_select_mii() { + if (getChild() != NULL) { + ipl::scene::FaceSelect* faceSelect = + static_cast(getChild()); + s32 faceId = faceSelect->getSelectedFaceId(); + if (faceId >= 0 && ipl::System::getMiiManager()->isAvalable(faceId) && + mNigaoeState == 0) { + RFLAdditionalInfo info; + RFLGetAdditionalInfo(&info, RFLDataSource_Official, NULL, faceId); + if (!RFLiIsSameID(&mCreateID, &info.createID)) { + memcpy(&mCreateID, &info.createID, sizeof(mCreateID)); + ipl::System::getMiiManager()->create( + ipl::System::getMem2App(), 0x4c, 0x4c, faceId, + ipl::scene::AddressEdit::nigaoe_create_callback_edit, + this); + mNigaoeState = 1; + update_friendinfo(); + } + } + } + + if (getChild() == NULL && ipl::System::getReservedScene() == NULL) { + static_cast(ipl::System::getScene(5))->setEventHandler(static_cast< ::gui::EventHandler*>(this), NULL); + mState = 0; + mNigaoeState = 0; + mpEditGui->init(); + for (u32 i = 0; i < 5; ++i) { + mPointCount[i] = 0; + } + } +} + +void ipl::scene::AddressEdit::set_textbox(nw4r::lyt::Pane* pane, const wchar_t* text) { + nw4r::lyt::TextBox* textBox = nw4r::ut::DynamicCast(pane); + textBox->SetString(text, 0); +} + +void ipl::scene::AddressEdit::setDefaultTitleText(const wchar_t* text, bool flag) { + if (!flag && (text == NULL || *text != L'\0')) { + goto set_empty_title; + } + switch (mState) { + case 0xe: + case 0x1a: + ipl::System::getKeyboard()->baseMgr()->setTitleText(ipl::System::getMessage(0x15e)); + return; + case 0x12: + ipl::System::getKeyboard()->baseMgr()->setTitleText(ipl::System::getMessage(0x15d)); + break; + } + return; + +set_empty_title: + ipl::System::getKeyboard()->baseMgr()->setTitleText(L""); +} + +void ipl::scene::AddressEditEvent::onEvent(u32 componentId, u32 event, void* data) { + s32 signedEvent = static_cast(event); + ::gui::Manager* manager = mpManager; + ::gui::PaneComponent* component = + static_cast< ::gui::PaneComponent*>(manager->getComponent(componentId)); + const char* paneName = component->getPane()->GetName(); + + if (signedEvent == 1) { + if (data != NULL) { + mpParent->start_point_event(paneName, static_cast(data)); + } + } else if (signedEvent >= 1) { + if (signedEvent < 3) { + mpParent->start_left_event(paneName); + } + } else if (signedEvent >= 0 && data != NULL && + static_cast(data)->downTrg(0x100800)) { + mpParent->start_trig_event(paneName); + } +} + +void ipl::scene::AddressInputEvent::onEvent(u32 componentId, u32 event, void* data) { + s32 signedEvent = static_cast(event); + ::gui::Manager* manager = mpManager; + ::gui::PaneComponent* component = + static_cast< ::gui::PaneComponent*>(manager->getComponent(componentId)); + const char* paneName = component->getPane()->GetName(); + ipl::controller::Interface* controller = static_cast(data); + + if (signedEvent == 1) { + if (controller != NULL) { + mpParent->start_ipt_point_event(paneName, controller->getChannel()); + } + } else if (signedEvent >= 1) { + if (signedEvent < 3 && controller != NULL) { + mpParent->start_ipt_left_event(paneName, controller->getChannel()); + } + } else if (signedEvent >= 0 && controller != NULL && controller->downTrg(0x100800)) { + mpParent->start_ipt_trig_event(paneName, controller->getChannel()); + } +} + +void ipl::scene::AddressEdit::nigaoe_create_callback_edit(ipl::nigaoe::Object* object, void* callbackWork) { + ipl::scene::AddressEdit* self = static_cast(callbackWork); + if (self->mpNigaoe != NULL) { + delete self->mpNigaoe; + } + self->mpNigaoe = object; + nw4r::lyt::Pane* pane = self->mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName( + "mii_icon_00", true); + pane->GetMaterial()->SetTexture(0, object->getIconTexture()); + self->mNigaoeState = 2; + self->mpBalloon->init(object->getName(), 0xa); +} + +void ipl::scene::AddressEdit::nigaoe_create_callback_add(ipl::nigaoe::Object* object, void* callbackWork) { + ipl::scene::AddressEdit* self = static_cast(callbackWork); + if (self->mpNigaoe != NULL) { + delete self->mpNigaoe; + } + self->mpNigaoe = object; + nw4r::lyt::Pane* pane = self->mpNameLayout->getNW4RLyt()->GetRootPane()->FindPaneByName( + "mii_icon_00", true); + pane->GetMaterial()->SetTexture(0, object->getIconTexture()); + pane = self->mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("mii_icon_00", true); + pane->GetMaterial()->SetTexture(0, object->getIconTexture()); + self->mNigaoeState = 2; + self->mpBalloon->init(object->getName(), 0xa); } extern "C" asm void calcFadein__Q33ipl5scene11AddressEditFv() { @@ -645,6 +1559,269 @@ initCalcNormal_L1: blr } +ipl::scene::FaderSceneCommand ipl::scene::AddressEdit::calcNormal() { + switch (mState) { + case 0: + stt_normal(); + break; + case 1: + stt_wait_decide_anm(); + break; + case 2: + stt_wait_btn_fadein(); + break; + case 3: + stt_wait_btn_fadeout(); + break; + case 4: + stt_wait_del_msg_fadein(); + break; + case 5: + stt_wait_del_msg_fadeout(); + break; + case 6: + stt_wait_del_msg_fadeout_to_rlt(); + break; + case 7: + stt_wait_delete(); + break; + case 8: + stt_msg_del_rlt(); + break; + case 9: + stt_msg_code_edit(); + break; + case 10: + stt_msg_no_mii(); + break; + case 11: + stt_select_mii(); + break; + case 12: + stt_ipt_wait_fadein(); + break; + case 13: + stt_ipt_normal(); + break; + case 14: + stt_ipt_input(); + break; + case 15: + stt_ipt_wait_fadeout(); + break; + case 16: + stt_add_code_fadein(); + break; + case 17: + stt_add_code_normal(); + break; + case 18: + stt_add_code_input(); + break; + case 19: + stt_msg_code_invalid(); + break; + case 20: + stt_msg_dup_wii_no(); + break; + case 21: + stt_msg_dup_email(); + break; + case 22: + stt_msg_my_wii_no(); + break; + case 23: + stt_add_code_fadeout(); + break; + case 24: + stt_add_name_fadein(); + break; + case 25: + stt_add_name_normal(); + break; + case 26: + stt_add_name_input(); + break; + case 27: + stt_add_name_fadeout(); + break; + case 28: + stt_add_mii_fadein(); + break; + case 29: + stt_add_mii_normal(); + break; + case 30: + stt_add_mii_input(); + break; + case 31: + stt_msg_no_mii_add(); + break; + case 32: + stt_add_mii_fadeout(); + break; + case 33: + stt_add_confirm_fadein(); + break; + case 34: + stt_add_confirm_normal(); + break; + case 35: + stt_add_confirm_fadeout(); + break; + case 36: + stt_wait_decide_anm_add(); + break; + case 37: + stt_msg_code_add(); + break; + case 38: + stt_msg_add_rlt(); + break; + case 39: + stt_msg_net(); + break; + case 40: + stt_wait_parental(); + break; + case 41: + stt_wait_parental_dst(); + break; + case 42: + stt_msg_wc(); + break; + case 43: + stt_wait_parental_wc(); + break; + case 44: + stt_wait_parental_dst_wc(); + break; + case 45: + stt_msg_parental(); + break; + case 46: + stt_msg_nwc24_error(); + break; + case 47: + stt_msg_no_established(); + break; + } + + switch (mState) { + case 0: + case 3: + case 9: + case 12: + case 29: + case 32: + case 34: + case 35: + case 36: + case 39: + case 42: + case 45: + case 46: + case 47: + mpBalloon->calc(); + break; + } + + return mState == 0x30 + ? ipl::scene::FADER_SCN_NEXT + : ipl::scene::FADER_SCN_CONTINUE; +} + +void ipl::scene::AddressEdit::stt_add_name_fadeout() { + + if (!mpNameLayout->getAnim(5)->isPlaying() && + !mpNameLayout->getAnim(7)->isPlaying() && + !mpNameLayout->getAnim(6)->isPlaying() && + !mpNameLayout->getAnim(9)->isPlaying()) { + s32 state = mSubState; + if (state == 6) { + goto state_done; + } + if (state >= 6) { + goto state_six_or_more; + } + if (state >= 5) { + goto state_five; + } + goto state_done; + + state_six_or_more: + if (state >= 8) { + goto state_done; + } + goto state_seven; + + state_five: { + ipl::layout::Animator* pane = mpNameLayout->getAnim(1); + pane->initFrame(); + pane->restart(); + pane = mpNameLayout->getAnim(2); + pane->initFrame(); + pane->restart(); + + s32 inputType = mMode; + switch (inputType) { + case 2: + goto address_type_two; + case 1: + goto address_type_one; + default: + goto address_type_common; + } + + address_type_one: { + nw4r::lyt::Pane* label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_question_00", true); + set_textbox(label, ipl::System::getMessage(0x31)); + label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_msg_00", true); + set_textbox(label, ipl::System::getMessage(0x47)); + } + goto address_type_common; + + address_type_two: { + nw4r::lyt::Pane* label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_question_00", true); + set_textbox(label, ipl::System::getMessage(0x3f)); + label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_msg_00", true); + set_textbox(label, ipl::System::getMessage(0x48)); + } + + address_type_common: { + nw4r::lyt::Pane* label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_name_00", true); + set_textbox(label, mString.mDisplayText); + mState = 0x10; + } + goto state_done; + } + + state_seven: { + ipl::layout::Animator* pane = mpNameLayout->getAnim(1); + pane->initFrame(); + pane->restart(); + pane = mpNameLayout->getAnim(4); + pane->initFrame(); + pane->restart(); + + nw4r::lyt::Pane* label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_question_00", true); + set_textbox(label, ipl::System::getMessage(0x55)); + label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_mii_msg_00", true); + set_textbox(label, ipl::System::getMessage(0x8b)); + mState = 0x1c; + } + state_done: + ; + } +} + extern "C" asm void initCalcFadeout__Q33ipl5scene11AddressEditFv() { nofralloc stwu r1, -0x10(r1) @@ -699,7 +1876,7 @@ extern "C" asm void calcCommonAfter__Q33ipl5scene11AddressEditFv() { blr } -extern "C" asm void stt_normal__Q33ipl5scene11AddressEditFv() { +extern "C" asm void stt_normal__Q33ipl5scene11AddressEditFv(ipl::scene::AddressEdit*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -733,7 +1910,7 @@ stt_normal_L2: blr } -extern "C" asm void stt_wait_del_msg_fadein__Q33ipl5scene11AddressEditFv() { +extern "C" asm void stt_wait_del_msg_fadein__Q33ipl5scene11AddressEditFv(ipl::scene::AddressEdit*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -757,7 +1934,7 @@ stt_wait_del_msg_fadein_L1: blr } -extern "C" asm void delete_friendinfo__Q33ipl5scene11AddressEditFv() { +extern "C" asm void delete_friendinfo__Q33ipl5scene11AddressEditFv(void* self) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -778,18 +1955,7 @@ extern "C" asm void delete_friendinfo__Q33ipl5scene11AddressEditFv() { blr } -extern "C" int get_button_no__Q33ipl5scene11AddressEditFPCc(void*, const char* paneName) { - int result = -1; - for (int i = 0; i < 5; i++) { - if (strcmp(smButtonName__Q33ipl5scene6Button[i], paneName) == 0) { - result = i; - break; - } - } - return result; -} - -extern "C" u64 utf16_wiiid__Q33ipl5scene11AddressEditFPCw(const wchar_t* value) { +u64 ipl::scene::AddressEdit::utf16_wiiid(const wchar_t* value) { u64 result = 0; u64 multiplier = 1; for (int i = 0; i < 0x10; i++) { @@ -799,7 +1965,7 @@ extern "C" u64 utf16_wiiid__Q33ipl5scene11AddressEditFPCw(const wchar_t* value) return result; } -extern "C" asm void wiiid_utf16__Q33ipl5scene11AddressEditFUxPw() { +extern "C" asm void wiiid_utf16__Q33ipl5scene11AddressEditFUxPw(u64, wchar_t*) { nofralloc stwu r1, -0x30(r1) mflr r0 @@ -846,17 +2012,16 @@ wiiid_utf16_L1: blr } -extern "C" void setName__Q43ipl5scene11AddressEdit6StringFPCw(void* self, const wchar_t* value) { - wchar_t* name = reinterpret_cast(reinterpret_cast(self) + 0x204); - wcsncpy(name, value, 0xa); +void ipl::scene::AddressEdit::String::setName(const wchar_t* value) { + wcsncpy(mName, value, 0xa); u32 length = wcslen(value); - reinterpret_cast(self)[0x421] = 0; + mbNameNotEmpty = false; for (u32 i = 0; i < length; i++) { if (value[i] == 0) { break; } if (value[i] != L' ' && value[i] != 0x3000) { - reinterpret_cast(self)[0x421] = 1; + mbNameNotEmpty = true; break; } } @@ -948,7 +2113,7 @@ draw_L1: blr } -extern "C" asm void stt_wait_btn_fadein__Q33ipl5scene11AddressEditFv() { +extern "C" asm void stt_wait_btn_fadein__Q33ipl5scene11AddressEditFv(ipl::scene::AddressEdit*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -1016,7 +2181,31 @@ stt_wait_btn_fadein_L3: blr } -extern "C" asm void stt_wait_del_msg_fadeout_to_rlt__Q33ipl5scene11AddressEditFv() { +void ipl::scene::AddressEdit::stt_wait_btn_fadeout() { + u32 index = mSelectedFriend; + u32 friendType = mpFriendCache->getInfo(index).attr.status; + u32 friendFinished; + if (friendType == 2) { + friendFinished = !mpCodeLayout->getAnim(0x15)->isPlaying(); + } else { + friendFinished = !mpCodeLayout->getAnim(0x1b)->isPlaying(); + } + + bool finished = friendFinished && !mpCodeLayout->getAnim(0x16)->isPlaying(); + finished = finished && !mpCodeLayout->getAnim(0x17)->isPlaying(); + + if (finished) { + nw4r::lyt::Pane* label = mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_card_msg_00", true); + const wchar_t* message = ipl::System::getMessage(0x30); + set_textbox(label, message); + ipl::System::getDialog()->callS2Btn2(0x142, 0x141, true); + mpCodeLayout->getAnim(0x1c)->initFrame(); + mpCodeLayout->getAnim(0x1c)->restart(); + mState = 4; + } +} + +extern "C" asm void stt_wait_del_msg_fadeout_to_rlt__Q33ipl5scene11AddressEditFv(ipl::scene::AddressEdit*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -1046,7 +2235,7 @@ stt_wait_del_msg_fadeout_to_rlt_L1: blr } -extern "C" asm void stt_msg_del_rlt__Q33ipl5scene11AddressEditFv() { +extern "C" asm void stt_msg_del_rlt__Q33ipl5scene11AddressEditFv(ipl::scene::AddressEdit*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -1091,7 +2280,7 @@ stt_msg_del_rlt_L1: blr } -extern "C" asm void stt_ipt_wait_fadein__Q33ipl5scene11AddressEditFv() { +extern "C" asm void stt_ipt_wait_fadein__Q33ipl5scene11AddressEditFv(ipl::scene::AddressEdit*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -1136,7 +2325,7 @@ stt_ipt_wait_fadein_L1: blr } -extern "C" asm void stt_ipt_normal__Q33ipl5scene11AddressEditFv() { +extern "C" asm void stt_ipt_normal__Q33ipl5scene11AddressEditFv(ipl::scene::AddressEdit*) { nofralloc stwu r1, -0x10(r1) mflr r0 @@ -1170,6 +2359,210 @@ stt_ipt_normal_L2: blr } +void ipl::scene::AddressEdit::stt_ipt_input() { + ipl::keyboard::Manager::State* state = ipl::System::getKeyboard()->getState(); + ipl::scene::Manager* sceneManager = ipl::System::getSceneManager(); + ipl::scene::Button* button = static_cast(sceneManager->getScene(5)); + s32 keyboardType = state->iplType; + if (keyboardType == ipl::keyboard::Manager::STATE_DISAPPEARING) { + goto state_disappearing; + } + if (keyboardType >= ipl::keyboard::Manager::STATE_DISAPPEARING) { + goto state_at_or_after_disappearing; + } + if (keyboardType >= ipl::keyboard::Manager::STATE_VISIBLE) { + goto done; + } + if (keyboardType >= ipl::keyboard::Manager::STATE_HIDDEN) { + goto state_hidden; + } + goto done; + +state_at_or_after_disappearing: + if (keyboardType >= 5) { + goto done; + } + goto state_hidden_after_disappear; + +state_disappearing: { + bool nameWasEmpty = mString.mName[0] == 0; + if (state->pressOK) { + mString.setName(state->wcString); + ipl::layout::Object* layout = + mpNameLayout; + nw4r::lyt::Pane* pane = layout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(pane, mString.mName); + } + if (mString.mName[0] == 0) { + if (!nameWasEmpty) { + ipl::layout::Animator* pane = mpNameLayout->getAnim(6); + pane->initFrame(); + pane->restart(); + pane = mpNameLayout->getAnim(3); + pane->initFrame(); + pane->restart(); + } + button->reserveAnm(0xb); + } else { + if (nameWasEmpty) { + ipl::layout::Animator* pane = mpNameLayout->getAnim(2); + pane->initFrame(); + pane->restart(); + pane = mpNameLayout->getAnim(7); + pane->initFrame(); + pane->restart(); + } + if (mString.mbNameNotEmpty != 0) { + button->reserveText(1, 0x2e); + button->reserveAnm(0xf); + } else { + button->reserveAnm(0xb); + } + } + } + goto done; + +state_hidden_after_disappear: { + mState = 0xd; + if (static_cast(ipl::System::getRegion()) == 6) { + ipl::System::getKeyboard()->baseMgr()->enableKSXFilter(false); + } + } + goto done; + +state_hidden: { + setDefaultTitleText(NULL, ipl::System::getKeyboard()->baseMgr()->isVacancy()); + } + +done: + return; +} + +void ipl::scene::AddressEdit::stt_add_code_input() { + ipl::keyboard::Manager::State* state = ipl::System::getKeyboard()->getState(); + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + switch (state->iplType) { + case ipl::keyboard::Manager::STATE_DISAPPEARING: { + bool codeWasEmpty = mString.mValue[0] == 0; + if (state->pressOK) { + if (mMode == 1) { + setWiiNo__Q43ipl5scene11AddressEdit6StringFPCw( + &mString, state->wcString); + } else { + mString.setEMail(state->wcString); + } + nw4r::lyt::Pane* label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(label, mString.mDisplayText); + } + if (mString.mValue[0] == 0) { + if (!codeWasEmpty) { + ipl::layout::Animator* pane = mpNameLayout->getAnim(6); + pane->initFrame(); + pane->restart(); + pane = mpNameLayout->getAnim(3); + pane->initFrame(); + pane->restart(); + } + button->reserveAnm(0xb); + } else { + if (codeWasEmpty) { + ipl::layout::Animator* pane = mpNameLayout->getAnim(2); + pane->initFrame(); + pane->restart(); + pane = mpNameLayout->getAnim(7); + pane->initFrame(); + pane->restart(); + } + if (mString.mbValidMail != 0 && + isDupCode__Q43ipl5scene11AddressEdit6StringCFv(&mString) == 0 && + isMyCode__Q43ipl5scene11AddressEdit6StringCFv(&mString) == 0) { + button->reserveText(1, 0x2e); + button->reserveAnm(0xf); + } else { + button->reserveAnm(0xb); + } + } + break; + } + case ipl::keyboard::Manager::STATE_HIDDEN_AFTER_DISAPPEAR: + if (state->pressOK) { + if (mString.mValue[0] != 0) { + if (mMode == 1) { + if (isMyCode__Q43ipl5scene11AddressEdit6StringCFv( + &mString) != 0) { + ipl::System::getDialog()->callBtn1(0x56, 0x2e); + mState = 0x16; + } else if (isDupCode__Q43ipl5scene11AddressEdit6StringCFv( + &mString) != 0) { + ipl::System::getDialog()->callBtn1(0x52, 0x2e); + mState = 0x14; + } else if (mString.mbValidMail == 0) { + ipl::System::getDialog()->callBtn1(0x54, 0x2e); + mState = 0x13; + } else { + mState = 0x11; + } + } else if (isDupCode__Q43ipl5scene11AddressEdit6StringCFv( + &mString) != 0) { + ipl::System::getDialog()->callBtn1(0x53, 0x2e); + mState = 0x15; + } else if (mString.mbValidMail == 0) { + ipl::System::getDialog()->callBtn1(0x1be, 0x2e); + mState = 0x13; + } else { + mState = 0x11; + } + } else { + mState = 0x11; + } + } else { + mState = 0x11; + } + break; + case ipl::keyboard::Manager::STATE_HIDDEN: + case ipl::keyboard::Manager::STATE_APPEARING: + if (mMode != 1) { + setDefaultTitleText(NULL, ipl::System::getKeyboard()->baseMgr()->isVacancy()); + } + break; + default: + break; + } +} + +void ipl::scene::AddressEdit::stt_add_code_fadeout() { + ipl::layout::Object* layout = mpNameLayout; + ipl::layout::Animator* pane = layout->getAnim(5); + if (!pane->isPlaying()) { + pane = mpNameLayout->getAnim(6); + if (!pane->isPlaying()) { + nw4r::lyt::Pane* label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + reinterpret_cast("T_question_00"), true); + set_textbox(label, ipl::System::getMessage(0x32)); + label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + reinterpret_cast("T_msg_00"), true); + set_textbox(label, ipl::System::getMessage(0x49)); + label = (mpNameLayout)->getNW4RLyt()->GetRootPane()->FindPaneByName( + reinterpret_cast("T_name_00"), true); + set_textbox(label, mString.mName); + pane = mpNameLayout->getAnim(1); + pane->initFrame(); + pane->restart(); + if (mString.mName[0] != 0) { + pane = mpNameLayout->getAnim(2); + pane->initFrame(); + pane->restart(); + } else { + pane = mpNameLayout->getAnim(3); + pane->initFrame(); + pane->restart(); + } + ipl::System::getKeyboard()->init(); + mState = 0x18; + } + } +} + /* This is a modified version of NWC24CheckPublicMailAddr. Changes: @@ -1299,3 +2692,824 @@ static ChkHostNameError CheckHostName(const char* hostName, u32 hostNameLength) return CHECK_HOSTNAME_SUCCESS; } + + + + + +void ipl::scene::AddressEdit::start_point_event( + const char* paneName, ipl::controller::Interface* controller) { + int buttonNo = get_button_no(paneName); + s32 state = mState; + + switch (state) { + case 0: + goto state0; + case 0x22: + goto state22; + default: + goto done; + } + +state0: + switch (buttonNo) { + case 0: + goto state0Button0; + case 1: + case 2: + goto state0Common; + case 3: + goto state0Button3; + default: + goto done; + } + +state0Button0: { + u32 friendIndex = mSelectedFriend; + u32 friendType = mpFriendCache->getInfo(friendIndex).attr.status; + if (friendType != 2) { + goto done; + } + s32* count = &mPointCount[buttonNo]; + if (*count == 0) { + ipl::layout::Object* layout = mpCodeLayout; + ipl::layout::Animator* pane = layout->getAnim(buttonNo + 1); + pane->initFrame(); + pane->restart(); + ipl::snd::getSystem()->startSE( + "WIPL_SE_BT_TARGETTING"); + controller->rumble(1); + } + ++*count; + goto done; +} + +state0Button3: { + s32* count = &mPointCount[buttonNo]; + if (*count == 0) { + ipl::layout::Object* layout = mpCodeLayout; + nw4r::lyt::Pane* pane = layout->getNW4RLyt()->GetRootPane()->FindPaneByName(paneName, true); + ipl::math::VEC3 position(0.0f, 0.0f, 0.0f); + PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast(&position), reinterpret_cast(&position)); + f32 xOffset = 15.0f; + f32 height = 50.0f; + f32 scale = 0.5f; + position.x = position.x + xOffset; + position.y = position.y + scale * height; + (mpBalloon) + ->setPos(position, false, 1); + (mpBalloon)->fadein(); + } +} + +state0Common: { + s32* count = &mPointCount[buttonNo]; + if (*count == 0) { + ipl::layout::Object* layout = mpCodeLayout; + ipl::layout::Animator* pane = layout->getAnim(buttonNo + 1); + pane->initFrame(); + pane->restart(); + ipl::snd::getSystem()->startSE( + "WIPL_SE_BT_TARGETTING"); + controller->rumble(1); + } + ++*count; + goto done; +} + +state22: + switch (buttonNo) { + case 3: + goto state22Button3; + default: + goto done; + } +state22Button3: + { + s32* count = &mPointCount[buttonNo]; + if (*count == 0) { + ipl::layout::Object* layout = mpCodeLayout; + nw4r::lyt::Pane* pane = layout->getNW4RLyt()->GetRootPane()->FindPaneByName(paneName, true); + ipl::math::VEC3 position(0.0f, 0.0f, 0.0f); + PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast(&position), reinterpret_cast(&position)); + f32 xOffset = 15.0f; + f32 height = 50.0f; + f32 scale = 0.5f; + position.x = position.x + xOffset; + position.y = position.y + scale * height; + (mpBalloon) + ->setPos(position, false, 1); + (mpBalloon)->fadein(); + } + ++*count; + } + +done: + return; +} + +void ipl::scene::AddressEdit::start_left_event( + const char* paneName) { + int buttonNo = get_button_no(paneName); + s32 state = mState; + switch (state) { + case 0x22: + goto state22; + case 0: + switch (buttonNo) { + case 3: + goto state0Button3; + case 0: + goto state0Friend; + case 1: + case 2: + goto state0Common; + default: + break; + } + break; + default: + break; + } + goto done; + +state0Friend: { + u32 friendIndex = mSelectedFriend; + u32 friendType = mpFriendCache->getInfo(friendIndex).attr.status; + if (friendType != 2) { + goto done; + } + s32* count = &mPointCount[buttonNo]; + if (*count == 1) { + ipl::layout::Object* layout = mpCodeLayout; + ipl::layout::Animator* pane = layout->getAnim(buttonNo + 0xb); + pane->initFrame(); + pane->restart(); + } + if (*count > 0) { + --*count; + } + goto done; + } + +state0Button3: { + s32* count = &mPointCount[buttonNo]; + if (*count == 1) { + (mpBalloon)->fadeoutForce(); + } + --*count; + goto done; + } + +state0Common: { + s32* count = &mPointCount[buttonNo]; + if (*count == 1) { + ipl::layout::Object* layout = mpCodeLayout; + ipl::layout::Animator* pane = layout->getAnim(buttonNo + 0xb); + pane->initFrame(); + pane->restart(); + } + if (*count > 0) { + --*count; + } + goto done; + } + +state22: + if (buttonNo != 3) { + goto done; + } + { + s32* count = &mPointCount[buttonNo]; + if (*count == 1) { + (mpBalloon)->fadeoutForce(); + } + --*count; + } + +done: + return; +} + +void ipl::scene::AddressEdit::start_trig_event( + const char* paneName) { + int buttonNo = get_button_no(paneName); + s32 state = mState; + + switch (state) { + case 0: { + if (buttonNo == 0) { + goto state0Friend; + } + if (buttonNo < 0) { + break; + } + if (buttonNo >= 5) { + break; + } + goto state0Event; + + state0Friend: { + u32 friendIndex = mSelectedFriend; + u32 friendType = mpFriendCache->getInfo(friendIndex).attr.status; + if (friendType != 2) { + goto state0FriendError; + } + reset_gui(); + ipl::layout::Object* layout = mpCodeLayout; + ipl::layout::Animator* pane = layout->getAnim(buttonNo + 6); + pane->initFrame(); + pane->restart(); + mSelectedButton = buttonNo; + ipl::snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING"); + mState = 1; + break; + } + + state0FriendError: { + ipl::System::getDialog()->callBtn1(0x57, 0x2e); + (mpBalloon)->fadeoutForce(); + reset_gui(); + mState = 0x2f; + break; + } + + state0Event: { + ipl::layout::Object* layout = mpCodeLayout; + ipl::layout::Animator* pane = layout->getAnim(buttonNo + 6); + pane->initFrame(); + pane->restart(); + mSelectedButton = buttonNo; + ipl::snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING"); + mState = 1; + break; + } + } + break; + + case 0x22: + switch (buttonNo) { + case 4: + goto state22Button4; + default: + break; + } + break; + + state22Button4: { + (mpBalloon)->fadeoutForce(); + for (s32 i = 0; i < 5; ++i) { + mPointCount[i] = 0; + } + ipl::layout::Object* layout = mpCodeLayout; + ipl::layout::Animator* pane = layout->getAnim(10); + pane->initFrame(); + pane->restart(); + mSelectedButton = buttonNo; + ipl::snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING"); + mState = 0x24; + break; + } + } +} + +void ipl::scene::AddressEdit::start_ipt_trig_event( + const char* paneName, int channel) { + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + ipl::controller::Interface* controller = ipl::System::getControllerManager()->getYoungController(); + if (controller == NULL) { + return; + } + if (controller->getChannel() != channel) { + return; + } + if (!strcmp(sInputPaneName, paneName)) { + s32 state = mState; + switch (state) { + case 0xd: { + ipl::keyboard::Manager::KeyboardSetting setting(static_cast(0xb), mString.mName, 0xa, 1); + + switch (ipl::System::getRegion()) { + case 0xb: { + void* oemDictionary; + void* systemDictionary; + systemDictionary = ipl::System::getKeyboard()->getZiSystemDic(); + oemDictionary = ipl::System::getKeyboard()->getZiOemDic(); + textinput::InputForm* inputForm = ipl::System::getKeyboard()->baseMgr()->getInputForm(); + inputForm->setZiDictionary(oemDictionary, systemDictionary); + setting.type = static_cast(0xd); + break; + } + case 6: + ipl::System::getKeyboard()->baseMgr()->enableKSXFilter(true); + setting.type = static_cast(0xd); + break; + default: + break; + } + + ipl::System::getKeyboard()->start(channel, setting); + setDefaultTitleText(mString.mName, false); + if (mString.mbNameNotEmpty != 0) { + button->reserveAnm(0x10); + } else { + button->reserveAnm(0xc); + } + button->reserveText(1, 0x2e); + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0xe; + break; + } + case 0x11: { + if (mMode == 1) { + ipl::keyboard::Manager::KeyboardSetting setting(static_cast(0xc), mString.mValue, 0x10, 2); + ipl::System::getKeyboard()->start(channel, setting); + } else { + ipl::keyboard::Manager::KeyboardSetting setting(static_cast(7), mString.mValue, 0x63, 5); + ipl::System::getKeyboard()->start(channel, setting); + } + setDefaultTitleText(mString.mValue, false); + if (mString.mbValidMail != 0 && + isDupCode__Q43ipl5scene11AddressEdit6StringCFv(&mString) == 0 && + isMyCode__Q43ipl5scene11AddressEdit6StringCFv(&mString) == 0) { + button->reserveAnm(0x10); + } else { + button->reserveAnm(0xc); + } + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x12; + break; + } + case 0x19: { + ipl::keyboard::Manager::KeyboardSetting setting(static_cast(0xb), mString.mName, 0xa, 1); + + switch (ipl::System::getRegion()) { + case 0xb: { + void* oemDictionary; + void* systemDictionary; + systemDictionary = ipl::System::getKeyboard()->getZiSystemDic(); + oemDictionary = ipl::System::getKeyboard()->getZiOemDic(); + textinput::InputForm* inputForm = ipl::System::getKeyboard()->baseMgr()->getInputForm(); + inputForm->setZiDictionary(oemDictionary, systemDictionary); + setting.type = static_cast(0xd); + break; + } + case 6: + ipl::System::getKeyboard()->baseMgr()->enableKSXFilter(true); + setting.type = static_cast(0xd); + break; + default: + break; + } + + ipl::System::getKeyboard()->start(channel, setting); + setDefaultTitleText(mString.mName, false); + if (mString.mbNameNotEmpty != 0) { + button->reserveAnm(0x10); + } else { + button->reserveAnm(0xc); + } + button->reserveText(1, 0x2e); + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x1a; + break; + } + case 0x1d: + if (mNigaoeState != 1) { + mNigaoeState = 0; + if (RFLGetAvailableOfficialDataNum() != 0) { + createChildScene(0x1c, this, NULL, reinterpret_cast(2)); + button->reserveAnm(0x10); + button->reserveAnm(0xb); + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x1e; + } else { + ipl::System::getDialog()->callBtn1(0x17c, 0x2e); + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x1f; + } + } + break; + default: + break; + } + } +} + + +void ipl::scene::AddressEdit::start_ipt_point_event( + const char* paneName, int channel) { + ipl::controller::Interface* controller = ipl::System::getControllerManager()->getYoungController(); + if (controller != NULL) { + if (controller->getChannel() == channel) { + switch (mState) { + case 0x1d: { + char paneNameCopy[12] = "mii_icon_00"; + if (strcmp(paneNameCopy, paneName) == 0) { + ipl::layout::Object* layout = mpNameLayout; + nw4r::lyt::Pane* pane = layout->getNW4RLyt()->GetRootPane()->FindPaneByName(paneName, true); + ipl::math::VEC3 position(0.0f, 0.0f, 0.0f); + PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast(&position), reinterpret_cast(&position)); + f32 y; + f32 offset; + offset = 50.0f; + y = position.y; + position.y = y + offset; + (mpBalloon) + ->setPos(position, false, 0); + (mpBalloon)->fadein(); + } + break; + } + } + } + } +} + +void ipl::scene::AddressEdit::onEventDerived(u32 componentId, u32 event, const ipl::controller::Interface* controller) { + + ::gui::Manager* manager = getGuiManager(); + gui::PaneComponent* component = + static_cast(manager->getComponent(componentId)); + nw4r::lyt::Pane* pane = component->getPane(); + + const char* paneName = pane->GetName(); + if (event != 0) { + return; + } + if (controller == NULL) { + return; + } + if (!controller->downTrg(0x100800)) { + return; + } + ipl::scene::Button* button = static_cast(ipl::System::getScene(5)); + ipl::System::getScene(0x14); + + if (strcmp(paneName, smButtonName__Q33ipl5scene6Button[5]) == 0) { + switch (mState) { + case 0: { + button->reserveAnm(0x1b); + button->reserveAnm(0xc); + button->reserveText(0, 0x23); + button->reserveText(1, 0x29); + button->reserveAnm(0xf); + ipl::layout::Animator* frame = mpCodeLayout->getAnim(0x1e); + frame->initFrame(); + frame->restart(); + mSubState = 5; + ipl::snd::getSystem()->startSE("WIPL_SE_CANCEL"); + (mpBalloon)->fadeoutForce(); + mState = 0x30; + break; + } + case 0xd: { + button->reserveAnm(0x1b); + if (mString.mbNameNotEmpty != 0) { + button->reserveAnm(0x10); + } else { + button->reserveAnm(0xc); + } + button->reserveAnm(0xb); + ipl::layout::Animator* frame = mpNameLayout->getAnim(9); + frame->initFrame(); + frame->restart(); + frame = mpBackgroundLayout->getAnim(1); + frame->initFrame(); + frame->restart(); + get_friendinfo(); + ipl::snd::getSystem()->startSE("WIPL_SE_CANCEL"); + mState = 0xf; + break; + } + case 0x11: { + requestSceneChange(getPreviousScene(), NULL); + button->reserveAnm(0x1b); + if (mString.mbValidMail != 0 && + isDupCode__Q43ipl5scene11AddressEdit6StringCFv( + &mString) == 0 && + isMyCode__Q43ipl5scene11AddressEdit6StringCFv( + &mString) == 0) { + button->reserveAnm(0x10); + } else { + button->reserveAnm(0xc); + } + ipl::layout::Animator* frame; + if (mString.mValue[0] != 0) { + frame = mpNameLayout->getAnim(6); + frame->initFrame(); + frame->restart(); + } else { + frame = mpNameLayout->getAnim(7); + frame->initFrame(); + frame->restart(); + } + button->reserveAnm(0xb); + frame = mpNameLayout->getAnim(9); + frame->initFrame(); + frame->restart(); + frame = mpNameLayout->getAnim(5); + frame->initFrame(); + frame->restart(); + mSubState = 5; + ipl::snd::getSystem()->startSE("WIPL_SE_CANCEL"); + mState = 0x30; + break; + } + case 0x19: { + button->reserveAnm(0x1b); + if (mString.mbNameNotEmpty != 0) { + button->reserveAnm(0x10); + ipl::layout::Animator* frame = mpNameLayout->getAnim(6); + frame->initFrame(); + frame->restart(); + } else { + u16 nameLength = mString.mName[0]; + if (nameLength != 0) { + button->reserveAnm(0xc); + ipl::layout::Animator* frame = mpNameLayout->getAnim(6); + frame->initFrame(); + frame->restart(); + } else { + button->reserveAnm(0xc); + ipl::layout::Animator* frame = mpNameLayout->getAnim(7); + frame->initFrame(); + frame->restart(); + } + } + button->reserveAnm(0xf); + ipl::layout::Animator* frame = mpNameLayout->getAnim(5); + frame->initFrame(); + frame->restart(); + mSubState = 5; + ipl::snd::getSystem()->startSE("WIPL_SE_CANCEL"); + mState = 0x1b; + break; + } + case 0x1d: { + button->reserveAnm(0x1b); + button->reserveAnm(0x10); + button->reserveAnm(0xf); + ipl::layout::Animator* frame = mpNameLayout->getAnim(5); + frame->initFrame(); + frame->restart(); + frame = mpNameLayout->getAnim(8); + frame->initFrame(); + frame->restart(); + mSubState = 5; + ipl::snd::getSystem()->startSE("WIPL_SE_CANCEL"); + mState = 0x20; + (mpBalloon)->fadeoutForce(); + reset_gui(); + break; + } + case 0x22: { + button->reserveAnm(0x1b); + button->reserveAnm(0x10); + button->reserveAnm(0xf); + ipl::layout::Animator* frame = mpCodeLayout->getAnim(0x1e); + frame->initFrame(); + frame->restart(); + mSubState = 5; + ipl::snd::getSystem()->startSE("WIPL_SE_CANCEL"); + mState = 0x23; + (mpBalloon)->fadeoutForce(); + reset_gui(); + break; + } + } + } else if (strcmp(paneName, smButtonName__Q33ipl5scene6Button[7]) == 0) { + switch (mState) { + case 0xd: { + button->reserveAnm(0x1d); + button->reserveAnm(0x10); + button->reserveAnm(0xb); + ipl::layout::Object* layout = mpCodeLayout; + nw4r::lyt::Pane* pane = layout->getNW4RLyt()->GetRootPane()->FindPaneByName( + "T_name_00", true); + set_textbox(pane, mString.mName); + mSubState = 7; + ipl::layout::Animator* frame = mpNameLayout->getAnim(9); + frame->initFrame(); + frame->restart(); + frame = mpBackgroundLayout->getAnim(1); + frame->initFrame(); + frame->restart(); + update_friendinfo(); + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0xf; + break; + } + case 0x11: { + button->reserveAnm(0x1d); + button->reserveAnm(0x10); + if (mString.mbNameNotEmpty != 0) { + button->reserveAnm(0xf); + } else { + button->reserveAnm(0xb); + } + ipl::layout::Animator* frame = mpNameLayout->getAnim(5); + frame->initFrame(); + frame->restart(); + frame = mpNameLayout->getAnim(6); + frame->initFrame(); + frame->restart(); + mSubState = 7; + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x17; + break; + } + case 0x19: { + button->reserveAnm(0x1d); + button->reserveAnm(0x10); + button->reserveAnm(0xf); + ipl::layout::Animator* frame = mpNameLayout->getAnim(5); + frame->initFrame(); + frame->restart(); + frame = mpNameLayout->getAnim(6); + frame->initFrame(); + frame->restart(); + mSubState = 7; + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x1b; + reset_gui(); + break; + } + case 0x1d: { + button->reserveAnm(0x1d); + button->reserveAnm(0x10); + button->reserveAnm(0xf); + ipl::layout::Animator* frame = mpNameLayout->getAnim(9); + frame->initFrame(); + frame->restart(); + mSubState = 7; + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x20; + (mpBalloon)->fadeoutForce(); + reset_gui(); + break; + } + case 0x22: { + button->reserveAnm(0x1d); + button->reserveAnm(0x10); + ipl::layout::Animator* frame = mpCodeLayout->getAnim(0x1e); + frame->initFrame(); + frame->restart(); + mSubState = 7; + ipl::snd::getSystem()->startSE("WIPL_SE_DECIDE"); + mState = 0x23; + (mpBalloon)->fadeoutForce(); + break; + } + } + } +} + +void ipl::scene::AddressEdit::start_ipt_left_event( + const char* paneName, int channel) { + ipl::controller::Interface* controller = ipl::System::getControllerManager()->getYoungController(); + if (controller != NULL) { + if (controller->getChannel() == channel) { + switch (mState) { + case 0x1d: { + char paneNameCopy[12] = "mii_icon_00"; + if (strcmp(paneNameCopy, paneName) == 0) { + (mpBalloon)->fadeoutForce(); + } + break; + } + } + } + } +} + +void ipl::scene::AddressEdit::set_err_msg(wchar_t* outErrMsg, u32 outErrMsgLen, NWC24Err nwc24Err) { + memset(outErrMsg, 0, outErrMsgLen * sizeof(wchar_t)); + wcsncat(outErrMsg, ipl::System::getMessage(MESG_ERROR_CODE), outErrMsgLen - wcslen(outErrMsg)); + + wchar_t nwc24ErrStr[32]; + memset(nwc24ErrStr, 0, sizeof(nwc24ErrStr)); + void* friendListCache = mpFriendCache; + NWC24Err errorCode = static_cast(mpFriendCache->getErrCode()); + swprintf(nwc24ErrStr, sizeof(nwc24ErrStr) / sizeof(wchar_t), L"%06d\n", errorCode); + wcsncat(outErrMsg, nwc24ErrStr, outErrMsgLen - wcslen(outErrMsg)); + + u32 messageId = MESG_ERROR_NWC24_SERVER; + switch (nwc24Err) { + case NWC24_ERR_NETWORK: + messageId = MESG_ERROR_NWC24_NETWORK; + break; + case NWC24_ERR_SERVER: + case NWC24_ERR_FULL: + messageId = MESG_ERROR_NWC24_SERVER; + break; + default: + break; + } + wcsncat(outErrMsg, ipl::System::getMessage(messageId), outErrMsgLen - wcslen(outErrMsg)); +} + + + + + + + +int ipl::scene::AddressEdit::get_button_no(const char* paneName) { + int result = -1; + for (int i = 0; i < 5; i++) { + if (strcmp(smButtonName__Q33ipl5scene6Button[i], paneName) == 0) { + result = i; + break; + } + } + return result; +} + +void ipl::scene::AddressEdit::add_friendinfo() { + NWC24FriendInfo info ALIGN32; + memset(&info, 0, sizeof(info)); + switch (mMode) { + case 1: + info.attr.type = 1; + { + const wchar_t* name = mString.mName; + wchar_t* storedName = reinterpret_cast(info.attr.name); + wcsncpy(storedName, name, 0xa); + } + info.addr.wiiId = ipl::scene::AddressEdit::utf16_wiiid(mString.mValue); + memcpy(&info.attr.fdId, &mCreateID, sizeof(mCreateID)); + break; + case 2: + info.attr.type = 2; + { + const wchar_t* name = mString.mName; + wchar_t* storedName = reinterpret_cast(info.attr.name); + wcsncpy(storedName, name, 0xa); + } + { + const wchar_t* value = mString.mValue; + u8* address = reinterpret_cast(&info.addr); + ipl::utility::CharacterCode::UTF16ToANSI(address, value, sizeof(info.addr)); + } + memcpy(&info.attr.fdId, &mCreateID, sizeof(mCreateID)); + break; + default: + break; + } + + ipl::scene::Address* address = + static_cast(ipl::System::getScene(0x14)); + u32 index = address->getChosenFriendIndex(); + if (index >= 100) { + index = 0; + for (u32 remaining = 100; remaining != 0; --remaining) { + if (!mpFriendCache->isThere(index)) { + break; + } + ++index; + } + } + mpFriendCache->add(index, info); + if (mMode == 2) { + mpFriendCache->sendRegisterMail(index); + } +} + +void ipl::scene::AddressEdit::get_friendinfo() { + const NWC24FriendInfo& friendInfo = mpFriendCache->getInfo(mSelectedFriend); + memcpy(&sFriendInfo__Q23ipl5scene, &friendInfo, sizeof(sFriendInfo__Q23ipl5scene)); + mString.setName(reinterpret_cast(sFriendInfo__Q23ipl5scene.attr.name)); + const wchar_t* name = mString.mName; + nw4r::lyt::Pane* namePane = + mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true); + set_textbox(namePane, name); + + wchar_t wiiNo[0x100]; + wchar_t email[0x102]; + if (sFriendInfo__Q23ipl5scene.attr.type == 1) { + memset(wiiNo, 0, sizeof(wiiNo)); + ipl::scene::AddressEdit::wiiid_utf16(sFriendInfo__Q23ipl5scene.addr.wiiId, wiiNo); + mString.setWiiNo(wiiNo); + } else { + memset(email, 0, sizeof(email)); + ipl::utility::CharacterCode::ANSIToUTF16(email, reinterpret_cast(&sFriendInfo__Q23ipl5scene.addr), 0x102); + mString.setEMail(email); + } + const wchar_t* displayText = mString.mDisplayText; + nw4r::lyt::Pane* friendCodePane = + mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true); + set_textbox(friendCodePane, displayText); + memcpy(&mCreateID, &sFriendInfo__Q23ipl5scene.attr.fdId, sizeof(mCreateID)); +} + +void ipl::scene::AddressEdit::update_friendinfo() { + memset(sFriendInfo__Q23ipl5scene.attr.name, 0, 0x18); + wcsncpy(reinterpret_cast(sFriendInfo__Q23ipl5scene.attr.name), mString.mName, 0xa); + memcpy(&sFriendInfo__Q23ipl5scene.attr.fdId, &mCreateID, sizeof(mCreateID)); + mpFriendCache->update( + mSelectedFriend, + reinterpret_cast(sFriendInfo__Q23ipl5scene.attr.name), + sFriendInfo__Q23ipl5scene.attr.fdId); + static_cast(ipl::System::getScene(0x14))->reset_friend(); +}