Mercurial > otakunoraifu
view scn2k/scn2k_textimpl.cc @ 57:6d9146f56ccf
* Move some opcodes
* Merge last changes from xclannad
author | Thibaut GIRKA <thib@sitedethib.com> |
---|---|
date | Sat, 14 Nov 2009 23:31:51 +0100 |
parents | c7bcc0ec2267 |
children | 0aaa5bb3dde5 |
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 == 112 || cmd.cmd3 == 121) wait_time = base_time + cmd.args[0].value; //FIXME: second argument, counter. See ReadFrame for this else wait_time = old_time + cmd.args[0].value; if (cmd.cmd3 == 101 || cmd.cmd3 == 112) status = WAIT_CLICK; else status = WAIT; cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため) } void Text::impl_GetClick(Cmd& cmd) { eprintf("wait and get mouse pos at click\n"); wait_time = old_time + 1000 * 1000; status = WAIT_CLICK_MOUSEPOS; wait_savedvar[0] = cmd.args[0]; wait_savedvar[1] = cmd.args[1]; cmd.clear(); } void Text::impl_ReadFrame(Cmd& cmd) { eprintf("get timer value[%d]\n",cmd.args[0].value); if (timer_var.find(cmd.args[0].value) == timer_var.end()) cmd.SetSysvar(0); else { TimerAtom& atom = timer_var[cmd.args[0].value]; if (atom.total_time <= 0) atom.total_time = 1; int cur_tm = old_time - atom.start_time; if (cur_tm < 0) cur_tm = atom.total_time; // エラーなら最終時間に合わせる if (cur_tm > atom.total_time) cur_tm = atom.total_time; // use 'long long'(64bit) or 'double'(80bit) type, since total_time, to and from is 32 bit. int v = atom.from + (long long)(atom.to-atom.from)*cur_tm/int(atom.total_time); cmd.SetSysvar(v); } }