Mercurial > otakunoraifu
view scn2k/scn2k_textimpl.cc @ 56:c7bcc0ec2267
* replaced Grp and Text classes by the TextImpl and GrpImpl ones
* splitted scn2k.h into smaller header files
* moved some definitions from scn2k_*.cc to the header files
* moved opcode implementation to scn2k_*impl.cc
author | thib |
---|---|
date | Thu, 30 Apr 2009 19:05:09 +0000 |
parents | |
children | 6d9146f56ccf |
line wrap: on
line source
/* * Copyright (c) 2009 Thibaut GIRKA * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "scn2k_text.h" void Text::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 Text::impl_logKoe(Cmd& cmd) { // PlayKoe ; 声出力コマンドをチェックする */ cur_backlog_item.koe = cmd.args[0].value; } void Text::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 Text::impl_br(Cmd& cmd) { text_stream.AddReturn(); cur_backlog_item.DeleteTextPos(); cmd.clear(); } void Text::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 Text::impl_FaceClear(Cmd& cmd) { if (text == NULL) show(); if (text) text->ResetFace(); cur_backlog_item.face = ""; cmd.cmd_type = CMD_SAVECMD_ONCE; } void Text::impl_doRuby(Cmd& cmd) { if (text == NULL) { show(); } if (cmd.cmd4 == 1) { ruby_text_flag = true; eprintf("SetRubyText."); cmd.clear(); } else if (cmd.cmd4 == 0) { if (ruby_text.length() == 0) { // ルビを振るテキストがない eprintf("Cannot find ruby text.\n"); return; } if (cmd.args.size() != 1) return; char debug1[1024], debug2[1024]; kconv( (unsigned char*)ruby_text.c_str(), (unsigned char*)debug1); kconv( (unsigned char*)cmd.Str(cmd.args[0]), (unsigned char*)debug2); eprintf("SetRuby. %s, %s",debug1, debug2); text_stream.AddRuby(ruby_text.c_str(), cmd.Str(cmd.args[0])); cur_backlog_item.DeleteTextPos(); cmd.clear(); } } void Text::impl_TextWindow(Cmd& cmd) { if (cmd.cmd4 == 0) { eprintf("set text window <- %d\n",cmd.args[0].value); if (text != NULL) show(cmd.args[0].value); else text_window_number = cmd.args[0].value; } else if (cmd.cmd4 == 1) { // default value eprintf("set text window <- default\n"); if (text != NULL) show(0); else text_window_number = 0; } cmd.clear(); } void Text::impl_FastText(Cmd& cmd) { //I think it's broken. For now, it's disabled. if (cmd.cmd3 == 103) { // テキストウィンドウ表示? show(); // 表示の際はテキストをクリアしない? // if (text) text->wid->Clear(); // text_stream.Clear(); cmd.clear(); } else if (cmd.cmd3 == 104) { // テキスト表示? // 全テキスト表示 if (text != NULL) { text->StartText(text_stream); text->wid->Flush(); } cmd.clear(); } } void Text::impl_msgClear(Cmd& cmd) { show(); if (text != NULL) text->wid->Clear(); text_stream.Clear(); cmd.clear(); } void Text::impl_createSelect(Cmd& cmd) { if (cmd.cmd4 == 0) { // 選択肢 CreateSelect(cmd); //FIXME: Check if it's really clean if (text_parsing) { show(); text->StartText(text_stream); if (skip_mode & SKIP_TEXT) text->wid->Flush(); else if (kcursor) kcursor->hide(); text_parsing = false; text_stream.Clear(); } cmd.cmd_type = CMD_ROLLBACKPOINT; /* 選択肢はセーブ位置 / シナリオ巻き戻し位置 */ // cmd.clear(); } else PrintCmd(cmd); //FIXME } void Text::impl_ShowBackground(Cmd& cmd) { status_mask = Status(CLEARSCR_MASK | status_mask); cmd.clear(); } void Text::impl_SetSkipMode(Cmd& cmd) { status_mask = Status(SKIPMASK | status_mask); cmd.clear(); } void Text::impl_Wait(Cmd& cmd) { eprintf("wait %dmsec\n",cmd.args[0].value); if (cmd.cmd3 == 100 && text != NULL) { /* 0x64 だと文字描画中の待ちに使うことがある */ text->StartText(text_stream); text->wid->Flush(); } if (cmd.cmd3 == 111 || cmd.cmd3 == 121) wait_time = base_time + cmd.args[0].value; //FIXME: second argument, counter else wait_time = old_time + cmd.args[0].value; status = WAIT; cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため) }