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