Mercurial > otakunoraifu
annotate scn2k/scn2k_grp.cc @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 35ce1a30f3f9 |
children | ddbcbd000206 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
52 | 28 #include "scn2k.h" |
29 #include "window/widget.h" | |
30 #include "system/file.h" | |
31 #include "system/system_config.h" | |
32 #include "font/text.h" | |
33 #include <set> | |
0 | 34 |
35 using namespace std; | |
36 | |
37 extern void DSurfaceFill(Surface* dest, const Rect& rect, int r, int g, int b, int a=0xff); | |
38 extern void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstpos); | |
39 extern Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect, | |
40 Surface* dst, const Rect& dstrect); | |
41 extern XKFont::HorizLayout* DefaultLayout(int text_size); | |
42 | |
43 /******************************************************************* | |
44 ** GrpObj(interface) | |
45 */ | |
46 | |
47 struct SEL { | |
48 Rect from; | |
49 Rect to; | |
50 int time; | |
51 int sel_no; | |
52 int args[8]; | |
53 SEL() : from(0,0), to(0,0) {} | |
54 }; | |
55 | |
56 struct GrpObj { | |
57 string name; | |
58 string gan_name; | |
59 PicContainer* pic_parent; | |
60 PicBase* picture; | |
61 WidAnmTime* anm; | |
62 int _posx, _posy; | |
52 | 63 int posx[9], posy[9]; |
0 | 64 Rect clip_area; |
65 unsigned char alpha; | |
66 int order; | |
67 int surface_num; | |
68 | |
69 string print_moji; | |
70 int print_size, print_r, print_b, print_g; | |
71 | |
72 int dig_number, dig_digit; | |
73 | |
74 // zoom / rotate 関係 | |
75 int zoom; // 256 で 1 倍 | |
76 int rotate; // 0-360度 | |
77 | |
78 vector<Rect> src_pos; | |
79 enum GrpType { FILLRECT = 1, FILE = 2, GAN = 3, MOJI = 4, DIGIT = 5} gtype; | |
80 enum Attribute { NONE=0, WIPEON=1, SATURATE=2, HIDDEN=4, HIDDEN_GROUP=8, | |
18 | 81 UPDATE_PICTURE = 16, UPDATE_POS = 32, UPDATE_ALPHA = 64, UPDATE_SNUM = 128, UPDATE_CLIP = 256, UPDATE_VISIBLE = 512, |
82 UPDATE_ALL = (16|32|64|128|256|512), | |
0 | 83 ANM_PLAYSTART = 0x8000, ANM_PLAYING = 0x10000, |
84 DIG_ZERO = 0x10000*2, DIG_SIGN = 0x10000*4, DIG_PACK=0x10000*8,DIG_SPACE=0x10000*16 | |
85 }; | |
86 Attribute attr; | |
87 | |
88 GrpImpl* parent_pimpl; | |
89 | |
90 GrpObj(void); | |
91 ~GrpObj(void); | |
92 | |
93 void SetPos(int index, int x, int y); | |
94 void GetPos(int index, int& x, int& y); | |
95 int PosX(void); | |
96 int PosY(void); | |
97 void SetAlpha(void); | |
98 void SetAlpha(int alpha); | |
99 void SetSurfaceNum(int num = -1); | |
100 void SetZoomRotate(int zoom=-1, int rotate=-1); | |
101 void SetClipArea(int x, int y, int width, int height); | |
102 void GetSrcGeom(int& width, int& height); | |
103 void SetUpdate(void); | |
104 TextStream ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size); | |
105 void UpdateMoji(void); | |
106 void UpdateDigit(void); | |
107 void UpdateSurface(void); | |
108 void ZoomRotate(void); | |
109 void Update(void); | |
110 void CreateSurface(PicContainer* parent); | |
111 void CreateGan(Event::Container& event, int event_number); | |
112 void CreateGanSpecial(Event::Container& event, int event_number, int time); | |
113 PicBase* DeletePic(void); | |
114 }; | |
115 | |
116 /******************************************************************* | |
117 ** GrpObj(interface) | |
118 */ | |
119 | |
120 | |
121 struct GrpObjMap : std::map<int, GrpObj> { | |
122 typedef pair<const int, GrpObj> value_type; | |
123 class GrpImpl* parent; | |
124 GrpObj& operator[](const int& k) { | |
125 iterator it = lower_bound(k); | |
126 if (it == end() || it->first != k) { | |
127 GrpObj obj; | |
128 obj.parent_pimpl = parent; | |
129 it = insert(it, value_type(k, obj)); | |
130 } | |
131 return it->second; | |
132 } | |
133 GrpObjMap(class GrpImpl* p) { | |
134 parent = p; | |
135 } | |
136 }; | |
137 | |
138 class GrpImpl { | |
139 #define MAXPDT 256 | |
140 #define WORKPDT 255 | |
52 | 141 private: |
142 Event::Container& event; | |
143 const Flags& flags; | |
144 PicBase* screen; | |
145 PicBase* screen_front; | |
146 Surface* surface, *surface_update; | |
0 | 147 |
52 | 148 Surface* dsurface[MAXPDT]; // 書き込み可能な Surface |
149 Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface | |
150 PicContainer& parent; | |
0 | 151 |
52 | 152 // 画像効果の保存用 |
153 WidAnmTime* anm1, *anm2; | |
154 typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status; | |
155 Status status; | |
156 SkipMode skip_mode; | |
0 | 157 |
52 | 158 std::string bg_name; |
159 std::map<int, SEL> anmtype; | |
160 GrpObjMap grpobj; | |
161 GrpObjMap bs_obj; | |
162 void CreateObj(int number); | |
163 void ZMoveObj(int number); | |
164 void SetObjChanged(int number); | |
165 void SetObjChangedGroup(int number); | |
166 void SwapObj(int a1, int a2); | |
167 void DeleteObjPic(int num);// object の surface のみ削除 | |
168 void DeleteObj(int num); | |
169 void DeleteObjRange(int num_b, int num_e); | |
0 | 170 |
52 | 171 std::set<int> changed_obj; |
172 string reserved_load_surface0; | |
173 vector<PicBase*> deleted_pic; | |
174 void RefreshObj(void); | |
0 | 175 |
52 | 176 Surface* Dsurface(int pdt); |
177 Surface* Ssurface(int pdt); | |
0 | 178 |
52 | 179 // cgmode 用画像処理関連 |
180 void LoadCgm(AyuSysConfig& config); | |
181 std::map<std::string, int> cgm_info; | |
182 set<int>& cgm_data; | |
183 int cgm_size; | |
184 | |
185 class MuSys& music; | |
186 | |
187 public: | |
188 AyuSysConfig& config; | |
189 void LoadSurface(const char* str, int pdt); | |
0 | 190 |
52 | 191 private: |
192 void LoadSurface(const char* str); | |
193 void LoadSurface(void); | |
194 void AddSurface(const char* str); | |
195 | |
196 void StartAnm(int type); | |
197 void StartShake(int total, const int* pattern); | |
198 void AbortAnm(void); | |
199 static bool Pressed(int x, int y, void* pointer); | |
0 | 200 |
52 | 201 public: |
202 GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config); | |
203 ~GrpImpl(); | |
204 bool Wait(unsigned int current_time, Cmd& cmd); | |
205 void Exec(Cmd& cmd); | |
206 void InitSel(AyuSysConfig& config); | |
207 void Save(std::string& str); | |
208 void Load(const char* str); | |
209 void SaveSys(std::string& str); | |
210 void LoadSys(const char* str); | |
211 void SetSkipMode(SkipMode _mode); | |
0 | 212 }; |
213 /******************************************************************* | |
214 ** GrpObj(implementation) | |
215 */ | |
216 | |
217 GrpObj::GrpObj(void) : | |
218 name(""), gan_name(""), pic_parent(0), picture(0), anm(0), | |
219 _posx(0), _posy(0), clip_area(0,0,0,0), | |
220 alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1), | |
221 dig_number(0), dig_digit(0), | |
222 zoom(-1), rotate(-1), attr(GrpObj::HIDDEN), parent_pimpl(0) { | |
223 int i; | |
224 for (i=0; i<9; i++) { | |
225 posx[i] = posy[i] = 0; | |
226 } | |
227 } | |
52 | 228 |
0 | 229 GrpObj::~GrpObj() { |
230 if (picture) delete picture; | |
231 if (parent_pimpl == 0) { | |
232 fprintf(stderr,"\n**************\nFATAL : UNINITIALIZED GrpObj IS FOUND!!! \n**************\n"); | |
233 } | |
234 } | |
52 | 235 |
0 | 236 int GrpObj::PosX() { |
237 return _posx; | |
238 } | |
52 | 239 |
0 | 240 int GrpObj::PosY() { |
241 return _posy; | |
242 } | |
52 | 243 |
0 | 244 void GrpObj::SetUpdate(void) { |
245 attr = Attribute (attr | UPDATE_PICTURE); | |
18 | 246 //Update(); //FIXME |
0 | 247 } |
52 | 248 |
0 | 249 void GrpObj::SetPos(int index, int x,int y) { |
250 if (index < 0 || index > 8) { | |
251 fprintf(stderr,"GrpObj::SetPos: Invalid index %d <- %d,%d\n",index,x,y); | |
252 return; | |
253 } | |
254 if (x == posx[index] && y == posy[index]) return; | |
255 attr = Attribute(attr | UPDATE_POS); | |
256 _posx += x-posx[index]; | |
257 _posy += y-posy[index]; | |
258 posx[index] = x; | |
259 posy[index] = y; | |
260 } | |
52 | 261 |
0 | 262 void GrpObj::GetPos(int index, int& x, int& y) { |
263 if (index < 0 || index > 8) { | |
264 fprintf(stderr,"GrpObj::GetPos: Invalid index %d\n",index); | |
265 x = 0; y = 0; | |
266 return; | |
267 } | |
268 x = posx[index]; | |
269 y = posy[index]; | |
270 return; | |
271 } | |
52 | 272 |
0 | 273 void GrpObj::SetAlpha(int new_alpha) { |
274 if (alpha == new_alpha) return; | |
275 alpha = new_alpha; | |
276 attr = Attribute(attr | UPDATE_ALPHA); | |
277 return; | |
278 } | |
52 | 279 |
0 | 280 void GrpObj::SetSurfaceNum(int num) { |
281 if (num != -1) { | |
282 if (surface_num == num) return; | |
283 surface_num = num; | |
284 } | |
285 attr = Attribute(attr | UPDATE_SNUM); | |
286 return; | |
287 } | |
288 | |
289 void GrpObj::SetClipArea(int x, int y, int w, int h) { | |
290 Rect new_clip(x,y,x+w,y+h); | |
291 if (clip_area == new_clip) return; | |
292 clip_area = new_clip; | |
293 attr = Attribute(attr | UPDATE_CLIP); | |
294 return; | |
295 } | |
52 | 296 |
0 | 297 PicBase* GrpObj::DeletePic(void) { |
298 PicBase* p = picture; | |
299 anm = 0; | |
300 picture = 0; | |
301 src_pos.clear(); | |
302 attr = Attribute(attr & (HIDDEN | HIDDEN_GROUP)); | |
303 return p; | |
304 } | |
52 | 305 |
0 | 306 void GrpObj::GetSrcGeom(int& width, int& height) { |
307 if (src_pos.empty()) { | |
308 width = 0; height = 0; | |
309 if (name.length() == 0) { | |
310 return; | |
311 } | |
312 /* ボタンの位置情報を求める */ | |
313 /* g00 ファイルのヘッダ部分に位置情報は入っている */ | |
314 string path(name); | |
315 path += ".g00"; | |
316 ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, path.c_str(), "g00"); | |
52 | 317 if (info == NULL) { // ファイルが見つからない |
318 fprintf(stderr, "GrpObj::GetSrcGeom : Cannot find file %s\n", path.c_str()); | |
0 | 319 return; |
320 } | |
321 const char* data = info->Read(); | |
52 | 322 if (data != NULL && *data == 2) { // 画像ファイル内にボタン情報が存在する |
0 | 323 int srclen = read_little_endian_int(data+5); |
324 int i; | |
325 for (i=0; i<srclen; i++) { | |
326 int x1 = read_little_endian_int(data+9+i*24+0); | |
327 int y1 = read_little_endian_int(data+9+i*24+4); | |
328 int x2 = read_little_endian_int(data+9+i*24+8); | |
329 int y2 = read_little_endian_int(data+9+i*24+12); | |
330 src_pos.push_back(Rect(x1, y1, x2+1, y2+1)); | |
331 if (width < src_pos.back().width()) width = src_pos.back().width(); | |
332 if (height < src_pos.back().height()) height = src_pos.back().height(); | |
333 } | |
334 } else { // 画像ファイルから大きさ取得 | |
335 width = read_little_endian_short(data+1); | |
336 height = read_little_endian_short(data+3); | |
337 src_pos.push_back(Rect(0,0,width,height)); | |
338 } | |
339 delete info; | |
340 } | |
341 int sn = surface_num; | |
342 if (sn < 0 || sn > src_pos.size()) sn = 0; | |
343 width = src_pos[sn].width(); | |
344 height = src_pos[sn].height(); | |
345 return; | |
346 } | |
52 | 347 |
0 | 348 void GrpObj::Update(void) { |
349 if (attr & UPDATE_PICTURE) { | |
350 UpdateSurface(); | |
351 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE)); | |
352 } | |
353 if (picture == 0) return; | |
354 if (attr & UPDATE_POS) { | |
18 | 355 if ( (attr & SATURATE) || zoom != -1) { |
0 | 356 int w=0, h=0; |
357 GetSrcGeom(w,h); | |
358 picture->Move(_posx-w/2, _posy-h/2); | |
359 } else { | |
360 picture->Move(_posx, _posy); | |
361 } | |
362 } | |
363 if (attr & UPDATE_ALPHA) { | |
364 if (alpha <= 0) { | |
365 picture->SetSurfaceAlpha(0, Rect(0,0)); | |
366 picture->hide(); | |
367 } else if (alpha >= ALPHA_MAX) { | |
368 picture->SetSurfaceAlpha(0, Rect(0,0)); | |
369 if (attr & HIDDEN) picture->hide(); | |
370 else picture->show(); | |
371 } else { | |
372 picture->SetSurfaceAlpha(&alpha, Rect(0,0,1,1)); | |
373 if (attr & HIDDEN) picture->hide(); | |
374 else picture->show(); | |
375 } | |
376 } | |
377 if ( (attr & UPDATE_SNUM) && (!src_pos.empty())) { | |
378 if (surface_num < 0 || surface_num >= src_pos.size()) surface_num = 0; | |
379 picture->SetSurfacePos(src_pos[surface_num].lx, src_pos[surface_num].ty); | |
380 } | |
381 if (attr & UPDATE_CLIP) { | |
382 picture->SetClipArea(clip_area); | |
383 } | |
384 attr = Attribute(attr & (~UPDATE_ALL)); | |
385 if (attr & ANM_PLAYSTART) { | |
386 if (anm) { | |
387 anm->Play(); | |
388 attr = Attribute(attr | ANM_PLAYING); | |
389 } | |
390 attr = Attribute(attr & (~ANM_PLAYSTART)); | |
391 } | |
392 } | |
52 | 393 |
0 | 394 void GrpObj::CreateSurface(PicContainer* parent) { |
52 | 395 if (picture != NULL) { |
0 | 396 PicBase* p = DeletePic(); |
397 delete p; | |
398 } | |
399 src_pos.clear(); | |
400 // picture を作成 | |
401 pic_parent = parent; | |
402 picture = parent->create_leaf(Rect(_posx,_posy,_posx+1,_posy+1), 0); | |
403 picture->hide(); | |
404 UpdateSurface(); | |
405 } | |
406 | |
407 void GrpObj::UpdateSurface(void) { | |
52 | 408 if (pic_parent == NULL || picture == NULL) return; |
0 | 409 int width = 0, height = 0; |
410 if (gtype == FILE || gtype == GAN) { | |
411 if (name.length() == 0) return; | |
412 // ファイル名が存在する場合、ファイルを読み込み | |
413 GetSrcGeom(width, height); | |
414 if (width <= 0 || height <= 0) return; | |
415 // surface の設定 | |
416 if (surface_num == 0 && ( (zoom > 0 && zoom != 256) || rotate > 0)) { | |
417 ZoomRotate(); | |
418 } else { | |
419 // 普通に surface を設定 | |
420 string path(name); | |
421 path += ".g00"; | |
422 picture->SetSurface(path.c_str(), 0, 0); | |
423 picture->SetSurfaceRect(Rect(0,0,width,height)); | |
424 } | |
425 if (attr & SATURATE) | |
426 picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); | |
427 } else if (gtype == MOJI) { // テキスト描画 | |
428 if (print_moji.length() == 0) return; | |
429 UpdateMoji(); | |
430 } else if (gtype == DIGIT) { // 数値を画像表示 | |
431 UpdateDigit(); | |
432 } | |
433 } | |
52 | 434 |
0 | 435 void GrpObj::ZoomRotate(void) { |
52 | 436 picture->SetSurface( (Surface*)0, 0, 0); |
0 | 437 |
438 // 回転、縮小拡大は座標原点が画像の中心になる | |
439 string path(name); | |
440 path += ".g00"; | |
441 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); | |
52 | 442 if (surface_orig == NULL) return; |
0 | 443 |
444 Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate); | |
445 Rect zoom_r (*zoom_surface); | |
446 picture->SetSurface(zoom_surface, 0, 0); | |
447 picture->SetSurfaceFreeFlag(); | |
448 //picture->Move(PosX() + - zoom_r.width()/2, PosY() + - zoom_r.height()/2); | |
449 // 中心座標がわからん・・・ | |
450 picture->Move(320 - zoom_r.width()/2, 240 - zoom_r.height()/2); | |
451 picture->SetSurfaceRect(Rect(0, 0, zoom_r.width(), zoom_r.height())); | |
452 | |
453 pic_parent->Root().DeleteSurface(surface_orig); | |
454 } | |
455 | |
456 static char* wstrchr(const char* s, unsigned int chr) { | |
457 int ws, wc; | |
458 while(*s != 0) { | |
459 if (*s < 0 && s[1] != 0) { | |
460 wc = int((unsigned char)(s[0]))*0x100 + int((unsigned char)(s[1])); | |
461 ws = 2; | |
462 } else { | |
463 wc = (unsigned char)(s[0]); | |
464 ws = 1; | |
465 } | |
466 if (wc == chr) return (char*)s; | |
467 s += ws; | |
468 } | |
52 | 469 return NULL; |
0 | 470 } |
52 | 471 |
472 //TODO: See why it does nothing with font/text_stream.cc:98 | |
0 | 473 TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse |
474 TextStream ts; | |
475 ts.kanji_type = TextStream::sjis; | |
476 ts.SetColor(def_r, def_g, def_b); | |
477 char* copy_str = new char[strlen(str)+1]; | |
478 char* next_str; | |
479 char* retptr; | |
480 int var; | |
481 | |
52 | 482 while( (next_str = wstrchr(str, '#')) != NULL) { |
0 | 483 int len = next_str - str; |
484 strncpy(copy_str, str, len); | |
485 copy_str[len] = 0; | |
486 ts.Add(copy_str); | |
487 str = next_str + 1; | |
488 | |
489 switch(str[0]) { | |
490 case '#': // separator | |
491 str += 1; | |
492 break; | |
493 case 'D': case 'd': // return | |
494 ts.AddReturn(); | |
495 str += 1; | |
496 break; | |
497 case 'C': case 'c': // color | |
498 str += 1; | |
499 var = strtol(str, &next_str,10); | |
500 if (var == 0 && str == next_str) { // no parameter | |
501 ts.SetColor(def_r, def_g, def_b); | |
502 } else { | |
503 int r,g,b; char key[1024]; | |
504 sprintf(key, "#COLOR_TABLE.%03d", var); | |
505 if (parent_pimpl->config.GetParam(key, 3, &r, &g, &b)) { // color not found | |
506 r = g = b = 0; | |
507 } | |
52 | 508 ts.SetColor(r, g, b); |
0 | 509 str = next_str; |
510 } | |
511 break; | |
512 case 'S': case 's': // size | |
513 str += 1; | |
514 var = strtol(str, &next_str, 10); | |
515 if (var == 0 && str == next_str) { // no parameter | |
516 ts.SetSize(1); | |
517 } else { | |
518 if (def_size == 0) def_size = 20; | |
519 if (var <= 0) var = 1; | |
520 ts.SetSize(double(var)/def_size); | |
521 } | |
522 break; | |
523 case 'X': case 'x': // xpos : not supported | |
524 case 'Y': case 'y': // ypos : not supported | |
525 default: | |
526 ts.Add("#"); | |
527 break; | |
528 } | |
529 } | |
530 ts.Add(str); | |
50 | 531 delete[] copy_str; |
0 | 532 return ts; |
533 } | |
52 | 534 |
0 | 535 void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更 |
14
8da1d92ac8f8
Don't create fonts faces for size <= 0, and update objects when their font size is set
thib
parents:
11
diff
changeset
|
536 if (print_moji.length() == 0 || print_size <= 2) return; |
0 | 537 if (pic_parent == 0) return; |
538 /* テキストの大きさを得る */ | |
539 int r, g, b; | |
540 if (print_r == -1 || print_g == -1 || print_b == -1) {// 色設定なし | |
541 r = g = b = 0; // とりあえず黒(clannad のSave/Loadメニュー用) | |
542 } else { | |
543 r = print_r; | |
544 g = print_g; | |
545 b = print_b; | |
546 } | |
547 TextStream ts = ParseMoji(print_moji.c_str(), r, g, b, print_size); | |
548 TextGlyphStream gs; | |
549 vector<int> lh; | |
550 // とりあえず drawable width は充分に大きく(2048)取る | |
551 DefaultLayout(print_size-2)->Layout(ts, gs, lh, 2048); // print_size そのままだと弱干大きすぎるので -2 | |
552 int width = gs.width(); | |
553 int height = gs.height(); | |
554 Surface* surface = pic_parent->Root().NewSurface(width, height, ALPHA_MASK); | |
555 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | |
556 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0, 0, width, height), surface, Rect(0,0)); | |
557 picture->SetSurface(surface, 0, 0); | |
558 picture->SetSurfaceRect(Rect(0,0,width,height)); | |
559 picture->SetSurfaceFreeFlag(); | |
560 } | |
52 | 561 |
0 | 562 void GrpObj::UpdateDigit(void) { |
563 // 画像表示の数値文字列を表示する | |
564 if (name.length() == 0) return; | |
565 // ファイル名が存在する場合、ファイルを読み込み | |
566 string path(name); | |
567 path += ".g00"; | |
568 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); | |
52 | 569 if (surface_orig == NULL) return; |
0 | 570 |
571 int width, height; | |
572 int i; | |
573 GetSrcGeom(width, height); | |
574 if (width <= 0 || height <= 0) return; | |
575 if (src_pos.size() < 14) { | |
576 // 必要な数の object がない | |
577 // 表示できない分の空の rect を追加しておく | |
578 for (i=src_pos.size(); i<14; i++) | |
579 src_pos.push_back(Rect(0,0,0,0)); | |
580 pic_parent->Root().DeleteSurface(surface_orig); | |
581 return; | |
582 } | |
583 // 桁数の計算 | |
584 char num_str[20]; | |
585 if (dig_number < 0) sprintf(num_str, "%d", -dig_number); | |
586 else sprintf(num_str, "%d", dig_number); | |
587 int sign_count = 0; | |
588 int space_count = 0; | |
589 int total_count; | |
590 int dig_count = strlen(num_str); | |
591 if (dig_number < 0 && (attr&DIG_SIGN) == 0) dig_count++; | |
592 if (dig_count < dig_digit) space_count = dig_digit - dig_count; | |
593 if (attr & DIG_SIGN) sign_count = 1; | |
594 total_count = dig_count + space_count + sign_count; | |
595 | |
596 Surface* surface = pic_parent->Root().NewSurface(width*total_count, height, ALPHA_MASK); | |
597 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | |
598 | |
599 /* surface にコピーする */ | |
600 int cur_x = 0; | |
601 if ( (attr & DIG_PACK) && !(attr & DIG_ZERO)) { // 始めに空白を挿入 | |
602 cur_x += space_count * width; | |
603 } | |
604 int plus = 10, minus = 11, plusminus = 12; | |
605 if (dig_number < 0) { | |
606 DSurfaceMove(surface, src_pos[minus], surface, Rect(cur_x,0)); | |
607 cur_x += width; | |
608 } else if (attr & DIG_SIGN) { | |
609 if (dig_number == 0) | |
610 DSurfaceMove(surface, src_pos[plusminus], surface, Rect(cur_x,0)); | |
611 else | |
612 DSurfaceMove(surface, src_pos[plus], surface, Rect(cur_x,0)); | |
613 cur_x += width; | |
614 } | |
615 if (attr & DIG_ZERO) { // ゼロ・パディング | |
616 for (i=0; i<space_count; i++) { | |
617 DSurfaceMove(surface, src_pos[0], surface, Rect(cur_x, 0)); | |
618 cur_x += width;; | |
619 } | |
620 } else if (!(attr & DIG_PACK)) { // PACK オプションなし | |
621 cur_x += space_count * width; | |
622 } | |
623 for (i=0; num_str[i] != 0; i++) { | |
624 DSurfaceMove(surface_orig, src_pos[num_str[i]-'0'], surface, Rect(cur_x, 0)); | |
625 cur_x += width; | |
626 } | |
627 | |
628 /* picture に設定 */ | |
629 picture->SetSurface(surface, 0, 0); | |
630 picture->SetSurfaceRect(Rect(0,0,width*total_count,height)); | |
631 picture->SetSurfaceFreeFlag(); | |
632 | |
633 pic_parent->Root().DeleteSurface(surface_orig); | |
634 } | |
52 | 635 |
0 | 636 void GrpObj::CreateGan(Event::Container& event, int event_number) { |
52 | 637 if (picture == NULL) { |
0 | 638 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); |
639 return; | |
640 } | |
641 if (anm) { | |
642 anm->Abort(); | |
643 delete anm; | |
644 } | |
645 if (gan_name.empty()) return; | |
646 /* アニーメション情報 (.GAN ファイル)を求める */ | |
647 string path(gan_name); | |
648 path += ".gan"; | |
649 ARCINFO* info = file_searcher.Find(FILESEARCH::GAN, path.c_str(), "gan"); | |
52 | 650 if (info == NULL) { |
0 | 651 fprintf(stderr,"GrpObj::CreateGan: Cannot Find 'GAN' file %s\n", path.c_str()); |
652 return; | |
653 } | |
654 const char* data = info->Read(); | |
655 if (read_little_endian_int(data) != 10000 || read_little_endian_int(data+4) != 10000) { | |
656 fprintf(stderr,"GrpObj::CreateGan: Invalid'GAN' file %s\n", path.c_str()); | |
657 delete info; | |
658 return; | |
659 } | |
660 | |
661 picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE); | |
662 attr = Attribute(attr | UPDATE_POS | SATURATE); | |
663 | |
664 const char* buf = data + 16; | |
665 buf += strlen(buf) + 1; // 画像ファイル名が入っている | |
666 buf += 4; // 定数 20000 | |
667 int pics = read_little_endian_int(buf); buf += 4; // 複数のアニメーション情報が入っている場合、情報数 | |
668 // 以下、pics 回繰り返し | |
669 // アニメーションを行う実体を作成 | |
670 AnmAlphaMove* wid = new AnmAlphaMove(event, picture); | |
671 | |
672 if (event_number && event_number < pics) { // 複数のアニメーション情報がある場合、先の情報を読み飛ばす */ | |
673 int i; for (i=0; i<event_number; i++) { | |
674 buf += 4; // 定数 30000 | |
675 int ptns = read_little_endian_int(buf); buf += 4; | |
676 buf += ptns*52; | |
677 } | |
678 } | |
679 buf += 4; // 定数 30000 | |
680 int ptns = read_little_endian_int(buf); buf += 4; | |
681 int total_time = 0; | |
682 int i; | |
683 for (i=0; i<ptns; i++) { | |
684 int p = read_little_endian_int(buf+i*52+0*8+4); | |
685 int x = read_little_endian_int(buf+i*52+1*8+4); | |
686 int y = read_little_endian_int(buf+i*52+2*8+4); | |
687 int t = read_little_endian_int(buf+i*52+3*8+4); | |
688 int a = read_little_endian_int(buf+i*52+4*8+4); | |
689 x += PosX(); | |
690 y += PosY(); | |
691 if (p == -1) { a = 0; p = 0; } // p == -1 ならなにも表示しない | |
692 if (p >= src_pos.size()) { | |
693 fprintf(stderr,"Reading GAN file %s (G00 %s) : not enough pictures in .G00 file\n", path.c_str(), name.c_str()); | |
694 a = 0; p = 0; | |
695 } | |
696 total_time += t; | |
697 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), src_pos[p], a, total_time)); | |
698 } | |
699 wid->SetPtn(); // パターン登録終了 | |
700 attr = Attribute(attr | ANM_PLAYSTART); | |
701 anm = wid; | |
52 | 702 } |
703 | |
0 | 704 void GrpObj::CreateGanSpecial(Event::Container& event, int event_number, int time) { |
52 | 705 if (picture == NULL) { |
0 | 706 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); |
707 return; | |
708 } | |
709 if (anm) { | |
710 anm->Abort(); | |
711 delete anm; | |
712 } | |
713 | |
714 // アニメーションを行う実体を作成 | |
715 AnmAlphaMove* wid = new AnmAlphaMove(event, picture); | |
716 | |
717 int i; | |
718 switch(event_number) { | |
52 | 719 case 0: // pattern を 0 から最後まで変化させる |
720 for (i=0; i<src_pos.size(); i++) { | |
721 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(PosX(), PosY()), src_pos[i], 255, time*i)); | |
722 } | |
723 wid->SetPtn(); // パターン登録終了 | |
724 anm = wid; | |
725 attr = Attribute(attr | ANM_PLAYSTART); | |
726 break; | |
727 default: | |
728 break; | |
0 | 729 } |
52 | 730 } |
0 | 731 |
732 void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) { | |
733 if (zoom == new_zoom && rotate == new_rotate) return; | |
18 | 734 if ( zoom == -1 || new_zoom == -1) { |
735 attr = Attribute(attr | UPDATE_POS); // centering する | |
736 } | |
737 zoom = new_zoom; | |
0 | 738 if (new_rotate != -1) rotate = new_rotate; |
739 if (zoom < 0) zoom = 256; | |
740 if (rotate < 0) rotate = 0; | |
741 else if (rotate > 360) rotate %= 360; | |
742 | |
743 attr = Attribute(attr | UPDATE_PICTURE); | |
744 } | |
745 /****************************************************************** | |
746 ** | |
747 ** class ScnGrp* | |
748 */ | |
749 /* Princess Bride: 背景画の一部のみ移動、の実装 */ | |
750 struct ScnGrpMove : public WidAnmTime { | |
751 Surface* dest; | |
752 Surface* src; | |
753 PicRoot& root; | |
754 Rect dest_r, from, to; | |
755 ScnGrpMove(Event::Container& container, PicBase* _pic, PicRoot& root, Surface* dest, const Rect& _dest_r, Surface* src, const Rect& from, const Rect& to, int total_time); | |
756 void Exec(int count); | |
757 }; | |
758 ScnGrpMove::ScnGrpMove(Event::Container& container, PicBase* _pic, PicRoot& _root, Surface* _dest, const Rect& _dest_r, Surface* _src, const Rect& _from, const Rect& _to, int total_time) : | |
759 WidAnmTime(container, _pic, total_time), | |
760 dest(_dest), src(_src), root(_root),dest_r(_dest_r), from(_from), to(_to) { | |
761 int dx = to.lx - from.lx; | |
762 int dy = to.ty - from.ty; | |
763 if (dx < 0) dx = -dx; | |
764 if (dy < 0) dy = -dy; | |
765 if (dx < dy) dx = dy; | |
766 if (dx == 0) dx = 1; | |
767 SetAllCount(dx); | |
768 } | |
52 | 769 |
0 | 770 void ScnGrpMove::Exec(int count) { |
771 Rect r(0,0,dest_r.width(),dest_r.height()); | |
772 int dx = to.lx - from.lx; | |
773 int dy = to.ty - from.ty; | |
774 int x = dx*count/all_count + from.lx; | |
775 int y = dy*count/all_count + from.ty; | |
776 r.rmove(x, y); | |
777 root.BlitSurface(src, r, dest, dest_r); | |
778 iterator it; | |
779 for (it=pic.begin(); it!=pic.end(); it++) | |
780 (*it)->SetSurface(dest, 0, 0); | |
781 } | |
782 | |
783 /* Princess Bride: カードがおちるアニメーション */ | |
784 | |
785 struct ScnGrpAnmAtom { | |
786 string name; | |
787 int time; | |
788 ScnGrpAnmAtom(const char* _n, int _t) : name(_n), time(_t) {} | |
789 }; | |
52 | 790 |
0 | 791 struct ScnGrpAnm : public WidAnmTime, vector<ScnGrpAnmAtom> { |
792 GrpImpl& owner; | |
793 ScnGrpAnm(Event::Container& container, PicBase* _pic, GrpImpl& _owner) : | |
794 WidAnmTime(container, _pic, 0), owner(_owner) { | |
795 } | |
796 void CalcTotal(void); | |
797 void Exec(int count); | |
798 }; | |
52 | 799 |
0 | 800 void ScnGrpAnm::CalcTotal(void) { |
801 /* total time を計算 */ | |
802 if (empty()) return; | |
803 int tm = 0; | |
804 vector<ScnGrpAnmAtom>::iterator it; | |
805 for (it=begin(); it != end(); it++) tm += it->time; | |
806 total_time = tm; | |
807 SetAllCount(tm); | |
808 } | |
52 | 809 |
0 | 810 void ScnGrpAnm::Exec(int count) { |
811 int tm = 0; vector<ScnGrpAnmAtom>::iterator it; | |
812 for (it=begin(); it != end(); it++) { | |
813 tm += it->time; | |
814 if (count < tm) break; | |
815 } | |
816 if (it == end()) it--; | |
817 owner.LoadSurface(it->name.c_str(), 0); | |
818 } | |
819 | |
820 | |
821 /***************************************************** | |
822 * | |
823 * GrpImpl(implementation) : 定義 | |
824 * | |
825 */ | |
826 | |
52 | 827 #include "music2/music.h" |
0 | 828 |
829 GrpImpl::GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm_data, class MuSys& _mu, AyuSysConfig& _config) : | |
830 event(_event), | |
831 flags(f), | |
832 parent(_parent), | |
833 status(NORMAL), | |
834 skip_mode(SKIP_NO), | |
835 music(_mu), | |
836 cgm_data(_cgm_data), | |
837 grpobj(this), | |
838 bs_obj(this), | |
839 config(_config) | |
840 { | |
841 int i; | |
842 for (i=0; i<MAXPDT; i++) { | |
843 ssurface[i] = 0; | |
844 dsurface[i] = 0; | |
845 } | |
846 screen = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
847 screen_front = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
848 surface = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK); | |
849 surface_update = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK); | |
850 DSurfaceFill(surface, Rect(*surface), 0, 0, 0); | |
851 DSurfaceFill(surface_update, Rect(*surface), 0, 0, 0); | |
852 screen->SetSurface(surface, 0, 0); | |
853 screen->show(); | |
854 screen_front->hide(); | |
855 screen_front->ZMove(screen); | |
856 | |
857 LoadCgm(config); | |
858 | |
859 anm1 = 0; anm2 = 0; | |
860 } | |
861 | |
862 GrpImpl::~GrpImpl() { | |
863 | |
864 map<int,GrpObj>::iterator it; | |
865 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
866 PicBase* p = it->second.DeletePic(); | |
867 delete p; | |
868 } | |
869 | |
870 delete screen; | |
871 delete screen_front; | |
872 parent.Root().DeleteSurface(surface); | |
50 | 873 parent.Root().DeleteSurface(surface_update); |
0 | 874 int i; |
875 for (i=0; i<MAXPDT; i++) { | |
876 if (ssurface[i]) parent.Root().DeleteSurface(ssurface[i]); | |
877 if (dsurface[i]) parent.Root().DeleteSurface(dsurface[i]); | |
878 } | |
879 } | |
880 | |
881 Surface* GrpImpl::Dsurface(int pdt) { | |
882 if (pdt == 0) return surface; | |
883 if (dsurface[pdt] == 0) { // とりあえず画面の大きさということにする | |
884 if (pdt == WORKPDT) | |
885 dsurface[pdt] = parent.Root().NewSurface(parent.Width(), parent.Height(), ALPHA_MASK); | |
886 else | |
887 dsurface[pdt] = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK); | |
888 } | |
889 if (ssurface[pdt]) { // ssurface が存在すれば、dsurface にコピーして返す | |
890 DSurfaceMove(ssurface[pdt], Rect(*ssurface[pdt]), dsurface[pdt], Rect(0,0)); | |
891 parent.Root().DeleteSurface(ssurface[pdt]); | |
892 ssurface[pdt] = 0; | |
893 } | |
894 return dsurface[pdt]; | |
895 } | |
52 | 896 |
897 #include <SDL.h> | |
0 | 898 Surface* GrpImpl::Ssurface(int pdt) { |
899 if (pdt == 0) return surface; | |
900 if (ssurface[pdt]) { | |
901 return ssurface[pdt]; | |
902 } | |
903 return Dsurface(pdt); | |
904 } | |
905 | |
906 void GrpImpl::LoadSurface(const char* str, int pdt) { | |
907 string s = str; | |
908 if (cgm_info.find(s) != cgm_info.end()) { | |
909 cgm_data.insert(cgm_info[s]); | |
910 } | |
911 Surface* bg = parent.Root().NewSurface(s.c_str()); | |
52 | 912 if (bg == NULL) { |
0 | 913 s += ".g00"; |
914 bg = parent.Root().NewSurface(s.c_str()); | |
915 } | |
916 if (bg) { | |
917 if (ssurface[pdt]) parent.Root().DeleteSurface(ssurface[pdt]); | |
918 ssurface[pdt] = bg; | |
919 if (pdt == 0) { | |
920 /* とりあえず Princess Bride のアニメーション効果専用 */ | |
921 Rect r(*ssurface[0]); | |
922 Rect dr(*surface); | |
923 int x = (dr.width()-r.width())/2; | |
924 int y = (dr.height()-r.height())/2; | |
925 DSurfaceMove(ssurface[0], r, surface, Rect(x,y)); | |
926 parent.Root().DeleteSurface(ssurface[0]); | |
52 | 927 ssurface[0] = NULL; |
0 | 928 screen->SetSurface(surface, 0, 0); |
929 } | |
930 } else { | |
931 if (str[0] != 0) | |
932 fprintf(stderr,"Cannot find surface %d <- '%s'\n",pdt,str); | |
933 } | |
934 return; | |
935 } | |
52 | 936 |
0 | 937 void GrpImpl::InitSel(AyuSysConfig& config) { |
52 | 938 int i; |
939 int args[16]; | |
940 char key[1024]; | |
0 | 941 for (i=0; i<999; i++) { |
942 sprintf(key, "#SEL.%03d",i); | |
943 if (config.GetParam(key, 15, &args[0], &args[1], | |
944 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], | |
945 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13], | |
946 &args[14])) { | |
947 | |
948 sprintf(key, "#SELR.%03d", i); | |
949 if (config.GetParam(key, 16, &args[0], &args[1], | |
950 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], | |
951 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13], | |
952 &args[14], &args[15])) continue; | |
953 } | |
954 SEL& s = anmtype[i]; | |
955 s.from = Rect(args[0], args[1], args[2]+1, args[3]+1); | |
956 s.to = Rect(args[4], args[5]); | |
957 s.time = args[6]; | |
958 s.sel_no = args[7]; | |
959 int j; for (j=0; j<8; j++) s.args[j] = args[8+j]; | |
960 } | |
961 } | |
52 | 962 |
0 | 963 void GrpImpl::SetSkipMode(SkipMode _mode) { |
964 if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) { | |
965 RefreshObj(); | |
966 } else if ( (skip_mode & SKIP_IN_MENU) == 0 && (_mode & SKIP_IN_MENU) ) { | |
967 } | |
968 skip_mode = _mode; | |
969 } | |
52 | 970 |
0 | 971 void GrpImpl::SetObjChanged(int num) { |
972 changed_obj.insert(num); | |
973 } | |
52 | 974 |
0 | 975 void GrpImpl::SetObjChangedGroup(int num) { |
976 if (num % 1000 != 0) { | |
977 SetObjChanged(num); | |
978 return; | |
979 } | |
980 std::map<int, GrpObj>::iterator begin,end,it; | |
981 begin = grpobj.lower_bound(num); | |
982 end = grpobj.lower_bound(num+1000); | |
983 for (it=begin;it!=end;it++) { | |
984 changed_obj.insert(it->first); | |
985 } | |
986 } | |
52 | 987 |
0 | 988 void GrpImpl::RefreshObj(void) { |
989 if (!deleted_pic.empty()) { | |
990 vector<PicBase*>::iterator it; | |
991 for (it=deleted_pic.begin(); it!=deleted_pic.end(); it++) { | |
992 if (*it) delete *it; | |
993 } | |
994 deleted_pic.clear(); | |
995 } | |
996 if (!changed_obj.empty()) { | |
997 set<int>::iterator it; | |
998 for (it=changed_obj.begin(); it != changed_obj.end(); it++) { | |
999 if (grpobj.find(*it) == grpobj.end()) continue; | |
1000 GrpObj& obj = grpobj[*it]; | |
1001 GrpObj& parent_obj = grpobj[ ((*it)/1000) * 1000]; | |
1002 if (obj.picture == 0) continue; | |
1003 if (obj.alpha == 0 || (obj.attr & GrpObj::HIDDEN) || (parent_obj.attr & GrpObj::HIDDEN_GROUP) ) { | |
1004 if (obj.attr & GrpObj::ANM_PLAYING) { | |
1005 obj.attr = GrpObj::Attribute(obj.attr & ~(GrpObj::ANM_PLAYING)); | |
1006 if (obj.anm) obj.anm->Abort(); | |
1007 } | |
1008 obj.picture->hide(); | |
1009 } else { | |
1010 obj.Update(); | |
1011 obj.picture->show(); | |
1012 } | |
1013 } | |
1014 changed_obj.clear(); | |
1015 } | |
1016 if (reserved_load_surface0.length() != 0) { | |
1017 LoadSurface(reserved_load_surface0.c_str(), 0); | |
1018 reserved_load_surface0 = ""; | |
1019 } | |
1020 screen->ReBlit(); | |
1021 } | |
1022 | |
1023 | |
52 | 1024 #include <SDL.h> |
0 | 1025 void GrpImpl::StartAnm(int type) { |
1026 SEL sel; | |
1027 | |
1028 if (anmtype.find(type) == anmtype.end()) { | |
1029 if (anmtype.find(0) == anmtype.end()) { | |
1030 sel.sel_no = 1; | |
1031 sel.from = Rect(*surface); | |
1032 sel.to = Rect(0,0); | |
1033 sel.time = 0; | |
1034 } else { | |
1035 sel = anmtype[0]; | |
1036 } | |
1037 } else { | |
1038 sel = anmtype[type]; | |
1039 } | |
52 | 1040 if (anm1 != NULL) { |
0 | 1041 fprintf(stderr,"Warning: StartAnm() called before anm1 finished\n"); |
1042 anm1->Abort(); | |
1043 delete anm1; | |
52 | 1044 anm1 = NULL; |
0 | 1045 } |
1046 map<int,GrpObj>::iterator it; | |
1047 // 現在表示中のobjectを消去 | |
1048 deleted_pic.push_back(screen); | |
1049 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
1050 if (! (it->second.attr & GrpObj::WIPEON)) { // 画像切り替え時に object 削除 | |
1051 deleted_pic.push_back(it->second.DeletePic()); | |
1052 } else { | |
1053 GrpObj& new_obj = bs_obj[it->first]; | |
1054 if (new_obj.name.empty()) { // 新しい object が存在しなければ内容を引き継ぐ | |
1055 new_obj = it->second; | |
1056 it->second.DeletePic(); | |
1057 } else { | |
1058 new_obj.attr = GrpObj::Attribute(new_obj.attr | GrpObj::WIPEON); | |
1059 deleted_pic.push_back(it->second.DeletePic()); | |
1060 } | |
1061 } | |
1062 } | |
1063 grpobj.clear(); // 全オブジェクト削除 | |
1064 | |
1065 // 全画像オブジェクトの前にscreen 移動 | |
1066 // 新しい screen_front を作成しておく | |
1067 screen = screen_front; | |
1068 screen->hide(); | |
1069 screen->SetSurface(surface_update, 0, 0); | |
1070 parent.Root().BlitSurface(Dsurface(1), Rect(*surface_update), surface_update, Rect(0,0)); | |
1071 | |
1072 screen_front = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
1073 screen_front->hide(); | |
1074 screen_front->ZMove(screen); | |
1075 | |
1076 // 新しい object へ更新、surface_update へ新しい object を表示 | |
1077 // (object 作成時は picture は hide されている) | |
1078 for (it=bs_obj.begin(); it!=bs_obj.end(); it++) { | |
1079 grpobj[it->first] = it->second; | |
1080 it->second.DeletePic(); | |
1081 CreateObj(it->first); | |
1082 GrpObj& g = grpobj[it->first]; | |
1083 GrpObj& parent_obj = grpobj[ (it->first/1000) * 1000]; | |
1084 if (g.picture) { | |
1085 g.Update(); | |
1086 if (g.alpha == 0 || (g.attr & GrpObj::HIDDEN) || (parent_obj.attr & GrpObj::HIDDEN_GROUP) ) ; | |
1087 else g.picture->SimpleBlit(surface_update); | |
1088 g.picture->hide(); | |
1089 } | |
1090 } | |
1091 bs_obj.clear(); | |
1092 // 画像効果開始 | |
1093 switch(sel.sel_no) { | |
1094 default: | |
1095 case 0: case 50: // 0 と 50 の違いが良くわからない | |
1096 if (skip_mode & SKIP_GRP_NOEFFEC) | |
1097 anm1 = new WidAnmAlpha(event, screen, ALPHA_MAX, ALPHA_MAX, 0); | |
1098 else if (skip_mode & SKIP_GRP_FAST) | |
1099 anm1 = new WidAnmAlpha(event, screen, 0, ALPHA_MAX, sel.time/4); | |
1100 else | |
1101 anm1 = new WidAnmAlpha(event, screen, 0, ALPHA_MAX, sel.time); | |
1102 break; | |
1103 } | |
1104 if (anm1) anm1->Play(); | |
1105 if (skip_mode & SKIP_GRP_NOEFFEC) AbortAnm(); | |
1106 } | |
52 | 1107 |
0 | 1108 void GrpImpl::StartShake(int total, const int* pattern) { |
1109 if (anm2) { | |
1110 fprintf(stderr,"Warning: StartShake() called before another animation finished\n"); | |
1111 anm2->Abort(); | |
1112 delete anm2; | |
52 | 1113 anm2 = NULL; |
0 | 1114 } |
1115 if (skip_mode & SKIP_GRP_NOEFFEC) return; | |
1116 AnmAlphaMove* new_anm = new AnmAlphaMove(event, &parent); // shake screen では元画面の座標を揺らす | |
52 | 1117 int i; |
1118 int tm = 0; | |
0 | 1119 for (i=0; i<total; i+=3) { |
1120 int x = pattern[i]; | |
1121 int y = pattern[i+1]; | |
1122 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), Rect(0,0), 255, tm)); | |
1123 tm += pattern[i+2]; | |
1124 } | |
1125 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(0,0), Rect(0,0), 255, tm)); | |
1126 new_anm->SetPtn(); // パターン登録終了 | |
1127 new_anm->Play(); | |
1128 anm2 = new_anm; | |
1129 } | |
52 | 1130 |
0 | 1131 void GrpImpl::AbortAnm(void) { |
52 | 1132 if (anm1 == NULL) return; |
0 | 1133 anm1->Abort(); |
1134 delete anm1; | |
52 | 1135 anm1 = NULL; |
0 | 1136 /* 画像効果終了 */ |
1137 /* 古い画面への画像効果があれば消去 */ | |
1138 if (anm2 && anm2->pic[0] != screen) { | |
1139 anm2->Abort(); | |
1140 delete anm2; | |
52 | 1141 anm2 = NULL; |
0 | 1142 } |
1143 /* pdt1 -> pdt0 へコピー */ | |
1144 DSurfaceMove(dsurface[1], Rect(*dsurface[1]), surface, Rect(0,0)); | |
1145 screen->SetSurface(surface, 0, 0); | |
1146 // 画像効果開始時に存在したobjectを消去 | |
1147 // 新しい object 表示 | |
1148 RefreshObj(); | |
1149 return; | |
1150 } | |
52 | 1151 |
0 | 1152 void GrpImpl::LoadSurface(const char* str) { |
1153 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | |
1154 LoadSurface(str, 1); | |
1155 bg_name = str; | |
1156 } | |
52 | 1157 |
0 | 1158 void GrpImpl::LoadSurface(void) { |
1159 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | |
1160 LoadSurface(bg_name.c_str(), 1); | |
1161 } | |
52 | 1162 |
0 | 1163 void GrpImpl::AddSurface(const char* str) { |
1164 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | |
1165 LoadSurface(bg_name.c_str()); | |
1166 | |
1167 string s = str; | |
1168 Surface* front = parent.Root().NewSurface(s.c_str()); | |
52 | 1169 if (front == NULL) { |
0 | 1170 s += ".g00"; |
1171 front = parent.Root().NewSurface(s.c_str()); | |
1172 } | |
52 | 1173 if (front != NULL) { |
0 | 1174 parent.Root().BlitSurface(front, Rect(*front), Dsurface(1), Rect(0,0)); |
1175 parent.Root().DeleteSurface(front); | |
1176 } else { | |
1177 fprintf(stderr,"Cannot find surface %s\n",str); | |
1178 } | |
1179 } | |
1180 | |
1181 void GrpImpl::CreateObj(int index) { | |
1182 std::map<int, GrpObj>::iterator cur = grpobj.find(index); | |
1183 if (cur == grpobj.end()) return; | |
1184 GrpObj& g = grpobj[index]; | |
1185 g.CreateSurface(&parent); | |
1186 g.order = index; | |
52 | 1187 if (g.picture == NULL) return; // エラー:surface が存在しない |
0 | 1188 g.picture->hide(); |
1189 SetObjChanged(index); | |
1190 ZMoveObj(index); | |
1191 } | |
52 | 1192 |
0 | 1193 void GrpImpl::ZMoveObj(int index) { |
1194 std::map<int, GrpObj>::iterator cur = grpobj.find(index); | |
1195 if (cur == grpobj.end()) return; | |
1196 GrpObj& g = grpobj[index]; | |
52 | 1197 if (g.picture == NULL) return; |
0 | 1198 // 自分より前に object があれば、その前に表示 |
1199 // そうでなければ screen の前に表示 | |
1200 std::map<int, GrpObj>::iterator cur_backobj = grpobj.end(); | |
1201 std::map<int, GrpObj>::iterator it; | |
1202 for (it = grpobj.begin(); it != grpobj.end(); it++) { | |
1203 if (it == cur) continue; | |
52 | 1204 if (it->second.picture == NULL) continue; |
0 | 1205 if (it->second.order < g.order) { |
1206 if (cur_backobj == grpobj.end()) { | |
1207 cur_backobj = it; | |
1208 } else if (cur_backobj->second.order < it->second.order) { | |
1209 cur_backobj = it; | |
1210 } | |
1211 } | |
1212 } | |
1213 if (cur_backobj == grpobj.end()) { | |
1214 g.picture->ZMove(screen); | |
1215 } else { | |
1216 g.picture->ZMove(cur_backobj->second.picture); | |
1217 } | |
1218 } | |
52 | 1219 |
0 | 1220 void GrpImpl::SwapObj(int index1, int index2) { |
1221 // デフォルト値から order が変更されていた場合のみ、order は保存される | |
1222 // まずは両方のobjectをswap | |
1223 if (grpobj.find(index1) == grpobj.end()) { | |
1224 if (grpobj.find(index2) == grpobj.end()) return; // どちらの object も存在しない | |
1225 grpobj[index1] = grpobj[index2]; | |
1226 if (grpobj[index1].order == index2) | |
1227 grpobj[index1].order = index1; | |
1228 grpobj[index2].DeletePic(); | |
1229 grpobj.erase(index2); | |
1230 ZMoveObj(index1); | |
1231 return; | |
1232 } else if (grpobj.find(index2) == grpobj.end()) { // index2 が存在しない場合 | |
1233 grpobj[index2] = grpobj[index1]; | |
1234 if (grpobj[index2].order == index1) | |
1235 grpobj[index2].order = index2; | |
1236 grpobj[index1].DeletePic(); | |
1237 grpobj.erase(index1); | |
1238 ZMoveObj(index2); | |
1239 return; | |
1240 } else { | |
1241 GrpObj obj = grpobj[index1]; | |
1242 grpobj[index1] = grpobj[index2]; | |
1243 grpobj[index2].DeletePic(); | |
1244 if (grpobj[index1].order == index2) | |
1245 grpobj[index1].order = index1; | |
1246 ZMoveObj(index1); | |
1247 grpobj[index2] = obj; | |
1248 if (grpobj[index2].order == index1) | |
1249 grpobj[index2].order = index2; | |
1250 ZMoveObj(index2); | |
1251 obj.DeletePic(); | |
1252 } | |
1253 } | |
1254 | |
1255 bool GrpImpl::Pressed(int x, int y, void* pointer) { // マウスクリックでキャンセル | |
1256 GrpImpl* g = (GrpImpl*)pointer; | |
1257 if (g->status == WAIT_MOVIE) | |
1258 g->music.StopMovie(); | |
1259 if (g->status == WAIT_ANM) | |
1260 g->AbortAnm(); | |
52 | 1261 if (g->status == WAIT_SHAKE && g->anm2 != NULL) { |
18 | 1262 g->anm2->Abort(); |
0 | 1263 delete g->anm2; |
52 | 1264 g->anm2 = NULL; |
0 | 1265 } |
1266 return false; // event deleted | |
1267 } | |
1268 | |
1269 /* mode.cgm の decode 用 */ | |
1270 static unsigned char decode_char[256] = { | |
1271 0x8b, 0xe5, 0x5d, 0xc3, 0xa1, 0xe0, 0x30, 0x44, | |
1272 0x00, 0x85, 0xc0, 0x74, 0x09, 0x5f, 0x5e, 0x33, | |
1273 0xc0, 0x5b, 0x8b, 0xe5, 0x5d, 0xc3, 0x8b, 0x45, | |
1274 0x0c, 0x85, 0xc0, 0x75, 0x14, 0x8b, 0x55, 0xec, | |
1275 0x83, 0xc2, 0x20, 0x52, 0x6a, 0x00, 0xe8, 0xf5, | |
1276 0x28, 0x01, 0x00, 0x83, 0xc4, 0x08, 0x89, 0x45, | |
1277 0x0c, 0x8b, 0x45, 0xe4, 0x6a, 0x00, 0x6a, 0x00, | |
1278 0x50, 0x53, 0xff, 0x15, 0x34, 0xb1, 0x43, 0x00, | |
1279 0x8b, 0x45, 0x10, 0x85, 0xc0, 0x74, 0x05, 0x8b, | |
1280 0x4d, 0xec, 0x89, 0x08, 0x8a, 0x45, 0xf0, 0x84, | |
1281 0xc0, 0x75, 0x78, 0xa1, 0xe0, 0x30, 0x44, 0x00, | |
1282 0x8b, 0x7d, 0xe8, 0x8b, 0x75, 0x0c, 0x85, 0xc0, | |
1283 0x75, 0x44, 0x8b, 0x1d, 0xd0, 0xb0, 0x43, 0x00, | |
1284 0x85, 0xff, 0x76, 0x37, 0x81, 0xff, 0x00, 0x00, | |
1285 0x04, 0x00, 0x6a, 0x00, 0x76, 0x43, 0x8b, 0x45, | |
1286 0xf8, 0x8d, 0x55, 0xfc, 0x52, 0x68, 0x00, 0x00, | |
1287 0x04, 0x00, 0x56, 0x50, 0xff, 0x15, 0x2c, 0xb1, | |
1288 0x43, 0x00, 0x6a, 0x05, 0xff, 0xd3, 0xa1, 0xe0, | |
1289 0x30, 0x44, 0x00, 0x81, 0xef, 0x00, 0x00, 0x04, | |
1290 0x00, 0x81, 0xc6, 0x00, 0x00, 0x04, 0x00, 0x85, | |
1291 0xc0, 0x74, 0xc5, 0x8b, 0x5d, 0xf8, 0x53, 0xe8, | |
1292 0xf4, 0xfb, 0xff, 0xff, 0x8b, 0x45, 0x0c, 0x83, | |
1293 0xc4, 0x04, 0x5f, 0x5e, 0x5b, 0x8b, 0xe5, 0x5d, | |
1294 0xc3, 0x8b, 0x55, 0xf8, 0x8d, 0x4d, 0xfc, 0x51, | |
1295 0x57, 0x56, 0x52, 0xff, 0x15, 0x2c, 0xb1, 0x43, | |
1296 0x00, 0xeb, 0xd8, 0x8b, 0x45, 0xe8, 0x83, 0xc0, | |
1297 0x20, 0x50, 0x6a, 0x00, 0xe8, 0x47, 0x28, 0x01, | |
1298 0x00, 0x8b, 0x7d, 0xe8, 0x89, 0x45, 0xf4, 0x8b, | |
1299 0xf0, 0xa1, 0xe0, 0x30, 0x44, 0x00, 0x83, 0xc4, | |
1300 0x08, 0x85, 0xc0, 0x75, 0x56, 0x8b, 0x1d, 0xd0, | |
1301 0xb0, 0x43, 0x00, 0x85, 0xff, 0x76, 0x49, 0x81, | |
1302 0xff, 0x00, 0x00, 0x04, 0x00, 0x6a, 0x00, 0x76 | |
1303 }; | |
1304 | |
1305 void GrpImpl::LoadCgm(AyuSysConfig& config) { | |
1306 /* cgm ファイル読み込み */ | |
1307 const char* fname = config.GetParaStr("#CGTABLE_FILE"); | |
52 | 1308 if (fname == NULL) return; |
0 | 1309 ARCINFO* info = file_searcher.Find(FILESEARCH::ALL, fname, ""); |
52 | 1310 if (info == NULL) return; |
0 | 1311 char* data = info->CopyRead(); |
1312 int sz = info->Size(); | |
1313 delete info; | |
1314 | |
1315 | |
8 | 1316 if ( strncmp(data, "CGTABLE", 7) != 0) { |
1317 delete[] data; | |
1318 return; | |
1319 } | |
20
824b89018ea8
* CG completion percentage (maybe not working properly?)
thib
parents:
18
diff
changeset
|
1320 cgm_size = read_little_endian_int(data+0x10); |
0 | 1321 |
52 | 1322 int i, j; |
0 | 1323 // xor 解除 |
52 | 1324 for (i=0; i < sz-0x20; i++) { |
0 | 1325 data[i+0x20]^=decode_char[i&0xff]; |
1326 } | |
1327 // 展開 | |
1328 int dest_size = cgm_size * 36; | |
1329 char* dest = new char[dest_size+1024]; | |
1330 char* src = data + 0x28; | |
1331 char* dest_orig = dest; | |
1332 ARCINFO::Extract2k(dest,src,dest+dest_size,data+sz); | |
1333 dest = dest_orig; | |
1334 for (i=0; i<cgm_size; i++) { | |
1335 char* s = dest + i * 36; | |
1336 int n = read_little_endian_int(dest + i * 36 + 32); | |
1337 cgm_info[s] = n; | |
1338 } | |
8 | 1339 delete[] data; |
0 | 1340 delete[] dest_orig; |
1341 } | |
1342 | |
1343 /***************************************************** | |
1344 * | |
1345 * GrpImpl :: Save, Load : セーブファイル処理 | |
1346 * | |
1347 */ | |
1348 void GrpImpl::Save(std::string& str) { | |
1349 } | |
52 | 1350 |
0 | 1351 void GrpImpl::Load(const char* str) { |
1352 status = NORMAL; | |
52 | 1353 if (anm1 != NULL) { |
0 | 1354 AbortAnm(); |
1355 } | |
52 | 1356 if (anm2 != NULL) { |
0 | 1357 anm2->Abort(); |
1358 delete anm2; | |
52 | 1359 anm2 = NULL; |
0 | 1360 } |
1361 map<int,GrpObj>::iterator it; | |
1362 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
1363 PicBase* p = it->second.DeletePic(); | |
1364 delete p; | |
1365 } | |
1366 grpobj.clear(); | |
1367 | |
1368 bg_name = ""; | |
1369 music.StopCDROM(100); | |
1370 } | |
52 | 1371 |
0 | 1372 void GrpImpl::SaveSys(string& save) { |
1373 char buf[1024]; | |
1374 save = "\n[Graphics]\n"; | |
1375 save += "CGM_CG="; | |
1376 | |
1377 set<int>::iterator it; | |
1378 for (it=cgm_data.begin(); it != cgm_data.end(); it++) { | |
1379 sprintf(buf,"%d,",*it); | |
1380 save += buf; | |
1381 } | |
1382 save += "\n"; | |
1383 } | |
52 | 1384 |
0 | 1385 void GrpImpl::LoadSys(const char* save) { |
1386 cgm_data.clear(); | |
1387 save = strstr(save, "\n[Graphics]\n"); | |
1388 | |
1389 if (save) { | |
1390 save += strlen("\n[Graphics]\n"); | |
1391 do { | |
1392 if (save[0] == '[') break; // next section | |
1393 if (strncmp(save, "CGM_CG=",7) == 0) { | |
1394 save += 7; | |
1395 while(isdigit(*save)) { | |
1396 int n = atoi(save); | |
1397 cgm_data.insert(n); | |
1398 save = strchr(save, ','); | |
1399 if (save) save++; | |
1400 } | |
1401 } | |
1402 save = strchr(save, '\n'); | |
1403 if (save) save++; | |
1404 } while (save); | |
1405 } | |
1406 return; | |
1407 } | |
1408 | |
1409 | |
1410 /***************************************************** | |
1411 * | |
1412 * GrpImpl :: Wait , Exec : コマンド実行部 | |
1413 * | |
1414 */ | |
1415 static vector<int> drawn_images; | |
1416 static int draw_n = 0; | |
1417 extern bool grpdump_req; | |
1418 bool GrpImpl::Wait(unsigned int current_time, Cmd& cmd) { | |
1419 if (grpdump_req) { | |
1420 grpdump_req = 0; | |
1421 std::map<int,GrpObj>::iterator it; | |
48 | 1422 fprintf(stderr,"front %p(%d) / %p(%d)\n",screen,screen->IsHidden(),screen_front,screen_front->IsHidden()); |
0 | 1423 for (it=grpobj.begin(); it != grpobj.end(); it++) { |
1424 GrpObj& obj = it->second; | |
1425 GrpObj& parent_obj = grpobj[ ((it->first)/1000) * 1000]; | |
1426 if (obj.picture) { | |
1427 if (!obj.name.empty()) { | |
48 | 1428 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n", |
0 | 1429 it->first,obj.picture,obj.name.c_str(), |
1430 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden()); | |
1431 } else if (!obj.print_moji.empty()) { | |
48 | 1432 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n", |
0 | 1433 it->first,obj.picture,obj.print_moji.c_str(), |
1434 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden()); | |
1435 } else { | |
48 | 1436 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n", |
0 | 1437 it->first,obj.picture,"<EMPTY>", |
1438 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden()); | |
1439 } | |
1440 } | |
1441 } | |
1442 std::list<PicBase*>::iterator it2; | |
1443 for (it2=parent.children.begin(); it2!=parent.children.end();it2++) { | |
48 | 1444 fprintf(stderr,"%p(%d)\n",*it2,(*it2)->IsHidden()); |
0 | 1445 } |
1446 RefreshObj(); | |
1447 | |
1448 } | |
1449 #if 0 | |
1450 if (event.presscount(MOUSE_UP)) { | |
1451 std::list<PicBase*>::iterator lit; | |
1452 draw_n++; int i=0; | |
1453 for (lit=parent.children.end(); lit!=parent.children.begin(); ) { | |
1454 lit--; | |
1455 (*lit)->hide(); | |
1456 i++; | |
1457 if (i >= draw_n) break; | |
1458 } | |
1459 if (drawn_images.empty()) { | |
1460 map<int, GrpObj>::iterator it; | |
1461 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | |
1462 if (it->second.picture) { | |
1463 drawn_images.push_back(it->first); | |
1464 PicBase* p = it->second.DeletePic(); | |
1465 delete p; | |
1466 } | |
1467 } | |
1468 } else { | |
1469 vector<int>::iterator it; | |
1470 for (it=drawn_images.begin(); it!=drawn_images.end(); it++) { | |
1471 CreateObj(*it); | |
1472 } | |
1473 drawn_images.clear(); | |
1474 } | |
1475 } | |
1476 #endif | |
1477 if (status == WAIT_ANM) { | |
52 | 1478 if (anm1 != NULL) { |
0 | 1479 if (!anm1->IsEnd()) return true; |
1480 AbortAnm(); | |
1481 } | |
1482 } else if (status == WAIT_SHAKE) { | |
52 | 1483 if (anm2 != NULL) { |
0 | 1484 if (!anm2->IsEnd()) return true; |
1485 delete anm2; | |
52 | 1486 anm2 = NULL; |
0 | 1487 } |
1488 status = NORMAL; | |
1489 } else if (status == WAIT_SE) { | |
1490 if (music.IsStopSE()) status = NORMAL; | |
1491 return true; | |
1492 } else if (status == WAIT_MOVIE) { | |
1493 if (music.IsStopMovie()) { | |
1494 music.StopMovie(); | |
1495 status = NORMAL; | |
1496 screen->ReBlit(); | |
1497 } | |
1498 return true; | |
1499 } | |
52 | 1500 if (anm2 != NULL) { |
0 | 1501 if (anm2->IsEnd()) { |
1502 delete anm2; | |
52 | 1503 anm2 = NULL; |
0 | 1504 } |
1505 } | |
1506 return false; | |
1507 } | |
1508 | |
1509 void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除 | |
1510 if (grpobj.find(num) == grpobj.end()) return; | |
1511 deleted_pic.push_back(grpobj[num].DeletePic()); | |
1512 } | |
52 | 1513 |
0 | 1514 void GrpImpl::DeleteObj(int num) { |
1515 if (grpobj.find(num) == grpobj.end()) return; | |
1516 deleted_pic.push_back(grpobj[num].DeletePic()); | |
1517 grpobj.erase(num); | |
1518 } | |
52 | 1519 |
0 | 1520 void GrpImpl::DeleteObjRange(int num_first, int num_end) { |
1521 std::map<int, GrpObj>::iterator begin,end,it; | |
1522 begin = grpobj.lower_bound(num_first); | |
1523 end = grpobj.lower_bound(num_end); | |
1524 for (it=begin;it!=end;it++) { | |
1525 deleted_pic.push_back(it->second.DeletePic()); | |
1526 } | |
1527 grpobj.erase(begin, end); | |
1528 } | |
52 | 1529 |
0 | 1530 void GrpImpl::Exec(Cmd& cmd) { |
1531 if (cmd.cmd_type == CMD_TEXTEND) { | |
1532 music.StopKoe(500); // テキスト終了で声を止める | |
1533 cmd.clear(); | |
1534 return; | |
1535 } | |
1536 if (cmd.cmd_type == CMD_WAITFRAMEUPDATE) { | |
1537 // wait する場合は RefreshObj() しておく | |
1538 RefreshObj(); | |
1539 } | |
1540 if (cmd.cmd_type != CMD_OTHER) return; | |
1541 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1e && cmd.cmd3 == 0) { | |
1542 cmd.cmd_type = CMD_SAVECMDGRP_START; // grp stack clear | |
1543 } | |
1544 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x21) { | |
1545 if (cmd.cmd3 == 0x46) { | |
1546 const char* name = cmd.Str(cmd.args[0]); | |
1547 int pdt = cmd.args[1].value; | |
1548 eprintf("load surface %s pdt %d\n",name, pdt); | |
1549 if (pdt == 0) | |
1550 reserved_load_surface0 = name; // 画像読み込みは 01-1f:0000 まで待つ | |
1551 else if (pdt == 1) | |
1552 LoadSurface(name); // 背景絵読み込み? | |
1553 else | |
1554 LoadSurface(name, pdt); | |
1555 cmd.cmd_type = CMD_SAVECMDGRP; | |
1556 } else if (cmd.cmd3 == 0x49) { | |
1557 const char* name = cmd.Str(cmd.args[0]); | |
1558 int sel = cmd.args[1].value; | |
1559 eprintf("set background %s sel %d\n",name, sel); | |
1560 if (name[0] == '?') { | |
1561 LoadSurface(); | |
1562 } else { | |
1563 LoadSurface(name); | |
1564 } | |
1565 StartAnm(sel); | |
1566 status = WAIT_ANM; | |
1567 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1568 if (name[0] == '?') | |
1569 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
1570 else | |
1571 cmd.cmd_type = CMD_SAVECMDGRP_START; | |
1572 } else if (cmd.cmd3 == 0x4b) { | |
1573 int pos = cmd.args[0].value; | |
1574 const char* name = cmd.Str(cmd.args[1]); | |
1575 int sel = cmd.args[2].value; | |
1576 eprintf("set foreground %s sel %d pos %d\n",name, sel, pos); | |
1577 AddSurface(name); | |
1578 StartAnm(sel); | |
1579 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1580 status = WAIT_ANM; | |
1581 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
1582 } else if (cmd.cmd3 == 0x4c) { | |
1583 /* 0x46 との違いがわからない */ | |
1584 /* とりあえず bg として登録しないでみる */ | |
1585 /* 735 / 19438 : unsupported command; 0x23 - cmd 01-21:004c:00[ 2] | |
1586 ** "?",0 | |
1587 */ | |
1588 /* arg1 = "?" arg2 = 0 */ | |
1589 const char* name = cmd.Str(cmd.args[0]); | |
1590 int sel = cmd.args[1].value; | |
1591 if (name[0] == '?') { | |
1592 LoadSurface(); | |
1593 } else { | |
1594 LoadSurface(name, 1); | |
1595 } | |
1596 StartAnm(sel); | |
1597 status = WAIT_ANM; | |
1598 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1599 if (name[0] == '?') | |
1600 cmd.cmd_type = CMD_SAVECMDGRP_ONCE; | |
1601 else | |
1602 cmd.cmd_type = CMD_SAVECMDGRP_START; | |
1603 } else if (cmd.cmd3 == 0x20) { | |
1604 // shake screen | |
1605 char key[1024]; | |
1606 sprintf(key, "#SHAKE.%03d", cmd.args[0].value); | |
1607 if (config.SearchParam(key) != 2) { | |
1608 fprintf(stderr,"Cannot find shake pattern %d; use default pattern\n",cmd.args[0].value); | |
1609 strcpy(key, "#SHAKE.000"); // default key | |
1610 } | |
1611 int num; const int* pattern; | |
1612 pattern = config.GetParamArray(key, num); | |
1613 if (pattern) { | |
1614 StartShake(num, pattern); | |
1615 status = WAIT_SHAKE; | |
1616 } | |
1617 cmd.clear(); | |
1618 } else if (cmd.cmd3 == 0x64 && cmd.cmd4 == 2) { // copy (KANOGI) | |
1619 int sx = cmd.args[0].value; | |
1620 int sy = cmd.args[1].value; | |
1621 int w = cmd.args[2].value - sx; | |
1622 int h = cmd.args[3].value - sy; | |
1623 Rect rect(sx, sy, sx+w, sy+h); | |
1624 int src = cmd.args[4].value; | |
1625 int dx = cmd.args[5].value; | |
1626 int dy = cmd.args[6].value; | |
1627 int dest = cmd.args[7].value; | |
1628 unsigned char alpha; | |
1629 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1630 printf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1631 if (src == dest) { | |
1632 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
1633 src = WORKPDT; | |
1634 } | |
1635 parent.Root().BlitSurface(Ssurface(src), rect, Dsurface(dest), Rect(dx,dy)); | |
1636 if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
1637 cmd.clear(); | |
1638 } else if (cmd.cmd3 == 0x4b1 && cmd.cmd4 == 2) { | |
1639 int x = cmd.args[0].value; | |
1640 int y = cmd.args[1].value; | |
1641 int w = cmd.args[2].value; | |
1642 int h = cmd.args[3].value; | |
1643 Rect rect(x,y,x+w,y+w); | |
1644 int pdt = cmd.args[4].value; | |
1645 int r = cmd.args[5].value; | |
1646 int g = cmd.args[6].value; | |
1647 int b = cmd.args[7].value; | |
1648 eprintf("clear %d:(%d,%d) size (%d,%d) r %d g %d b %d\n",pdt,x,y,w,h,r,g,b); | |
1649 DSurfaceFill(Dsurface(pdt), rect, r, g, b, 0xff); | |
1650 // if (pdt == 0) screen->ReBlit(rect); | |
1651 cmd.cmd_type = CMD_SAVECMDGRP; | |
1652 } else if (cmd.cmd3 == 0x4b1 && cmd.cmd4 == 3) { // alpha つきfill | |
1653 int x = cmd.args[0].value; | |
1654 int y = cmd.args[1].value; | |
1655 int w = cmd.args[2].value; | |
1656 int h = cmd.args[3].value; | |
1657 Rect rect(x,y,x+w,y+h); | |
1658 int pdt = cmd.args[4].value; | |
1659 int r = cmd.args[5].value; | |
1660 int g = cmd.args[6].value; | |
1661 int b = cmd.args[7].value; | |
1662 int a = cmd.args[8].value; | |
1663 eprintf("alpha-clear %d:(%d,%d) size (%d,%d) r %d g %d b %d a %d\n",pdt,x,y,w,h,r,g,b,a); | |
1664 if (a <= 0) ; | |
1665 else if (a >= 255) DSurfaceFill(Dsurface(pdt), rect, r, g, b); | |
1666 else { | |
1667 DSurfaceFill(Dsurface(WORKPDT), rect, r, g, b, a); | |
1668 parent.Root().BlitSurface(Dsurface(WORKPDT), rect, Dsurface(pdt), rect); | |
1669 } | |
1670 // if (pdt == 0) screen->ReBlit(rect); | |
1671 cmd.clear(); | |
1672 } else if (cmd.cmd3 == 0x44c && cmd.cmd4 == 2) { | |
1673 int sx = cmd.args[0].value; | |
1674 int sy = cmd.args[1].value; | |
1675 int w = cmd.args[2].value; | |
1676 int h = cmd.args[3].value; | |
1677 int src = cmd.args[4].value; | |
1678 int dx = cmd.args[5].value; | |
1679 int dy = cmd.args[6].value; | |
1680 int dest = cmd.args[7].value; | |
1681 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1682 parent.Root().BlitSurface(Ssurface(src), Rect(sx,sy,sx+w,sy+h), Dsurface(dest), Rect(dx,dy)); | |
1683 //DSurfaceMove(Ssurface(src), Rect(sx,sy,sx+w,sy+h), Dsurface(dest), Rect(dx,dy)); | |
1684 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
1685 cmd.cmd_type = CMD_SAVECMDGRP; | |
1686 } else if (cmd.cmd3 == 0x44c && cmd.cmd4 == 3) { // alpha つきcopy | |
1687 int sx = cmd.args[0].value; | |
1688 int sy = cmd.args[1].value; | |
1689 int w = cmd.args[2].value; | |
1690 int h = cmd.args[3].value; | |
1691 Rect rect(sx, sy, sx+w, sy+h); | |
1692 int src = cmd.args[4].value; | |
1693 int dx = cmd.args[5].value; | |
1694 int dy = cmd.args[6].value; | |
1695 int dest = cmd.args[7].value; | |
1696 unsigned char alpha; | |
1697 if (cmd.args[8].value < 0) alpha = 0; | |
1698 else if (cmd.args[8].value > 255) alpha = 255; | |
1699 else alpha = cmd.args[8].value; | |
1700 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1701 if (src == dest) { | |
1702 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
1703 src = WORKPDT; | |
1704 } | |
1705 if (alpha != 0) | |
1706 parent.Root().BlitSurface(Ssurface(src), rect, &alpha, Rect(0,0,1,1), Dsurface(dest), Rect(dx,dy), 0); | |
1707 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h)); | |
1708 cmd.clear(); | |
1709 } else if (cmd.cmd3 == 0x640 && cmd.cmd4 == 3) { // saturate mode で alpha 付き copy | |
1710 int sx = cmd.args[0].value; | |
1711 int sy = cmd.args[1].value; | |
1712 int w = cmd.args[2].value; | |
1713 int h = cmd.args[3].value; | |
1714 Rect rect(sx, sy, sx+w, sy+h); | |
1715 int src = cmd.args[4].value; | |
1716 int dx = cmd.args[5].value; | |
1717 int dy = cmd.args[6].value; | |
1718 int dest = cmd.args[7].value; | |
1719 unsigned char alpha; | |
1720 if (cmd.args[8].value < 0) alpha = 0; | |
1721 else if (cmd.args[8].value > 255) alpha = 255; | |
1722 else alpha = cmd.args[8].value; | |
1723 eprintf("copy surface w/ saturate %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy); | |
1724 if (src == dest) { | |
1725 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect); | |
1726 src = WORKPDT; | |
1727 } | |
1728 if (alpha != 0) { | |
1729 // saturate mode : screen (picture) を一時的に作成 | |
1730 PicBase* screen_tmp = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0); | |
1731 screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_SATURATE); | |
1732 screen_tmp->SetSurfaceRect(rect); | |
1733 screen_tmp->Move(dx, dy); | |
1734 screen_tmp->SetSurfaceAlpha(&alpha, Rect(0,0,1,1)); | |
1735 screen_tmp->SimpleBlit(Dsurface(dest)); | |
1736 delete screen_tmp; | |
1737 } | |
1738 cmd.clear(); | |
1739 } else if (cmd.cmd3 == 0x196 && cmd.cmd4 == 0) { | |
1740 Rect r_from(cmd.args[0].value, cmd.args[1].value); | |
1741 Rect r_to(cmd.args[2].value, cmd.args[3].value); | |
1742 int src_pdt = cmd.args[4].value; | |
1743 Rect r(cmd.args[5].value,cmd.args[6].value,cmd.args[7].value+1,cmd.args[8].value+1); | |
1744 int tm = cmd.args[9].value; | |
1745 fprintf(stderr,"??? cmd time %d\n",tm); | |
1746 // anm1 = new ScnGrpMove(event, screen, parent.Root(), surface, r, Ssurface(2), r_from, r_to, tm); | |
1747 // status = WAIT_ANM; | |
1748 } | |
1749 } | |
1750 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x22) { | |
1751 if (cmd.cmd3 == 0x0c30 && cmd.cmd4 == 0) { // スクロールする画像効果(Princess Bride) | |
1752 if (anm2) { | |
1753 anm2->Abort(); | |
1754 delete anm2; | |
1755 } | |
1756 PicBase* pic; Surface* s; | |
1757 Rect r(cmd.args[1].value, cmd.args[2].value, cmd.args[3].value+1, cmd.args[4].value+1); | |
1758 const char* name = cmd.Str(cmd.args[5]); | |
1759 Rect sr_start(cmd.args[6].value,cmd.args[7].value); | |
1760 Rect sr_end(cmd.args[8].value,cmd.args[9].value); | |
1761 int tm = cmd.args[10].value; | |
1762 LoadSurface(name, 2); /* PDT2 に読み込み、と決め打ち */ | |
1763 | |
1764 anm2 = new ScnGrpMove(event, screen, parent.Root(), Dsurface(1), r, Ssurface(2), sr_start, sr_end, tm); | |
1765 cmd.cmd_type = CMD_SAVECMDGRP; | |
1766 } | |
1767 if ( (cmd.cmd3 == 0xc1c && cmd.cmd4 == 0) || (cmd.cmd3 == 0x835 && cmd.cmd4 == 0) ) { | |
1768 // カードが落ちるアニメーション | |
1769 int i; | |
1770 ScnGrpAnm* new_anm = new ScnGrpAnm(event, screen, *this); | |
1771 if (cmd.cmd3 == 0x835) { | |
1772 AbortAnm(); | |
1773 anm1 = new_anm; | |
1774 status = WAIT_ANM; | |
1775 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
1776 } else { | |
1777 anm2 = new_anm; | |
1778 } | |
1779 for (i=0; i<cmd.argc; i++) { | |
1780 const char* name = cmd.Str(cmd.args[i*3+1]); | |
1781 int tm = cmd.args[i*3+2].value; | |
1782 new_anm->push_back(ScnGrpAnmAtom(name,tm)); | |
1783 } | |
1784 new_anm->CalcTotal(); | |
1785 cmd.clear(); | |
1786 } | |
1787 } | |
26 | 1788 if (cmd.cmd1 == 1 && cmd.cmd2 == 4) { |
1789 if (cmd.cmd3 == 0x5dc) // Total number of CG | |
1790 cmd.SetSysvar(cgm_size); | |
1791 if (cmd.cmd3 == 0x5dd) // Number of CG viewed | |
1792 cmd.SetSysvar(cgm_data.size()); | |
1793 if (cmd.cmd3 == 0x5de) // Percentage of CG viewed | |
20
824b89018ea8
* CG completion percentage (maybe not working properly?)
thib
parents:
18
diff
changeset
|
1794 cmd.SetSysvar(cgm_data.size() * 100 / cgm_size); |
26 | 1795 |
0 | 1796 if (cmd.cmd3 == 0xd8 || cmd.cmd3 == 0xd3 || cmd.cmd3 == 0xd2 || cmd.cmd3 == 0xd7) { |
1797 cmd.clear(); // いつも 0xd8 / 0xd7 と組で出てくる | |
1798 } | |
26 | 1799 |
1800 // CG Status | |
0 | 1801 if (cmd.cmd3 == 0x5e0) { // 画像既視フラグを得る |
1802 string s = cmd.Str(cmd.args[0]); | |
1803 if (cgm_info.find(s) == cgm_info.end()) { | |
1804 fprintf(stderr,"cmd 01-04:05e0 : cannot find cgm-info of '%s'\n",s.c_str()); | |
1805 return; | |
1806 } | |
1807 int n = cgm_info[s]; | |
1808 if (cgm_data.find(n) == cgm_data.end()) cmd.SetSysvar(0); | |
1809 else cmd.SetSysvar(1); | |
1810 } | |
26 | 1811 |
1812 if (cmd.cmd3 == 0x6a4) { // CreateInput (index, x, y, width, height, fontsize, br, bg, bb, fr, fg, fb) | |
1813 int index = cmd.args[0].value; | |
1814 int x = cmd.args[1].value; | |
1815 int y = cmd.args[2].value; | |
1816 //TODO | |
1817 } | |
1818 if (cmd.cmd3 == 0x6ae) { // SetInput (index, text) | |
1819 //TODO | |
1820 } | |
0 | 1821 } |
1822 #if 1 | |
1823 /* object 操作 */ | |
1824 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && (cmd.cmd2 == 0x3d || cmd.cmd2 == 0x3e) && (cmd.cmd3 == 0x0a || cmd.cmd3 == 0x0b || cmd.cmd3 == 0x0e)) { // clear object | |
1825 if (cmd.cmd3 == 0x0a || cmd.cmd3 == 0x0b) { | |
1826 if (cmd.cmd1 == 2 && cmd.args.size() == 2) { | |
1827 int num = cmd.args[0].value*1000 + cmd.args[1].value + 500; | |
1828 DeleteObj(num); | |
1829 } else if (cmd.args.size() == 1) { // group ごと消去 | |
1830 int num_first = cmd.args[0].value * 1000; | |
1831 int num_end = num_first+1000; | |
1832 DeleteObjRange(num_first, num_end); | |
1833 } | |
1834 } else { // 0x0e | |
1835 if (cmd.cmd1 == 1 && cmd.args.size() == 2) { | |
1836 SwapObj(cmd.args[0].value * 1000, cmd.args[1].value * 1000); | |
1837 } else if (cmd.cmd1 == 2 && cmd.args.size() == 3) { | |
1838 int v1 = cmd.args[0].value*1000 + cmd.args[1].value + 500; | |
1839 int v2 = cmd.args[0].value*1000 + cmd.args[2].value + 500; | |
1840 SwapObj(v1, v2); | |
1841 } | |
1842 } | |
1843 cmd.clear(); | |
1844 } | |
1845 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0x01) { // ??? : CLANNAD | |
1846 cmd.clear(); | |
1847 } | |
1848 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0) { // ??? : KANOGI : 画像オブジェクトの削除? | |
1849 DeleteObjPic(cmd.args[0].value * 1000); // 旧ファイル名のsurfaceを削除 | |
1850 GrpObj& g = grpobj[cmd.args[0].value * 1000]; | |
1851 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1852 cmd.clear(); | |
1853 } | |
1854 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && (cmd.cmd2 == 0x47 || cmd.cmd2 == 0x48|| cmd.cmd2 == 0x49 || cmd.cmd2 == 0x51 || cmd.cmd2 == 0x52 || cmd.cmd2 == 0x54)) { | |
1855 if (cmd.cmd1 == 1) { | |
1856 if (cmd.args.size() >= 1) cmd.args[0].value *= 1000; // とりあえず 1000倍しておく | |
1857 } else { // cmd.cmd2 == 2 | |
1858 // オブジェクト番号を指定するコマンド引数が一つ増えているのを消去 | |
1859 vector<VarInfo> args = cmd.args; | |
1860 cmd.args.clear(); | |
1861 if (args.size() >= 2) { | |
1862 cmd.args.push_back(args[0].value*1000 + args[1].value + 500); | |
1863 cmd.args.insert(cmd.args.end(), args.begin()+2, args.end()); | |
1864 } | |
1865 } | |
1866 if (cmd.cmd2 == 0x47) { | |
1867 /**************: | |
1868 0x47 : オブジェクト内容の設定 | |
1869 0x3e8: G00 ファイル | |
1870 0x3eb: GAN ファイル | |
1871 0x44c: 矩形領域 | |
1872 0x4b0: 文字列 | |
1873 0x514: 天候効果 | |
1874 0x578: 数字の画像表示 | |
1875 */ | |
1876 int base_argc = 0; | |
1877 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除 | |
1878 GrpObj& g = grpobj[cmd.args[0].value]; | |
1879 if (cmd.cmd3 == 0x3e8) { /* ファイル名設定 */ | |
1880 g.gtype = GrpObj::FILE; | |
1881 string name = cmd.Str(cmd.args[1]); | |
1882 if (name.find('?') != -1) { | |
1883 name.erase(name.find('?')); // '?' 以降の意味がわからない | |
1884 } | |
1885 g.name = name; | |
1886 } else if (cmd.cmd3 == 0x3eb) { /* ファイル名設定(GAN含む) */ | |
1887 g.gtype = GrpObj::GAN; | |
1888 if (cmd.Str(cmd.args[1]) == string("???")) | |
1889 g.name = cmd.Str(cmd.args[2]); | |
1890 else | |
1891 g.name = cmd.Str(cmd.args[1]); | |
1892 g.gan_name = cmd.Str(cmd.args[2]); | |
5 | 1893 |
1894 if (cmd.cmd4 >= 1 && cmd.args[3].value == 0) | |
1895 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1896 else | |
1897 g.attr = GrpObj::Attribute(g.attr & ~(GrpObj::HIDDEN)); | |
1898 | |
1899 if (cmd.argc >= 5) | |
1900 g.SetPos(1, cmd.args[4].value, -cmd.args[5].value); | |
1901 | |
1902 if (g.name.find('?') != -1) { | |
4 | 1903 g.name.erase(g.name.find('?')); |
1904 g.gan_name = cmd.Str(cmd.args[2]); | |
1905 } | |
0 | 1906 } else if (cmd.cmd3 == 0x4b0) { // 画像を文字列として指定 |
1907 g.gtype = GrpObj::MOJI; | |
1908 g.print_moji = cmd.Str(cmd.args[1]); | |
1909 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); // 常に表示がデフォルト? | |
1910 cmd.clear(); | |
1911 } else if (cmd.cmd3 == 0x578) { // 数値を画像として表示 | |
1912 g.gtype = GrpObj::DIGIT; | |
1913 g.name = cmd.Str(cmd.args[1]); | |
1914 } | |
1915 CreateObj(cmd.args[0].value); | |
1916 if (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3eb || cmd.cmd3 == 0x4b0 || cmd.cmd3 == 0x578) { | |
1917 // FILE, GAN, MOJI, DIGIT ならば座標等の設定を行う | |
18 | 1918 if (cmd.cmd4 >= 1) { |
0 | 1919 if (cmd.args[2+base_argc].value == 0) { |
1920 if (cmd.cmd1 == 1) | |
1921 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP); | |
1922 else | |
1923 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1924 } else { | |
1925 if (cmd.cmd1 == 1) | |
1926 g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP))); | |
1927 else | |
1928 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
1929 } | |
1930 if (cmd.cmd1 == 1) | |
1931 SetObjChangedGroup(cmd.args[0].value); | |
1932 } | |
18 | 1933 if (cmd.cmd4 >= 2) { // 座標等も設定 |
0 | 1934 g.SetPos(0,cmd.args[3+base_argc].value, cmd.args[4+base_argc].value); |
1935 } | |
18 | 1936 if ( (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3eb) && cmd.cmd4 >= 3) { // pattern 番号も設定 |
0 | 1937 g.SetSurfaceNum(cmd.args[5+base_argc].value); |
1938 base_argc++; // 0x3e8 (FILE) / 0x3eb (GAN) の場合のみこのオプションは存在する | |
1939 } | |
1940 cmd.clear(); | |
1941 } else { | |
1942 fprintf(stderr,"CreateObj : cmd.cmd3 = %04x ; not supported!\n",cmd.cmd3); | |
1943 } | |
1944 } else if (cmd.cmd2 == 0x48) { | |
1945 // 画面切り替え後の object (back screen object) 設定 | |
1946 if (cmd.cmd3 == 0x3e8) { | |
1947 // cmd.cmd4 == 0 : args = 2, CLANNAD : cg mode | |
1948 // cmd.cmd4 == 1 : args = 3, CLANNAD : 春原回想?のところで画面が黒くなってしまうので、とりあえず。 | |
1949 // cmd.cmd4 == 2 : args = 5, KANOGI : Fore Graphics | |
1950 // cmd.cmd4 == 3 : args = 6, KANOGI : CG mode | |
1951 GrpObj& g = bs_obj[cmd.args[0].value]; | |
1952 string name = cmd.Str(cmd.args[1]); | |
1953 if (name.find('?') != -1) { | |
1954 name.erase(name.find('?')); // '?' 以降の意味がわからない | |
1955 } | |
1956 g.gtype = GrpObj::FILE; | |
1957 g.name = name; | |
1958 if (cmd.cmd4 >= 1 && cmd.args[2].value == 0) | |
1959 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
1960 else | |
1961 g.attr = GrpObj::Attribute(g.attr & ~(GrpObj::HIDDEN)); | |
1962 if (cmd.cmd4 >= 2) | |
1963 g.SetPos(0,cmd.args[3].value, cmd.args[4].value); | |
1964 if (cmd.cmd4 >= 3) | |
1965 g.SetSurfaceNum(cmd.args[5].value); | |
1966 if (cmd.cmd4 <= 3) | |
1967 cmd.cmd_type = CMD_SAVECMDGRP; | |
1968 } | |
1969 } else if (cmd.cmd2 == 0x49) { | |
1970 if (cmd.cmd3 == 0) { // アニメーションを強制終了 | |
1971 GrpObj& g = grpobj[cmd.args[0].value]; | |
52 | 1972 if (g.anm == NULL || g.anm->IsEnd()) ; |
0 | 1973 else g.anm->Abort(); |
1974 } else if (cmd.cmd3 == 3) { // アニメーション中か? | |
1975 GrpObj& g = grpobj[cmd.args[0].value]; | |
52 | 1976 if (g.anm == NULL || g.anm->IsEnd()) { |
0 | 1977 cmd.SetSysvar(0); |
1978 } else { | |
1979 cmd.SetSysvar(1); | |
1980 } | |
1981 } else if (cmd.cmd3 == 1000) { | |
1982 // アニメーションを途中で停止した状態にする | |
1983 GrpObj& g = grpobj[cmd.args[0].value]; | |
52 | 1984 if (g.anm == NULL || g.anm->IsEnd()) { |
0 | 1985 // fprintf(stderr,"AnimPause : no animation in %d (%d)\n",cmd.args[0].value, cmd.args[1].value); |
1986 g.SetSurfaceNum(cmd.args[1].value); | |
1987 } else { | |
1988 g.anm->Abort(); | |
1989 g.SetSurfaceNum(cmd.args[1].value); | |
1990 } | |
1991 SetObjChanged(cmd.args[0].value); | |
1992 cmd.clear(); | |
1993 } else if (cmd.cmd3 == 0x7d3) { // surface を増加させる画像効果 | |
1994 GrpObj& g = grpobj[cmd.args[0].value]; | |
1995 g.CreateGanSpecial(event, 0, cmd.args[1].value); | |
1996 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
1997 SetObjChanged(cmd.args[0].value); | |
1998 cmd.clear(); | |
1999 } else if (cmd.cmd3 == 0xbbd || cmd.cmd3 == 0xbbb || cmd.cmd3 == 0xbb9) { // アニメーション開始 | |
2000 GrpObj& g = grpobj[cmd.args[0].value]; | |
2001 g.CreateGan(event, cmd.args[1].value); | |
2002 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
2003 SetObjChanged(cmd.args[0].value); | |
2004 cmd.clear(); | |
2005 } | |
2006 } else if (cmd.cmd2 == 0x51 || cmd.cmd2 == 0x52) { | |
2007 GrpObj& g = (cmd.cmd2 == 0x51) ? | |
2008 grpobj[cmd.args[0].value] : | |
2009 bs_obj[cmd.args[0].value]; | |
2010 if (cmd.cmd3 == 0x3e8) { /* 座標設定 */ | |
2011 g.SetPos(0,cmd.args[1].value, cmd.args[2].value); | |
2012 cmd.clear(); | |
2013 } else if (cmd.cmd3 == 0x3e9 || cmd.cmd3 == 0x3ea) { /* x / y 座標のみ設定 */ | |
2014 int x0, y0; | |
2015 g.GetPos(0, x0, y0); | |
2016 if (cmd.cmd3 == 0x3e9) | |
2017 g.SetPos(0,cmd.args[1].value, y0); | |
2018 else | |
2019 g.SetPos(0,x0, cmd.args[1].value); | |
2020 cmd.clear(); | |
2021 } else if (cmd.cmd3 == 0x3eb) { /* alpha */ | |
2022 g.SetAlpha(cmd.args[1].value); | |
2023 cmd.clear(); | |
2024 } else if (cmd.cmd3 == 0x3ec) { /* visible flag */ | |
2025 if (cmd.cmd1 == 1) { | |
2026 if (cmd.args[1].value) g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP))); | |
2027 else g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP); | |
2028 } else { | |
2029 if (cmd.args[1].value) g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); | |
2030 else g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN); | |
2031 } | |
2032 g.attr = GrpObj::Attribute(g.attr | GrpObj::UPDATE_VISIBLE); | |
2033 // グループ単位で次の RefreshObj で表示・消去 | |
2034 if (cmd.cmd2 == 0x51 && cmd.cmd1 == 1) | |
2035 SetObjChangedGroup(cmd.args[0].value); | |
2036 cmd.clear(); | |
2037 } else if (cmd.cmd3 == 0x3ee || cmd.cmd3 == 0x7d6) { /* 座標設定その2? */ | |
2038 /* 0x7d6 : 画像側の基準座標を args[4,5] に入れているのかもしれない */ | |
2039 int index = cmd.args[1].value; | |
2040 int x = cmd.args[2].value; | |
2041 int y = cmd.args[3].value; | |
2042 g.SetPos(index+1, x, y); | |
2043 cmd.clear(); | |
2044 } else if (cmd.cmd3 == 0x3f8) { // 画像を文字列として設定:色の設定 | |
2045 g.print_r = cmd.args[1].value; | |
2046 g.print_g = cmd.args[2].value; | |
2047 g.print_b = cmd.args[3].value; | |
2048 g.SetUpdate(); | |
2049 // grpobj[cmd.args[0].value].print_a = cmd.args[4].value; | |
2050 /* args:229,18,minus-1,0,99,255,-1 */ | |
2051 /* args:102,26,minus-1,0,99,0,255 */ | |
2052 cmd.clear(); | |
2053 } else if (cmd.cmd3 == 0x3fd) { // centering mode などを設定? | |
2054 if (cmd.args[1].value == 1) { | |
2055 g.attr = GrpObj::Attribute(g.attr | GrpObj::SATURATE); | |
2056 cmd.clear(); | |
2057 } else if (cmd.args[1].value == 0) { | |
2058 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::SATURATE)); | |
2059 cmd.clear(); | |
2060 } | |
2061 g.SetUpdate(); | |
2062 /* cmd3 == 0x41c : ゲームの進行とともに | |
2063 args:10,105 | |
2064 args:10,133 | |
2065 args:10,144 | |
2066 args:10,144 | |
2067 と変化 | |
2068 | |
2069 cmd3 == 0x418 : | |
2070 args: 10, 400 -> 100 | |
2071 と、alpha の増加とともに変化 | |
2072 */ | |
2073 /* | |
2074 487 / 8047 : unsupported command; 0x23 - cmd 01-51:0419:00[ 2] | |
2075 81,-40, | |
2076 第二引数の 1/10 がオブジェクトの回転角 | |
2077 */ | |
2078 } else if (cmd.cmd3 == 0x400) { // 画像を文字列として指定 | |
2079 g.print_moji = cmd.Str(cmd.args[1]); | |
2080 g.SetUpdate(); | |
2081 cmd.clear(); | |
2082 } else if (cmd.cmd3 == 0x401) { // 画像を文字列として設定:文字の大きさなど | |
2083 /* args: size, xspace, yspace, vertical, color, shadow */ | |
2084 /* | |
2085 args:17, 0,0,-1, 0,-1 DT in Tomoyo | |
2086 args:17, 0,0,-1,200,-1 Save/Load in Tomoyo | |
2087 args:20, 0,0, 0,255,-1 "──ありがとう…。" (勝平Ed付近) | |
2088 args:16,-1,0,99,255,-1 "やあ、久しぶり──…。" (同上,Save/Load Menu) | |
2089 args:26,-1,0,99, 0,255 Kuma in CLANNAD | |
2090 */ | |
2091 g.print_size = cmd.args[1].value; | |
2092 /* 前景色を得る */ | |
2093 int cr,cg,cb; char key[1024]; | |
2094 sprintf(key, "#COLOR_TABLE.%03d", cmd.args[5].value); | |
2095 if (config.GetParam(key, 3, &cr, &cg, &cb)) { // color not found | |
2096 cr = cg = cb = 0; | |
2097 } | |
2098 g.print_r = cr; | |
2099 g.print_g = cg; | |
2100 g.print_b = cb; | |
2101 g.SetUpdate(); | |
2102 cmd.clear(); | |
2103 } else if (cmd.cmd3 == 0x408) { // set order | |
2104 int order = cmd.args[1].value; | |
2105 if (cmd.cmd1 == 1) order *= 1000; // order も 1000 倍する必要がある? | |
2106 g.order = order; | |
2107 ZMoveObj(cmd.args[0].value); | |
2108 cmd.clear(); | |
2109 } else if (cmd.cmd3 == 0x40a && cmd.cmd4 == 1) { // set surface geometry? | |
2110 // オブジェクトのどの部分を画面に表示するか(クリップ領域)の設定 | |
2111 int rx = cmd.args[1].value; | |
2112 int ry = cmd.args[2].value; | |
43
01aa5ddf7dc8
A lot of very minor improvements (deleted some unused variables, and other things like that...)
thib
parents:
26
diff
changeset
|
2113 int x2 = cmd.args[3].value; |
01aa5ddf7dc8
A lot of very minor improvements (deleted some unused variables, and other things like that...)
thib
parents:
26
diff
changeset
|
2114 int y2 = cmd.args[4].value; |
01aa5ddf7dc8
A lot of very minor improvements (deleted some unused variables, and other things like that...)
thib
parents:
26
diff
changeset
|
2115 g.SetClipArea(rx, ry, x2, y2); //TODO: case when cmd.args.size() == 1 |
0 | 2116 cmd.clear(); |
2117 } else if (cmd.cmd3 == 0x40d) { // set digit number | |
2118 g.dig_number = cmd.args[1].value; | |
2119 g.SetUpdate(); | |
2120 cmd.clear(); | |
2121 } else if (cmd.cmd3 == 0x40e) { // set digit option | |
2122 g.dig_digit = cmd.args[1].value; | |
2123 int attr = g.attr; | |
2124 attr &= ~(GrpObj::DIG_ZERO | GrpObj::DIG_SIGN | GrpObj::DIG_PACK); | |
2125 if (cmd.args[2].value) attr |= GrpObj::DIG_ZERO; | |
2126 if (cmd.args[3].value) attr |= GrpObj::DIG_SIGN; | |
2127 if (cmd.args[4].value) attr |= GrpObj::DIG_PACK; | |
2128 g.attr = GrpObj::Attribute(attr); | |
2129 g.SetUpdate(); | |
2130 cmd.clear(); | |
2131 } else if (cmd.cmd3 == 0x40f) { /* set surface number */ | |
2132 g.SetSurfaceNum(cmd.args[1].value); | |
2133 cmd.clear(); | |
2134 } else if (cmd.cmd3 == 0x416) { // オブジェクトの拡大率設定 | |
2135 int zoom = (cmd.args[1].value + cmd.args[2].value)/2; // x,y 別に設定できるらしい | |
2136 zoom = zoom*256/100; | |
2137 g.SetZoomRotate(zoom, -1); | |
2138 cmd.clear(); | |
2139 } else if (cmd.cmd3 == 0x419) { // オブジェクトの回転設定 | |
2140 int angle = cmd.args[1].value; | |
2141 angle /= 10; | |
2142 if (angle < 0) { | |
2143 angle %= 360; | |
2144 angle += 360; | |
2145 } | |
2146 angle %= 360; | |
2147 g.SetZoomRotate(-1, angle); | |
2148 cmd.clear(); | |
2149 } | |
2150 if (cmd.cmd2 == 0x51 && (g.attr & GrpObj::UPDATE_ALL)) { | |
2151 SetObjChanged(cmd.args[0].value); | |
2152 } | |
2153 } else if (cmd.cmd2 == 0x54) { | |
2154 /* 座標取得 */ | |
2155 if (cmd.cmd3 == 0x3e8) { | |
2156 GrpObj& obj = grpobj[cmd.args[0].value]; | |
2157 VarInfo arg1 = cmd.args[1]; | |
2158 VarInfo arg2 = cmd.args[2]; | |
2159 int x0, y0; | |
2160 obj.GetPos(0,x0, y0); | |
2161 cmd.SetFlagvar(arg1, x0); | |
2162 cmd.SetFlagvar(arg2, y0); | |
2163 } else if (cmd.cmd3 == 0x44c) { | |
2164 int w, h; | |
2165 GrpObj& obj = grpobj[cmd.args[0].value]; | |
2166 obj.GetSrcGeom(w, h); | |
2167 VarInfo arg1 = cmd.args[1]; | |
2168 VarInfo arg2 = cmd.args[2]; | |
2169 cmd.SetFlagvar(arg1, w); | |
2170 cmd.SetFlagvar(arg2, h); | |
2171 } | |
2172 } | |
2173 // セーブ用にコマンドを元に戻す | |
2174 if (cmd.args.size() != 0 && (cmd.cmd_type == CMD_SAVECMDGRP || cmd.cmd_type == CMD_SAVECMDGRP_ONCE)) { | |
2175 if (cmd.cmd1 == 1) cmd.args[0].value /= 1000; | |
2176 else if (cmd.cmd1 == 2) { | |
2177 vector<VarInfo> args = cmd.args; | |
2178 int value = args[0].value; | |
2179 cmd.args.clear(); | |
2180 args[0].value = value / 1000; | |
2181 cmd.args.push_back(args[0]); | |
2182 args[0].value = value % 1000 - 500; | |
2183 cmd.args.push_back(args[0]); | |
2184 cmd.args.insert(cmd.args.end(), args.begin()+1, args.end()); | |
2185 } | |
2186 } | |
2187 } | |
2188 #endif | |
2189 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1f) { // 本来は grpstack clear らしい | |
2190 RefreshObj(); | |
2191 // Princess Bride の中途 Staff roll | |
2192 // このタイミングで描画するのが都合がいいので、 | |
2193 //シナリオループを抜けて描画を起動 | |
2194 cmd.cmd_type = CMD_WAITFRAMEUPDATE; | |
2195 } | |
2196 | |
2197 /* XXX : GiGiGi */ | |
2198 /* 122 : 0x23 - cmd 01-04:0924:00[ 0] : V<sys> にBGM再生モードを返す (0/1) | |
2199 ** 256 : 0x23 - cmd 01-04:091a:00[ 0] : V<sys> にBGM音量を返す (0-255?) | |
2200 ** 278 : 0x23 - cmd 01-04:0926:00[ 0] : V<sys> にEff再生モードを返す (0/1) | |
2201 ** 412 : 0x23 - cmd 01-04:091c:00[ 0] : V<sys> にEff音量を返す (0-255?) | |
2202 ** 434 : 0x23 - cmd 01-04:0927:00[ 0] : V<sys> にSE 再生モードを返す (0/1) | |
2203 ** 568 : 0x23 - cmd 01-04:091d:00[ 0] : V<sys> にSE 音量を返す (0-255?) | |
2204 | |
2205 ** 122 : 0x23 - cmd 01-04:08c0:00[ 0] : V<sys> にBGM再生モードを設定 (0/1) | |
2206 ** 256 : 0x23 - cmd 01-04:08b6:00[ 0] : V<sys> にBGM音量を設定 (0-255?) | |
2207 ** 278 : 0x23 - cmd 01-04:08c2:00[ 0] : V<sys> にEff再生モードを設定 (0/1) | |
2208 ** 412 : 0x23 - cmd 01-04:08b8:00[ 0] : V<sys> にEff音量を設定 (0-255?) | |
2209 ** 434 : 0x23 - cmd 01-04:08c3:00[ 0] : V<sys> にSE 再生モードを設定 (0/1) | |
2210 ** 568 : 0x23 - cmd 01-04:08b9:00[ 0] : V<sys> にSE 音量を設定 (0-255?) | |
2211 */ | |
2212 // 本来は音楽関連のコマンド | |
2213 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x14) { | |
2214 if (cmd.cmd3 == 0 && cmd.cmd4 == 0) { | |
2215 eprintf("play bgm %s\n",cmd.Str(cmd.args[0])); | |
2216 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000); | |
2217 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2218 } | |
2219 if (cmd.cmd3 == 2 && (cmd.cmd4 == 2 || cmd.cmd4 == 0) ) { /* ??? : ことみシナリオラストの音楽再生 */ | |
2220 eprintf("play bgm %s\n",cmd.Str(cmd.args[0])); | |
2221 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 1); | |
2222 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2223 } | |
2224 if (cmd.cmd3 == 0 && cmd.cmd4 == 2) { | |
2225 eprintf("fade bgm %d? and play bgm %s; %d\n",cmd.args[1].value, cmd.Str(cmd.args[0]), cmd.args[2].value); | |
2226 // music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000, cmd.args[2].value); | |
2227 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000); | |
2228 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2229 } | |
2230 if ( (cmd.cmd3 == 5 || cmd.cmd3 == 0x69) && cmd.cmd4 == 0) { | |
2231 if (cmd.cmd3 == 5) { | |
2232 music.StopCDROM(0); | |
2233 eprintf("stop bgm\n"); | |
2234 } else { | |
2235 music.StopCDROM(cmd.args[0].value); | |
2236 eprintf("fade bgm %d\n",cmd.args[0].value); | |
2237 } | |
2238 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2239 } | |
2240 } | |
2241 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x15) { | |
10 | 2242 if ((cmd.cmd3 == 2) || (cmd.cmd3 == 0 && (cmd.cmd4 == 1 || cmd.cmd4 == 2)) || (cmd.cmd3 == 0 && cmd.cmd4 == 0)) { |
11 | 2243 eprintf("play SE %s\n",cmd.Str(cmd.args[0])); |
0 | 2244 if (cmd.cmd3 == 2) { |
2245 music.PlaySE(cmd.Str(cmd.args[0]),1); | |
2246 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2247 } else { | |
2248 music.PlaySE(cmd.Str(cmd.args[0])); | |
2249 cmd.clear(); | |
2250 } | |
2251 } else if (cmd.cmd3 == 5) { | |
2252 eprintf("Stop SE\n"); | |
2253 music.StopSE(); | |
2254 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2255 } else if (cmd.cmd3 == 0x69) { | |
2256 eprintf("Stop SE with fade %d\n",cmd.args[0].value); | |
2257 music.StopSE(cmd.args[0].value); | |
2258 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
2259 } | |
2260 } | |
2261 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && (cmd.cmd3 == 0x4bb || cmd.cmd3 == 0x4bc) ) { | |
2262 // 音楽を待ってみる(絶対に違うが)。本来、04-803 に対応してなにかの終わりをwaitするっぽい(風子/智代Ed付近) | |
2263 // EnableSyscom らしいが、よくわからない (rldev) | |
2264 // if (!music.IsStopSE()) status = WAIT_SE; | |
2265 cmd.clear(); | |
2266 } | |
26 | 2267 |
0 | 2268 // 音楽モードで音量を上げるためのコマンド (SetBgmVolume) |
2269 // とりあえず未実装 | |
26 | 2270 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && cmd.cmd3 >= 0x8b6 && cmd.cmd3 <= 0x8b9) { // Set{Bgm,Koe,PCM,Se}VolMod |
2271 music.volmod[cmd.cmd3-0x8b6] = cmd.args[0].value; | |
2272 config.SetParam("#VOLMOD", 4, music.volmod[0], music.volmod[1], music.volmod[2], music.volmod[3]); | |
0 | 2273 cmd.clear(); |
2274 } | |
26 | 2275 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && cmd.cmd3 >= 0x91a && cmd.cmd3 <= 0x91d) { // Get{Bgm,Koe,PCM,Se}VolMod |
2276 cmd.SetSysvar(music.volmod[cmd.cmd3-0x91a]); | |
2277 } | |
0 | 2278 |
2279 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x16) { | |
2280 if (cmd.cmd3 == 0 && cmd.cmd4 == 0) { | |
2281 eprintf("play SE %d\n",cmd.args[0].value); | |
2282 music.PlaySE(cmd.args[0].value); | |
2283 cmd.clear(); | |
2284 } | |
2285 } | |
2286 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x17) { | |
2287 if (cmd.cmd3 == 0) { | |
2288 eprintf("play koe %d",cmd.args[0].value); | |
2289 if (cmd.cmd4 == 1) { | |
2290 eprintf(", para? %d",cmd.args[1].value); | |
2291 } | |
2292 eprintf("\n"); | |
2293 char buf[1024]; sprintf(buf, "%d",cmd.args[0].value); | |
2294 if ( !(skip_mode & SKIP_TEXT)) music.PlayKoe(buf); | |
2295 cmd.clear(); | |
2296 } | |
2297 } | |
2298 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1a) { | |
2299 if ( (cmd.cmd3 == 0x14 || cmd.cmd3 == 1) && cmd.cmd4 == 0) { | |
2300 const char* str = cmd.Str(cmd.args[0]); | |
2301 int x = cmd.args[1].value; | |
2302 int y = cmd.args[2].value; | |
2303 int x2 = cmd.args[3].value; | |
2304 int y2 = cmd.args[4].value; | |
2305 eprintf("play movie ; name %s pos %d,%d - %d,%d\n",str,x,y,x2,y2); | |
2306 music.PlayMovie(str, x, y, x2, y2,1); | |
2307 status = WAIT_MOVIE; | |
2308 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | |
2309 cmd.clear(); | |
2310 } | |
2311 } | |
2312 return; | |
2313 } | |
2314 | |
2315 | |
2316 /******************************************************** | |
2317 ** | |
2318 ** class Grp | |
2319 */ | |
2320 | |
2321 Grp::Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm,class MuSys& mu, AyuSysConfig& config) { | |
2322 pimpl = new GrpImpl(_event, _parent, f, _cgm, mu, config); | |
52 | 2323 } |
2324 | |
0 | 2325 Grp::~Grp() { |
2326 delete pimpl; | |
2327 } | |
2328 | |
2329 bool Grp::Wait(unsigned int current_time, Cmd& cmd) { | |
2330 return pimpl->Wait(current_time, cmd); | |
2331 } | |
52 | 2332 |
0 | 2333 void Grp::Exec(Cmd& cmd) { |
2334 pimpl->Exec(cmd); | |
2335 } | |
52 | 2336 |
0 | 2337 void Grp::SetSkipMode(SkipMode mode) { |
2338 pimpl->SetSkipMode(mode); | |
2339 } | |
52 | 2340 |
0 | 2341 void Grp::InitSel(AyuSysConfig& config) { |
2342 pimpl->InitSel(config); | |
2343 } | |
52 | 2344 |
0 | 2345 void Grp::Save(std::string& str) { |
2346 pimpl->Save(str); | |
2347 } | |
2348 | |
2349 void Grp::Load(const char* str) { | |
2350 pimpl->Load(str); | |
2351 } | |
2352 void Grp::SaveSys(std::string& str) { | |
2353 pimpl->SaveSys(str); | |
2354 } | |
2355 | |
2356 void Grp::LoadSys(const char* str) { | |
2357 pimpl->LoadSys(str); | |
2358 } |