comparison 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
comparison
equal deleted inserted replaced
55:f1a27ee7e03c 56:c7bcc0ec2267
1 /*
2 * Copyright (c) 2009 Thibaut GIRKA
3 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include "scn2k_text.h"
30
31 void Text::impl_txtClear(Cmd& cmd) {
32 if (text != NULL) {
33 text->ResetFace();
34 if (cmd.cmd2 == 3 && cmd.cmd3 == 151)
35 text->wid->Clear();
36 }
37 cur_backlog_item.face = "";
38 if (cmd.cmd2 == 3 && cmd.cmd3 == 151)
39 text_stream.Clear();
40 hide();
41 }
42
43 void Text::impl_logKoe(Cmd& cmd) {
44 // PlayKoe ; 声出力コマンドをチェックする */
45 cur_backlog_item.koe = cmd.args[0].value;
46 }
47
48 void Text::impl_pause(Cmd& cmd) {
49 if (text != NULL) {
50 eprintf("start\n");
51 text->StartText(text_stream);
52 if (skip_mode & SKIP_TEXT) text->wid->Flush();
53 else if (kcursor) kcursor->show();
54 status = WAIT_TEXT;
55 text_parsing = false;
56 }
57 backlog_item = cur_backlog_item;
58 if (cur_backlog_item.scn == 0 && cur_backlog_item.pos == -1) backlog_item.text = text_stream;
59 cur_backlog_item.Clear();
60
61 cmd.clear();
62 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため)
63 }
64
65 void Text::impl_br(Cmd& cmd) {
66 text_stream.AddReturn();
67 cur_backlog_item.DeleteTextPos();
68 cmd.clear();
69 }
70
71 void Text::impl_FaceOpen(Cmd& cmd) {
72 if (text == NULL)
73 show();
74 string s = cmd.Str(cmd.args[0]);
75 s += ".g00";
76 if (text != NULL)
77 text->ShowFace(s.c_str());
78 cur_backlog_item.face = s;
79 cmd.cmd_type = CMD_SAVECMD_ONCE;
80 }
81
82 void Text::impl_FaceClear(Cmd& cmd) {
83 if (text == NULL)
84 show();
85 if (text)
86 text->ResetFace();
87 cur_backlog_item.face = "";
88 cmd.cmd_type = CMD_SAVECMD_ONCE;
89 }
90
91 void Text::impl_doRuby(Cmd& cmd) {
92 if (text == NULL) {
93 show();
94 }
95 if (cmd.cmd4 == 1) {
96 ruby_text_flag = true;
97 eprintf("SetRubyText.");
98 cmd.clear();
99 } else if (cmd.cmd4 == 0) {
100 if (ruby_text.length() == 0) { // ルビを振るテキストがない
101 eprintf("Cannot find ruby text.\n");
102 return;
103 }
104 if (cmd.args.size() != 1) return;
105 char debug1[1024], debug2[1024];
106 kconv( (unsigned char*)ruby_text.c_str(), (unsigned char*)debug1);
107 kconv( (unsigned char*)cmd.Str(cmd.args[0]), (unsigned char*)debug2);
108 eprintf("SetRuby. %s, %s",debug1, debug2);
109 text_stream.AddRuby(ruby_text.c_str(), cmd.Str(cmd.args[0]));
110 cur_backlog_item.DeleteTextPos();
111 cmd.clear();
112 }
113 }
114
115 void Text::impl_TextWindow(Cmd& cmd) {
116 if (cmd.cmd4 == 0) {
117 eprintf("set text window <- %d\n",cmd.args[0].value);
118 if (text != NULL) show(cmd.args[0].value);
119 else text_window_number = cmd.args[0].value;
120 } else if (cmd.cmd4 == 1) { // default value
121 eprintf("set text window <- default\n");
122 if (text != NULL) show(0);
123 else text_window_number = 0;
124 }
125 cmd.clear();
126 }
127
128 void Text::impl_FastText(Cmd& cmd) {
129 //I think it's broken. For now, it's disabled.
130 if (cmd.cmd3 == 103) {
131 // テキストウィンドウ表示?
132 show();
133 // 表示の際はテキストをクリアしない?
134 // if (text) text->wid->Clear();
135 // text_stream.Clear();
136 cmd.clear();
137 }
138 else if (cmd.cmd3 == 104) { // テキスト表示?
139 // 全テキスト表示
140 if (text != NULL) {
141 text->StartText(text_stream);
142 text->wid->Flush();
143 }
144 cmd.clear();
145 }
146 }
147
148 void Text::impl_msgClear(Cmd& cmd) {
149 show();
150 if (text != NULL) text->wid->Clear();
151 text_stream.Clear();
152 cmd.clear();
153 }
154
155 void Text::impl_createSelect(Cmd& cmd) {
156 if (cmd.cmd4 == 0) {
157 // 選択肢
158 CreateSelect(cmd);
159 //FIXME: Check if it's really clean
160 if (text_parsing) {
161 show();
162 text->StartText(text_stream);
163 if (skip_mode & SKIP_TEXT) text->wid->Flush();
164 else if (kcursor) kcursor->hide();
165 text_parsing = false;
166 text_stream.Clear();
167 }
168 cmd.cmd_type = CMD_ROLLBACKPOINT; /* 選択肢はセーブ位置 / シナリオ巻き戻し位置 */
169 // cmd.clear();
170 }
171 else
172 PrintCmd(cmd); //FIXME
173 }
174
175 void Text::impl_ShowBackground(Cmd& cmd) {
176 status_mask = Status(CLEARSCR_MASK | status_mask);
177 cmd.clear();
178 }
179
180 void Text::impl_SetSkipMode(Cmd& cmd) {
181 status_mask = Status(SKIPMASK | status_mask);
182 cmd.clear();
183 }
184
185 void Text::impl_Wait(Cmd& cmd) {
186 eprintf("wait %dmsec\n",cmd.args[0].value);
187 if (cmd.cmd3 == 100 && text != NULL) {
188 /* 0x64 だと文字描画中の待ちに使うことがある */
189 text->StartText(text_stream);
190 text->wid->Flush();
191 }
192 if (cmd.cmd3 == 111 || cmd.cmd3 == 121)
193 wait_time = base_time + cmd.args[0].value; //FIXME: second argument, counter
194 else
195 wait_time = old_time + cmd.args[0].value;
196 status = WAIT;
197 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため)
198 }