annotate scn2k/scn2k_text.cc @ 39:de29c4d2d043

(none)
author thib
date Tue, 17 Mar 2009 22:00:05 +0000
parents 658272d883ed
children 651237260724
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 TODO:
223b71206888 Initial import
thib
parents:
diff changeset
3 日付のラベルが画面切り替え時に欠けるのを修正
223b71206888 Initial import
thib
parents:
diff changeset
4 画像効果 : 人間の入れ換わりなど
223b71206888 Initial import
thib
parents:
diff changeset
5 kcursor の操作を WidText クラスに任せる
223b71206888 Initial import
thib
parents:
diff changeset
6 WidText クラスには新たに以下の操作を加える
223b71206888 Initial import
thib
parents:
diff changeset
7 ・ウェイト終了後、クリアなしに新たなテキストを追加、新たにstart-waitする
223b71206888 Initial import
thib
parents:
diff changeset
8 ・文字の描画 (Start) と Wait(カーソル表示待ち)の分離。
223b71206888 Initial import
thib
parents:
diff changeset
9 Start すると文字を描画開始する。クリックで全描画。
223b71206888 Initial import
thib
parents:
diff changeset
10 Flush するとバッファ内の文字をすべて描画する
223b71206888 Initial import
thib
parents:
diff changeset
11 Wait すると全描画後、クリックされるまでカーソルを表示するまで待つ
223b71206888 Initial import
thib
parents:
diff changeset
12 TextImpl 側の状態としては Wait のみを持つ (PREPAREに戻るのを待つ)
223b71206888 Initial import
thib
parents:
diff changeset
13 ただし、Skip の権利はどっちがもつ?(現状は?)
223b71206888 Initial import
thib
parents:
diff changeset
14
223b71206888 Initial import
thib
parents:
diff changeset
15 GrpObj: NextObj と GrpObj を分離。CreateObj は現状通り、Visible=1 時に行う。
223b71206888 Initial import
thib
parents:
diff changeset
16 それぞれ num=0 (screen) の枝leaf として実装。delete時は親のdeleteのみを
223b71206888 Initial import
thib
parents:
diff changeset
17 行い、子はGrpObjの実体だけを削除する
223b71206888 Initial import
thib
parents:
diff changeset
18 Visible 後のhide は実際に hide とする
223b71206888 Initial import
thib
parents:
diff changeset
19 ExecReservedCmd() はなくせるはず。Delete() もなくなる。
223b71206888 Initial import
thib
parents:
diff changeset
20 カノギ:ReBlit() がうまくいかないせいで名前ウィンドウが消えた時の背景がなくなる
223b71206888 Initial import
thib
parents:
diff changeset
21
223b71206888 Initial import
thib
parents:
diff changeset
22 くら:回想表示
223b71206888 Initial import
thib
parents:
diff changeset
23 SEL画像効果
223b71206888 Initial import
thib
parents:
diff changeset
24 DONE:
223b71206888 Initial import
thib
parents:
diff changeset
25 ともよのテキストウィンドウ実装、ボタン実装
223b71206888 Initial import
thib
parents:
diff changeset
26 shake の画像効果
223b71206888 Initial import
thib
parents:
diff changeset
27 オブジェクト内のテキスト色の実装
223b71206888 Initial import
thib
parents:
diff changeset
28 画像効果の改善
223b71206888 Initial import
thib
parents:
diff changeset
29 */
223b71206888 Initial import
thib
parents:
diff changeset
30
223b71206888 Initial import
thib
parents:
diff changeset
31 /*
223b71206888 Initial import
thib
parents:
diff changeset
32 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
223b71206888 Initial import
thib
parents:
diff changeset
33 * All rights reserved.
223b71206888 Initial import
thib
parents:
diff changeset
34 *
223b71206888 Initial import
thib
parents:
diff changeset
35 * Redistribution and use in source and binary forms, with or without
223b71206888 Initial import
thib
parents:
diff changeset
36 * modification, are permitted provided that the following conditions
223b71206888 Initial import
thib
parents:
diff changeset
37 * are met:
223b71206888 Initial import
thib
parents:
diff changeset
38 * 1. Redistributions of source code must retain the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
39 * notice, this list of conditions and the following disclaimer.
223b71206888 Initial import
thib
parents:
diff changeset
40 * 2. Redistributions in binary form must reproduce the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
41 * notice, this list of conditions and the following disclaimer in the
223b71206888 Initial import
thib
parents:
diff changeset
42 * documentation and/or other materials provided with the distribution.
223b71206888 Initial import
thib
parents:
diff changeset
43 * 3. The name of the author may not be used to endorse or promote products
223b71206888 Initial import
thib
parents:
diff changeset
44 * derived from this software without specific prior written permission.
223b71206888 Initial import
thib
parents:
diff changeset
45 *
223b71206888 Initial import
thib
parents:
diff changeset
46 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
223b71206888 Initial import
thib
parents:
diff changeset
47 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223b71206888 Initial import
thib
parents:
diff changeset
48 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223b71206888 Initial import
thib
parents:
diff changeset
49 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223b71206888 Initial import
thib
parents:
diff changeset
50 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b71206888 Initial import
thib
parents:
diff changeset
51 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223b71206888 Initial import
thib
parents:
diff changeset
52 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b71206888 Initial import
thib
parents:
diff changeset
53 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
223b71206888 Initial import
thib
parents:
diff changeset
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
223b71206888 Initial import
thib
parents:
diff changeset
55 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223b71206888 Initial import
thib
parents:
diff changeset
56 */
223b71206888 Initial import
thib
parents:
diff changeset
57
223b71206888 Initial import
thib
parents:
diff changeset
58 #include"window/event.h"
223b71206888 Initial import
thib
parents:
diff changeset
59 #include"window/picture.h"
223b71206888 Initial import
thib
parents:
diff changeset
60 #include"window/widget.h"
223b71206888 Initial import
thib
parents:
diff changeset
61 #include"system/file.h"
223b71206888 Initial import
thib
parents:
diff changeset
62 #include"system/system_config.h"
223b71206888 Initial import
thib
parents:
diff changeset
63 #include"scn2k.h"
223b71206888 Initial import
thib
parents:
diff changeset
64
223b71206888 Initial import
thib
parents:
diff changeset
65 #include<string>
223b71206888 Initial import
thib
parents:
diff changeset
66 using namespace std;
223b71206888 Initial import
thib
parents:
diff changeset
67
223b71206888 Initial import
thib
parents:
diff changeset
68 // kanji conv : デバッグ表示用
223b71206888 Initial import
thib
parents:
diff changeset
69 void kconv(const unsigned char* src, unsigned char* dest);
223b71206888 Initial import
thib
parents:
diff changeset
70 void kconv_rev(const unsigned char* src, unsigned char* dest);
223b71206888 Initial import
thib
parents:
diff changeset
71 string kconv(const string& s);
223b71206888 Initial import
thib
parents:
diff changeset
72 string kconv_rev(const string& s);
223b71206888 Initial import
thib
parents:
diff changeset
73 // render.cc
223b71206888 Initial import
thib
parents:
diff changeset
74 void DSurfaceFillA(Surface* src, const Rect& rect, int r, int g, int b, int a); // テキストウィンドウ背景の設定
223b71206888 Initial import
thib
parents:
diff changeset
75 void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); // コピー
223b71206888 Initial import
thib
parents:
diff changeset
76
223b71206888 Initial import
thib
parents:
diff changeset
77 /**************************************************************::
223b71206888 Initial import
thib
parents:
diff changeset
78 **
223b71206888 Initial import
thib
parents:
diff changeset
79 ** TextImpl(interface)
223b71206888 Initial import
thib
parents:
diff changeset
80 */
223b71206888 Initial import
thib
parents:
diff changeset
81 struct TimerAtom {
223b71206888 Initial import
thib
parents:
diff changeset
82 int from;
223b71206888 Initial import
thib
parents:
diff changeset
83 int to;
223b71206888 Initial import
thib
parents:
diff changeset
84 unsigned int start_time;
223b71206888 Initial import
thib
parents:
diff changeset
85 unsigned int total_time;
223b71206888 Initial import
thib
parents:
diff changeset
86 };
223b71206888 Initial import
thib
parents:
diff changeset
87
223b71206888 Initial import
thib
parents:
diff changeset
88 struct TextWindow {
223b71206888 Initial import
thib
parents:
diff changeset
89 /* @@@ : SetWindowColor での surface 再設定に注意 */
223b71206888 Initial import
thib
parents:
diff changeset
90 WidText* wid;
223b71206888 Initial import
thib
parents:
diff changeset
91 bool name_visible;
223b71206888 Initial import
thib
parents:
diff changeset
92 WidLabel* name;
223b71206888 Initial import
thib
parents:
diff changeset
93 PicContainer* name_container;
223b71206888 Initial import
thib
parents:
diff changeset
94 PicBase* face;
223b71206888 Initial import
thib
parents:
diff changeset
95 PicBase* face_pics[8];
223b71206888 Initial import
thib
parents:
diff changeset
96 TextWindow(PicContainer& parent, Event::Container& event, int window_no, const AyuSysConfig& config, void* callback);
223b71206888 Initial import
thib
parents:
diff changeset
97 ~TextWindow() {
223b71206888 Initial import
thib
parents:
diff changeset
98 if (name_container) delete name_container;
223b71206888 Initial import
thib
parents:
diff changeset
99 int i; for (i=0; i<8; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
100 if (face_pics[i]) delete face_pics[i];
223b71206888 Initial import
thib
parents:
diff changeset
101 }
223b71206888 Initial import
thib
parents:
diff changeset
102 if (wid) delete wid;
223b71206888 Initial import
thib
parents:
diff changeset
103 }
223b71206888 Initial import
thib
parents:
diff changeset
104 Rect WakuSize(PicContainer& pic, int waku_no, const AyuSysConfig& config);
223b71206888 Initial import
thib
parents:
diff changeset
105 void MakeWaku(PicContainer& pic, Event::Container& event, int waku_no,int window_no, bool* use_btn, const AyuSysConfig& config, void* callback);
223b71206888 Initial import
thib
parents:
diff changeset
106 void show(void) {
223b71206888 Initial import
thib
parents:
diff changeset
107 wid->show();
223b71206888 Initial import
thib
parents:
diff changeset
108 if (name_container && name_visible) name_container->show();
223b71206888 Initial import
thib
parents:
diff changeset
109 if (face) face->show();
223b71206888 Initial import
thib
parents:
diff changeset
110 }
223b71206888 Initial import
thib
parents:
diff changeset
111 void hide(void) {
223b71206888 Initial import
thib
parents:
diff changeset
112 wid->hide();
223b71206888 Initial import
thib
parents:
diff changeset
113 if (name_container) name_container->hide();
223b71206888 Initial import
thib
parents:
diff changeset
114 if (face) face->hide();
223b71206888 Initial import
thib
parents:
diff changeset
115 }
223b71206888 Initial import
thib
parents:
diff changeset
116 void ShowFace(const char* path) {
223b71206888 Initial import
thib
parents:
diff changeset
117 if (!face) return;
223b71206888 Initial import
thib
parents:
diff changeset
118 face->SetSurface( path, 0,0);
223b71206888 Initial import
thib
parents:
diff changeset
119 }
223b71206888 Initial import
thib
parents:
diff changeset
120 void ResetFace(void) {
223b71206888 Initial import
thib
parents:
diff changeset
121 if (!face) return;
223b71206888 Initial import
thib
parents:
diff changeset
122 face->SetSurface( (Surface*)0, 0,0);
223b71206888 Initial import
thib
parents:
diff changeset
123 }
223b71206888 Initial import
thib
parents:
diff changeset
124 void StartText(const TextStream& _stream) {
223b71206888 Initial import
thib
parents:
diff changeset
125 wid->Clear();
223b71206888 Initial import
thib
parents:
diff changeset
126 wid->stream = _stream;
223b71206888 Initial import
thib
parents:
diff changeset
127 if (name_container) {
223b71206888 Initial import
thib
parents:
diff changeset
128 char namestr[1024];
223b71206888 Initial import
thib
parents:
diff changeset
129 namestr[0] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
130 wid->stream.RemoveName(namestr, 1024);
223b71206888 Initial import
thib
parents:
diff changeset
131 if (namestr[0] == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
132 name_container->hide();
223b71206888 Initial import
thib
parents:
diff changeset
133 } else {
223b71206888 Initial import
thib
parents:
diff changeset
134 if (name) {
223b71206888 Initial import
thib
parents:
diff changeset
135 name_container->show_all();
223b71206888 Initial import
thib
parents:
diff changeset
136 name->SetText(namestr);
223b71206888 Initial import
thib
parents:
diff changeset
137 }
223b71206888 Initial import
thib
parents:
diff changeset
138 }
223b71206888 Initial import
thib
parents:
diff changeset
139 }
223b71206888 Initial import
thib
parents:
diff changeset
140 wid->Start();
223b71206888 Initial import
thib
parents:
diff changeset
141 }
223b71206888 Initial import
thib
parents:
diff changeset
142 void SetName(const char* n) {
223b71206888 Initial import
thib
parents:
diff changeset
143 if (name_container && name) {
223b71206888 Initial import
thib
parents:
diff changeset
144 if (n[0]) {
223b71206888 Initial import
thib
parents:
diff changeset
145 name_container->show();
223b71206888 Initial import
thib
parents:
diff changeset
146 name->SetText(n);
223b71206888 Initial import
thib
parents:
diff changeset
147 name_visible = true;
223b71206888 Initial import
thib
parents:
diff changeset
148 } else {
223b71206888 Initial import
thib
parents:
diff changeset
149 name_container->hide();
223b71206888 Initial import
thib
parents:
diff changeset
150 name_visible = false;
223b71206888 Initial import
thib
parents:
diff changeset
151 }
223b71206888 Initial import
thib
parents:
diff changeset
152 }
223b71206888 Initial import
thib
parents:
diff changeset
153 }
223b71206888 Initial import
thib
parents:
diff changeset
154 };
223b71206888 Initial import
thib
parents:
diff changeset
155
223b71206888 Initial import
thib
parents:
diff changeset
156 class TextImpl {
223b71206888 Initial import
thib
parents:
diff changeset
157 private:
223b71206888 Initial import
thib
parents:
diff changeset
158 public:
223b71206888 Initial import
thib
parents:
diff changeset
159 TextWindow* text;
223b71206888 Initial import
thib
parents:
diff changeset
160 typedef enum {NORMAL=0, WAIT_TEXT=1, WAIT=2, WAIT_CLICK=3, WAIT_ABORT=4, WAIT_CLICK_MOUSEPOS = 5, WAIT_CLICK_MOUSEPOSEND_L = 6, WAIT_CLICK_MOUSEPOSEND_R = 7,
223b71206888 Initial import
thib
parents:
diff changeset
161 WAIT_SELECT_INBOX = 10, WAIT_SELECT_OUTBOX=11, WAIT_SELECT_VALUE = 12,
223b71206888 Initial import
thib
parents:
diff changeset
162 WAIT_EXTRN_MASK = 64, SAVEMASK = 128, LOADMASK = 256, SKIPMASK = 512,
223b71206888 Initial import
thib
parents:
diff changeset
163 CLEARSCR_MASK = 1024, STATSAVE_MASK = 2048, CLEARSCR_WAIT_MASK=(1<<12),
223b71206888 Initial import
thib
parents:
diff changeset
164 SKIPEND_MASK = (1<<13), BACKLOG_MASK=(1<<14), BACKLOG_MASK_FWD=(1<<15), BACKLOG_MASK_KOE=(1<<16), BACKLOG_WAIT_MASK=(1<<17),
223b71206888 Initial import
thib
parents:
diff changeset
165 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)
223b71206888 Initial import
thib
parents:
diff changeset
166 } Status;
223b71206888 Initial import
thib
parents:
diff changeset
167 Status status, status_saved, status_mask;
223b71206888 Initial import
thib
parents:
diff changeset
168 private:
223b71206888 Initial import
thib
parents:
diff changeset
169 std::string ruby_text;
223b71206888 Initial import
thib
parents:
diff changeset
170 bool ruby_text_flag;
223b71206888 Initial import
thib
parents:
diff changeset
171 unsigned int wait_time;
223b71206888 Initial import
thib
parents:
diff changeset
172 unsigned int old_time;
223b71206888 Initial import
thib
parents:
diff changeset
173 unsigned int base_time;
223b71206888 Initial import
thib
parents:
diff changeset
174 int text_window_number;
223b71206888 Initial import
thib
parents:
diff changeset
175 bool text_parsing;
223b71206888 Initial import
thib
parents:
diff changeset
176 TextStream text_stream;
223b71206888 Initial import
thib
parents:
diff changeset
177 SkipMode skip_mode;
223b71206888 Initial import
thib
parents:
diff changeset
178 int save_selectcount;
223b71206888 Initial import
thib
parents:
diff changeset
179
223b71206888 Initial import
thib
parents:
diff changeset
180 std::map<int, TimerAtom> timer_var;
223b71206888 Initial import
thib
parents:
diff changeset
181 std::vector<WidTextButton*> selects;
223b71206888 Initial import
thib
parents:
diff changeset
182 std::vector<int> sel_backlog_pos;
223b71206888 Initial import
thib
parents:
diff changeset
183 string replace_name[26];
223b71206888 Initial import
thib
parents:
diff changeset
184 string replace_name2[26];
223b71206888 Initial import
thib
parents:
diff changeset
185 PicContainer* sel_widget;
223b71206888 Initial import
thib
parents:
diff changeset
186 PicWidget* backlog_widget;
223b71206888 Initial import
thib
parents:
diff changeset
187
223b71206888 Initial import
thib
parents:
diff changeset
188 vector<BacklogItem>& backlog;
223b71206888 Initial import
thib
parents:
diff changeset
189 BacklogItem& backlog_item;
223b71206888 Initial import
thib
parents:
diff changeset
190 BacklogItem cur_backlog_item;
223b71206888 Initial import
thib
parents:
diff changeset
191 BacklogItem drawn_backlog_item;
223b71206888 Initial import
thib
parents:
diff changeset
192
223b71206888 Initial import
thib
parents:
diff changeset
193 public:
223b71206888 Initial import
thib
parents:
diff changeset
194 PicContainer& parent;
223b71206888 Initial import
thib
parents:
diff changeset
195 Event::Container& event;
223b71206888 Initial import
thib
parents:
diff changeset
196 AyuSysConfig& config;
223b71206888 Initial import
thib
parents:
diff changeset
197 private:
223b71206888 Initial import
thib
parents:
diff changeset
198 TextWindow* widgets[32];
223b71206888 Initial import
thib
parents:
diff changeset
199 WidTimeCursor* kcursor;
223b71206888 Initial import
thib
parents:
diff changeset
200 Surface* sel_bg1;
223b71206888 Initial import
thib
parents:
diff changeset
201 Surface* sel_bg2;
223b71206888 Initial import
thib
parents:
diff changeset
202 Rect sel_bg_rect;
223b71206888 Initial import
thib
parents:
diff changeset
203
223b71206888 Initial import
thib
parents:
diff changeset
204 void SetCursor(int num);
223b71206888 Initial import
thib
parents:
diff changeset
205 VarInfo wait_savedvar[2];
223b71206888 Initial import
thib
parents:
diff changeset
206
223b71206888 Initial import
thib
parents:
diff changeset
207 public:
223b71206888 Initial import
thib
parents:
diff changeset
208 void AddText(const char* str);
223b71206888 Initial import
thib
parents:
diff changeset
209
223b71206888 Initial import
thib
parents:
diff changeset
210 static void PressFuncSkip(void* pointer, WidButton* from);
223b71206888 Initial import
thib
parents:
diff changeset
211 static void PressFuncLoad(void* pointer, WidButton* from);
223b71206888 Initial import
thib
parents:
diff changeset
212 static void PressFuncSave(void* pointer, WidButton* from);
223b71206888 Initial import
thib
parents:
diff changeset
213 static void PressFuncBacklog(void* pointer, WidButton* from);
223b71206888 Initial import
thib
parents:
diff changeset
214 static void PressFuncBacklogFwd(void* pointer, WidButton* from);
223b71206888 Initial import
thib
parents:
diff changeset
215 private:
223b71206888 Initial import
thib
parents:
diff changeset
216 static void PressFuncButton(void* pointer, WidButton* from);
223b71206888 Initial import
thib
parents:
diff changeset
217 static bool PressFunc(int x, int y, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
218
223b71206888 Initial import
thib
parents:
diff changeset
219 public:
223b71206888 Initial import
thib
parents:
diff changeset
220 TextImpl(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item);
223b71206888 Initial import
thib
parents:
diff changeset
221 ~TextImpl();
223b71206888 Initial import
thib
parents:
diff changeset
222 void InitWindow(void);
223b71206888 Initial import
thib
parents:
diff changeset
223 void SetWindowColor(int r, int g, int b, int a, bool is_transparent);
223b71206888 Initial import
thib
parents:
diff changeset
224 void SetTextSpeed(int new_speed);
223b71206888 Initial import
thib
parents:
diff changeset
225 void SetTextWait(int new_wait);
223b71206888 Initial import
thib
parents:
diff changeset
226 void CreateSelect(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
227 void Exec(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
228 bool Wait(unsigned int current_time, Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
229 void hide(void);
223b71206888 Initial import
thib
parents:
diff changeset
230 void show(void) { show(text_window_number); }
223b71206888 Initial import
thib
parents:
diff changeset
231 void show(int num);
223b71206888 Initial import
thib
parents:
diff changeset
232 void DrawBacklog(BacklogItem& item, Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
233 void Save(std::string& str, bool select_save);
223b71206888 Initial import
thib
parents:
diff changeset
234 void Load(const char* str);
223b71206888 Initial import
thib
parents:
diff changeset
235 void SetSkipMode(SkipMode _mode);
223b71206888 Initial import
thib
parents:
diff changeset
236 void CreateSelBG(void);
223b71206888 Initial import
thib
parents:
diff changeset
237 };
223b71206888 Initial import
thib
parents:
diff changeset
238
223b71206888 Initial import
thib
parents:
diff changeset
239 /**************************************************************::
223b71206888 Initial import
thib
parents:
diff changeset
240 **
223b71206888 Initial import
thib
parents:
diff changeset
241 ** TextImpl(implementation)
223b71206888 Initial import
thib
parents:
diff changeset
242 */
223b71206888 Initial import
thib
parents:
diff changeset
243 TextImpl::TextImpl(Event::Container& _event, PicContainer& _parent, AyuSysConfig& _config, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item) :
223b71206888 Initial import
thib
parents:
diff changeset
244 text(0),status(TextImpl::NORMAL), status_saved(TextImpl::NORMAL), status_mask(TextImpl::NORMAL), ruby_text_flag(false),
223b71206888 Initial import
thib
parents:
diff changeset
245 old_time(0), base_time(0), text_window_number(0), text_parsing(false), skip_mode(SKIP_NO), save_selectcount(0), sel_widget(0),
223b71206888 Initial import
thib
parents:
diff changeset
246 backlog_widget(0), backlog(parent_backlog), backlog_item(parent_backlog_item), parent(_parent), event(_event), config(_config),
223b71206888 Initial import
thib
parents:
diff changeset
247 kcursor(0), sel_bg1(0), sel_bg2(0), sel_bg_rect(0,0,0,0) {
223b71206888 Initial import
thib
parents:
diff changeset
248 int i;
223b71206888 Initial import
thib
parents:
diff changeset
249 for (i=0; i<32; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
250 widgets[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
251 }
223b71206888 Initial import
thib
parents:
diff changeset
252 text_stream.kanji_type = TextStream::sjis;
223b71206888 Initial import
thib
parents:
diff changeset
253 event.RegisterGlobalPressFunc(&PressFunc, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
254 }
223b71206888 Initial import
thib
parents:
diff changeset
255
223b71206888 Initial import
thib
parents:
diff changeset
256 TextImpl::~TextImpl() {
223b71206888 Initial import
thib
parents:
diff changeset
257 if (sel_widget) delete sel_widget;
223b71206888 Initial import
thib
parents:
diff changeset
258 int i;
223b71206888 Initial import
thib
parents:
diff changeset
259 for (i=0; i<32; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
260 if (widgets[i]) delete widgets[i];
223b71206888 Initial import
thib
parents:
diff changeset
261 }
223b71206888 Initial import
thib
parents:
diff changeset
262 if (backlog_widget) delete backlog_widget;
223b71206888 Initial import
thib
parents:
diff changeset
263 if (sel_bg1) parent.Root().DeleteSurface(sel_bg1);
223b71206888 Initial import
thib
parents:
diff changeset
264 if (sel_bg2) parent.Root().DeleteSurface(sel_bg2);
223b71206888 Initial import
thib
parents:
diff changeset
265 event.DeleteGlobalPressFunc(&PressFunc, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
266 }
223b71206888 Initial import
thib
parents:
diff changeset
267
223b71206888 Initial import
thib
parents:
diff changeset
268 bool TextImpl::PressFunc(int x, int y, void* pointer) {
223b71206888 Initial import
thib
parents:
diff changeset
269 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
270 if (t->status == WAIT_CLICK) {
223b71206888 Initial import
thib
parents:
diff changeset
271 t->status = WAIT_ABORT;
223b71206888 Initial import
thib
parents:
diff changeset
272 } else if (t->status == WAIT_CLICK_MOUSEPOS) {
223b71206888 Initial import
thib
parents:
diff changeset
273 t->status = WAIT_CLICK_MOUSEPOSEND_L;
223b71206888 Initial import
thib
parents:
diff changeset
274 } else if (t->status_mask & CLEARSCR_WAIT_MASK) {
223b71206888 Initial import
thib
parents:
diff changeset
275 t->status_mask = Status(t->status_mask & (~CLEARSCR_WAIT_MASK));
223b71206888 Initial import
thib
parents:
diff changeset
276 if (t->text) t->text->show();
223b71206888 Initial import
thib
parents:
diff changeset
277 if (t->kcursor) {
223b71206888 Initial import
thib
parents:
diff changeset
278 if (t->status == WAIT_TEXT) t->kcursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
279 }
223b71206888 Initial import
thib
parents:
diff changeset
280 if (t->sel_widget) t->sel_widget->show();
223b71206888 Initial import
thib
parents:
diff changeset
281 if (t->backlog_widget) t->backlog_widget->show();
223b71206888 Initial import
thib
parents:
diff changeset
282 } else if (t->status_mask & BACKLOG_WAIT_MASK) {
223b71206888 Initial import
thib
parents:
diff changeset
283 t->status_mask = Status(t->status_mask | BACKLOG_MASK_KOE);
223b71206888 Initial import
thib
parents:
diff changeset
284 } else if ( (t->skip_mode & SKIP_TEXT) && (!(t->skip_mode & SKIP_IN_MENU)) ) {
223b71206888 Initial import
thib
parents:
diff changeset
285 if (t->status == WAIT_SELECT_INBOX) ;
223b71206888 Initial import
thib
parents:
diff changeset
286 else if (t->status == WAIT_SELECT_OUTBOX) ;
223b71206888 Initial import
thib
parents:
diff changeset
287 else if (t->status == WAIT_SELECT_VALUE) ;
223b71206888 Initial import
thib
parents:
diff changeset
288 else t->status_mask = Status(t->status_mask | SKIPEND_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
289 }
223b71206888 Initial import
thib
parents:
diff changeset
290 return true; // event not deleted
223b71206888 Initial import
thib
parents:
diff changeset
291 }
223b71206888 Initial import
thib
parents:
diff changeset
292 void TextImpl::PressFuncButton(void* pointer, WidButton* from) {
223b71206888 Initial import
thib
parents:
diff changeset
293 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
294 if (t->status != WAIT_SELECT_INBOX && t->status != WAIT_SELECT_OUTBOX) return;
223b71206888 Initial import
thib
parents:
diff changeset
295 vector<WidTextButton*>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
296 int sel = 0;
223b71206888 Initial import
thib
parents:
diff changeset
297 for (it=t->selects.begin(); it != t->selects.end(); it++, sel++) {
223b71206888 Initial import
thib
parents:
diff changeset
298 if (from == *it) break;
223b71206888 Initial import
thib
parents:
diff changeset
299 }
223b71206888 Initial import
thib
parents:
diff changeset
300 if (it == t->selects.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
301 fprintf(stderr,"TextImpl::PressFuncButton: Cannot find select widget\n");
223b71206888 Initial import
thib
parents:
diff changeset
302 return;
223b71206888 Initial import
thib
parents:
diff changeset
303 }
223b71206888 Initial import
thib
parents:
diff changeset
304 t->status = Status(WAIT_SELECT_VALUE + sel);
223b71206888 Initial import
thib
parents:
diff changeset
305 return;
223b71206888 Initial import
thib
parents:
diff changeset
306 }
223b71206888 Initial import
thib
parents:
diff changeset
307
223b71206888 Initial import
thib
parents:
diff changeset
308 void TextImpl::SetSkipMode(SkipMode _mode) {
223b71206888 Initial import
thib
parents:
diff changeset
309 if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
310 if (status_mask & BACKLOG_WAIT_MASK) { // backlog mode から復帰
223b71206888 Initial import
thib
parents:
diff changeset
311 status_mask = Status(status_mask & (~(BACKLOG_MASK|BACKLOG_MASK_FWD|BACKLOG_MASK_KOE|BACKLOG_WAIT_MASK)));
223b71206888 Initial import
thib
parents:
diff changeset
312 text->wid->Clear();
223b71206888 Initial import
thib
parents:
diff changeset
313 if (status == WAIT_TEXT && text != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
314 text->StartText(text_stream);
223b71206888 Initial import
thib
parents:
diff changeset
315 text->ShowFace(backlog_item.face.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
316 text->wid->Flush();
223b71206888 Initial import
thib
parents:
diff changeset
317 if (kcursor) kcursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
318 }
223b71206888 Initial import
thib
parents:
diff changeset
319 drawn_backlog_item.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
320 }
223b71206888 Initial import
thib
parents:
diff changeset
321 if (text) text->wid->activate();
223b71206888 Initial import
thib
parents:
diff changeset
322 if (sel_widget) {
223b71206888 Initial import
thib
parents:
diff changeset
323 sel_widget->show();
223b71206888 Initial import
thib
parents:
diff changeset
324 if (kcursor) kcursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
325 }
223b71206888 Initial import
thib
parents:
diff changeset
326 if (backlog_widget) backlog_widget->show();
223b71206888 Initial import
thib
parents:
diff changeset
327 if (status_mask & STATSAVE_MASK) {
223b71206888 Initial import
thib
parents:
diff changeset
328 status_mask = Status(status_mask & (~STATSAVE_MASK));
223b71206888 Initial import
thib
parents:
diff changeset
329 status = status_saved;
223b71206888 Initial import
thib
parents:
diff changeset
330 }
223b71206888 Initial import
thib
parents:
diff changeset
331 } else if ( (skip_mode & SKIP_IN_MENU) == 0 && (_mode & SKIP_IN_MENU) ) {
223b71206888 Initial import
thib
parents:
diff changeset
332 if (text) text->wid->deactivate();
223b71206888 Initial import
thib
parents:
diff changeset
333 if (sel_widget) sel_widget->hide();
223b71206888 Initial import
thib
parents:
diff changeset
334 if (backlog_widget) backlog_widget->hide();
223b71206888 Initial import
thib
parents:
diff changeset
335 }
223b71206888 Initial import
thib
parents:
diff changeset
336 skip_mode = _mode;
223b71206888 Initial import
thib
parents:
diff changeset
337 }
223b71206888 Initial import
thib
parents:
diff changeset
338
223b71206888 Initial import
thib
parents:
diff changeset
339 /* hash_map が欲しい……*/
223b71206888 Initial import
thib
parents:
diff changeset
340 #include<map>
223b71206888 Initial import
thib
parents:
diff changeset
341 #include<list>
223b71206888 Initial import
thib
parents:
diff changeset
342 struct SaveFaceHash { // バックログセーブ時の顔画像管理を行う
223b71206888 Initial import
thib
parents:
diff changeset
343 map<string, int> facetonum;
223b71206888 Initial import
thib
parents:
diff changeset
344 typedef pair<string,int> Node;
223b71206888 Initial import
thib
parents:
diff changeset
345 typedef list<Node> List;
223b71206888 Initial import
thib
parents:
diff changeset
346 List container;
223b71206888 Initial import
thib
parents:
diff changeset
347 int id_max;
223b71206888 Initial import
thib
parents:
diff changeset
348 static int size_max;
223b71206888 Initial import
thib
parents:
diff changeset
349 SaveFaceHash() : id_max(0) {
223b71206888 Initial import
thib
parents:
diff changeset
350 }
223b71206888 Initial import
thib
parents:
diff changeset
351 void NewNode(string face, int face_id) {
223b71206888 Initial import
thib
parents:
diff changeset
352 facetonum[face] = face_id;
223b71206888 Initial import
thib
parents:
diff changeset
353 container.push_front(Node(face, face_id));
223b71206888 Initial import
thib
parents:
diff changeset
354 if (container.size() > size_max) {
223b71206888 Initial import
thib
parents:
diff changeset
355 Node remove = container.back();
223b71206888 Initial import
thib
parents:
diff changeset
356 container.pop_back();
223b71206888 Initial import
thib
parents:
diff changeset
357 facetonum.erase(remove.first);
223b71206888 Initial import
thib
parents:
diff changeset
358 }
223b71206888 Initial import
thib
parents:
diff changeset
359 }
223b71206888 Initial import
thib
parents:
diff changeset
360 int Add(string face) {
223b71206888 Initial import
thib
parents:
diff changeset
361 int id; int ret = -1;
223b71206888 Initial import
thib
parents:
diff changeset
362 int i; List::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
363 if (face.empty()) return -1;
223b71206888 Initial import
thib
parents:
diff changeset
364 if (facetonum.find(face) == facetonum.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
365 id = ++id_max;
223b71206888 Initial import
thib
parents:
diff changeset
366 NewNode(face, id);
223b71206888 Initial import
thib
parents:
diff changeset
367 ret = -1;
223b71206888 Initial import
thib
parents:
diff changeset
368 } else {
223b71206888 Initial import
thib
parents:
diff changeset
369 id = facetonum[face];
223b71206888 Initial import
thib
parents:
diff changeset
370 for (i=0, it=container.begin(); it != container.end(); i++, it++) {
223b71206888 Initial import
thib
parents:
diff changeset
371 if (it->second == id) {
223b71206888 Initial import
thib
parents:
diff changeset
372 ret = i;
223b71206888 Initial import
thib
parents:
diff changeset
373 Node n = *it;
223b71206888 Initial import
thib
parents:
diff changeset
374 container.erase(it);
223b71206888 Initial import
thib
parents:
diff changeset
375 container.push_front(n);
223b71206888 Initial import
thib
parents:
diff changeset
376 break;
223b71206888 Initial import
thib
parents:
diff changeset
377 }
223b71206888 Initial import
thib
parents:
diff changeset
378 }
223b71206888 Initial import
thib
parents:
diff changeset
379 }
223b71206888 Initial import
thib
parents:
diff changeset
380 return ret;
223b71206888 Initial import
thib
parents:
diff changeset
381 }
223b71206888 Initial import
thib
parents:
diff changeset
382 string Get(int num) {
223b71206888 Initial import
thib
parents:
diff changeset
383 if (num < 0) return "";
223b71206888 Initial import
thib
parents:
diff changeset
384 List::iterator it = container.begin();
223b71206888 Initial import
thib
parents:
diff changeset
385 for (; it != container.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
386 if (num == 0) return it->first;
223b71206888 Initial import
thib
parents:
diff changeset
387 num--;
223b71206888 Initial import
thib
parents:
diff changeset
388 }
223b71206888 Initial import
thib
parents:
diff changeset
389 return "";
223b71206888 Initial import
thib
parents:
diff changeset
390 }
223b71206888 Initial import
thib
parents:
diff changeset
391 };
223b71206888 Initial import
thib
parents:
diff changeset
392 int SaveFaceHash::size_max = 20;
223b71206888 Initial import
thib
parents:
diff changeset
393
223b71206888 Initial import
thib
parents:
diff changeset
394 void TextImpl::Save(string& str, bool rollback_save) {
223b71206888 Initial import
thib
parents:
diff changeset
395 char buf[1024];
223b71206888 Initial import
thib
parents:
diff changeset
396 str = "\n";
223b71206888 Initial import
thib
parents:
diff changeset
397 str += "[TextImpl Window]\n";
223b71206888 Initial import
thib
parents:
diff changeset
398 sprintf(buf, "TextImplWindow=%d\n",text_window_number);
223b71206888 Initial import
thib
parents:
diff changeset
399 str += buf;
223b71206888 Initial import
thib
parents:
diff changeset
400 if (rollback_save) {
223b71206888 Initial import
thib
parents:
diff changeset
401 ++save_selectcount;
223b71206888 Initial import
thib
parents:
diff changeset
402 BacklogItem save_item;
223b71206888 Initial import
thib
parents:
diff changeset
403 save_item.SetSavepos(save_selectcount);
223b71206888 Initial import
thib
parents:
diff changeset
404 backlog.push_back(save_item);
223b71206888 Initial import
thib
parents:
diff changeset
405 }
223b71206888 Initial import
thib
parents:
diff changeset
406 sprintf(buf, "SaveSelectCount=%d\n",save_selectcount);
223b71206888 Initial import
thib
parents:
diff changeset
407
223b71206888 Initial import
thib
parents:
diff changeset
408 str += buf;
223b71206888 Initial import
thib
parents:
diff changeset
409 int i;
223b71206888 Initial import
thib
parents:
diff changeset
410 for (i=0; i<26; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
411 if (replace_name2[i].empty()) continue;
223b71206888 Initial import
thib
parents:
diff changeset
412 sprintf(buf, "RName.%c=%s\n",i+'A',replace_name2[i].c_str());
223b71206888 Initial import
thib
parents:
diff changeset
413 str += buf;
223b71206888 Initial import
thib
parents:
diff changeset
414 }
223b71206888 Initial import
thib
parents:
diff changeset
415 int cnt = 0;
223b71206888 Initial import
thib
parents:
diff changeset
416 vector<BacklogItem>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
417 it = backlog.begin();
223b71206888 Initial import
thib
parents:
diff changeset
418 if (!rollback_save) {
223b71206888 Initial import
thib
parents:
diff changeset
419 SaveFaceHash face_log;
223b71206888 Initial import
thib
parents:
diff changeset
420 do {
223b71206888 Initial import
thib
parents:
diff changeset
421 int cur_scn = -1; int cur_pos = -1;
223b71206888 Initial import
thib
parents:
diff changeset
422 sprintf(buf, "Backlog.%d=",++cnt);
223b71206888 Initial import
thib
parents:
diff changeset
423 str += buf;
223b71206888 Initial import
thib
parents:
diff changeset
424 for (; it != backlog.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
425 buf[0] = 0; int buflen = 0;
223b71206888 Initial import
thib
parents:
diff changeset
426 if (it->scn == -1) continue;
223b71206888 Initial import
thib
parents:
diff changeset
427 if (it->pos == -1 && it->scn != 0) continue;
223b71206888 Initial import
thib
parents:
diff changeset
428
223b71206888 Initial import
thib
parents:
diff changeset
429 buf[buflen++] = ';';
223b71206888 Initial import
thib
parents:
diff changeset
430 if (it->scn == 0 && it->pos == -1) {
223b71206888 Initial import
thib
parents:
diff changeset
431 buflen += snprintf(buf+buflen, 1000-buflen, "\"%s\".", it->text.Save().c_str());
223b71206888 Initial import
thib
parents:
diff changeset
432 } else {
223b71206888 Initial import
thib
parents:
diff changeset
433 if (cur_scn != -1 && cur_scn != it->scn) break; // scn change
223b71206888 Initial import
thib
parents:
diff changeset
434 if (cur_pos != -1 && cur_pos/5000 != it->pos/5000) break; // pos exceeded
223b71206888 Initial import
thib
parents:
diff changeset
435 if (!it->text.container.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
436 buflen += snprintf(buf+buflen, 1000-buflen, "\"%s\"", it->text.Save().c_str());
223b71206888 Initial import
thib
parents:
diff changeset
437 }
223b71206888 Initial import
thib
parents:
diff changeset
438 if (cur_scn == -1) { // scene change
223b71206888 Initial import
thib
parents:
diff changeset
439 buflen += snprintf(buf+buflen, 1000-buflen, ":%d:%d",it->scn,it->pos);
223b71206888 Initial import
thib
parents:
diff changeset
440 cur_scn = it->scn;
223b71206888 Initial import
thib
parents:
diff changeset
441 } else {
223b71206888 Initial import
thib
parents:
diff changeset
442 buflen += snprintf(buf+buflen, 1000-buflen, "%d",it->pos);
223b71206888 Initial import
thib
parents:
diff changeset
443 }
223b71206888 Initial import
thib
parents:
diff changeset
444 cur_pos = it->pos;
223b71206888 Initial import
thib
parents:
diff changeset
445 }
223b71206888 Initial import
thib
parents:
diff changeset
446 if (it->koe != -1)
223b71206888 Initial import
thib
parents:
diff changeset
447 buflen += snprintf(buf+buflen, 1000-buflen, ",%d",it->koe);
223b71206888 Initial import
thib
parents:
diff changeset
448 if (!it->face.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
449 if (it->koe == -1) buf[buflen++] = ',';
223b71206888 Initial import
thib
parents:
diff changeset
450 int face_num = face_log.Add(it->face);
223b71206888 Initial import
thib
parents:
diff changeset
451 if (face_num >= 0 && face_num < 20)
223b71206888 Initial import
thib
parents:
diff changeset
452 buflen += snprintf(buf+buflen, 1000-buflen, ",%c", 'A'+face_num);
223b71206888 Initial import
thib
parents:
diff changeset
453 else
223b71206888 Initial import
thib
parents:
diff changeset
454 buflen += snprintf(buf+buflen, 1000-buflen, ",\"%s\"", it->face.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
455 }
223b71206888 Initial import
thib
parents:
diff changeset
456 buf[buflen++] = '\0';
223b71206888 Initial import
thib
parents:
diff changeset
457 if (buflen >= 1000) { // 万が一、バックログ1アイテムの大きさが 1000byte を越えるとき
223b71206888 Initial import
thib
parents:
diff changeset
458 fprintf(stderr,"Fatal : Cannot save backlog crrectly; Please send bug report to the author.\n");
223b71206888 Initial import
thib
parents:
diff changeset
459 } else str += buf;
223b71206888 Initial import
thib
parents:
diff changeset
460 }
223b71206888 Initial import
thib
parents:
diff changeset
461 str += "\n";
223b71206888 Initial import
thib
parents:
diff changeset
462 } while(it != backlog.end());
223b71206888 Initial import
thib
parents:
diff changeset
463 }
223b71206888 Initial import
thib
parents:
diff changeset
464 return;
223b71206888 Initial import
thib
parents:
diff changeset
465 }
223b71206888 Initial import
thib
parents:
diff changeset
466 void TextImpl::Load(const char* str) {
223b71206888 Initial import
thib
parents:
diff changeset
467 if (text) text->wid->Clear();
223b71206888 Initial import
thib
parents:
diff changeset
468 hide();
223b71206888 Initial import
thib
parents:
diff changeset
469 text_window_number = 0;
223b71206888 Initial import
thib
parents:
diff changeset
470 save_selectcount = 0;
223b71206888 Initial import
thib
parents:
diff changeset
471 if (sel_widget) {
223b71206888 Initial import
thib
parents:
diff changeset
472 selects.clear();
223b71206888 Initial import
thib
parents:
diff changeset
473 sel_backlog_pos.clear();
223b71206888 Initial import
thib
parents:
diff changeset
474 delete sel_widget;
223b71206888 Initial import
thib
parents:
diff changeset
475 sel_widget = 0;
223b71206888 Initial import
thib
parents:
diff changeset
476 }
223b71206888 Initial import
thib
parents:
diff changeset
477 if (backlog_widget) {
223b71206888 Initial import
thib
parents:
diff changeset
478 delete backlog_widget;
223b71206888 Initial import
thib
parents:
diff changeset
479 backlog_widget = 0;
223b71206888 Initial import
thib
parents:
diff changeset
480 }
223b71206888 Initial import
thib
parents:
diff changeset
481 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
482 status_mask = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
483 status_saved = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
484 text_parsing = false;
223b71206888 Initial import
thib
parents:
diff changeset
485 text_stream.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
486 // backlog.clear();
223b71206888 Initial import
thib
parents:
diff changeset
487 vector<BacklogItem> new_backlog;
223b71206888 Initial import
thib
parents:
diff changeset
488 backlog_item.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
489 cur_backlog_item.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
490 drawn_backlog_item.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
491
223b71206888 Initial import
thib
parents:
diff changeset
492 str = strstr(str, "\n[TextImpl Window]\n");
223b71206888 Initial import
thib
parents:
diff changeset
493
223b71206888 Initial import
thib
parents:
diff changeset
494 if (str) {
223b71206888 Initial import
thib
parents:
diff changeset
495 SaveFaceHash face_log;
223b71206888 Initial import
thib
parents:
diff changeset
496 str += strlen("\n[TextImpl Window]\n");
223b71206888 Initial import
thib
parents:
diff changeset
497 const char* strend = str;
223b71206888 Initial import
thib
parents:
diff changeset
498 do {
223b71206888 Initial import
thib
parents:
diff changeset
499 str = strend;
223b71206888 Initial import
thib
parents:
diff changeset
500
223b71206888 Initial import
thib
parents:
diff changeset
501 strend = strchr(str, '\n');
223b71206888 Initial import
thib
parents:
diff changeset
502 if (strend == 0) strend = str + strlen(str);
223b71206888 Initial import
thib
parents:
diff changeset
503 else strend++;
223b71206888 Initial import
thib
parents:
diff changeset
504
223b71206888 Initial import
thib
parents:
diff changeset
505 if (str[0] == '[') break; // next section
223b71206888 Initial import
thib
parents:
diff changeset
506 if (strncmp(str, "TextImplWindow=",15) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
507 str += 15;
223b71206888 Initial import
thib
parents:
diff changeset
508 sscanf(str, "%d", &text_window_number);
223b71206888 Initial import
thib
parents:
diff changeset
509 } else if (strncmp(str, "SaveSelectCount=",16) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
510 str += 16;
223b71206888 Initial import
thib
parents:
diff changeset
511 sscanf(str, "%d", &save_selectcount);
223b71206888 Initial import
thib
parents:
diff changeset
512 } else if (strncmp(str, "RName.", 6) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
513 int n = str[6]-'A';
223b71206888 Initial import
thib
parents:
diff changeset
514 if (n >= 0 && n < 26 && str[7] == '=') {
223b71206888 Initial import
thib
parents:
diff changeset
515 const char* s = strchr(str, '\n');
223b71206888 Initial import
thib
parents:
diff changeset
516 int len = -1;
223b71206888 Initial import
thib
parents:
diff changeset
517 if (s) len = s-(str+8);
223b71206888 Initial import
thib
parents:
diff changeset
518 if (len > 0) {
223b71206888 Initial import
thib
parents:
diff changeset
519 replace_name2[n].assign(str+8, len);
223b71206888 Initial import
thib
parents:
diff changeset
520 }
223b71206888 Initial import
thib
parents:
diff changeset
521 }
223b71206888 Initial import
thib
parents:
diff changeset
522 } else if (strncmp(str, "Backlog.", 8) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
523 int cur_scn = -1;
223b71206888 Initial import
thib
parents:
diff changeset
524 int n = -1;
223b71206888 Initial import
thib
parents:
diff changeset
525 sscanf(str+8, "%d", &n); /* not used */
223b71206888 Initial import
thib
parents:
diff changeset
526 const char* next_str = strchr(str, ';');
223b71206888 Initial import
thib
parents:
diff changeset
527 while(next_str != 0 && next_str < strend) {
223b71206888 Initial import
thib
parents:
diff changeset
528 str = next_str + 1;
223b71206888 Initial import
thib
parents:
diff changeset
529 next_str = strchr(str, ';');
223b71206888 Initial import
thib
parents:
diff changeset
530 if (next_str == 0) next_str = strend;
223b71206888 Initial import
thib
parents:
diff changeset
531
223b71206888 Initial import
thib
parents:
diff changeset
532 BacklogItem item;
223b71206888 Initial import
thib
parents:
diff changeset
533 if (str[0] == '"') {
223b71206888 Initial import
thib
parents:
diff changeset
534 const char* send = strchr(str+1, '"');
223b71206888 Initial import
thib
parents:
diff changeset
535 if (send == 0 || send > next_str) continue;
223b71206888 Initial import
thib
parents:
diff changeset
536 string tmp_str; tmp_str.assign(str+1, send-str-1);
223b71206888 Initial import
thib
parents:
diff changeset
537 item.DeleteTextPos();
223b71206888 Initial import
thib
parents:
diff changeset
538 item.text.Load(tmp_str);
223b71206888 Initial import
thib
parents:
diff changeset
539 str = send + 1;
223b71206888 Initial import
thib
parents:
diff changeset
540 }
223b71206888 Initial import
thib
parents:
diff changeset
541 if (str[0] == '.') {
223b71206888 Initial import
thib
parents:
diff changeset
542 item.DeleteTextPos();
223b71206888 Initial import
thib
parents:
diff changeset
543 str++;
223b71206888 Initial import
thib
parents:
diff changeset
544 } else if (str[0] == ':') {
223b71206888 Initial import
thib
parents:
diff changeset
545 sscanf(str, ":%d:%d", &item.scn, &item.pos);
223b71206888 Initial import
thib
parents:
diff changeset
546 cur_scn = item.scn;
223b71206888 Initial import
thib
parents:
diff changeset
547
223b71206888 Initial import
thib
parents:
diff changeset
548 } else {
223b71206888 Initial import
thib
parents:
diff changeset
549 item.scn = cur_scn;
223b71206888 Initial import
thib
parents:
diff changeset
550 sscanf(str, "%d", &item.pos);
223b71206888 Initial import
thib
parents:
diff changeset
551 }
223b71206888 Initial import
thib
parents:
diff changeset
552 str = strchr(str, ',');
223b71206888 Initial import
thib
parents:
diff changeset
553 if (str == 0 || str > next_str) goto backlog_store;
223b71206888 Initial import
thib
parents:
diff changeset
554 str++;
223b71206888 Initial import
thib
parents:
diff changeset
555 if (str[0] == ';' || str[0] == ',')
223b71206888 Initial import
thib
parents:
diff changeset
556 item.koe = -1;
223b71206888 Initial import
thib
parents:
diff changeset
557 else
223b71206888 Initial import
thib
parents:
diff changeset
558 sscanf(str, "%d", &item.koe);
223b71206888 Initial import
thib
parents:
diff changeset
559 str = strchr(str, ',');
223b71206888 Initial import
thib
parents:
diff changeset
560 if (str == 0 || str > next_str) goto backlog_store;
223b71206888 Initial import
thib
parents:
diff changeset
561 str++;
223b71206888 Initial import
thib
parents:
diff changeset
562 if (*str == '"') {
223b71206888 Initial import
thib
parents:
diff changeset
563 const char* send = strchr(str+1, '"');
223b71206888 Initial import
thib
parents:
diff changeset
564 if (send) {
223b71206888 Initial import
thib
parents:
diff changeset
565 item.face.assign(str+1, send-str-1);
223b71206888 Initial import
thib
parents:
diff changeset
566 }
223b71206888 Initial import
thib
parents:
diff changeset
567 } else if (*str >= 'A' && *str <= 'Z') {
223b71206888 Initial import
thib
parents:
diff changeset
568 item.face = face_log.Get(*str - 'A');
223b71206888 Initial import
thib
parents:
diff changeset
569 }
223b71206888 Initial import
thib
parents:
diff changeset
570 face_log.Add(item.face);
223b71206888 Initial import
thib
parents:
diff changeset
571 backlog_store:
223b71206888 Initial import
thib
parents:
diff changeset
572 new_backlog.push_back(item);
223b71206888 Initial import
thib
parents:
diff changeset
573 }
223b71206888 Initial import
thib
parents:
diff changeset
574 }
223b71206888 Initial import
thib
parents:
diff changeset
575 } while (*strend != 0);
223b71206888 Initial import
thib
parents:
diff changeset
576 }
223b71206888 Initial import
thib
parents:
diff changeset
577 if (new_backlog.empty() && (!backlog.empty())) { // empty なら save_selectcount まで backlog を巻き戻す
223b71206888 Initial import
thib
parents:
diff changeset
578 vector<BacklogItem>::iterator it = backlog.end();
223b71206888 Initial import
thib
parents:
diff changeset
579 do {
223b71206888 Initial import
thib
parents:
diff changeset
580 it--;
223b71206888 Initial import
thib
parents:
diff changeset
581 if (it->scn == BacklogItem::SaveSelect && it->pos == save_selectcount) {
223b71206888 Initial import
thib
parents:
diff changeset
582 // Save 位置を見つけたらそれ以降を erase
223b71206888 Initial import
thib
parents:
diff changeset
583 backlog.erase(it, backlog.end());
223b71206888 Initial import
thib
parents:
diff changeset
584 break;
223b71206888 Initial import
thib
parents:
diff changeset
585 }
223b71206888 Initial import
thib
parents:
diff changeset
586 } while(it != backlog.begin());
223b71206888 Initial import
thib
parents:
diff changeset
587 --save_selectcount;
223b71206888 Initial import
thib
parents:
diff changeset
588 } else {
223b71206888 Initial import
thib
parents:
diff changeset
589 backlog.swap(new_backlog);
223b71206888 Initial import
thib
parents:
diff changeset
590 }
223b71206888 Initial import
thib
parents:
diff changeset
591 // backlog.clear();
223b71206888 Initial import
thib
parents:
diff changeset
592 return;
223b71206888 Initial import
thib
parents:
diff changeset
593 }
223b71206888 Initial import
thib
parents:
diff changeset
594
223b71206888 Initial import
thib
parents:
diff changeset
595 void TextImpl::hide(void) {
223b71206888 Initial import
thib
parents:
diff changeset
596 if (text) text->hide();
223b71206888 Initial import
thib
parents:
diff changeset
597 if (kcursor) kcursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
598 text = 0;
223b71206888 Initial import
thib
parents:
diff changeset
599 }
223b71206888 Initial import
thib
parents:
diff changeset
600 void TextImpl::show(int num) {
223b71206888 Initial import
thib
parents:
diff changeset
601 if (num != text_window_number) {
223b71206888 Initial import
thib
parents:
diff changeset
602 hide();
223b71206888 Initial import
thib
parents:
diff changeset
603 if (num >= 0 && num < 32 && widgets[num] != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
604 text_window_number = num;
223b71206888 Initial import
thib
parents:
diff changeset
605 }
223b71206888 Initial import
thib
parents:
diff changeset
606 }
223b71206888 Initial import
thib
parents:
diff changeset
607 text = widgets[text_window_number];
223b71206888 Initial import
thib
parents:
diff changeset
608 text->show();
223b71206888 Initial import
thib
parents:
diff changeset
609 if (kcursor) {
223b71206888 Initial import
thib
parents:
diff changeset
610 int kx, ky, d;
223b71206888 Initial import
thib
parents:
diff changeset
611 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
612 sprintf(key, "#WINDOW.%03d.KEYCUR_MOD", text_window_number);
223b71206888 Initial import
thib
parents:
diff changeset
613 config.GetParam(key, 3, &d, &kx, &ky);
223b71206888 Initial import
thib
parents:
diff changeset
614 // 正しくない気がする
223b71206888 Initial import
thib
parents:
diff changeset
615 kx += text->wid->Pic()->PosX();
223b71206888 Initial import
thib
parents:
diff changeset
616 ky += text->wid->Pic()->PosY();
223b71206888 Initial import
thib
parents:
diff changeset
617 // 微妙に下にする
223b71206888 Initial import
thib
parents:
diff changeset
618 ky += 8;
223b71206888 Initial import
thib
parents:
diff changeset
619 kcursor->Pic()->Move(kx, ky);
223b71206888 Initial import
thib
parents:
diff changeset
620 }
223b71206888 Initial import
thib
parents:
diff changeset
621 }
223b71206888 Initial import
thib
parents:
diff changeset
622 void TextImpl::DrawBacklog(BacklogItem& item, Cmd& cmd) {
18
4d7486cb20a9 Sync with upstream
thib
parents: 17
diff changeset
623 show();
0
223b71206888 Initial import
thib
parents:
diff changeset
624 text->wid->deactivate();
223b71206888 Initial import
thib
parents:
diff changeset
625 status_mask = Status(status_mask | BACKLOG_WAIT_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
626 drawn_backlog_item = item;
223b71206888 Initial import
thib
parents:
diff changeset
627 if (item.text.container.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
628 // cmd から text 内容を再構成
223b71206888 Initial import
thib
parents:
diff changeset
629 TextStream saved_text = text_stream;
223b71206888 Initial import
thib
parents:
diff changeset
630 text_stream.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
631 AddText(cmd.Str(cmd.args[0]));
223b71206888 Initial import
thib
parents:
diff changeset
632 item.text = text_stream;
223b71206888 Initial import
thib
parents:
diff changeset
633 text_stream = saved_text;
223b71206888 Initial import
thib
parents:
diff changeset
634 }
18
4d7486cb20a9 Sync with upstream
thib
parents: 17
diff changeset
635 item.text.InsertColor(0, item.text.container.size(), 0xff,0xff,0);
17
a95c130b567b Shows name in backlog
thib
parents: 0
diff changeset
636 text->StartText(item.text);
0
223b71206888 Initial import
thib
parents:
diff changeset
637 text->wid->Flush();
223b71206888 Initial import
thib
parents:
diff changeset
638 if (item.face.empty()) text->ResetFace();
223b71206888 Initial import
thib
parents:
diff changeset
639 else text->ShowFace(item.face.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
640 if (kcursor) kcursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
641 }
223b71206888 Initial import
thib
parents:
diff changeset
642
223b71206888 Initial import
thib
parents:
diff changeset
643 void TextImpl::CreateSelBG(void) {
223b71206888 Initial import
thib
parents:
diff changeset
644 if (sel_bg1 != 0 || sel_bg2 != 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
645
223b71206888 Initial import
thib
parents:
diff changeset
646 const char* btnfile1 = config.GetParaStr("#SELBTN.000.NAME");
223b71206888 Initial import
thib
parents:
diff changeset
647 const char* btnfile2 = config.GetParaStr("#SELBTN.000.BACK");
223b71206888 Initial import
thib
parents:
diff changeset
648 char path[1024];
223b71206888 Initial import
thib
parents:
diff changeset
649 strcpy(path, btnfile1);
223b71206888 Initial import
thib
parents:
diff changeset
650 sel_bg1 = parent.Root().NewSurface(path);
223b71206888 Initial import
thib
parents:
diff changeset
651 if (sel_bg1 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
652 sprintf(path,"%s.g00",btnfile1);
223b71206888 Initial import
thib
parents:
diff changeset
653 sel_bg1 = parent.Root().NewSurface(path);
223b71206888 Initial import
thib
parents:
diff changeset
654 }
223b71206888 Initial import
thib
parents:
diff changeset
655 strcpy(path, btnfile2);
223b71206888 Initial import
thib
parents:
diff changeset
656 sel_bg2 = parent.Root().NewSurface(path);
223b71206888 Initial import
thib
parents:
diff changeset
657 if (sel_bg2 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
658 sprintf(path,"%s.g00",btnfile2);
223b71206888 Initial import
thib
parents:
diff changeset
659 sel_bg2 = parent.Root().NewSurface(path);
223b71206888 Initial import
thib
parents:
diff changeset
660 }
223b71206888 Initial import
thib
parents:
diff changeset
661 sel_bg_rect = Rect(0,0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
662 if (sel_bg1) sel_bg_rect.join(Rect(*sel_bg1));
223b71206888 Initial import
thib
parents:
diff changeset
663 if (sel_bg2) sel_bg_rect.join(Rect(*sel_bg2));
223b71206888 Initial import
thib
parents:
diff changeset
664 return;
223b71206888 Initial import
thib
parents:
diff changeset
665 }
223b71206888 Initial import
thib
parents:
diff changeset
666
223b71206888 Initial import
thib
parents:
diff changeset
667 void TextImpl::CreateSelect(Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
668 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
669 sprintf(key, "#WINDOW.%03d.SELCOM_USE",text_window_number);
223b71206888 Initial import
thib
parents:
diff changeset
670 int sel_type = 0;
38
658272d883ed * Support (more or less) button style selects (fuuko's ones)
thib
parents: 18
diff changeset
671 if (cmd.cmd3 == 1) config.GetParam(key, 1, &sel_type);
658272d883ed * Support (more or less) button style selects (fuuko's ones)
thib
parents: 18
diff changeset
672 else if (cmd.cmd3 == 3) sel_type = 0;
0
223b71206888 Initial import
thib
parents:
diff changeset
673
223b71206888 Initial import
thib
parents:
diff changeset
674 int sel_size = cmd.args.size() / 2;
223b71206888 Initial import
thib
parents:
diff changeset
675 int i;
223b71206888 Initial import
thib
parents:
diff changeset
676 // cur_backlog_item に次にbacklogに入るべき内容を作成
223b71206888 Initial import
thib
parents:
diff changeset
677 // CreateSelect() 後、SAVEPOINT なので現在のbacklogの内容(前のメッセージ)が
223b71206888 Initial import
thib
parents:
diff changeset
678 // backlog に代入される。その後、backlog_item に cur_backlog_item の内容がセットされる(Wait()内)
223b71206888 Initial import
thib
parents:
diff changeset
679 char backlog_sel_text[11] = {0x81,0x69,0x91,0x49,0x91,0xf0,0x8e,0x88,0x81,0x6a,0x00};
223b71206888 Initial import
thib
parents:
diff changeset
680 cur_backlog_item.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
681 cur_backlog_item.AddTextPos(cmd);
223b71206888 Initial import
thib
parents:
diff changeset
682 cur_backlog_item.text.Add(backlog_sel_text);
223b71206888 Initial import
thib
parents:
diff changeset
683 cur_backlog_item.text.AddReturn();
223b71206888 Initial import
thib
parents:
diff changeset
684 sel_backlog_pos.clear();
223b71206888 Initial import
thib
parents:
diff changeset
685 for (i=0; i<sel_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
686 sel_backlog_pos.push_back(cur_backlog_item.text.container.size());
223b71206888 Initial import
thib
parents:
diff changeset
687 cur_backlog_item.text.Add(cmd.Str(cmd.args[i*2]));
223b71206888 Initial import
thib
parents:
diff changeset
688 cur_backlog_item.text.AddReturn();
223b71206888 Initial import
thib
parents:
diff changeset
689 }
223b71206888 Initial import
thib
parents:
diff changeset
690 sel_backlog_pos.push_back(cur_backlog_item.text.container.size());
223b71206888 Initial import
thib
parents:
diff changeset
691
223b71206888 Initial import
thib
parents:
diff changeset
692 if (sel_type == 0) { // Princess Bride: 選択ウィンドウを別表示
223b71206888 Initial import
thib
parents:
diff changeset
693 External_select:
223b71206888 Initial import
thib
parents:
diff changeset
694 CreateSelBG();
223b71206888 Initial import
thib
parents:
diff changeset
695 hide(); // なので、テキストウィンドウは消去
223b71206888 Initial import
thib
parents:
diff changeset
696 int baseposx, baseposy, repposx, repposy;
223b71206888 Initial import
thib
parents:
diff changeset
697 int mojisize, col1, col2;
223b71206888 Initial import
thib
parents:
diff changeset
698 config.GetParam("#SELBTN.000.BASEPOS", 2, &baseposx, &baseposy);
223b71206888 Initial import
thib
parents:
diff changeset
699 config.GetParam("#SELBTN.000.REPPOS", 2, &repposx, &repposy);
223b71206888 Initial import
thib
parents:
diff changeset
700 config.GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize);
223b71206888 Initial import
thib
parents:
diff changeset
701 config.GetParam("#SELBTN.000.MOJIDEFAULTCOL", 1, &col1);
223b71206888 Initial import
thib
parents:
diff changeset
702 config.GetParam("#SELBTN.000.MOJISELECTCOL", 1, &col2);
223b71206888 Initial import
thib
parents:
diff changeset
703 if (col1 == col2) col2 = 1; // CLANNAD でとりあえず。
223b71206888 Initial import
thib
parents:
diff changeset
704 int r, g, b;
223b71206888 Initial import
thib
parents:
diff changeset
705 sprintf(key, "#COLOR_TABLE.%03d", col1);
223b71206888 Initial import
thib
parents:
diff changeset
706 config.GetParam(key, 3, &r, &g, &b);
223b71206888 Initial import
thib
parents:
diff changeset
707 Color fore(r,g,b);
223b71206888 Initial import
thib
parents:
diff changeset
708 sprintf(key, "#COLOR_TABLE.%03d", col2);
223b71206888 Initial import
thib
parents:
diff changeset
709 config.GetParam(key, 3, &r, &g, &b);
223b71206888 Initial import
thib
parents:
diff changeset
710 Color seled(r,g,b);
223b71206888 Initial import
thib
parents:
diff changeset
711
223b71206888 Initial import
thib
parents:
diff changeset
712 /* ウィジット作成 */
223b71206888 Initial import
thib
parents:
diff changeset
713 /* ウィンドウ背景の大きさを求める */
223b71206888 Initial import
thib
parents:
diff changeset
714 if (baseposx == 0 && sel_bg_rect.width() != 0)
223b71206888 Initial import
thib
parents:
diff changeset
715 baseposx = (parent.Width()-sel_bg_rect.width()) / 2; // ボタン位置をセンタリング
223b71206888 Initial import
thib
parents:
diff changeset
716
223b71206888 Initial import
thib
parents:
diff changeset
717 sel_widget = parent.create_node( Rect(0, 0, parent.Width(), parent.Height()),0);
223b71206888 Initial import
thib
parents:
diff changeset
718
223b71206888 Initial import
thib
parents:
diff changeset
719 for (i=0; i<sel_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
720 PicBase* p;
223b71206888 Initial import
thib
parents:
diff changeset
721 // 背景作成
223b71206888 Initial import
thib
parents:
diff changeset
722 if (sel_bg2) {
223b71206888 Initial import
thib
parents:
diff changeset
723 p = sel_widget->create_node(Rect(baseposx, baseposy, baseposx+sel_bg_rect.width(), baseposy+sel_bg_rect.height()),0);
223b71206888 Initial import
thib
parents:
diff changeset
724 p->SetSurface(sel_bg2, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
725 }
223b71206888 Initial import
thib
parents:
diff changeset
726 if (sel_bg1) {
223b71206888 Initial import
thib
parents:
diff changeset
727 p = sel_widget->create_node(Rect(baseposx, baseposy, baseposx+sel_bg_rect.width(), baseposy+sel_bg_rect.height()),0);
223b71206888 Initial import
thib
parents:
diff changeset
728 p->SetSurface(sel_bg1, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
729 }
223b71206888 Initial import
thib
parents:
diff changeset
730 /* ボタン作成 */
223b71206888 Initial import
thib
parents:
diff changeset
731 const char* str = cmd.Str(cmd.args[i*2]);
223b71206888 Initial import
thib
parents:
diff changeset
732 int value = cmd.args[i*2+1].value;
223b71206888 Initial import
thib
parents:
diff changeset
733 while(selects.size() <= value) selects.push_back(0); // vector の大きさを広げる
223b71206888 Initial import
thib
parents:
diff changeset
734
223b71206888 Initial import
thib
parents:
diff changeset
735 kconv( (const unsigned char*)str, (unsigned char*)key);
223b71206888 Initial import
thib
parents:
diff changeset
736 selects[value] = new WidTextButton(event, sel_widget, key, mojisize, WidTextButton::CENTER,
223b71206888 Initial import
thib
parents:
diff changeset
737 Rect(baseposx, baseposy, baseposx+sel_bg_rect.width(), baseposy+sel_bg_rect.height()), 1, fore, seled, Color(0,0,0,0));
223b71206888 Initial import
thib
parents:
diff changeset
738 selects[value]->press_func = &PressFuncButton;
223b71206888 Initial import
thib
parents:
diff changeset
739 selects[value]->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
740
223b71206888 Initial import
thib
parents:
diff changeset
741 baseposx += repposx;
223b71206888 Initial import
thib
parents:
diff changeset
742 baseposy += repposy;
223b71206888 Initial import
thib
parents:
diff changeset
743 }
223b71206888 Initial import
thib
parents:
diff changeset
744 sel_widget->show_all();
223b71206888 Initial import
thib
parents:
diff changeset
745 status = WAIT_SELECT_OUTBOX;
223b71206888 Initial import
thib
parents:
diff changeset
746 } else { // CLANNAD: テキストウィンドウ内に選択肢表示
223b71206888 Initial import
thib
parents:
diff changeset
747 int mojisize;
223b71206888 Initial import
thib
parents:
diff changeset
748 config.GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize);
223b71206888 Initial import
thib
parents:
diff changeset
749 Color fore(0xff,0xff,0xff);
223b71206888 Initial import
thib
parents:
diff changeset
750 Color seled(0xff,0xff,0xff);
223b71206888 Initial import
thib
parents:
diff changeset
751
223b71206888 Initial import
thib
parents:
diff changeset
752 show();
223b71206888 Initial import
thib
parents:
diff changeset
753 if (text == 0) goto External_select; // テキスト・ウィンドウを表示できなければ外部選択肢にする
223b71206888 Initial import
thib
parents:
diff changeset
754 text->wid->Clear();
223b71206888 Initial import
thib
parents:
diff changeset
755 if (kcursor) kcursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
756 /* ウィジット作成 : テキスト表示範囲と同じ*/
223b71206888 Initial import
thib
parents:
diff changeset
757 int posx = text->wid->pictext->PosX();
223b71206888 Initial import
thib
parents:
diff changeset
758 int posy = text->wid->pictext->PosY();
223b71206888 Initial import
thib
parents:
diff changeset
759 int sel_w = text->wid->pictext->Width();
223b71206888 Initial import
thib
parents:
diff changeset
760 int sel_h = text->wid->pictext->Height();
223b71206888 Initial import
thib
parents:
diff changeset
761 sel_widget = text->wid->PicNode()->create_node(Rect(posx, posy, posx+sel_w, posy+sel_h), 0);
223b71206888 Initial import
thib
parents:
diff changeset
762
223b71206888 Initial import
thib
parents:
diff changeset
763 int sel_y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
764 for (i=0; i<sel_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
765 PicBase* p;
223b71206888 Initial import
thib
parents:
diff changeset
766 /* ボタン作成 */
223b71206888 Initial import
thib
parents:
diff changeset
767 const char* str = cmd.Str(cmd.args[i*2]);
223b71206888 Initial import
thib
parents:
diff changeset
768 int value = cmd.args[i*2+1].value;
223b71206888 Initial import
thib
parents:
diff changeset
769 while(selects.size() <= value) selects.push_back(0); // vector の大きさを広げる
223b71206888 Initial import
thib
parents:
diff changeset
770
223b71206888 Initial import
thib
parents:
diff changeset
771 kconv( (const unsigned char*)str, (unsigned char*)key);
223b71206888 Initial import
thib
parents:
diff changeset
772 selects[value] = new WidTextButton(event, sel_widget, key, mojisize, WidTextButton::Attribute(WidTextButton::REVERSE | WidTextButton::NOPADDING),
223b71206888 Initial import
thib
parents:
diff changeset
773 Rect(0, sel_y, sel_w, sel_y), 1, fore, seled, Color(0,0,0,0));
223b71206888 Initial import
thib
parents:
diff changeset
774 selects[value]->press_func = &PressFuncButton;
223b71206888 Initial import
thib
parents:
diff changeset
775 selects[value]->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
776
223b71206888 Initial import
thib
parents:
diff changeset
777 sel_y += selects[value]->Pic()->Height() + 1;
223b71206888 Initial import
thib
parents:
diff changeset
778 }
223b71206888 Initial import
thib
parents:
diff changeset
779 sel_widget->show_all();
223b71206888 Initial import
thib
parents:
diff changeset
780 status = WAIT_SELECT_INBOX;
223b71206888 Initial import
thib
parents:
diff changeset
781 }
223b71206888 Initial import
thib
parents:
diff changeset
782 }
223b71206888 Initial import
thib
parents:
diff changeset
783
223b71206888 Initial import
thib
parents:
diff changeset
784 void TextImpl::AddText(const char* str_o) {
223b71206888 Initial import
thib
parents:
diff changeset
785 char str[10001];
223b71206888 Initial import
thib
parents:
diff changeset
786 if (text == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
787 /* まず、replace string を変換 */
223b71206888 Initial import
thib
parents:
diff changeset
788 int i;
223b71206888 Initial import
thib
parents:
diff changeset
789 int cnt = 0;
223b71206888 Initial import
thib
parents:
diff changeset
790 /* * = 81 96 A-Z = 0x82 [0x60-0x79] */
223b71206888 Initial import
thib
parents:
diff changeset
791 /* % = 81 93 A-Z = 0x82 [0x60-0x79] */
223b71206888 Initial import
thib
parents:
diff changeset
792 for (i=0; cnt<10000 && str_o[i] != 0; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
793 if (str_o[i] < 0) {
223b71206888 Initial import
thib
parents:
diff changeset
794 if ( (unsigned char)str_o[i] == 0x81 && (unsigned char)str_o[i+1] == 0x96 && (unsigned char)str_o[i+2] == 0x82) {
223b71206888 Initial import
thib
parents:
diff changeset
795 int c = str_o[i+3];
223b71206888 Initial import
thib
parents:
diff changeset
796 if (c >= 0x60 && c <= 0x79 && replace_name[c-0x60].length() != 0) { // 名前変換
223b71206888 Initial import
thib
parents:
diff changeset
797 i += 3;
223b71206888 Initial import
thib
parents:
diff changeset
798 strcpy(str+cnt, replace_name[c-0x60].c_str());
223b71206888 Initial import
thib
parents:
diff changeset
799 cnt += replace_name[c-0x60].length();
223b71206888 Initial import
thib
parents:
diff changeset
800 continue;
223b71206888 Initial import
thib
parents:
diff changeset
801 }
223b71206888 Initial import
thib
parents:
diff changeset
802 } else if ( (unsigned char)str_o[i] == 0x81 && (unsigned char)str_o[i+1] == 0x93 && (unsigned char)str_o[i+2] == 0x82) {
223b71206888 Initial import
thib
parents:
diff changeset
803 int c = str_o[i+3];
223b71206888 Initial import
thib
parents:
diff changeset
804 if (c >= 0x60 && c <= 0x79 && replace_name2[c-0x60].length() != 0) { // 名前変換2
223b71206888 Initial import
thib
parents:
diff changeset
805 i += 3;
223b71206888 Initial import
thib
parents:
diff changeset
806 strcpy(str+cnt, replace_name2[c-0x60].c_str());
223b71206888 Initial import
thib
parents:
diff changeset
807 cnt += replace_name2[c-0x60].length();
223b71206888 Initial import
thib
parents:
diff changeset
808 continue;
223b71206888 Initial import
thib
parents:
diff changeset
809 }
223b71206888 Initial import
thib
parents:
diff changeset
810 }
223b71206888 Initial import
thib
parents:
diff changeset
811 str[cnt++] = str_o[i++];
223b71206888 Initial import
thib
parents:
diff changeset
812 }
223b71206888 Initial import
thib
parents:
diff changeset
813 str[cnt++] = str_o[i];
223b71206888 Initial import
thib
parents:
diff changeset
814 }
223b71206888 Initial import
thib
parents:
diff changeset
815 str[cnt] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
816 str[10000] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
817 char* str_top = str;
223b71206888 Initial import
thib
parents:
diff changeset
818
223b71206888 Initial import
thib
parents:
diff changeset
819 for (char* s = str_top; *s != 0; s++) {
223b71206888 Initial import
thib
parents:
diff changeset
820 // if (*(unsigned char*)s == 0xa1 && *(unsigned char*)(s+1) == 0xda) { /* euc */
223b71206888 Initial import
thib
parents:
diff changeset
821 if (*(unsigned char*)s == 0x81 && *(unsigned char*)(s+1) == 0x79) { /* sjis */
223b71206888 Initial import
thib
parents:
diff changeset
822 // 名前
223b71206888 Initial import
thib
parents:
diff changeset
823 *s = 0;
223b71206888 Initial import
thib
parents:
diff changeset
824 if (s != str_top) text_stream.Add(str_top);
223b71206888 Initial import
thib
parents:
diff changeset
825 s += 2;
223b71206888 Initial import
thib
parents:
diff changeset
826 char* name_top = s;
223b71206888 Initial import
thib
parents:
diff changeset
827 for (; *s != 0; s++) {
223b71206888 Initial import
thib
parents:
diff changeset
828 // if (*(unsigned char*)s == 0xa1 && *(unsigned char*)(s+1) == 0xdb) { /* euc */
223b71206888 Initial import
thib
parents:
diff changeset
829 if (*(unsigned char*)s == 0x81 && *(unsigned char*)(s+1) == 0x7a) { /* sjis */
223b71206888 Initial import
thib
parents:
diff changeset
830 *s = 0;
223b71206888 Initial import
thib
parents:
diff changeset
831 s += 2;
223b71206888 Initial import
thib
parents:
diff changeset
832 text_stream.AddName(name_top);
223b71206888 Initial import
thib
parents:
diff changeset
833 break;
223b71206888 Initial import
thib
parents:
diff changeset
834 }
223b71206888 Initial import
thib
parents:
diff changeset
835 if (*s < 0 && s[1] != 0) s++; // 全角文字なら2字飛ばす
223b71206888 Initial import
thib
parents:
diff changeset
836 }
223b71206888 Initial import
thib
parents:
diff changeset
837 str_top = s;
223b71206888 Initial import
thib
parents:
diff changeset
838 }
223b71206888 Initial import
thib
parents:
diff changeset
839 if (*s == 0x0a) {
223b71206888 Initial import
thib
parents:
diff changeset
840 *s = 0;
223b71206888 Initial import
thib
parents:
diff changeset
841 text_stream.Add(str_top);
223b71206888 Initial import
thib
parents:
diff changeset
842 text_stream.AddReturn();
223b71206888 Initial import
thib
parents:
diff changeset
843 str_top = s;
223b71206888 Initial import
thib
parents:
diff changeset
844 } else if (*s < 0 && s[1] != 0) s++;
223b71206888 Initial import
thib
parents:
diff changeset
845 }
223b71206888 Initial import
thib
parents:
diff changeset
846 text_stream.Add(str_top);
223b71206888 Initial import
thib
parents:
diff changeset
847 return;
223b71206888 Initial import
thib
parents:
diff changeset
848 }
223b71206888 Initial import
thib
parents:
diff changeset
849
223b71206888 Initial import
thib
parents:
diff changeset
850 void TextImpl::Exec(Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
851 if (cmd.cmd_type == CMD_TEXT) {
223b71206888 Initial import
thib
parents:
diff changeset
852 if (text == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
853 show();
223b71206888 Initial import
thib
parents:
diff changeset
854 }
223b71206888 Initial import
thib
parents:
diff changeset
855 if (cmd.args.size() != 1) return;
223b71206888 Initial import
thib
parents:
diff changeset
856 if (ruby_text_flag) {
223b71206888 Initial import
thib
parents:
diff changeset
857 ruby_text = cmd.Str(cmd.args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
858 ruby_text_flag = 0;
223b71206888 Initial import
thib
parents:
diff changeset
859 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
860 return;
223b71206888 Initial import
thib
parents:
diff changeset
861 }
223b71206888 Initial import
thib
parents:
diff changeset
862 cur_backlog_item.AddTextPos(cmd);
223b71206888 Initial import
thib
parents:
diff changeset
863 AddText(cmd.Str(cmd.args[0]));
223b71206888 Initial import
thib
parents:
diff changeset
864 char debug[1024];
223b71206888 Initial import
thib
parents:
diff changeset
865 kconv( (unsigned char*)cmd.Str(cmd.args[0]), (unsigned char*)debug);
223b71206888 Initial import
thib
parents:
diff changeset
866 eprintf("text: %s\n",debug);
223b71206888 Initial import
thib
parents:
diff changeset
867 if (text_parsing)
223b71206888 Initial import
thib
parents:
diff changeset
868 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
869 else
223b71206888 Initial import
thib
parents:
diff changeset
870 cmd.cmd_type = CMD_SAVEPOINT;
223b71206888 Initial import
thib
parents:
diff changeset
871 text_parsing = true; /* テキスト待ち直後のテキスト位置=セーブ位置 */
223b71206888 Initial import
thib
parents:
diff changeset
872 return;
223b71206888 Initial import
thib
parents:
diff changeset
873 }
223b71206888 Initial import
thib
parents:
diff changeset
874 if (cmd.cmd_type != CMD_OTHER) return;
223b71206888 Initial import
thib
parents:
diff changeset
875 /* テキストウィンドウを消去するコマンド類をチェックする */
223b71206888 Initial import
thib
parents:
diff changeset
876 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x21) {
223b71206888 Initial import
thib
parents:
diff changeset
877 if (cmd.cmd3 == 0x49 || cmd.cmd3 == 0x4b || cmd.cmd3 == 0x4c) {
223b71206888 Initial import
thib
parents:
diff changeset
878 if (text) text->ResetFace();
223b71206888 Initial import
thib
parents:
diff changeset
879 cur_backlog_item.face = "";
223b71206888 Initial import
thib
parents:
diff changeset
880 hide();
223b71206888 Initial import
thib
parents:
diff changeset
881 }
223b71206888 Initial import
thib
parents:
diff changeset
882 }
223b71206888 Initial import
thib
parents:
diff changeset
883 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x17 && cmd.cmd3 == 0 && cmd.cmd4 == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
884 // PlayKoe ; 声出力コマンドをチェックする */
223b71206888 Initial import
thib
parents:
diff changeset
885 cur_backlog_item.koe = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
886 }
223b71206888 Initial import
thib
parents:
diff changeset
887 if (cmd.cmd1 == 0 && cmd.cmd2 == 3 && cmd.cmd3 == 0x97) { // いいのかなー
223b71206888 Initial import
thib
parents:
diff changeset
888
223b71206888 Initial import
thib
parents:
diff changeset
889 if (text) {
223b71206888 Initial import
thib
parents:
diff changeset
890 text->ResetFace();
223b71206888 Initial import
thib
parents:
diff changeset
891 text->wid->Clear();
223b71206888 Initial import
thib
parents:
diff changeset
892 }
223b71206888 Initial import
thib
parents:
diff changeset
893 cur_backlog_item.face = "";
223b71206888 Initial import
thib
parents:
diff changeset
894 text_stream.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
895 hide();
223b71206888 Initial import
thib
parents:
diff changeset
896 }
223b71206888 Initial import
thib
parents:
diff changeset
897 if (cmd.cmd1 == 0 && cmd.cmd2 == 3) {
223b71206888 Initial import
thib
parents:
diff changeset
898 if (cmd.cmd3 == 0x11) { // テキスト表示、クリック待ち
223b71206888 Initial import
thib
parents:
diff changeset
899 if (text) {
223b71206888 Initial import
thib
parents:
diff changeset
900 eprintf("start\n");
223b71206888 Initial import
thib
parents:
diff changeset
901 text->StartText(text_stream);
223b71206888 Initial import
thib
parents:
diff changeset
902 if (skip_mode & SKIP_TEXT) text->wid->Flush();
223b71206888 Initial import
thib
parents:
diff changeset
903 else if (kcursor) kcursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
904 status = WAIT_TEXT;
223b71206888 Initial import
thib
parents:
diff changeset
905 text_parsing = false;
223b71206888 Initial import
thib
parents:
diff changeset
906 }
223b71206888 Initial import
thib
parents:
diff changeset
907 backlog_item = cur_backlog_item;
223b71206888 Initial import
thib
parents:
diff changeset
908 if (cur_backlog_item.scn == 0 && cur_backlog_item.pos == -1) backlog_item.text = text_stream;
223b71206888 Initial import
thib
parents:
diff changeset
909 cur_backlog_item.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
910
223b71206888 Initial import
thib
parents:
diff changeset
911 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
912 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため)
223b71206888 Initial import
thib
parents:
diff changeset
913 // これだと1フレーム1テキストしか表示されなくなるので注意
223b71206888 Initial import
thib
parents:
diff changeset
914 } else if (cmd.cmd3 == 3 || cmd.cmd3 == 0xc9) { // リターン挿入
223b71206888 Initial import
thib
parents:
diff changeset
915 text_stream.AddReturn();
223b71206888 Initial import
thib
parents:
diff changeset
916 cur_backlog_item.DeleteTextPos();
223b71206888 Initial import
thib
parents:
diff changeset
917 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
918 } else if (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3e9) { // 顔グラフィック変更
223b71206888 Initial import
thib
parents:
diff changeset
919 if (text == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
920 show();
223b71206888 Initial import
thib
parents:
diff changeset
921 }
223b71206888 Initial import
thib
parents:
diff changeset
922 if (cmd.cmd3 == 0x3e8) {
223b71206888 Initial import
thib
parents:
diff changeset
923 string s = cmd.Str(cmd.args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
924 s += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
925 if (text) text->ShowFace(s.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
926 cur_backlog_item.face = s;
223b71206888 Initial import
thib
parents:
diff changeset
927 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
928 } else if (cmd.cmd3 == 0x3e9) { // 顔グラフィック消去
223b71206888 Initial import
thib
parents:
diff changeset
929 if (text) text->ResetFace();
223b71206888 Initial import
thib
parents:
diff changeset
930 cur_backlog_item.face = "";
223b71206888 Initial import
thib
parents:
diff changeset
931 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
932 }
223b71206888 Initial import
thib
parents:
diff changeset
933 } else if (cmd.cmd3 == 0x78) { // ルビ関連
223b71206888 Initial import
thib
parents:
diff changeset
934 if (text == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
935 show();
223b71206888 Initial import
thib
parents:
diff changeset
936 }
223b71206888 Initial import
thib
parents:
diff changeset
937 if (cmd.cmd4 == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
938 ruby_text_flag = true;
223b71206888 Initial import
thib
parents:
diff changeset
939 eprintf("SetRubyTextImpl.");
223b71206888 Initial import
thib
parents:
diff changeset
940 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
941 } else if (cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
942 if (ruby_text.length() == 0) { // ルビを振るテキストがない
223b71206888 Initial import
thib
parents:
diff changeset
943 eprintf("Cannot find ruby text.\n");
223b71206888 Initial import
thib
parents:
diff changeset
944 return;
223b71206888 Initial import
thib
parents:
diff changeset
945 }
223b71206888 Initial import
thib
parents:
diff changeset
946 if (cmd.args.size() != 1) return;
223b71206888 Initial import
thib
parents:
diff changeset
947 char debug1[1024], debug2[1024];
223b71206888 Initial import
thib
parents:
diff changeset
948 kconv( (unsigned char*)ruby_text.c_str(), (unsigned char*)debug1);
223b71206888 Initial import
thib
parents:
diff changeset
949 kconv( (unsigned char*)cmd.Str(cmd.args[0]), (unsigned char*)debug2);
223b71206888 Initial import
thib
parents:
diff changeset
950 eprintf("SetRuby. %s, %s",debug1, debug2);
223b71206888 Initial import
thib
parents:
diff changeset
951 text_stream.AddRuby(ruby_text.c_str(), cmd.Str(cmd.args[0]));
223b71206888 Initial import
thib
parents:
diff changeset
952 cur_backlog_item.DeleteTextPos();
223b71206888 Initial import
thib
parents:
diff changeset
953 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
954 }
223b71206888 Initial import
thib
parents:
diff changeset
955 } else if (cmd.cmd3 == 0x66) { // テキストウィンドウの形
223b71206888 Initial import
thib
parents:
diff changeset
956 if (cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
957 eprintf("set text window <- %d\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
958 if (text) show(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
959 else text_window_number = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
960 } else if (cmd.cmd4 == 1) { // default value
223b71206888 Initial import
thib
parents:
diff changeset
961 eprintf("set text window <- default\n");
223b71206888 Initial import
thib
parents:
diff changeset
962 if (text) show(0);
223b71206888 Initial import
thib
parents:
diff changeset
963 else text_window_number = 0;
223b71206888 Initial import
thib
parents:
diff changeset
964 }
223b71206888 Initial import
thib
parents:
diff changeset
965 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
966 } else if (cmd.cmd3 == 0x67) { // テキストウィンドウ表示?
223b71206888 Initial import
thib
parents:
diff changeset
967 show();
223b71206888 Initial import
thib
parents:
diff changeset
968 // 表示の際はテキストをクリアしない?
223b71206888 Initial import
thib
parents:
diff changeset
969 // if (text) text->wid->Clear();
223b71206888 Initial import
thib
parents:
diff changeset
970 // text_stream.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
971 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
972 } else if (cmd.cmd3 == 0x68) { // テキスト表示?
223b71206888 Initial import
thib
parents:
diff changeset
973 // 全テキスト表示
223b71206888 Initial import
thib
parents:
diff changeset
974 if (text) {
223b71206888 Initial import
thib
parents:
diff changeset
975 text->StartText(text_stream);
223b71206888 Initial import
thib
parents:
diff changeset
976 text->wid->Flush();
223b71206888 Initial import
thib
parents:
diff changeset
977 }
223b71206888 Initial import
thib
parents:
diff changeset
978 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
979 } else if (cmd.cmd3 == 0x98) { // テキストウィンドウクリア?
223b71206888 Initial import
thib
parents:
diff changeset
980 show();
223b71206888 Initial import
thib
parents:
diff changeset
981 if (text) text->wid->Clear();
223b71206888 Initial import
thib
parents:
diff changeset
982 text_stream.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
983 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
984 }
223b71206888 Initial import
thib
parents:
diff changeset
985 } else if (cmd.cmd1 == 0 && cmd.cmd2 == 2 && (cmd.cmd3 == 1 || cmd.cmd3 == 3) && cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
986 // 選択肢
223b71206888 Initial import
thib
parents:
diff changeset
987 CreateSelect(cmd);
39 988 //FIXME: Check if it's really clean
989 if (text_parsing) {
990 show();
991 text->StartText(text_stream);
992 if (skip_mode & SKIP_TEXT) text->wid->Flush();
993 else if (kcursor) kcursor->hide();
994 text_parsing = false;
995 text_stream.Clear();
996 }
0
223b71206888 Initial import
thib
parents:
diff changeset
997 cmd.cmd_type = CMD_ROLLBACKPOINT; /* 選択肢はセーブ位置 / シナリオ巻き戻し位置 */
223b71206888 Initial import
thib
parents:
diff changeset
998 // cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
999 } else if (cmd.cmd1 == 0 && cmd.cmd2 == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
1000 if (cmd.cmd3 == 0x44c) { // テキストスキップ開始
223b71206888 Initial import
thib
parents:
diff changeset
1001 status_mask = Status(SKIPMASK | status_mask);
223b71206888 Initial import
thib
parents:
diff changeset
1002 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1003 } else if (cmd.cmd3 == 0x3e8) { // ウィンドウ消去
223b71206888 Initial import
thib
parents:
diff changeset
1004 status_mask = Status(CLEARSCR_MASK | status_mask);
223b71206888 Initial import
thib
parents:
diff changeset
1005 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1006 }
223b71206888 Initial import
thib
parents:
diff changeset
1007 } else if (cmd.cmd1 == 1 && cmd.cmd2 == 0x04) {
223b71206888 Initial import
thib
parents:
diff changeset
1008 /* ウェイト関連命令 */
223b71206888 Initial import
thib
parents:
diff changeset
1009 if (cmd.cmd3 == 0x64 || cmd.cmd3 == 0x6f || cmd.cmd3 == 0x79) {
223b71206888 Initial import
thib
parents:
diff changeset
1010 eprintf("wait %dmsec\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1011 if (cmd.cmd3 == 0x64 && text) {
223b71206888 Initial import
thib
parents:
diff changeset
1012 /* 0x64 だと文字描画中の待ちに使うことがある */
223b71206888 Initial import
thib
parents:
diff changeset
1013 text->StartText(text_stream);
223b71206888 Initial import
thib
parents:
diff changeset
1014 text->wid->Flush();
223b71206888 Initial import
thib
parents:
diff changeset
1015 }
223b71206888 Initial import
thib
parents:
diff changeset
1016 if (cmd.cmd3 == 0x6f || cmd.cmd3 == 0x79) wait_time = base_time + cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1017 else wait_time = old_time + cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1018 status = WAIT;
223b71206888 Initial import
thib
parents:
diff changeset
1019 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため)
223b71206888 Initial import
thib
parents:
diff changeset
1020 } else if (cmd.cmd3 == 0x65 || cmd.cmd3 == 0x70) {
223b71206888 Initial import
thib
parents:
diff changeset
1021 eprintf("wait %dmsec(click stop)\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1022 if (cmd.cmd3 == 0x70) wait_time = base_time + cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1023 else wait_time = old_time + cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1024 status = WAIT_CLICK;
223b71206888 Initial import
thib
parents:
diff changeset
1025 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため)
223b71206888 Initial import
thib
parents:
diff changeset
1026 } else if (cmd.cmd3 == 0x83) {
223b71206888 Initial import
thib
parents:
diff changeset
1027 /* マウスがクリックされるまで待つ */
223b71206888 Initial import
thib
parents:
diff changeset
1028 eprintf("wait and get mouse pos at click\n");
223b71206888 Initial import
thib
parents:
diff changeset
1029 wait_time = old_time + 1000 * 1000;
223b71206888 Initial import
thib
parents:
diff changeset
1030 status = WAIT_CLICK_MOUSEPOS;
223b71206888 Initial import
thib
parents:
diff changeset
1031 wait_savedvar[0] = cmd.args[0];
223b71206888 Initial import
thib
parents:
diff changeset
1032 wait_savedvar[1] = cmd.args[1];
223b71206888 Initial import
thib
parents:
diff changeset
1033 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1034 } else if (cmd.cmd3 == 0x1fe) {
223b71206888 Initial import
thib
parents:
diff changeset
1035 eprintf("get timer value[%d]\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1036 if (timer_var.find(cmd.args[0].value) == timer_var.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
1037 cmd.SetSysvar(0);
223b71206888 Initial import
thib
parents:
diff changeset
1038 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1039 TimerAtom& atom = timer_var[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1040 if (atom.total_time <= 0) atom.total_time = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1041 int cur_tm = old_time - atom.start_time;
223b71206888 Initial import
thib
parents:
diff changeset
1042 if (cur_tm < 0) cur_tm = atom.total_time; // エラーなら最終時間に合わせる
223b71206888 Initial import
thib
parents:
diff changeset
1043 if (cur_tm > atom.total_time) cur_tm = atom.total_time;
223b71206888 Initial import
thib
parents:
diff changeset
1044 // use 'long long'(64bit) or 'double'(80bit) type, since total_time, to and from is 32 bit.
223b71206888 Initial import
thib
parents:
diff changeset
1045 int v = atom.from + (long long)(atom.to-atom.from)*cur_tm/int(atom.total_time);
223b71206888 Initial import
thib
parents:
diff changeset
1046 cmd.SetSysvar(v);
223b71206888 Initial import
thib
parents:
diff changeset
1047 }
223b71206888 Initial import
thib
parents:
diff changeset
1048 /* From rldev-1.40, reallive.kfn
223b71206888 Initial import
thib
parents:
diff changeset
1049 0x72 fun Timer (store) <1:Sys:00114, 1> ('counter') ()
223b71206888 Initial import
thib
parents:
diff changeset
1050 0x73 fun CmpTimer (store) <1:Sys:00115, 1> ('time') ('time', 'counter')
223b71206888 Initial import
thib
parents:
diff changeset
1051 0x74 fun SetTimer <1:Sys:00116, 1> ('time') ('time', 'counter')
223b71206888 Initial import
thib
parents:
diff changeset
1052
223b71206888 Initial import
thib
parents:
diff changeset
1053 0x78 fun ResetExTimer <1:Sys:00120, 1> ('counter') ()
223b71206888 Initial import
thib
parents:
diff changeset
1054 0x79 fun timeEx <1:Sys:00121, 1> ('time') ('time', 'counter')
223b71206888 Initial import
thib
parents:
diff changeset
1055 0x7a fun timeExC (store) <1:Sys:00122, 1> ('time') ('time', 'counter')
223b71206888 Initial import
thib
parents:
diff changeset
1056 0x7b fun timeExC2 (store) <1:Sys:00123, 1> ('time') ('time', 'counter') // UNDOCUMENTED
223b71206888 Initial import
thib
parents:
diff changeset
1057 0x7c fun ExTimer (store) <1:Sys:00124, 1> ('counter') ()
223b71206888 Initial import
thib
parents:
diff changeset
1058 0x7d fun CmpExTimer (store) <1:Sys:00125, 1> ('time') ('time', 'counter')
223b71206888 Initial import
thib
parents:
diff changeset
1059 0x7e fun SetExTimer <1:Sys:00126, 1> ('time') ('time', 'counter')
223b71206888 Initial import
thib
parents:
diff changeset
1060 */
223b71206888 Initial import
thib
parents:
diff changeset
1061
223b71206888 Initial import
thib
parents:
diff changeset
1062 } else if (cmd.cmd3 == 0x6e || cmd.cmd3 == 0x78) { // set basetime
223b71206888 Initial import
thib
parents:
diff changeset
1063 if (cmd.cmd4 == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
1064 eprintf("set basetime\n");
223b71206888 Initial import
thib
parents:
diff changeset
1065 base_time = old_time;
223b71206888 Initial import
thib
parents:
diff changeset
1066 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1067 } else if (cmd.cmd4 == 0) { // n-th base time
223b71206888 Initial import
thib
parents:
diff changeset
1068 int index = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1069 eprintf("set basetime (%d)\n",index);
223b71206888 Initial import
thib
parents:
diff changeset
1070 TimerAtom& atom = timer_var[index];
223b71206888 Initial import
thib
parents:
diff changeset
1071 atom.from = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1072 atom.to = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1073 atom.total_time = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1074 atom.start_time = old_time;
223b71206888 Initial import
thib
parents:
diff changeset
1075 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1076 }
223b71206888 Initial import
thib
parents:
diff changeset
1077 } else if (cmd.cmd3 == 0x72 || cmd.cmd3 == 0x7c) { // get time
223b71206888 Initial import
thib
parents:
diff changeset
1078 if (cmd.cmd4 == 1) { // get time
223b71206888 Initial import
thib
parents:
diff changeset
1079 eprintf("get time\n");
223b71206888 Initial import
thib
parents:
diff changeset
1080 cmd.SetSysvar(old_time - base_time);
223b71206888 Initial import
thib
parents:
diff changeset
1081 } else if (cmd.cmd4 == 0) { // n-th get time
223b71206888 Initial import
thib
parents:
diff changeset
1082 int index = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1083 eprintf("get time %dth\n",index);
223b71206888 Initial import
thib
parents:
diff changeset
1084 if (timer_var.find(index) == timer_var.end()) cmd.SetSysvar(0);
223b71206888 Initial import
thib
parents:
diff changeset
1085 else cmd.SetSysvar(old_time - timer_var[index].start_time);
223b71206888 Initial import
thib
parents:
diff changeset
1086 }
223b71206888 Initial import
thib
parents:
diff changeset
1087 } else if (cmd.cmd3 == 0x26c || cmd.cmd3 == 0x270) { // set basetime(multi)
223b71206888 Initial import
thib
parents:
diff changeset
1088 int j = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1089 eprintf("set basetime\n");
223b71206888 Initial import
thib
parents:
diff changeset
1090 int i; for (i=0; i<cmd.argc; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1091 int cnt = cmd.args[j++].value; // 3なので無視
223b71206888 Initial import
thib
parents:
diff changeset
1092 int num = cmd.args[j++].value;
223b71206888 Initial import
thib
parents:
diff changeset
1093 TimerAtom& atom = timer_var[num];
223b71206888 Initial import
thib
parents:
diff changeset
1094 atom.from = cmd.args[j++].value;
223b71206888 Initial import
thib
parents:
diff changeset
1095 atom.to = cmd.args[j++].value;
223b71206888 Initial import
thib
parents:
diff changeset
1096 atom.total_time = cmd.args[j++].value;
223b71206888 Initial import
thib
parents:
diff changeset
1097 atom.start_time = old_time;
223b71206888 Initial import
thib
parents:
diff changeset
1098 }
223b71206888 Initial import
thib
parents:
diff changeset
1099 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1100 } else if (cmd.cmd3 == 0x276) { // get time (multi)
223b71206888 Initial import
thib
parents:
diff changeset
1101 int j = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1102 eprintf("get timer value\n");
223b71206888 Initial import
thib
parents:
diff changeset
1103 vector<VarInfo> args = cmd.args;
223b71206888 Initial import
thib
parents:
diff changeset
1104 vector<VarInfo>::iterator it = args.begin();
223b71206888 Initial import
thib
parents:
diff changeset
1105 int argc = cmd.argc;
223b71206888 Initial import
thib
parents:
diff changeset
1106 int active_timers = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1107 int i; for (i=0; i<argc; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1108 int cnt = (it++)->value;
223b71206888 Initial import
thib
parents:
diff changeset
1109 int num = (it++)->value;
223b71206888 Initial import
thib
parents:
diff changeset
1110
223b71206888 Initial import
thib
parents:
diff changeset
1111 if (timer_var.find(num) == timer_var.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
1112 cmd.SetFlagvar(*it++, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1113 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1114 TimerAtom& atom = timer_var[num];
223b71206888 Initial import
thib
parents:
diff changeset
1115 if (atom.total_time <= 0) atom.total_time = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1116 int cur_tm = old_time - atom.start_time;
223b71206888 Initial import
thib
parents:
diff changeset
1117 if (cur_tm < 0) cur_tm = atom.total_time; // エラーなら最終時間に合わせる
223b71206888 Initial import
thib
parents:
diff changeset
1118 if (cur_tm > atom.total_time) cur_tm = atom.total_time;
223b71206888 Initial import
thib
parents:
diff changeset
1119 // use 'long long'(64bit) or 'double'(80bit) type, since total_time, to and from is 32 bit.
223b71206888 Initial import
thib
parents:
diff changeset
1120 int v = atom.from + (long long)(atom.to-atom.from)*cur_tm/int(atom.total_time);
223b71206888 Initial import
thib
parents:
diff changeset
1121 cmd.SetFlagvar(*it++, v);
223b71206888 Initial import
thib
parents:
diff changeset
1122 if (atom.total_time != -1 && cur_tm < atom.total_time) active_timers++;
223b71206888 Initial import
thib
parents:
diff changeset
1123 }
223b71206888 Initial import
thib
parents:
diff changeset
1124 }
223b71206888 Initial import
thib
parents:
diff changeset
1125 if (active_timers) active_timers = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1126 cmd.SetSysvar(active_timers);
223b71206888 Initial import
thib
parents:
diff changeset
1127 } else if (cmd.cmd3 == 0x1f4) {
223b71206888 Initial import
thib
parents:
diff changeset
1128 TimerAtom& atom = timer_var[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1129 atom.from = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1130 atom.to = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1131 atom.total_time = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1132 atom.start_time = old_time;
223b71206888 Initial import
thib
parents:
diff changeset
1133 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1134 } else if (cmd.cmd3 == 0x3e8) {
223b71206888 Initial import
thib
parents:
diff changeset
1135 /* rand() */
223b71206888 Initial import
thib
parents:
diff changeset
1136 int min = 0, max;
223b71206888 Initial import
thib
parents:
diff changeset
1137 if (cmd.args.size() == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1138 min = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1139 max = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1140 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1141 max = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1142 }
223b71206888 Initial import
thib
parents:
diff changeset
1143 if (min > max) {
223b71206888 Initial import
thib
parents:
diff changeset
1144 int tmp = max;
223b71206888 Initial import
thib
parents:
diff changeset
1145 max = min;
223b71206888 Initial import
thib
parents:
diff changeset
1146 min = tmp;
223b71206888 Initial import
thib
parents:
diff changeset
1147 }
223b71206888 Initial import
thib
parents:
diff changeset
1148 int r = random();
223b71206888 Initial import
thib
parents:
diff changeset
1149 if (min == max) r = min;
223b71206888 Initial import
thib
parents:
diff changeset
1150 else r = (r % (max-min)) + min;
223b71206888 Initial import
thib
parents:
diff changeset
1151 cmd.SetSysvar(r);
223b71206888 Initial import
thib
parents:
diff changeset
1152 } else if (cmd.cmd3 == 0x3ea) {
223b71206888 Initial import
thib
parents:
diff changeset
1153 int val = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1154 if (val < 0) val = -val;
223b71206888 Initial import
thib
parents:
diff changeset
1155 cmd.SetSysvar(val);
223b71206888 Initial import
thib
parents:
diff changeset
1156 } else if (cmd.cmd3 == 0x3ec) {
223b71206888 Initial import
thib
parents:
diff changeset
1157 /* min だよなあ・・・*/
223b71206888 Initial import
thib
parents:
diff changeset
1158 int min = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1159 int max = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1160 if (max < min) min = max;
223b71206888 Initial import
thib
parents:
diff changeset
1161 cmd.SetSysvar(min);
223b71206888 Initial import
thib
parents:
diff changeset
1162 } else if (cmd.cmd3 == 0x3ef) {
223b71206888 Initial import
thib
parents:
diff changeset
1163 /* min */
223b71206888 Initial import
thib
parents:
diff changeset
1164 int min = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1165 int max = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1166 if (max < min) min = max;
223b71206888 Initial import
thib
parents:
diff changeset
1167 cmd.SetSysvar(min);
223b71206888 Initial import
thib
parents:
diff changeset
1168 } else if (cmd.cmd3 == 0x320) {
223b71206888 Initial import
thib
parents:
diff changeset
1169 /* range conversion : 比率に丸める */
223b71206888 Initial import
thib
parents:
diff changeset
1170 // アルゴリズムは間違えてるような気がする
223b71206888 Initial import
thib
parents:
diff changeset
1171 //
223b71206888 Initial import
thib
parents:
diff changeset
1172 if (cmd.args.size() >= 7) {
223b71206888 Initial import
thib
parents:
diff changeset
1173 int val = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1174 int offset = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1175 int r_min = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1176 int v_min = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1177 int v_max = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1178 int r_max = cmd.args[5].value;
223b71206888 Initial import
thib
parents:
diff changeset
1179 int mode = cmd.args[6].value;
223b71206888 Initial import
thib
parents:
diff changeset
1180 // rldev : mode == 1,3 : 'acceralating curve', 2,3: 'decelerating curve'
223b71206888 Initial import
thib
parents:
diff changeset
1181 // 複数の引数リスト(r_minからmodeまでのリスト)もつこともあり、その場合は
223b71206888 Initial import
thib
parents:
diff changeset
1182 // "cancel out in some way" らしい
223b71206888 Initial import
thib
parents:
diff changeset
1183 if (mode == 1 || mode == 3) val += offset;
223b71206888 Initial import
thib
parents:
diff changeset
1184 else if (mode == 2 || mode == 4) val -= offset;
223b71206888 Initial import
thib
parents:
diff changeset
1185 if (cmd.args.size() != 7)
223b71206888 Initial import
thib
parents:
diff changeset
1186 fprintf(stderr,"\n%d/%d: cmd 01-04:0320 : XXXX NOT SUPPORTED LIST : DOUBLE RANGE CONVERSION! XXXXXXXXXXX\n",cmd.scn,cmd.pos);
223b71206888 Initial import
thib
parents:
diff changeset
1187 if (val < v_min) val = v_min;
223b71206888 Initial import
thib
parents:
diff changeset
1188 if (val > v_max) val = v_max;
223b71206888 Initial import
thib
parents:
diff changeset
1189 val = (r_max-r_min)*(val-v_min)/(v_max-v_min) + r_min;
223b71206888 Initial import
thib
parents:
diff changeset
1190 cmd.SetSysvar(val);
223b71206888 Initial import
thib
parents:
diff changeset
1191 }
223b71206888 Initial import
thib
parents:
diff changeset
1192 } else if (cmd.cmd3 == 0x3f1) {
223b71206888 Initial import
thib
parents:
diff changeset
1193 /* range 内に丸める */
223b71206888 Initial import
thib
parents:
diff changeset
1194 int min = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1195 int val = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1196 int max = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1197 if (min > max) {
223b71206888 Initial import
thib
parents:
diff changeset
1198 int tmp = max;
223b71206888 Initial import
thib
parents:
diff changeset
1199 max = min;
223b71206888 Initial import
thib
parents:
diff changeset
1200 min = tmp;
223b71206888 Initial import
thib
parents:
diff changeset
1201 }
223b71206888 Initial import
thib
parents:
diff changeset
1202 if (val < min) val = min;
223b71206888 Initial import
thib
parents:
diff changeset
1203 if (val > max) val = max;
223b71206888 Initial import
thib
parents:
diff changeset
1204 cmd.SetSysvar(val);
223b71206888 Initial import
thib
parents:
diff changeset
1205 } else if (cmd.cmd3 == 0x16c && cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1206 /* なんかよくわからないけどカーソル形状変更にしとく */
223b71206888 Initial import
thib
parents:
diff changeset
1207 SetCursor(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1208 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1209 } else if (cmd.cmd3 == 0x0bc1) { // メニューからのロード
223b71206888 Initial import
thib
parents:
diff changeset
1210 cmd.cmd_type = CMD_LOADREQ;
223b71206888 Initial import
thib
parents:
diff changeset
1211 } else if ( (cmd.cmd3 >= 0x8d4 && cmd.cmd3 <= 0x8d8) || cmd.cmd3 == 0x8db || cmd.cmd3 == 0x93f || cmd.cmd3 == 0xa39) {
223b71206888 Initial import
thib
parents:
diff changeset
1212 // テキストウィンドウの色設定
223b71206888 Initial import
thib
parents:
diff changeset
1213 int r, g, b, a, flag;
223b71206888 Initial import
thib
parents:
diff changeset
1214 if (cmd.cmd3 == 0xa39) { // 元設定を取り出す
223b71206888 Initial import
thib
parents:
diff changeset
1215 config.GetOriginalParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag);
223b71206888 Initial import
thib
parents:
diff changeset
1216 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1217 config.GetParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag);
223b71206888 Initial import
thib
parents:
diff changeset
1218 }
223b71206888 Initial import
thib
parents:
diff changeset
1219 if (cmd.cmd3 == 0xa39 || cmd.cmd3 == 0x93f) { // 設定を変数に取り出す
223b71206888 Initial import
thib
parents:
diff changeset
1220 if (cmd.args.size() != 5) {
223b71206888 Initial import
thib
parents:
diff changeset
1221 fprintf(stderr,"cmd 01-04:%4d : invalid arg size\n", cmd.cmd3);
223b71206888 Initial import
thib
parents:
diff changeset
1222 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1223 vector<VarInfo> args(cmd.args);
223b71206888 Initial import
thib
parents:
diff changeset
1224 cmd.SetFlagvar(args[0], r);
223b71206888 Initial import
thib
parents:
diff changeset
1225 cmd.SetFlagvar(args[1], g);
223b71206888 Initial import
thib
parents:
diff changeset
1226 cmd.SetFlagvar(args[2], b);
223b71206888 Initial import
thib
parents:
diff changeset
1227 cmd.SetFlagvar(args[3], a);
223b71206888 Initial import
thib
parents:
diff changeset
1228 cmd.SetFlagvar(args[4], flag);
223b71206888 Initial import
thib
parents:
diff changeset
1229 }
223b71206888 Initial import
thib
parents:
diff changeset
1230 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1231 switch(cmd.cmd3) {
223b71206888 Initial import
thib
parents:
diff changeset
1232 case 0x8d4: r = cmd.args[0].value; break;
223b71206888 Initial import
thib
parents:
diff changeset
1233 case 0x8d5: g = cmd.args[0].value; break;
223b71206888 Initial import
thib
parents:
diff changeset
1234 case 0x8d6: b = cmd.args[0].value; break;
223b71206888 Initial import
thib
parents:
diff changeset
1235 case 0x8d7: a = cmd.args[0].value; break;
223b71206888 Initial import
thib
parents:
diff changeset
1236 case 0x8d8: flag = cmd.args[0].value; break;
223b71206888 Initial import
thib
parents:
diff changeset
1237 case 0x8db:
223b71206888 Initial import
thib
parents:
diff changeset
1238 r = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1239 g = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1240 b = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1241 a = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1242 flag = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1243 break;
223b71206888 Initial import
thib
parents:
diff changeset
1244 }
223b71206888 Initial import
thib
parents:
diff changeset
1245 config.SetParam("#WINDOW_ATTR", 5, r, g, b, a, flag);
223b71206888 Initial import
thib
parents:
diff changeset
1246 SetWindowColor(r, g, b, a, flag);
223b71206888 Initial import
thib
parents:
diff changeset
1247 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1248 }
223b71206888 Initial import
thib
parents:
diff changeset
1249 } else if (cmd.cmd3 == 0xa28 || cmd.cmd3 == 0xa29 || cmd.cmd3 == 0xa2c || cmd.cmd3 == 0xa2d || cmd.cmd3 == 0xa2e) {
223b71206888 Initial import
thib
parents:
diff changeset
1250 int v = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1251 switch(cmd.cmd3) {
223b71206888 Initial import
thib
parents:
diff changeset
1252 case 0xa28: case 0xa2d: config.GetOriginalParam("#INIT_MESSAGE_SPEED", 1, &v); break;
223b71206888 Initial import
thib
parents:
diff changeset
1253 case 0xa29: config.GetOriginalParam("#INIT_MESSAGE_SPEED_MOD", 1, &v); break;
223b71206888 Initial import
thib
parents:
diff changeset
1254 case 0xa2c: config.GetOriginalParam("#MESSAGE_KEY_WAIT_USE", 1, &v); break;
223b71206888 Initial import
thib
parents:
diff changeset
1255 case 0xa2e: config.GetOriginalParam("#MESSAGE_KEY_WAIT_TIME", 1, &v); break;
223b71206888 Initial import
thib
parents:
diff changeset
1256 }
223b71206888 Initial import
thib
parents:
diff changeset
1257 cmd.SetSysvar(v);
223b71206888 Initial import
thib
parents:
diff changeset
1258 } else if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x914 || cmd.cmd3 == 0x92f || cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8b0 || cmd.cmd3 == 0x8cb) {
223b71206888 Initial import
thib
parents:
diff changeset
1259 // テキスト表示速度関連
223b71206888 Initial import
thib
parents:
diff changeset
1260 int m, speed;
223b71206888 Initial import
thib
parents:
diff changeset
1261 config.GetParam("#INIT_MESSAGE_SPEED", 1, &speed);
223b71206888 Initial import
thib
parents:
diff changeset
1262 config.GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &m);
223b71206888 Initial import
thib
parents:
diff changeset
1263 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) fprintf(stderr,"TEXT speed %d\n",speed);
223b71206888 Initial import
thib
parents:
diff changeset
1264 else if (cmd.cmd3 == 0x914) fprintf(stderr,"TEXT mode %d\n",m);
223b71206888 Initial import
thib
parents:
diff changeset
1265 else if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) fprintf(stderr,"TEXT %d, %d <- speed %d\n",m,speed,cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1266 else fprintf(stderr,"TEXT %d, %d <- mode %d\n",m,speed,cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1267 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) cmd.SetSysvar(speed);
223b71206888 Initial import
thib
parents:
diff changeset
1268 else if (cmd.cmd3 == 0x914) cmd.SetSysvar(m);
223b71206888 Initial import
thib
parents:
diff changeset
1269 else {
223b71206888 Initial import
thib
parents:
diff changeset
1270 if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) speed = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1271 else m = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1272 if (speed < 10) speed = 10;
223b71206888 Initial import
thib
parents:
diff changeset
1273 else if (speed > 1000) speed = 1000;
223b71206888 Initial import
thib
parents:
diff changeset
1274 config.SetParam("#INIT_MESSAGE_SPEED", 1, speed);
223b71206888 Initial import
thib
parents:
diff changeset
1275 config.SetParam("#INIT_MESSAGE_SPEED_MOD", 1, m);
223b71206888 Initial import
thib
parents:
diff changeset
1276 if (m) speed = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1277 SetTextSpeed(speed);
223b71206888 Initial import
thib
parents:
diff changeset
1278 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1279 }
223b71206888 Initial import
thib
parents:
diff changeset
1280 } else if (cmd.cmd3 == 0x92e || cmd.cmd3 == 0x930 || cmd.cmd3 == 0x8ca || cmd.cmd3 == 0x8cc) {
223b71206888 Initial import
thib
parents:
diff changeset
1281 // テキストオートモード関連
223b71206888 Initial import
thib
parents:
diff changeset
1282 int m, wait;
223b71206888 Initial import
thib
parents:
diff changeset
1283 config.GetParam("#MESSAGE_KEY_WAIT_USE", 1, &m);
223b71206888 Initial import
thib
parents:
diff changeset
1284 config.GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait);
223b71206888 Initial import
thib
parents:
diff changeset
1285 if (cmd.cmd3 == 0x92e) fprintf(stderr,"AUTO mode %d\n",m);
223b71206888 Initial import
thib
parents:
diff changeset
1286 else if (cmd.cmd3 == 0x930) fprintf(stderr,"AUTO wait %d\n",wait);
223b71206888 Initial import
thib
parents:
diff changeset
1287 else if (cmd.cmd3 == 0x8ca) fprintf(stderr,"AUTO %d,%d <- mode %d\n",m,wait,cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1288 else fprintf(stderr,"AUTO %d,%d <- wait %d\n",m,wait,cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1289
223b71206888 Initial import
thib
parents:
diff changeset
1290 if (cmd.cmd3 == 0x92e) cmd.SetSysvar(m);
223b71206888 Initial import
thib
parents:
diff changeset
1291 else if (cmd.cmd3 == 0x930) cmd.SetSysvar(wait);
223b71206888 Initial import
thib
parents:
diff changeset
1292 else {
223b71206888 Initial import
thib
parents:
diff changeset
1293 if (cmd.cmd3 == 0x8ca) m = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1294 else wait = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1295 if (wait < 0) wait = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1296 else if (wait > 60000) wait = 60000;
223b71206888 Initial import
thib
parents:
diff changeset
1297 config.SetParam("#MESSAGE_KEY_WAIT_USE", 1, m);
223b71206888 Initial import
thib
parents:
diff changeset
1298 config.SetParam("#MESSAGE_KEY_WAIT_TIME", 1, wait);
223b71206888 Initial import
thib
parents:
diff changeset
1299 if (m) SetTextWait(wait);
223b71206888 Initial import
thib
parents:
diff changeset
1300 else SetTextWait(-1);
223b71206888 Initial import
thib
parents:
diff changeset
1301 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1302 }
223b71206888 Initial import
thib
parents:
diff changeset
1303 } else if (cmd.cmd3 == 0x51f && cmd.cmd4 == 0) { // replace_name2 の設定
223b71206888 Initial import
thib
parents:
diff changeset
1304 int n = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1305 if (n>=0 && n<26) {
223b71206888 Initial import
thib
parents:
diff changeset
1306 replace_name2[n] = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1307 }
223b71206888 Initial import
thib
parents:
diff changeset
1308 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1309 } else if (cmd.cmd3 == 0x51e && cmd.cmd4 == 0) { // replace_name2 を得る
223b71206888 Initial import
thib
parents:
diff changeset
1310 int n = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1311 if (n >= 0 && n < 26) {
223b71206888 Initial import
thib
parents:
diff changeset
1312 cmd.SetStrvar(cmd.args[1], replace_name2[n]);
223b71206888 Initial import
thib
parents:
diff changeset
1313 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1314 cmd.SetStrvar(cmd.args[1], "");
223b71206888 Initial import
thib
parents:
diff changeset
1315 }
223b71206888 Initial import
thib
parents:
diff changeset
1316 } else if (cmd.cmd3 == 0x514 && cmd.cmd4 == 0) { // replace_name を得る
223b71206888 Initial import
thib
parents:
diff changeset
1317 int n = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1318 if (n >= 0 && n < 26) {
223b71206888 Initial import
thib
parents:
diff changeset
1319 cmd.SetStrvar(cmd.args[1], replace_name[n]);
223b71206888 Initial import
thib
parents:
diff changeset
1320 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1321 cmd.SetStrvar(cmd.args[1], "");
223b71206888 Initial import
thib
parents:
diff changeset
1322 }
223b71206888 Initial import
thib
parents:
diff changeset
1323 }
223b71206888 Initial import
thib
parents:
diff changeset
1324 }
223b71206888 Initial import
thib
parents:
diff changeset
1325
223b71206888 Initial import
thib
parents:
diff changeset
1326 return;
223b71206888 Initial import
thib
parents:
diff changeset
1327 }
223b71206888 Initial import
thib
parents:
diff changeset
1328 extern int print_blit;
223b71206888 Initial import
thib
parents:
diff changeset
1329 bool TextImpl::Wait(unsigned int current_time, Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
1330 if (current_time != 0xffffffffUL) old_time = current_time;
223b71206888 Initial import
thib
parents:
diff changeset
1331 /*
223b71206888 Initial import
thib
parents:
diff changeset
1332 if (event.presscount(MOUSE_UP)) {
223b71206888 Initial import
thib
parents:
diff changeset
1333 if (text) text->Pic()->ReBlit();
223b71206888 Initial import
thib
parents:
diff changeset
1334 }
223b71206888 Initial import
thib
parents:
diff changeset
1335 if (event.presscount(MOUSE_DOWN)) {
223b71206888 Initial import
thib
parents:
diff changeset
1336 print_blit^=1;
223b71206888 Initial import
thib
parents:
diff changeset
1337 }
223b71206888 Initial import
thib
parents:
diff changeset
1338 */
223b71206888 Initial import
thib
parents:
diff changeset
1339
223b71206888 Initial import
thib
parents:
diff changeset
1340 if (status == NORMAL && status_mask == NORMAL) return false;
223b71206888 Initial import
thib
parents:
diff changeset
1341
223b71206888 Initial import
thib
parents:
diff changeset
1342 if (status_mask & WAIT_EXTRN_MASK) return true;
223b71206888 Initial import
thib
parents:
diff changeset
1343 if (status_mask & (BACKLOG_MASK|BACKLOG_MASK_FWD) ) {
223b71206888 Initial import
thib
parents:
diff changeset
1344 if (status_mask & BACKLOG_WAIT_MASK) ;
223b71206888 Initial import
thib
parents:
diff changeset
1345 else {
223b71206888 Initial import
thib
parents:
diff changeset
1346 if ( (status == WAIT_TEXT && text != 0) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) {
223b71206888 Initial import
thib
parents:
diff changeset
1347 if(text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) {
223b71206888 Initial import
thib
parents:
diff changeset
1348 text->wid->Flush(); // 表示を最後の状態にする
223b71206888 Initial import
thib
parents:
diff changeset
1349 }
223b71206888 Initial import
thib
parents:
diff changeset
1350 if (status == WAIT_TEXT && text != 0 && kcursor) kcursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
1351 }
223b71206888 Initial import
thib
parents:
diff changeset
1352 }
223b71206888 Initial import
thib
parents:
diff changeset
1353 if (status_mask & BACKLOG_MASK) {
223b71206888 Initial import
thib
parents:
diff changeset
1354 cmd.cmd_type = CMD_BACKLOGREQ;
223b71206888 Initial import
thib
parents:
diff changeset
1355 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1356 cmd.cmd_type = CMD_BACKLOGREQ_FWD;
223b71206888 Initial import
thib
parents:
diff changeset
1357 }
223b71206888 Initial import
thib
parents:
diff changeset
1358 status_mask = Status(status_mask & ~(BACKLOG_MASK|BACKLOG_MASK_FWD));
223b71206888 Initial import
thib
parents:
diff changeset
1359 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1360 }
223b71206888 Initial import
thib
parents:
diff changeset
1361 if ( (status_mask & BACKLOG_WAIT_MASK) && (status_mask & BACKLOG_MASK_KOE)) {
223b71206888 Initial import
thib
parents:
diff changeset
1362 if (drawn_backlog_item.koe != -1) {
223b71206888 Initial import
thib
parents:
diff changeset
1363 cmd.cmd_type = CMD_OTHER;
223b71206888 Initial import
thib
parents:
diff changeset
1364 cmd.cmd1 = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1365 cmd.cmd2 = 0x17;
223b71206888 Initial import
thib
parents:
diff changeset
1366 cmd.cmd3 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1367 cmd.cmd4 = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1368 cmd.args.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1369 cmd.args.push_back(VarInfo(drawn_backlog_item.koe));
223b71206888 Initial import
thib
parents:
diff changeset
1370 cmd.args.push_back(VarInfo(0));
223b71206888 Initial import
thib
parents:
diff changeset
1371 }
223b71206888 Initial import
thib
parents:
diff changeset
1372 status_mask = Status(status_mask & ~BACKLOG_MASK_KOE);
223b71206888 Initial import
thib
parents:
diff changeset
1373 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1374 }
223b71206888 Initial import
thib
parents:
diff changeset
1375 if (skip_mode & SKIP_IN_MENU) return false;
223b71206888 Initial import
thib
parents:
diff changeset
1376 if (status_mask & SAVEMASK) {
223b71206888 Initial import
thib
parents:
diff changeset
1377 cmd.cmd_type = CMD_SAVEREQ;
223b71206888 Initial import
thib
parents:
diff changeset
1378 status_mask = Status(status_mask & ~SAVEMASK);
223b71206888 Initial import
thib
parents:
diff changeset
1379 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1380 }
223b71206888 Initial import
thib
parents:
diff changeset
1381 if (status_mask & LOADMASK) {
223b71206888 Initial import
thib
parents:
diff changeset
1382 cmd.cmd_type = CMD_LOADREQ;
223b71206888 Initial import
thib
parents:
diff changeset
1383 status_mask = Status(status_mask & ~LOADMASK);
223b71206888 Initial import
thib
parents:
diff changeset
1384 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1385 }
223b71206888 Initial import
thib
parents:
diff changeset
1386 if (status_mask & SKIPEND_MASK) {
223b71206888 Initial import
thib
parents:
diff changeset
1387 if ( (skip_mode & SKIP_TEXT) && (skip_mode & SKIPEND_TEXT)) {
223b71206888 Initial import
thib
parents:
diff changeset
1388 if (skip_mode & SKIPEND_KEY) { // shift skip 中
223b71206888 Initial import
thib
parents:
diff changeset
1389 SkipMode new_mode = SkipMode(skip_mode & (~SKIPEND_TEXT));
223b71206888 Initial import
thib
parents:
diff changeset
1390 if (new_mode & (SKIP_GRP_NOEFFEC || SKIP_GRP_NODRAW))
223b71206888 Initial import
thib
parents:
diff changeset
1391 new_mode = SkipMode(new_mode & (~SKIP_GRP_FAST));
223b71206888 Initial import
thib
parents:
diff changeset
1392 cmd.SetSysvar(TYPE_SYS_SKIPMODE, new_mode);
223b71206888 Initial import
thib
parents:
diff changeset
1393 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1394 cmd.SetSysvar(TYPE_SYS_SKIPMODE, SKIP_NO);
223b71206888 Initial import
thib
parents:
diff changeset
1395 }
223b71206888 Initial import
thib
parents:
diff changeset
1396 }
223b71206888 Initial import
thib
parents:
diff changeset
1397 status_mask = Status(status_mask & ~SKIPEND_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1398 }
223b71206888 Initial import
thib
parents:
diff changeset
1399 if (status_mask & SKIPMASK) {
223b71206888 Initial import
thib
parents:
diff changeset
1400 if (skip_mode != SKIP_NO) {
223b71206888 Initial import
thib
parents:
diff changeset
1401 cmd.SetSysvar(TYPE_SYS_SKIPMODE, skip_mode | SKIPEND_TEXT);
223b71206888 Initial import
thib
parents:
diff changeset
1402 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1403 cmd.SetSysvar(TYPE_SYS_SKIPMODE, SKIP_TEXT | SKIP_GRP_FAST | SKIPEND_TEXT);
223b71206888 Initial import
thib
parents:
diff changeset
1404 }
223b71206888 Initial import
thib
parents:
diff changeset
1405 status_mask = Status(status_mask & ~SKIPMASK);
223b71206888 Initial import
thib
parents:
diff changeset
1406 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1407 }
223b71206888 Initial import
thib
parents:
diff changeset
1408 if (event.presscount(MOUSE_RIGHT)) {
223b71206888 Initial import
thib
parents:
diff changeset
1409 if ( (status == WAIT_TEXT && text != 0) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) {
223b71206888 Initial import
thib
parents:
diff changeset
1410 if(text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) {
223b71206888 Initial import
thib
parents:
diff changeset
1411 text->wid->Flush(); // 表示を最後の状態にする
223b71206888 Initial import
thib
parents:
diff changeset
1412 }
223b71206888 Initial import
thib
parents:
diff changeset
1413 cmd.cmd_type = CMD_MENUREQ;
223b71206888 Initial import
thib
parents:
diff changeset
1414 if (!(status_mask & STATSAVE_MASK)) {
223b71206888 Initial import
thib
parents:
diff changeset
1415 status_saved = status;
223b71206888 Initial import
thib
parents:
diff changeset
1416 status_mask = Status(status_mask | STATSAVE_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1417 }
223b71206888 Initial import
thib
parents:
diff changeset
1418 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1419 } else if (status == WAIT_CLICK_MOUSEPOS) {
223b71206888 Initial import
thib
parents:
diff changeset
1420 status = WAIT_CLICK_MOUSEPOSEND_R;
223b71206888 Initial import
thib
parents:
diff changeset
1421 }
223b71206888 Initial import
thib
parents:
diff changeset
1422 }
223b71206888 Initial import
thib
parents:
diff changeset
1423 if (event.presscount(MOUSE_UP)) {
223b71206888 Initial import
thib
parents:
diff changeset
1424 if ( (status == WAIT_TEXT && text != 0) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) {
223b71206888 Initial import
thib
parents:
diff changeset
1425 if(text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) {
223b71206888 Initial import
thib
parents:
diff changeset
1426 text->wid->Flush(); // 表示を最後の状態にする
223b71206888 Initial import
thib
parents:
diff changeset
1427 }
223b71206888 Initial import
thib
parents:
diff changeset
1428 cmd.cmd_type = CMD_BACKLOGREQ;
223b71206888 Initial import
thib
parents:
diff changeset
1429 if (!(status_mask & STATSAVE_MASK)) {
223b71206888 Initial import
thib
parents:
diff changeset
1430 status_saved = status;
223b71206888 Initial import
thib
parents:
diff changeset
1431 status_mask = Status(status_mask | STATSAVE_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1432 }
223b71206888 Initial import
thib
parents:
diff changeset
1433 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1434 }
223b71206888 Initial import
thib
parents:
diff changeset
1435 }
223b71206888 Initial import
thib
parents:
diff changeset
1436 if (status_mask & CLEARSCR_MASK) {
223b71206888 Initial import
thib
parents:
diff changeset
1437 if ( (status == WAIT_TEXT && text != 0 ) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) {
223b71206888 Initial import
thib
parents:
diff changeset
1438 if (skip_mode) skip_mode = SKIP_NO;
223b71206888 Initial import
thib
parents:
diff changeset
1439 if (text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) {
223b71206888 Initial import
thib
parents:
diff changeset
1440 text->wid->Flush(); // 表示を最後の状態にする
223b71206888 Initial import
thib
parents:
diff changeset
1441 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1442 }
223b71206888 Initial import
thib
parents:
diff changeset
1443 status_mask = Status(status_mask & (~CLEARSCR_MASK) | CLEARSCR_WAIT_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1444 if (text) text->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1445 if (kcursor) kcursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1446 if (sel_widget) sel_widget->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1447 if (backlog_widget) backlog_widget->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1448 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1449 }
223b71206888 Initial import
thib
parents:
diff changeset
1450 status_mask = Status(status_mask & (~CLEARSCR_MASK));
223b71206888 Initial import
thib
parents:
diff changeset
1451 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1452 }
223b71206888 Initial import
thib
parents:
diff changeset
1453 if (status_mask & CLEARSCR_WAIT_MASK) {
223b71206888 Initial import
thib
parents:
diff changeset
1454 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1455 }
223b71206888 Initial import
thib
parents:
diff changeset
1456 if (status == WAIT_TEXT) {
223b71206888 Initial import
thib
parents:
diff changeset
1457 if (text == 0) { status = NORMAL; return false;}
223b71206888 Initial import
thib
parents:
diff changeset
1458 if (skip_mode & SKIP_TEXT) {
223b71206888 Initial import
thib
parents:
diff changeset
1459 } else if (text->wid->status != WidText::PREPARE) {
223b71206888 Initial import
thib
parents:
diff changeset
1460 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1461 }
223b71206888 Initial import
thib
parents:
diff changeset
1462 if (kcursor) kcursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1463 text_stream.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
1464 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1465 cmd.cmd_type = CMD_TEXTEND;
223b71206888 Initial import
thib
parents:
diff changeset
1466 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1467 }
223b71206888 Initial import
thib
parents:
diff changeset
1468 if (status == WAIT) {
223b71206888 Initial import
thib
parents:
diff changeset
1469 if (skip_mode & SKIP_TEXT) ;
223b71206888 Initial import
thib
parents:
diff changeset
1470 else if (wait_time > current_time) return true;
223b71206888 Initial import
thib
parents:
diff changeset
1471 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1472 } else if (status == WAIT_CLICK) {
223b71206888 Initial import
thib
parents:
diff changeset
1473 if (skip_mode & SKIP_TEXT) ;
223b71206888 Initial import
thib
parents:
diff changeset
1474 else if (wait_time > current_time) return true;
223b71206888 Initial import
thib
parents:
diff changeset
1475 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1476 cmd.SetSysvar(0);
223b71206888 Initial import
thib
parents:
diff changeset
1477 } else if (status == WAIT_ABORT) {
223b71206888 Initial import
thib
parents:
diff changeset
1478 cmd.SetSysvar(1);
223b71206888 Initial import
thib
parents:
diff changeset
1479 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1480 } else if (status == WAIT_CLICK_MOUSEPOS || status == WAIT_CLICK_MOUSEPOSEND_L || status == WAIT_CLICK_MOUSEPOSEND_R) {
223b71206888 Initial import
thib
parents:
diff changeset
1481 if (status == WAIT_CLICK_MOUSEPOS && (skip_mode & SKIP_TEXT) == 0) return true; // keep wait
223b71206888 Initial import
thib
parents:
diff changeset
1482 else {
223b71206888 Initial import
thib
parents:
diff changeset
1483 int x, y;
223b71206888 Initial import
thib
parents:
diff changeset
1484 event.MousePos(x,y);
223b71206888 Initial import
thib
parents:
diff changeset
1485 if (status == WAIT_CLICK_MOUSEPOS) x = y = 0; // skip mode
223b71206888 Initial import
thib
parents:
diff changeset
1486 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1487 cmd.SetFlagvar(wait_savedvar[0], x);
223b71206888 Initial import
thib
parents:
diff changeset
1488 cmd.SetFlagvar(wait_savedvar[1], y);
223b71206888 Initial import
thib
parents:
diff changeset
1489 if (status == WAIT_CLICK_MOUSEPOSEND_R) cmd.SetSysvar(-1);
223b71206888 Initial import
thib
parents:
diff changeset
1490 else cmd.SetSysvar(0);
223b71206888 Initial import
thib
parents:
diff changeset
1491 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1492 }
223b71206888 Initial import
thib
parents:
diff changeset
1493 } else if (status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) {
223b71206888 Initial import
thib
parents:
diff changeset
1494 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1495 } else if ( int(status) >= WAIT_SELECT_VALUE) {
223b71206888 Initial import
thib
parents:
diff changeset
1496 int sel_val = int(status) - WAIT_SELECT_VALUE;
223b71206888 Initial import
thib
parents:
diff changeset
1497 cmd.SetSysvar(sel_val);
223b71206888 Initial import
thib
parents:
diff changeset
1498 selects.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1499 delete sel_widget;
223b71206888 Initial import
thib
parents:
diff changeset
1500 sel_widget = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1501 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1502 // CreateSelect() で作成された cur_backlog_item を backlog_item へ反映させる
223b71206888 Initial import
thib
parents:
diff changeset
1503 cur_backlog_item.text.InsertColor(sel_backlog_pos[sel_val], sel_backlog_pos[sel_val+1], 0xff, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1504 backlog_item = cur_backlog_item;
223b71206888 Initial import
thib
parents:
diff changeset
1505 cur_backlog_item.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
1506 }
223b71206888 Initial import
thib
parents:
diff changeset
1507 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1508 }
223b71206888 Initial import
thib
parents:
diff changeset
1509
223b71206888 Initial import
thib
parents:
diff changeset
1510 void clearbtn_press(void* pointer, WidButton* button) {
223b71206888 Initial import
thib
parents:
diff changeset
1511 if (pointer == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1512 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1513 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::CLEARSCR_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1514 return;
223b71206888 Initial import
thib
parents:
diff changeset
1515 }
223b71206888 Initial import
thib
parents:
diff changeset
1516 void TextImpl::PressFuncSkip(void* pointer, WidButton* from) {
223b71206888 Initial import
thib
parents:
diff changeset
1517 if (pointer == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1518 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1519 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::SKIPMASK);
223b71206888 Initial import
thib
parents:
diff changeset
1520 return;
223b71206888 Initial import
thib
parents:
diff changeset
1521 }
223b71206888 Initial import
thib
parents:
diff changeset
1522 void TextImpl::PressFuncLoad(void* pointer, WidButton* from) {
223b71206888 Initial import
thib
parents:
diff changeset
1523 if (pointer == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1524 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1525 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::LOADMASK);
223b71206888 Initial import
thib
parents:
diff changeset
1526 return;
223b71206888 Initial import
thib
parents:
diff changeset
1527 }
223b71206888 Initial import
thib
parents:
diff changeset
1528 void TextImpl::PressFuncSave(void* pointer, WidButton* from) {
223b71206888 Initial import
thib
parents:
diff changeset
1529 if (pointer == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1530 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1531 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::SAVEMASK);
223b71206888 Initial import
thib
parents:
diff changeset
1532 return;
223b71206888 Initial import
thib
parents:
diff changeset
1533 }
223b71206888 Initial import
thib
parents:
diff changeset
1534 void TextImpl::PressFuncBacklog(void* pointer, WidButton* from) {
223b71206888 Initial import
thib
parents:
diff changeset
1535 if (pointer == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1536 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1537 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::BACKLOG_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1538 return;
223b71206888 Initial import
thib
parents:
diff changeset
1539 }
223b71206888 Initial import
thib
parents:
diff changeset
1540 void TextImpl::PressFuncBacklogFwd(void* pointer, WidButton* from) {
223b71206888 Initial import
thib
parents:
diff changeset
1541 if (pointer == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1542 TextImpl* t = (TextImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1543 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::BACKLOG_MASK_FWD);
223b71206888 Initial import
thib
parents:
diff changeset
1544 return;
223b71206888 Initial import
thib
parents:
diff changeset
1545 }
223b71206888 Initial import
thib
parents:
diff changeset
1546 void movebtn_drag(int from_x, int from_y, int x, int y, void* pointer, WidButton* button) {
223b71206888 Initial import
thib
parents:
diff changeset
1547 if (pointer == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1548 fprintf(stderr,"drag.\n");
223b71206888 Initial import
thib
parents:
diff changeset
1549 }
223b71206888 Initial import
thib
parents:
diff changeset
1550 #define BTNCNT 10
223b71206888 Initial import
thib
parents:
diff changeset
1551 static char* btnname[BTNCNT] = {
223b71206888 Initial import
thib
parents:
diff changeset
1552 "MOVE",
223b71206888 Initial import
thib
parents:
diff changeset
1553 "CLEAR",
223b71206888 Initial import
thib
parents:
diff changeset
1554 "READJUMP",
223b71206888 Initial import
thib
parents:
diff changeset
1555 "AUTOMODE",
223b71206888 Initial import
thib
parents:
diff changeset
1556 "MSGBK",
223b71206888 Initial import
thib
parents:
diff changeset
1557 "MSGBKLEFT",
223b71206888 Initial import
thib
parents:
diff changeset
1558 "MSGBKRIGHT",
223b71206888 Initial import
thib
parents:
diff changeset
1559 "EXBTN_000",
223b71206888 Initial import
thib
parents:
diff changeset
1560 "EXBTN_001",
223b71206888 Initial import
thib
parents:
diff changeset
1561 "EXBTN_002"
223b71206888 Initial import
thib
parents:
diff changeset
1562 };
223b71206888 Initial import
thib
parents:
diff changeset
1563 static int btnpos[BTNCNT] = { // g00 ファイル内のボタン情報の位置
223b71206888 Initial import
thib
parents:
diff changeset
1564 // 0, 1, 13, 12, 2, 3, 4, 5, 6, 7 // princess bride?
223b71206888 Initial import
thib
parents:
diff changeset
1565 0, 1, 13, 14, 2, 3, 4, 5, 6, 7 // tomoyo after?
223b71206888 Initial import
thib
parents:
diff changeset
1566 };
223b71206888 Initial import
thib
parents:
diff changeset
1567 static WidButton::PressFunc btnpress[BTNCNT] = {
223b71206888 Initial import
thib
parents:
diff changeset
1568 0, clearbtn_press, &TextImpl::PressFuncSkip,0,&TextImpl::PressFuncBacklogFwd,&TextImpl::PressFuncBacklog,&TextImpl::PressFuncBacklogFwd,&TextImpl::PressFuncSave,&TextImpl::PressFuncLoad,0
223b71206888 Initial import
thib
parents:
diff changeset
1569 };
223b71206888 Initial import
thib
parents:
diff changeset
1570 static WidButton::DragFunc btndrag[BTNCNT] = {
223b71206888 Initial import
thib
parents:
diff changeset
1571 movebtn_drag, 0,0,0,0, 0,0,0,0, 0
223b71206888 Initial import
thib
parents:
diff changeset
1572 };
223b71206888 Initial import
thib
parents:
diff changeset
1573
223b71206888 Initial import
thib
parents:
diff changeset
1574 void TextImpl::SetTextSpeed(int speed) {
223b71206888 Initial import
thib
parents:
diff changeset
1575 // 100 : 10char / sec
223b71206888 Initial import
thib
parents:
diff changeset
1576 // 10 : 100char / sec
223b71206888 Initial import
thib
parents:
diff changeset
1577 // text widget:
223b71206888 Initial import
thib
parents:
diff changeset
1578 if (speed <= 0) speed = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1579 else if (speed > 1000) speed = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1580 else speed = 1000 / speed;
223b71206888 Initial import
thib
parents:
diff changeset
1581 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1582 for (i=0; i<32; i++)
223b71206888 Initial import
thib
parents:
diff changeset
1583 if (widgets[i]) widgets[i]->wid->SetSpeed(speed);
223b71206888 Initial import
thib
parents:
diff changeset
1584 }
223b71206888 Initial import
thib
parents:
diff changeset
1585 void TextImpl::SetTextWait(int wait) {
223b71206888 Initial import
thib
parents:
diff changeset
1586 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1587 for (i=0; i<32; i++)
223b71206888 Initial import
thib
parents:
diff changeset
1588 if (widgets[i]) widgets[i]->wid->SetWait(wait);
223b71206888 Initial import
thib
parents:
diff changeset
1589 }
223b71206888 Initial import
thib
parents:
diff changeset
1590
223b71206888 Initial import
thib
parents:
diff changeset
1591 void TextImpl::SetWindowColor(int r, int g, int b, int a, bool is_transparent) {
223b71206888 Initial import
thib
parents:
diff changeset
1592 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1593 int w;
223b71206888 Initial import
thib
parents:
diff changeset
1594
223b71206888 Initial import
thib
parents:
diff changeset
1595 for (w=0; w<32; w++) {
223b71206888 Initial import
thib
parents:
diff changeset
1596 if (widgets[w] == 0) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1597 sprintf(key, "#WAKU.%03d.000.BACK", w);
223b71206888 Initial import
thib
parents:
diff changeset
1598 const char* back = config.GetParaStr(key);
223b71206888 Initial import
thib
parents:
diff changeset
1599 if (back == 0 || back[0] == 0) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1600 sprintf(key, "%s.g00", back);
223b71206888 Initial import
thib
parents:
diff changeset
1601 Surface* back_s = parent.Root().NewSurface(key);
223b71206888 Initial import
thib
parents:
diff changeset
1602 if (back_s == 0) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1603 Rect rect(*back_s);
223b71206888 Initial import
thib
parents:
diff changeset
1604 Surface* new_s = parent.Root().NewSurface(rect.width(), rect.height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1605 DSurfaceMove(back_s, rect, new_s, rect);
223b71206888 Initial import
thib
parents:
diff changeset
1606 DSurfaceFillA(new_s, rect, r, g, b, a);
223b71206888 Initial import
thib
parents:
diff changeset
1607 widgets[w]->wid->Pic()->SetSurface(new_s, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1608 widgets[w]->wid->Pic()->SetSurfaceFreeFlag(1);
223b71206888 Initial import
thib
parents:
diff changeset
1609 if (!is_transparent)
223b71206888 Initial import
thib
parents:
diff changeset
1610 widgets[w]->wid->Pic()->SetSurfaceAttribute(PicBase::BLIT_MULTIPLY);
223b71206888 Initial import
thib
parents:
diff changeset
1611 parent.Root().DeleteSurface(back_s);
223b71206888 Initial import
thib
parents:
diff changeset
1612 }
223b71206888 Initial import
thib
parents:
diff changeset
1613 return;
223b71206888 Initial import
thib
parents:
diff changeset
1614 }
223b71206888 Initial import
thib
parents:
diff changeset
1615
223b71206888 Initial import
thib
parents:
diff changeset
1616 void TextImpl::SetCursor(int cursor_no) {
223b71206888 Initial import
thib
parents:
diff changeset
1617 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1618 sprintf(key, "#CURSOR.%03d.NAME", cursor_no);
223b71206888 Initial import
thib
parents:
diff changeset
1619 string path = config.GetParaStr(key);
223b71206888 Initial import
thib
parents:
diff changeset
1620 if (path.length() == 0) return; // 名前なし
223b71206888 Initial import
thib
parents:
diff changeset
1621 path += ".pdt";
223b71206888 Initial import
thib
parents:
diff changeset
1622 int w,h,cont,speed;
223b71206888 Initial import
thib
parents:
diff changeset
1623 sprintf(key, "#CURSOR.%03d.SIZE", cursor_no);
223b71206888 Initial import
thib
parents:
diff changeset
1624 config.GetParam(key, 2, &w, &h);
223b71206888 Initial import
thib
parents:
diff changeset
1625 sprintf(key, "#CURSOR.%03d.CONT", cursor_no);
223b71206888 Initial import
thib
parents:
diff changeset
1626 config.GetParam(key, 1, &cont);
223b71206888 Initial import
thib
parents:
diff changeset
1627 sprintf(key, "#CURSOR.%03d.SPEED", cursor_no);
223b71206888 Initial import
thib
parents:
diff changeset
1628 config.GetParam(key, 1, &speed);
223b71206888 Initial import
thib
parents:
diff changeset
1629
223b71206888 Initial import
thib
parents:
diff changeset
1630 // speed で1周、cont 回変化
223b71206888 Initial import
thib
parents:
diff changeset
1631 if (kcursor) delete kcursor;
223b71206888 Initial import
thib
parents:
diff changeset
1632
223b71206888 Initial import
thib
parents:
diff changeset
1633 kcursor = new WidTimeCursor(event, speed/cont, &parent, path.c_str(), 0, 0, w, 0, cont, Rect(0,0,w,h));
223b71206888 Initial import
thib
parents:
diff changeset
1634 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1635 for (i=0; i<32; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1636 if (widgets[i]) widgets[i]->wid->SetCursor(kcursor);
223b71206888 Initial import
thib
parents:
diff changeset
1637 }
223b71206888 Initial import
thib
parents:
diff changeset
1638 }
223b71206888 Initial import
thib
parents:
diff changeset
1639
223b71206888 Initial import
thib
parents:
diff changeset
1640 void kconv(const unsigned char* src, unsigned char* dest) {
223b71206888 Initial import
thib
parents:
diff changeset
1641 /* input : sjis output: euc */
223b71206888 Initial import
thib
parents:
diff changeset
1642 while(*src) {
223b71206888 Initial import
thib
parents:
diff changeset
1643 unsigned int high = *src++;
223b71206888 Initial import
thib
parents:
diff changeset
1644 if (high < 0x80) {
223b71206888 Initial import
thib
parents:
diff changeset
1645 /* ASCII */
223b71206888 Initial import
thib
parents:
diff changeset
1646 *dest++ = high; continue;
223b71206888 Initial import
thib
parents:
diff changeset
1647 } else if (high < 0xa0) {
223b71206888 Initial import
thib
parents:
diff changeset
1648 /* SJIS */
223b71206888 Initial import
thib
parents:
diff changeset
1649 high -= 0x71;
223b71206888 Initial import
thib
parents:
diff changeset
1650 } else if (high < 0xe0) {
223b71206888 Initial import
thib
parents:
diff changeset
1651 /* hankaku KANA */
223b71206888 Initial import
thib
parents:
diff changeset
1652 *dest++ = 0x8e; *dest++ = high;
223b71206888 Initial import
thib
parents:
diff changeset
1653 continue;
223b71206888 Initial import
thib
parents:
diff changeset
1654 } else { /* high >= 0xe0 : SJIS */
223b71206888 Initial import
thib
parents:
diff changeset
1655 high -= 0xb1;
223b71206888 Initial import
thib
parents:
diff changeset
1656 }
223b71206888 Initial import
thib
parents:
diff changeset
1657 /* SJIS convert */
223b71206888 Initial import
thib
parents:
diff changeset
1658 high = (high<<1) + 1;
223b71206888 Initial import
thib
parents:
diff changeset
1659
223b71206888 Initial import
thib
parents:
diff changeset
1660 unsigned int low = *src++;
223b71206888 Initial import
thib
parents:
diff changeset
1661 if (low == 0) break; /* incorrect code */
223b71206888 Initial import
thib
parents:
diff changeset
1662 if (low > 0x7f) low--;
223b71206888 Initial import
thib
parents:
diff changeset
1663 if (low >= 0x9e) {
223b71206888 Initial import
thib
parents:
diff changeset
1664 low -= 0x7d;
223b71206888 Initial import
thib
parents:
diff changeset
1665 high++;
223b71206888 Initial import
thib
parents:
diff changeset
1666 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1667 low -= 0x1f;
223b71206888 Initial import
thib
parents:
diff changeset
1668 }
223b71206888 Initial import
thib
parents:
diff changeset
1669 *dest++ = high | 0x80; *dest++ = low | 0x80;
223b71206888 Initial import
thib
parents:
diff changeset
1670 }
223b71206888 Initial import
thib
parents:
diff changeset
1671 *dest = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1672 }
223b71206888 Initial import
thib
parents:
diff changeset
1673 void kconv_rev(const unsigned char* src, unsigned char* dest) {
223b71206888 Initial import
thib
parents:
diff changeset
1674 /* input : euc output: sjis */
223b71206888 Initial import
thib
parents:
diff changeset
1675 while(*src) {
223b71206888 Initial import
thib
parents:
diff changeset
1676 unsigned int high = *src++;
223b71206888 Initial import
thib
parents:
diff changeset
1677 if (high < 0x80) {
223b71206888 Initial import
thib
parents:
diff changeset
1678 /* ASCII */
223b71206888 Initial import
thib
parents:
diff changeset
1679 *dest++ = high; continue;
223b71206888 Initial import
thib
parents:
diff changeset
1680 } else if (high == 0x8e) { /* hankaku KANA */
223b71206888 Initial import
thib
parents:
diff changeset
1681 high = *src;
223b71206888 Initial import
thib
parents:
diff changeset
1682 if (high >= 0xa0 && high < 0xe0)
223b71206888 Initial import
thib
parents:
diff changeset
1683 *dest++ = *src++;
223b71206888 Initial import
thib
parents:
diff changeset
1684 continue;
223b71206888 Initial import
thib
parents:
diff changeset
1685 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1686 unsigned int low = *src++;
223b71206888 Initial import
thib
parents:
diff changeset
1687 if (low == 0) break; /* incorrect code , EOS */
223b71206888 Initial import
thib
parents:
diff changeset
1688 if (low < 0x80) continue; /* incorrect code */
223b71206888 Initial import
thib
parents:
diff changeset
1689 /* convert */
223b71206888 Initial import
thib
parents:
diff changeset
1690 low &= 0x7f; high &= 0x7f;
223b71206888 Initial import
thib
parents:
diff changeset
1691 low += (high & 1) ? 0x1f : 0x7d;
223b71206888 Initial import
thib
parents:
diff changeset
1692 high = (high-0x21)>>1;
223b71206888 Initial import
thib
parents:
diff changeset
1693 high += (high > 0x1e) ? 0xc1 : 0x81;
223b71206888 Initial import
thib
parents:
diff changeset
1694 *dest++ = high;
223b71206888 Initial import
thib
parents:
diff changeset
1695 if (low > 0x7f) low++;
223b71206888 Initial import
thib
parents:
diff changeset
1696 *dest++ = low;
223b71206888 Initial import
thib
parents:
diff changeset
1697 }
223b71206888 Initial import
thib
parents:
diff changeset
1698 }
223b71206888 Initial import
thib
parents:
diff changeset
1699 *dest = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1700 }
223b71206888 Initial import
thib
parents:
diff changeset
1701 string kconv(const string& s) {
223b71206888 Initial import
thib
parents:
diff changeset
1702 char* out = new char[s.length()*2+100];
223b71206888 Initial import
thib
parents:
diff changeset
1703 kconv((const unsigned char*)s.c_str(), (unsigned char*)out);
223b71206888 Initial import
thib
parents:
diff changeset
1704 string ret = out;
223b71206888 Initial import
thib
parents:
diff changeset
1705 delete[] out;
223b71206888 Initial import
thib
parents:
diff changeset
1706 return ret;
223b71206888 Initial import
thib
parents:
diff changeset
1707 }
223b71206888 Initial import
thib
parents:
diff changeset
1708 string kconv_rev(const string& s) {
223b71206888 Initial import
thib
parents:
diff changeset
1709 char* out = new char[s.length()*2+100];
223b71206888 Initial import
thib
parents:
diff changeset
1710 kconv_rev((const unsigned char*)s.c_str(), (unsigned char*)out);
223b71206888 Initial import
thib
parents:
diff changeset
1711 string ret = out;
223b71206888 Initial import
thib
parents:
diff changeset
1712 delete[] out;
223b71206888 Initial import
thib
parents:
diff changeset
1713 return ret;
223b71206888 Initial import
thib
parents:
diff changeset
1714 }
223b71206888 Initial import
thib
parents:
diff changeset
1715
223b71206888 Initial import
thib
parents:
diff changeset
1716 /**************************************************************::
223b71206888 Initial import
thib
parents:
diff changeset
1717 **
223b71206888 Initial import
thib
parents:
diff changeset
1718 ** Text
223b71206888 Initial import
thib
parents:
diff changeset
1719 */
223b71206888 Initial import
thib
parents:
diff changeset
1720 Text::Text(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config) {
223b71206888 Initial import
thib
parents:
diff changeset
1721 pimpl = new TextImpl(_event, _parent, config, backlog, backlog_item);
223b71206888 Initial import
thib
parents:
diff changeset
1722 }
223b71206888 Initial import
thib
parents:
diff changeset
1723 Text::~Text() {
223b71206888 Initial import
thib
parents:
diff changeset
1724 delete pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
1725 }
223b71206888 Initial import
thib
parents:
diff changeset
1726 void Text::InitWindow(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1727 pimpl->InitWindow();
223b71206888 Initial import
thib
parents:
diff changeset
1728 }
223b71206888 Initial import
thib
parents:
diff changeset
1729 void Text::Exec(Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
1730 pimpl->Exec(cmd);
223b71206888 Initial import
thib
parents:
diff changeset
1731 }
223b71206888 Initial import
thib
parents:
diff changeset
1732 bool Text::Wait(unsigned int current_time, Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
1733 return pimpl->Wait(current_time, cmd);
223b71206888 Initial import
thib
parents:
diff changeset
1734 }
223b71206888 Initial import
thib
parents:
diff changeset
1735 void Text::SetSkipMode(SkipMode mode) {
223b71206888 Initial import
thib
parents:
diff changeset
1736 pimpl->SetSkipMode(mode);
223b71206888 Initial import
thib
parents:
diff changeset
1737 }
223b71206888 Initial import
thib
parents:
diff changeset
1738 void Text::Save(std::string& str, bool select_save) {
223b71206888 Initial import
thib
parents:
diff changeset
1739 pimpl->Save(str, select_save);
223b71206888 Initial import
thib
parents:
diff changeset
1740 }
223b71206888 Initial import
thib
parents:
diff changeset
1741 void Text::Load(const char* str) {
223b71206888 Initial import
thib
parents:
diff changeset
1742 pimpl->Load(str);
223b71206888 Initial import
thib
parents:
diff changeset
1743 }
223b71206888 Initial import
thib
parents:
diff changeset
1744
223b71206888 Initial import
thib
parents:
diff changeset
1745 void Text::hide(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1746 pimpl->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1747 }
223b71206888 Initial import
thib
parents:
diff changeset
1748 void Text::show(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1749 pimpl->show();
223b71206888 Initial import
thib
parents:
diff changeset
1750 }
223b71206888 Initial import
thib
parents:
diff changeset
1751 void Text::show(int num) {
223b71206888 Initial import
thib
parents:
diff changeset
1752 pimpl->show(num);
223b71206888 Initial import
thib
parents:
diff changeset
1753 }
223b71206888 Initial import
thib
parents:
diff changeset
1754 void Text::DrawBacklog(BacklogItem& item, Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
1755 pimpl->DrawBacklog(item, cmd);
223b71206888 Initial import
thib
parents:
diff changeset
1756 }
223b71206888 Initial import
thib
parents:
diff changeset
1757 /**************************************************************::
223b71206888 Initial import
thib
parents:
diff changeset
1758 **
223b71206888 Initial import
thib
parents:
diff changeset
1759 ** BacklogItem
223b71206888 Initial import
thib
parents:
diff changeset
1760 */
223b71206888 Initial import
thib
parents:
diff changeset
1761
223b71206888 Initial import
thib
parents:
diff changeset
1762 BacklogItem::BacklogItem(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1763 scn = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1764 pos = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1765 koe = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1766 face = "";
223b71206888 Initial import
thib
parents:
diff changeset
1767 text.kanji_type = TextStream::sjis;
223b71206888 Initial import
thib
parents:
diff changeset
1768 }
223b71206888 Initial import
thib
parents:
diff changeset
1769 void BacklogItem::Clear(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1770 scn = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1771 pos = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1772 koe = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1773 text.Clear();
223b71206888 Initial import
thib
parents:
diff changeset
1774 }
223b71206888 Initial import
thib
parents:
diff changeset
1775 void BacklogItem::AddTextPos(Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
1776 if (scn == -1 && pos == -1) {
223b71206888 Initial import
thib
parents:
diff changeset
1777 scn = cmd.scn;
223b71206888 Initial import
thib
parents:
diff changeset
1778 pos = cmd.pos;
223b71206888 Initial import
thib
parents:
diff changeset
1779 return;
223b71206888 Initial import
thib
parents:
diff changeset
1780 }
223b71206888 Initial import
thib
parents:
diff changeset
1781 DeleteTextPos();
223b71206888 Initial import
thib
parents:
diff changeset
1782 }
223b71206888 Initial import
thib
parents:
diff changeset
1783 void BacklogItem::DeleteTextPos(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1784 scn = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1785 pos = -1;
223b71206888 Initial import
thib
parents:
diff changeset
1786 }
223b71206888 Initial import
thib
parents:
diff changeset
1787 BacklogItem& BacklogItem::operator =(const BacklogItem& p) {
223b71206888 Initial import
thib
parents:
diff changeset
1788 scn = p.scn;
223b71206888 Initial import
thib
parents:
diff changeset
1789 pos = p.pos;
223b71206888 Initial import
thib
parents:
diff changeset
1790 koe = p.koe;
223b71206888 Initial import
thib
parents:
diff changeset
1791 face = p.face;
223b71206888 Initial import
thib
parents:
diff changeset
1792 text = p.text;
223b71206888 Initial import
thib
parents:
diff changeset
1793 }
223b71206888 Initial import
thib
parents:
diff changeset
1794 void BacklogItem::SetSavepos(int p) {
223b71206888 Initial import
thib
parents:
diff changeset
1795 Clear();
223b71206888 Initial import
thib
parents:
diff changeset
1796 scn = SaveSelect;
223b71206888 Initial import
thib
parents:
diff changeset
1797 pos = p;
223b71206888 Initial import
thib
parents:
diff changeset
1798 }
223b71206888 Initial import
thib
parents:
diff changeset
1799
223b71206888 Initial import
thib
parents:
diff changeset
1800 Rect TextWindow::WakuSize(PicContainer& pic, int waku_no, const AyuSysConfig& config) {
223b71206888 Initial import
thib
parents:
diff changeset
1801 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1802 sprintf(key, "#WAKU.%03d.000.NAME", waku_no);
223b71206888 Initial import
thib
parents:
diff changeset
1803 const char* name = config.GetParaStr(key);
223b71206888 Initial import
thib
parents:
diff changeset
1804 if (!name) return Rect(0,0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
1805 std::string str = name; str += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
1806 Surface* s = pic.Root().NewSurface(str.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
1807 if (!s) return Rect(0,0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
1808 Rect r(*s);
223b71206888 Initial import
thib
parents:
diff changeset
1809 pic.Root().DeleteSurface(s);
223b71206888 Initial import
thib
parents:
diff changeset
1810 return r;
223b71206888 Initial import
thib
parents:
diff changeset
1811 }
223b71206888 Initial import
thib
parents:
diff changeset
1812 void TextWindow::MakeWaku(PicContainer& pic, Event::Container& event, int waku_no, int window_no, bool* use_btn, const AyuSysConfig& config, void* callback) {
223b71206888 Initial import
thib
parents:
diff changeset
1813 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1814 std::string str;
223b71206888 Initial import
thib
parents:
diff changeset
1815 /* 枠を作成 */
223b71206888 Initial import
thib
parents:
diff changeset
1816 sprintf(key, "#WAKU.%03d.000.NAME", waku_no);
223b71206888 Initial import
thib
parents:
diff changeset
1817 const char* name = config.GetParaStr(key);
223b71206888 Initial import
thib
parents:
diff changeset
1818 if (name && name[0] == 0) name = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1819 sprintf(key, "#WAKU.%03d.000.BACK", waku_no);
223b71206888 Initial import
thib
parents:
diff changeset
1820 const char* back = config.GetParaStr(key);
223b71206888 Initial import
thib
parents:
diff changeset
1821 if (back && back[0] == 0) back = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1822 sprintf(key, "#WAKU.%03d.000.BTN", waku_no);
223b71206888 Initial import
thib
parents:
diff changeset
1823 const char* btn = config.GetParaStr(key);
223b71206888 Initial import
thib
parents:
diff changeset
1824 if (btn && btn[0] == 0) btn = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1825
223b71206888 Initial import
thib
parents:
diff changeset
1826 if (name == 0 && back == 0 && btn == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1827
223b71206888 Initial import
thib
parents:
diff changeset
1828 /* まず、テキスト背景を設定 */
223b71206888 Initial import
thib
parents:
diff changeset
1829 if (back) {
223b71206888 Initial import
thib
parents:
diff changeset
1830 str = back; str += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
1831 int rc,gc,bc,ac, flag;
223b71206888 Initial import
thib
parents:
diff changeset
1832 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1833 sprintf(key, "#WINDOW.%03d.ATTR", window_no);
223b71206888 Initial import
thib
parents:
diff changeset
1834 if (config.GetParam(key, 5, &rc, &gc, &bc, &ac, &flag) == -1) {
223b71206888 Initial import
thib
parents:
diff changeset
1835 config.GetParam("#WINDOW_ATTR", 5, &rc, &gc, &bc, &ac, &flag);
223b71206888 Initial import
thib
parents:
diff changeset
1836 }
223b71206888 Initial import
thib
parents:
diff changeset
1837 Surface* back_s = pic.Root().NewSurface(str.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
1838 if (back_s) {
223b71206888 Initial import
thib
parents:
diff changeset
1839 Rect rect(*back_s);
223b71206888 Initial import
thib
parents:
diff changeset
1840 Surface* s = pic.Root().NewSurface(rect.width(), rect.height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
1841 DSurfaceMove(back_s, rect, s, rect);
223b71206888 Initial import
thib
parents:
diff changeset
1842 DSurfaceFillA(s, rect, rc, gc, bc, ac); // 透明度設定
223b71206888 Initial import
thib
parents:
diff changeset
1843 pic.SetSurface(s, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1844 pic.SetSurfaceFreeFlag(1);
223b71206888 Initial import
thib
parents:
diff changeset
1845 if (flag == 0) wid->Pic()->SetSurfaceAttribute(PicBase::BLIT_MULTIPLY);
223b71206888 Initial import
thib
parents:
diff changeset
1846 pic.Root().DeleteSurface(back_s);
223b71206888 Initial import
thib
parents:
diff changeset
1847 }
223b71206888 Initial import
thib
parents:
diff changeset
1848 }
223b71206888 Initial import
thib
parents:
diff changeset
1849 /* その前に枠飾りを設定 */
223b71206888 Initial import
thib
parents:
diff changeset
1850 if (name) {
223b71206888 Initial import
thib
parents:
diff changeset
1851 str = name; str += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
1852 Surface* s = pic.Root().NewSurface(str.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
1853 if (s) {
223b71206888 Initial import
thib
parents:
diff changeset
1854 Rect rect(*s);
223b71206888 Initial import
thib
parents:
diff changeset
1855 pic.Root().DeleteSurface(s);
223b71206888 Initial import
thib
parents:
diff changeset
1856 PicBase* p = pic.create_leaf(Rect(0, 0, rect.width(), rect.height()),0);
223b71206888 Initial import
thib
parents:
diff changeset
1857 p->SetSurface(str.c_str(), 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1858 p->ZMove(ZMOVE_BOTTOM);
223b71206888 Initial import
thib
parents:
diff changeset
1859 p->show();
223b71206888 Initial import
thib
parents:
diff changeset
1860 }
223b71206888 Initial import
thib
parents:
diff changeset
1861 }
223b71206888 Initial import
thib
parents:
diff changeset
1862 if (btn == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1863 if (use_btn == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1864 // ボタンの作成
223b71206888 Initial import
thib
parents:
diff changeset
1865 // 使用するボタンについては、必要に応じて show() すること
223b71206888 Initial import
thib
parents:
diff changeset
1866
223b71206888 Initial import
thib
parents:
diff changeset
1867 /* ボタンの位置情報を求める */
223b71206888 Initial import
thib
parents:
diff changeset
1868 str = btn; str += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
1869 ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, str.c_str(), "g00");
223b71206888 Initial import
thib
parents:
diff changeset
1870 if (info == 0) return; // cannot find file
223b71206888 Initial import
thib
parents:
diff changeset
1871 const char* data = info->Read();
223b71206888 Initial import
thib
parents:
diff changeset
1872 /* g00 ファイルのヘッダ部分に位置情報は入っている */
223b71206888 Initial import
thib
parents:
diff changeset
1873 /* 存在しなければボタン画像ではない */
223b71206888 Initial import
thib
parents:
diff changeset
1874 if (data == 0 || *data != 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1875 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
1876 return;
223b71206888 Initial import
thib
parents:
diff changeset
1877 }
223b71206888 Initial import
thib
parents:
diff changeset
1878 int index_count = read_little_endian_int(data+5); // 0x70 == 112 ( 8 個ずつグループなので、14個のボタン ) が標準
223b71206888 Initial import
thib
parents:
diff changeset
1879 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1880 for (i=0; i<BTNCNT; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1881 if (!use_btn[i]) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1882 if (btnpos[i]*8 >= index_count) {
223b71206888 Initial import
thib
parents:
diff changeset
1883 continue; // ボタンが存在しない
223b71206888 Initial import
thib
parents:
diff changeset
1884 }
223b71206888 Initial import
thib
parents:
diff changeset
1885 int x, y, w, h;
223b71206888 Initial import
thib
parents:
diff changeset
1886 sprintf(key, "#WAKU.%03d.000.%s_BOX", waku_no, btnname[i]);
223b71206888 Initial import
thib
parents:
diff changeset
1887 if (config.GetParam(key, 5, 0, &x, &y, &w, &h) == -1) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1888 int sx, sy, sdx, sdy, cnt;
223b71206888 Initial import
thib
parents:
diff changeset
1889 const char* d = data + 9 + btnpos[i]*24*8;
223b71206888 Initial import
thib
parents:
diff changeset
1890 sx = read_little_endian_int(d);
223b71206888 Initial import
thib
parents:
diff changeset
1891 sy = read_little_endian_int(d+4);
223b71206888 Initial import
thib
parents:
diff changeset
1892 sdx = read_little_endian_int(d+24) - sx;
223b71206888 Initial import
thib
parents:
diff changeset
1893 sdy = read_little_endian_int(d+24 + 4) - sy;
223b71206888 Initial import
thib
parents:
diff changeset
1894 cnt = 2;
223b71206888 Initial import
thib
parents:
diff changeset
1895 if (sx+sdx*2 == read_little_endian_int(d+2*24) && sy+sdy*2 == read_little_endian_int(d+2*24+4)) cnt = 3;
223b71206888 Initial import
thib
parents:
diff changeset
1896 WidButton* wid = new WidButton(event, &pic, str.c_str(), sx, sy, sdx, sdy, cnt, Rect(x, y, x+w, y+h), 1);
223b71206888 Initial import
thib
parents:
diff changeset
1897 if (btnpress[i]) { wid->press_func = btnpress[i]; wid->press_pointer = callback;}
223b71206888 Initial import
thib
parents:
diff changeset
1898 if (btndrag[i]) { wid->drag_func = btndrag[i]; wid->drag_pointer = callback;}
223b71206888 Initial import
thib
parents:
diff changeset
1899 }
223b71206888 Initial import
thib
parents:
diff changeset
1900 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
1901 return;
223b71206888 Initial import
thib
parents:
diff changeset
1902 }
223b71206888 Initial import
thib
parents:
diff changeset
1903
223b71206888 Initial import
thib
parents:
diff changeset
1904 TextWindow::TextWindow(PicContainer& parent, Event::Container& event, int win_no, const AyuSysConfig& config, void* callback) :
223b71206888 Initial import
thib
parents:
diff changeset
1905 wid(0), name_visible(true),name(0),name_container(0), face(0) {
223b71206888 Initial import
thib
parents:
diff changeset
1906 int i; for (i=0; i<8; i++) face_pics[i]=0;
223b71206888 Initial import
thib
parents:
diff changeset
1907 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1908 bool use_btn[BTNCNT];
223b71206888 Initial import
thib
parents:
diff changeset
1909 int size, rep1, rep2, cntw, cnth, mposx, mposy, posd, posx, posy, minx, miny, waku_no, ruby;
223b71206888 Initial import
thib
parents:
diff changeset
1910 sprintf(key, "#WINDOW.%03d.MOJI_SIZE", win_no); if (config.GetParam(key, 1, &size) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1911 sprintf(key, "#WINDOW.%03d.MOJI_REP", win_no); if (config.GetParam(key, 2, &rep1, &rep2) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1912 sprintf(key, "#WINDOW.%03d.MOJI_CNT", win_no); if (config.GetParam(key, 2, &cntw, &cnth) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1913 sprintf(key, "#WINDOW.%03d.POS", win_no); if (config.GetParam(key, 3, &posd, &posx, &posy) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1914 sprintf(key, "#WINDOW.%03d.MOJI_POS", win_no); if (config.GetParam(key, 4, &mposy, 0, &mposx, 0) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1915 sprintf(key, "#WINDOW.%03d.MOJI_MIN", win_no); if (config.GetParam(key, 2, &minx, &miny) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1916 sprintf(key, "#WINDOW.%03d.WAKU_SETNO", win_no);if (config.GetParam(key, 1, &waku_no) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1917 sprintf(key, "#WINDOW.%03d.LUBY_SIZE", win_no); if (config.GetParam(key, 1, &ruby) == -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1918
223b71206888 Initial import
thib
parents:
diff changeset
1919 /* テキストウィジット:画面の右下一杯まで使用 */
223b71206888 Initial import
thib
parents:
diff changeset
1920 /* posd == 2 なら画面下にひっつくように配置 */
223b71206888 Initial import
thib
parents:
diff changeset
1921 Rect r(0,0);
223b71206888 Initial import
thib
parents:
diff changeset
1922 if (posd == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1923 r = WakuSize(parent, waku_no, config);
223b71206888 Initial import
thib
parents:
diff changeset
1924 r = Rect(0, parent.Height()-r.height(), r.width(), parent.Height());
223b71206888 Initial import
thib
parents:
diff changeset
1925 posx = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1926 posy = parent.Height()-r.height();
223b71206888 Initial import
thib
parents:
diff changeset
1927 } else /* posd == 0 ? */
223b71206888 Initial import
thib
parents:
diff changeset
1928 r = Rect(posx, posy, parent.Width(), parent.Height());
223b71206888 Initial import
thib
parents:
diff changeset
1929
223b71206888 Initial import
thib
parents:
diff changeset
1930 /* テキストウィンドウの作成 */
223b71206888 Initial import
thib
parents:
diff changeset
1931 int w = size*cntw; int h = (size+ruby+2)*cnth;
223b71206888 Initial import
thib
parents:
diff changeset
1932 wid = new WidText(event, &parent, r, Rect(mposx, mposy, mposx+w, mposy+h), size);
223b71206888 Initial import
thib
parents:
diff changeset
1933 wid->stream.kanji_type = TextStream::sjis;
223b71206888 Initial import
thib
parents:
diff changeset
1934 /* 顔ウィンドウの作成 */
223b71206888 Initial import
thib
parents:
diff changeset
1935 for (i=0; i<8; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1936 int x,y;
223b71206888 Initial import
thib
parents:
diff changeset
1937 sprintf(key, "#WINDOW.%03d.FACE.%03d", win_no, i);
223b71206888 Initial import
thib
parents:
diff changeset
1938 if (config.GetParam(key, 2, &x, &y) == -1) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1939 /* 顔ウィンドウを作成する */
223b71206888 Initial import
thib
parents:
diff changeset
1940 if (x >= 0 && y >= 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1941 face_pics[i] = wid->PicNode()->create_leaf(Rect(x,y), PicBase::FIT_SURFACE);
223b71206888 Initial import
thib
parents:
diff changeset
1942 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1943 face_pics[i] = parent.create_leaf(Rect(x+posx,y+posy), PicBase::FIT_SURFACE);
223b71206888 Initial import
thib
parents:
diff changeset
1944 }
223b71206888 Initial import
thib
parents:
diff changeset
1945 face_pics[i]->show();
223b71206888 Initial import
thib
parents:
diff changeset
1946 }
223b71206888 Initial import
thib
parents:
diff changeset
1947 face = face_pics[0];
223b71206888 Initial import
thib
parents:
diff changeset
1948 // ボタンの設定
223b71206888 Initial import
thib
parents:
diff changeset
1949 for (i=0; i<BTNCNT; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1950 int num;
223b71206888 Initial import
thib
parents:
diff changeset
1951 sprintf(key, "#WINDOW.%03d.%s_USE", win_no, btnname[i]);
223b71206888 Initial import
thib
parents:
diff changeset
1952 config.GetParam(key, 1, &num);
223b71206888 Initial import
thib
parents:
diff changeset
1953 use_btn[i] = (num==0) ? false : true;
223b71206888 Initial import
thib
parents:
diff changeset
1954 }
223b71206888 Initial import
thib
parents:
diff changeset
1955 // make name window
223b71206888 Initial import
thib
parents:
diff changeset
1956 int shadow, name_mod, name_size, name_min, name_center, name_posx, name_posy, name_mposx, name_mposy;
223b71206888 Initial import
thib
parents:
diff changeset
1957 sprintf(key, "#WINDOW.%03d.MOJI_SHADOW", win_no); config.GetParam(key, 1, &shadow);
223b71206888 Initial import
thib
parents:
diff changeset
1958 sprintf(key, "#WINDOW.%03d.NAME_MOD", win_no); config.GetParam(key, 1, &name_mod);
223b71206888 Initial import
thib
parents:
diff changeset
1959 sprintf(key, "#WINDOW.%03d.NAME_MOJI_SIZE", win_no); config.GetParam(key, 1, &name_size);
223b71206888 Initial import
thib
parents:
diff changeset
1960 sprintf(key, "#WINDOW.%03d.NAME_MOJI_MIN", win_no); config.GetParam(key, 1, &name_min);
223b71206888 Initial import
thib
parents:
diff changeset
1961 sprintf(key, "#WINDOW.%03d.NAME_MOJI_POS", win_no); config.GetParam(key, 2, &name_mposx, &name_mposy);
223b71206888 Initial import
thib
parents:
diff changeset
1962 sprintf(key, "#WINDOW.%03d.NAME_CENTERING", win_no); config.GetParam(key, 1, &name_center);
223b71206888 Initial import
thib
parents:
diff changeset
1963 sprintf(key, "#WINDOW.%03d.NAME_POS", win_no); config.GetParam(key, 2, &name_posx, &name_posy);
223b71206888 Initial import
thib
parents:
diff changeset
1964 // if name_mode==0 name is in the text window
223b71206888 Initial import
thib
parents:
diff changeset
1965 // if name_mode == 1 open name window
223b71206888 Initial import
thib
parents:
diff changeset
1966 // if name_mode == 2 name is not used
223b71206888 Initial import
thib
parents:
diff changeset
1967 if (name_mod) {
223b71206888 Initial import
thib
parents:
diff changeset
1968 if (name_mod == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
1969 int w = name_size*name_min; int h = name_size;
223b71206888 Initial import
thib
parents:
diff changeset
1970 int name_waku;
223b71206888 Initial import
thib
parents:
diff changeset
1971 sprintf(key, "#WINDOW.%03d.NAME_WAKU_SETNO", win_no);
223b71206888 Initial import
thib
parents:
diff changeset
1972 if (config.GetParam(key, 1, &name_waku) != -1 && name_waku != -1) {
223b71206888 Initial import
thib
parents:
diff changeset
1973 Rect waku_r = WakuSize(parent, name_waku, config);
223b71206888 Initial import
thib
parents:
diff changeset
1974 waku_r.rmove(r.lx, r.ty); // テキストウィンドウ位置に動かす
223b71206888 Initial import
thib
parents:
diff changeset
1975 waku_r.rmove(name_posx, name_posy-waku_r.height()); // NAME_POS へ位置補正
223b71206888 Initial import
thib
parents:
diff changeset
1976 name_container = parent.create_node(waku_r, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1977 MakeWaku(*name_container, event, name_waku, win_no, 0, config, callback);
223b71206888 Initial import
thib
parents:
diff changeset
1978 Rect name_r(0,0,w,h);
223b71206888 Initial import
thib
parents:
diff changeset
1979 name_r.rmove(name_mposx, name_mposy);
223b71206888 Initial import
thib
parents:
diff changeset
1980 name = new WidLabel(name_container, name_r, true, 0, name_size);
223b71206888 Initial import
thib
parents:
diff changeset
1981 name->show();
223b71206888 Initial import
thib
parents:
diff changeset
1982 } else { // 名前専用枠なし
223b71206888 Initial import
thib
parents:
diff changeset
1983 Rect name_r(0, 0, w, h);
223b71206888 Initial import
thib
parents:
diff changeset
1984 name_r.rmove(r.lx, r.ty);
223b71206888 Initial import
thib
parents:
diff changeset
1985 name_r.rmove(name_posx, name_posy-name_size);
223b71206888 Initial import
thib
parents:
diff changeset
1986 name_container = parent.create_node(name_r, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1987 name = new WidLabel(name_container, Rect(0,0,w,h), true, 0, name_size);
223b71206888 Initial import
thib
parents:
diff changeset
1988 name->show();
223b71206888 Initial import
thib
parents:
diff changeset
1989 name_container->show();
223b71206888 Initial import
thib
parents:
diff changeset
1990 }
223b71206888 Initial import
thib
parents:
diff changeset
1991 } else { // name_mod == 2 or 3
223b71206888 Initial import
thib
parents:
diff changeset
1992 name_container = parent.create_node( Rect(0,0,1,1), 0);
223b71206888 Initial import
thib
parents:
diff changeset
1993 }
223b71206888 Initial import
thib
parents:
diff changeset
1994 }
223b71206888 Initial import
thib
parents:
diff changeset
1995 MakeWaku(*wid->PicNode(), event,waku_no, win_no, use_btn, config, callback);
223b71206888 Initial import
thib
parents:
diff changeset
1996 }
223b71206888 Initial import
thib
parents:
diff changeset
1997 void TextImpl::InitWindow(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1998 int i,j,k;
223b71206888 Initial import
thib
parents:
diff changeset
1999 int w;
223b71206888 Initial import
thib
parents:
diff changeset
2000 std::string str;
223b71206888 Initial import
thib
parents:
diff changeset
2001
223b71206888 Initial import
thib
parents:
diff changeset
2002 for (w=0; w<32; w++) {
223b71206888 Initial import
thib
parents:
diff changeset
2003 widgets[w] = new TextWindow(parent, event, w, config, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
2004 if (widgets[w]->wid == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2005 delete widgets[w];
223b71206888 Initial import
thib
parents:
diff changeset
2006 widgets[w] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
2007 }
223b71206888 Initial import
thib
parents:
diff changeset
2008 }
223b71206888 Initial import
thib
parents:
diff changeset
2009 SetCursor(0);
223b71206888 Initial import
thib
parents:
diff changeset
2010 for (i=0; i<26; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
2011 char buf[1024];
223b71206888 Initial import
thib
parents:
diff changeset
2012 sprintf(buf, "#NAME.%c", i+'A');
223b71206888 Initial import
thib
parents:
diff changeset
2013 const char* s = config.GetParaStr(buf);
223b71206888 Initial import
thib
parents:
diff changeset
2014 if (s) replace_name[i] = s;
223b71206888 Initial import
thib
parents:
diff changeset
2015 }
223b71206888 Initial import
thib
parents:
diff changeset
2016 // replace_name2 : 初期設定
223b71206888 Initial import
thib
parents:
diff changeset
2017 // 渚、秋生、渚 (CLANNAD)
223b71206888 Initial import
thib
parents:
diff changeset
2018 char name_nagisa[3] = {0x8f,0x8d,0};
223b71206888 Initial import
thib
parents:
diff changeset
2019 char name_akio[5] = {0x8f, 0x48, 0x90, 0xb6, 0};
223b71206888 Initial import
thib
parents:
diff changeset
2020 replace_name2[0] = name_nagisa;
223b71206888 Initial import
thib
parents:
diff changeset
2021 replace_name2[1] = name_akio;
223b71206888 Initial import
thib
parents:
diff changeset
2022 replace_name2[2] = name_nagisa;
223b71206888 Initial import
thib
parents:
diff changeset
2023 text = 0;
223b71206888 Initial import
thib
parents:
diff changeset
2024 /* テキスト速度の設定 */
223b71206888 Initial import
thib
parents:
diff changeset
2025 int speed, mod, wait, auto_mod;
223b71206888 Initial import
thib
parents:
diff changeset
2026 config.GetParam("#INIT_MESSAGE_SPEED", 1, &speed);
223b71206888 Initial import
thib
parents:
diff changeset
2027 config.GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &mod);
223b71206888 Initial import
thib
parents:
diff changeset
2028 config.GetParam("#MESSAGE_KEY_WAIT_USE", 1, &auto_mod);
223b71206888 Initial import
thib
parents:
diff changeset
2029 config.GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait);
223b71206888 Initial import
thib
parents:
diff changeset
2030 if (mod) speed = -1;
223b71206888 Initial import
thib
parents:
diff changeset
2031 if (!auto_mod) wait = -1;
223b71206888 Initial import
thib
parents:
diff changeset
2032 SetTextSpeed(speed);
223b71206888 Initial import
thib
parents:
diff changeset
2033 SetTextWait(wait);
223b71206888 Initial import
thib
parents:
diff changeset
2034 return;
223b71206888 Initial import
thib
parents:
diff changeset
2035 }