Mercurial > otakunoraifu
diff scn2k/scn2k_text.cc @ 55:f1a27ee7e03c
* started the same changes on scn2k_text.cc
* handle opcodes childObj*. In fact, it was handled (in a strange way, but it worked) before the previous changeset
author | thib |
---|---|
date | Wed, 22 Apr 2009 15:01:42 +0000 |
parents | ddbcbd000206 |
children | c7bcc0ec2267 |
line wrap: on
line diff
--- a/scn2k/scn2k_text.cc +++ b/scn2k/scn2k_text.cc @@ -163,7 +163,39 @@ struct TextWindow { } }; -class TextImpl { +class TextImpl : public CommandHandler { + public: + TextImpl(Event::Container& _event, PicContainer& _parent, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item); + ~TextImpl(); + void InitWindow(void); + void SetWindowColor(int r, int g, int b, int a, bool is_transparent); + void SetTextSpeed(int new_speed); + void SetTextWait(int new_wait); + void CreateSelect(Cmd& cmd); + void Exec(Cmd& cmd); + bool Wait(unsigned int current_time, Cmd& cmd); + void hide(void); + void show(void) { show(text_window_number); } + void show(int num); + void DrawBacklog(BacklogItem& item, Cmd& cmd); + void Save(std::string& str, bool select_save); + void Load(const char* str); + void SetSkipMode(SkipMode _mode); + void CreateSelBG(void); + + void AddText(const char* str); + + static void PressFuncSkip(void* pointer, WidButton* from); + static void PressFuncLoad(void* pointer, WidButton* from); + static void PressFuncSave(void* pointer, WidButton* from); + static void PressFuncBacklog(void* pointer, WidButton* from); + static void PressFuncBacklogFwd(void* pointer, WidButton* from); + + private: + static void PressFuncButton(void* pointer, WidButton* from); + static bool PressFunc(int x, int y, void* pointer); + void SetCursor(int num); + public: TextWindow* text; typedef enum {NORMAL=0, WAIT_TEXT=1, WAIT=2, @@ -174,9 +206,13 @@ class TextImpl { CLEARSCR_MASK = 1024, STATSAVE_MASK = 2048, CLEARSCR_WAIT_MASK=(1<<12), SKIPEND_MASK = (1<<13), BACKLOG_MASK=(1<<14), BACKLOG_MASK_FWD=(1<<15), BACKLOG_MASK_KOE=(1<<16), BACKLOG_WAIT_MASK=(1<<17), - ALLMASK = (CLEARSCR_MASK | WAIT_EXTRN_MASK | SAVEMASK | LOADMASK | SKIPMASK | BACKLOG_MASK | BACKLOG_MASK_FWD | BACKLOG_MASK_KOE | BACKLOG_WAIT_MASK | STATSAVE_MASK | CLEARSCR_WAIT_MASK | SKIPEND_MASK) + ALLMASK = (CLEARSCR_MASK | WAIT_EXTRN_MASK | SAVEMASK | + LOADMASK | SKIPMASK | BACKLOG_MASK | BACKLOG_MASK_FWD | + BACKLOG_MASK_KOE | BACKLOG_WAIT_MASK | STATSAVE_MASK | + CLEARSCR_WAIT_MASK | SKIPEND_MASK) } Status; Status status, status_saved, status_mask; + private: std::string ruby_text; bool ruby_text_flag; @@ -202,50 +238,26 @@ class TextImpl { BacklogItem cur_backlog_item; BacklogItem drawn_backlog_item; - public: - PicContainer& parent; - Event::Container& event; - AyuSysConfig *config; - private: TextWindow* widgets[32]; WidTimeCursor* kcursor; Surface* sel_bg1; Surface* sel_bg2; Rect sel_bg_rect; - void SetCursor(int num); VarInfo wait_savedvar[2]; - public: - void AddText(const char* str); + AyuSysConfig *config; - static void PressFuncSkip(void* pointer, WidButton* from); - static void PressFuncLoad(void* pointer, WidButton* from); - static void PressFuncSave(void* pointer, WidButton* from); - static void PressFuncBacklog(void* pointer, WidButton* from); - static void PressFuncBacklogFwd(void* pointer, WidButton* from); - private: - static void PressFuncButton(void* pointer, WidButton* from); - static bool PressFunc(int x, int y, void* pointer); + Event::Container& event; + PicContainer& parent; - public: - TextImpl(Event::Container& _event, PicContainer& _parent, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item); - ~TextImpl(); - void InitWindow(void); - void SetWindowColor(int r, int g, int b, int a, bool is_transparent); - void SetTextSpeed(int new_speed); - void SetTextWait(int new_wait); - void CreateSelect(Cmd& cmd); - void Exec(Cmd& cmd); - bool Wait(unsigned int current_time, Cmd& cmd); - void hide(void); - void show(void) { show(text_window_number); } - void show(int num); - void DrawBacklog(BacklogItem& item, Cmd& cmd); - void Save(std::string& str, bool select_save); - void Load(const char* str); - void SetSkipMode(SkipMode _mode); - void CreateSelBG(void); + //Opcode handling + void impl_txtClear(Cmd& cmd); + void impl_logKoe(Cmd& cmd); + void impl_pause(Cmd& cmd); + void impl_br(Cmd& cmd); + void impl_FaceOpen(Cmd& cmd); + void impl_FaceClear(Cmd& cmd); }; /**************************************************************:: @@ -264,6 +276,20 @@ TextImpl::TextImpl(Event::Container& _ev } text_stream.kanji_type = TextStream::sjis; event.RegisterGlobalPressFunc(&PressFunc, (void*)this); + + RegisterCommand(1, 33, 73, "grpOpenBg", (CmdImpl) &TextImpl::impl_txtClear); + RegisterCommand(1, 33, 75, "grpMulti", (CmdImpl) &TextImpl::impl_txtClear); + RegisterCommand(1, 33, 76, "grpOpen", (CmdImpl) &TextImpl::impl_txtClear); + + RegisterCommand(1, 23, 0, "koePlay", (CmdImpl) &TextImpl::impl_logKoe); + RegisterCommand(1, 23, 8, "koeDoPlay", (CmdImpl) &TextImpl::impl_logKoe); + + RegisterCommand(0, 3, 151, "msgHide", (CmdImpl) &TextImpl::impl_txtClear); + RegisterCommand(0, 3, 17, "pause", (CmdImpl) &TextImpl::impl_pause); + RegisterCommand(0, 3, 3, "par", (CmdImpl) &TextImpl::impl_br); //FIXME + RegisterCommand(0, 3, 201, "br", (CmdImpl) &TextImpl::impl_br); + RegisterCommand(0, 3, 1000, "FaceOpen", (CmdImpl) &TextImpl::impl_FaceOpen); + RegisterCommand(0, 3, 1001, "FaceClear", (CmdImpl) &TextImpl::impl_FaceClear); } TextImpl::~TextImpl() { @@ -864,6 +890,66 @@ void TextImpl::AddText(const char* str_o text_stream.Add(str_top); } +void TextImpl::impl_txtClear(Cmd& cmd) { + if (text != NULL) { + text->ResetFace(); + if (cmd.cmd2 == 3 && cmd.cmd3 == 151) + text->wid->Clear(); + } + cur_backlog_item.face = ""; + if (cmd.cmd2 == 3 && cmd.cmd3 == 151) + text_stream.Clear(); + hide(); +} + +void TextImpl::impl_logKoe(Cmd& cmd) { + // PlayKoe ; 声出力コマンドをチェックする */ + cur_backlog_item.koe = cmd.args[0].value; +} + +void TextImpl::impl_pause(Cmd& cmd) { + if (text != NULL) { + eprintf("start\n"); + text->StartText(text_stream); + if (skip_mode & SKIP_TEXT) text->wid->Flush(); + else if (kcursor) kcursor->show(); + status = WAIT_TEXT; + text_parsing = false; + } + backlog_item = cur_backlog_item; + if (cur_backlog_item.scn == 0 && cur_backlog_item.pos == -1) backlog_item.text = text_stream; + cur_backlog_item.Clear(); + + cmd.clear(); + cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため) +} + +void TextImpl::impl_br(Cmd& cmd) { + text_stream.AddReturn(); + cur_backlog_item.DeleteTextPos(); + cmd.clear(); +} + +void TextImpl::impl_FaceOpen(Cmd& cmd) { + if (text == NULL) + show(); + string s = cmd.Str(cmd.args[0]); + s += ".g00"; + if (text != NULL) + text->ShowFace(s.c_str()); + cur_backlog_item.face = s; + cmd.cmd_type = CMD_SAVECMD_ONCE; +} + +void TextImpl::impl_FaceClear(Cmd& cmd) { + if (text == NULL) + show(); + if (text) + text->ResetFace(); + cur_backlog_item.face = ""; + cmd.cmd_type = CMD_SAVECMD_ONCE; +} + void TextImpl::Exec(Cmd& cmd) { if (cmd.cmd_type == CMD_TEXT) { if (text == NULL) { @@ -888,66 +974,13 @@ void TextImpl::Exec(Cmd& cmd) { text_parsing = true; /* テキスト待ち直後のテキスト位置=セーブ位置 */ return; } + if (cmd.cmd_type != CMD_OTHER) return; - /* テキストウィンドウを消去するコマンド類をチェックする */ - if (cmd.cmd1 == 1 && cmd.cmd2 == 0x21) { - if (cmd.cmd3 == 0x49 || cmd.cmd3 == 0x4b || cmd.cmd3 == 0x4c) { - if (text) text->ResetFace(); - cur_backlog_item.face = ""; - hide(); - } - } - if (cmd.cmd1 == 1 && cmd.cmd2 == 0x17 && cmd.cmd3 == 0 && cmd.cmd4 == 1) { - // PlayKoe ; 声出力コマンドをチェックする */ - cur_backlog_item.koe = cmd.args[0].value; - } - if (cmd.cmd1 == 0 && cmd.cmd2 == 3 && cmd.cmd3 == 0x97) { // いいのかなー - - if (text) { - text->ResetFace(); - text->wid->Clear(); - } - cur_backlog_item.face = ""; - text_stream.Clear(); - hide(); - } + + CommandHandler::Exec(cmd); + if (cmd.cmd1 == 0 && cmd.cmd2 == 3) { - if (cmd.cmd3 == 0x11) { // テキスト表示、クリック待ち - if (text) { - eprintf("start\n"); - text->StartText(text_stream); - if (skip_mode & SKIP_TEXT) text->wid->Flush(); - else if (kcursor) kcursor->show(); - status = WAIT_TEXT; - text_parsing = false; - } - backlog_item = cur_backlog_item; - if (cur_backlog_item.scn == 0 && cur_backlog_item.pos == -1) backlog_item.text = text_stream; - cur_backlog_item.Clear(); - - cmd.clear(); - cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため) - // これだと1フレーム1テキストしか表示されなくなるので注意 - } else if (cmd.cmd3 == 3 || cmd.cmd3 == 0xc9) { // リターン挿入 - text_stream.AddReturn(); - cur_backlog_item.DeleteTextPos(); - cmd.clear(); - } else if (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3e9) { // 顔グラフィック変更 - if (text == NULL) { - show(); - } - if (cmd.cmd3 == 0x3e8) { - string s = cmd.Str(cmd.args[0]); - s += ".g00"; - if (text) text->ShowFace(s.c_str()); - cur_backlog_item.face = s; - cmd.cmd_type = CMD_SAVECMD_ONCE; - } else if (cmd.cmd3 == 0x3e9) { // 顔グラフィック消去 - if (text) text->ResetFace(); - cur_backlog_item.face = ""; - cmd.cmd_type = CMD_SAVECMD_ONCE; - } - } else if (cmd.cmd3 == 0x78) { // ルビ関連 + if (cmd.cmd3 == 0x78) { // ルビ関連 if (text == NULL) { show(); }