Mercurial > otakunoraifu
comparison scn2k/scn2k_grp.cc @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 35ce1a30f3f9 |
children | ddbcbd000206 |
comparison
equal
deleted
inserted
replaced
51:cbb301016a4e | 52:15a18fbe6f21 |
---|---|
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 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 | 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. | 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include"scn2k.h" | 28 #include "scn2k.h" |
29 #include"window/widget.h" | 29 #include "window/widget.h" |
30 #include"system/file.h" | 30 #include "system/file.h" |
31 #include"system/system_config.h" | 31 #include "system/system_config.h" |
32 #include"font/text.h" | 32 #include "font/text.h" |
33 #include<set> | 33 #include <set> |
34 | 34 |
35 using namespace std; | 35 using namespace std; |
36 | 36 |
37 extern void DSurfaceFill(Surface* dest, const Rect& rect, int r, int g, int b, int a=0xff); | 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); | 38 extern void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstpos); |
58 string gan_name; | 58 string gan_name; |
59 PicContainer* pic_parent; | 59 PicContainer* pic_parent; |
60 PicBase* picture; | 60 PicBase* picture; |
61 WidAnmTime* anm; | 61 WidAnmTime* anm; |
62 int _posx, _posy; | 62 int _posx, _posy; |
63 int posx[9],posy[9]; | 63 int posx[9], posy[9]; |
64 Rect clip_area; | 64 Rect clip_area; |
65 unsigned char alpha; | 65 unsigned char alpha; |
66 int order; | 66 int order; |
67 int surface_num; | 67 int surface_num; |
68 | 68 |
136 }; | 136 }; |
137 | 137 |
138 class GrpImpl { | 138 class GrpImpl { |
139 #define MAXPDT 256 | 139 #define MAXPDT 256 |
140 #define WORKPDT 255 | 140 #define WORKPDT 255 |
141 Event::Container& event; | 141 private: |
142 const Flags& flags; | 142 Event::Container& event; |
143 PicBase* screen; | 143 const Flags& flags; |
144 PicBase* screen_front; | 144 PicBase* screen; |
145 Surface* surface, *surface_update; | 145 PicBase* screen_front; |
146 | 146 Surface* surface, *surface_update; |
147 Surface* dsurface[MAXPDT]; // 書き込み可能な Surface | 147 |
148 Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface | 148 Surface* dsurface[MAXPDT]; // 書き込み可能な Surface |
149 PicContainer& parent; | 149 Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface |
150 | 150 PicContainer& parent; |
151 // 画像効果の保存用 | 151 |
152 WidAnmTime* anm1, *anm2; | 152 // 画像効果の保存用 |
153 typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status; | 153 WidAnmTime* anm1, *anm2; |
154 Status status; | 154 typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status; |
155 SkipMode skip_mode; | 155 Status status; |
156 | 156 SkipMode skip_mode; |
157 std::string bg_name; | 157 |
158 std::map<int, SEL> anmtype; | 158 std::string bg_name; |
159 GrpObjMap grpobj; | 159 std::map<int, SEL> anmtype; |
160 GrpObjMap bs_obj; | 160 GrpObjMap grpobj; |
161 void CreateObj(int number); | 161 GrpObjMap bs_obj; |
162 void ZMoveObj(int number); | 162 void CreateObj(int number); |
163 void SetObjChanged(int number); | 163 void ZMoveObj(int number); |
164 void SetObjChangedGroup(int number); | 164 void SetObjChanged(int number); |
165 void SwapObj(int a1, int a2); | 165 void SetObjChangedGroup(int number); |
166 void DeleteObjPic(int num);// object の surface のみ削除 | 166 void SwapObj(int a1, int a2); |
167 void DeleteObj(int num); | 167 void DeleteObjPic(int num);// object の surface のみ削除 |
168 void DeleteObjRange(int num_b, int num_e); | 168 void DeleteObj(int num); |
169 | 169 void DeleteObjRange(int num_b, int num_e); |
170 std::set<int> changed_obj; | 170 |
171 string reserved_load_surface0; | 171 std::set<int> changed_obj; |
172 vector<PicBase*> deleted_pic; | 172 string reserved_load_surface0; |
173 void RefreshObj(void); | 173 vector<PicBase*> deleted_pic; |
174 | 174 void RefreshObj(void); |
175 Surface* Dsurface(int pdt); | 175 |
176 Surface* Ssurface(int pdt); | 176 Surface* Dsurface(int pdt); |
177 | 177 Surface* Ssurface(int pdt); |
178 // cgmode 用画像処理関連 | 178 |
179 void LoadCgm(AyuSysConfig& config); | 179 // cgmode 用画像処理関連 |
180 std::map<std::string, int> cgm_info; | 180 void LoadCgm(AyuSysConfig& config); |
181 set<int>& cgm_data; | 181 std::map<std::string, int> cgm_info; |
182 int cgm_size; | 182 set<int>& cgm_data; |
183 | 183 int cgm_size; |
184 class MuSys& music; | 184 |
185 | 185 class MuSys& music; |
186 public: | 186 |
187 AyuSysConfig& config; | 187 public: |
188 void LoadSurface(const char* str, int pdt); | 188 AyuSysConfig& config; |
189 private: | 189 void LoadSurface(const char* str, int pdt); |
190 void LoadSurface(const char* str); | 190 |
191 void LoadSurface(void); | 191 private: |
192 void AddSurface(const char* str); | 192 void LoadSurface(const char* str); |
193 | 193 void LoadSurface(void); |
194 void StartAnm(int type); | 194 void AddSurface(const char* str); |
195 void StartShake(int total, const int* pattern); | 195 |
196 void AbortAnm(void); | 196 void StartAnm(int type); |
197 static bool Pressed(int x, int y, void* pointer); | 197 void StartShake(int total, const int* pattern); |
198 public: | 198 void AbortAnm(void); |
199 GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config); | 199 static bool Pressed(int x, int y, void* pointer); |
200 ~GrpImpl(); | 200 |
201 bool Wait(unsigned int current_time, Cmd& cmd); | 201 public: |
202 void Exec(Cmd& cmd); | 202 GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config); |
203 void InitSel(AyuSysConfig& config); | 203 ~GrpImpl(); |
204 void Save(std::string& str); | 204 bool Wait(unsigned int current_time, Cmd& cmd); |
205 void Load(const char* str); | 205 void Exec(Cmd& cmd); |
206 void SaveSys(std::string& str); | 206 void InitSel(AyuSysConfig& config); |
207 void LoadSys(const char* str); | 207 void Save(std::string& str); |
208 void SetSkipMode(SkipMode _mode); | 208 void Load(const char* str); |
209 void SaveSys(std::string& str); | |
210 void LoadSys(const char* str); | |
211 void SetSkipMode(SkipMode _mode); | |
209 }; | 212 }; |
210 /******************************************************************* | 213 /******************************************************************* |
211 ** GrpObj(implementation) | 214 ** GrpObj(implementation) |
212 */ | 215 */ |
213 | 216 |
220 int i; | 223 int i; |
221 for (i=0; i<9; i++) { | 224 for (i=0; i<9; i++) { |
222 posx[i] = posy[i] = 0; | 225 posx[i] = posy[i] = 0; |
223 } | 226 } |
224 } | 227 } |
228 | |
225 GrpObj::~GrpObj() { | 229 GrpObj::~GrpObj() { |
226 if (picture) delete picture; | 230 if (picture) delete picture; |
227 if (parent_pimpl == 0) { | 231 if (parent_pimpl == 0) { |
228 fprintf(stderr,"\n**************\nFATAL : UNINITIALIZED GrpObj IS FOUND!!! \n**************\n"); | 232 fprintf(stderr,"\n**************\nFATAL : UNINITIALIZED GrpObj IS FOUND!!! \n**************\n"); |
229 } | 233 } |
230 } | 234 } |
235 | |
231 int GrpObj::PosX() { | 236 int GrpObj::PosX() { |
232 return _posx; | 237 return _posx; |
233 } | 238 } |
239 | |
234 int GrpObj::PosY() { | 240 int GrpObj::PosY() { |
235 return _posy; | 241 return _posy; |
236 } | 242 } |
243 | |
237 void GrpObj::SetUpdate(void) { | 244 void GrpObj::SetUpdate(void) { |
238 attr = Attribute (attr | UPDATE_PICTURE); | 245 attr = Attribute (attr | UPDATE_PICTURE); |
239 //Update(); //FIXME | 246 //Update(); //FIXME |
240 } | 247 } |
248 | |
241 void GrpObj::SetPos(int index, int x,int y) { | 249 void GrpObj::SetPos(int index, int x,int y) { |
242 if (index < 0 || index > 8) { | 250 if (index < 0 || index > 8) { |
243 fprintf(stderr,"GrpObj::SetPos: Invalid index %d <- %d,%d\n",index,x,y); | 251 fprintf(stderr,"GrpObj::SetPos: Invalid index %d <- %d,%d\n",index,x,y); |
244 return; | 252 return; |
245 } | 253 } |
248 _posx += x-posx[index]; | 256 _posx += x-posx[index]; |
249 _posy += y-posy[index]; | 257 _posy += y-posy[index]; |
250 posx[index] = x; | 258 posx[index] = x; |
251 posy[index] = y; | 259 posy[index] = y; |
252 } | 260 } |
261 | |
253 void GrpObj::GetPos(int index, int& x, int& y) { | 262 void GrpObj::GetPos(int index, int& x, int& y) { |
254 if (index < 0 || index > 8) { | 263 if (index < 0 || index > 8) { |
255 fprintf(stderr,"GrpObj::GetPos: Invalid index %d\n",index); | 264 fprintf(stderr,"GrpObj::GetPos: Invalid index %d\n",index); |
256 x = 0; y = 0; | 265 x = 0; y = 0; |
257 return; | 266 return; |
258 } | 267 } |
259 x = posx[index]; | 268 x = posx[index]; |
260 y = posy[index]; | 269 y = posy[index]; |
261 return; | 270 return; |
262 } | 271 } |
272 | |
263 void GrpObj::SetAlpha(int new_alpha) { | 273 void GrpObj::SetAlpha(int new_alpha) { |
264 if (alpha == new_alpha) return; | 274 if (alpha == new_alpha) return; |
265 alpha = new_alpha; | 275 alpha = new_alpha; |
266 attr = Attribute(attr | UPDATE_ALPHA); | 276 attr = Attribute(attr | UPDATE_ALPHA); |
267 return; | 277 return; |
268 } | 278 } |
279 | |
269 void GrpObj::SetSurfaceNum(int num) { | 280 void GrpObj::SetSurfaceNum(int num) { |
270 if (num != -1) { | 281 if (num != -1) { |
271 if (surface_num == num) return; | 282 if (surface_num == num) return; |
272 surface_num = num; | 283 surface_num = num; |
273 } | 284 } |
280 if (clip_area == new_clip) return; | 291 if (clip_area == new_clip) return; |
281 clip_area = new_clip; | 292 clip_area = new_clip; |
282 attr = Attribute(attr | UPDATE_CLIP); | 293 attr = Attribute(attr | UPDATE_CLIP); |
283 return; | 294 return; |
284 } | 295 } |
296 | |
285 PicBase* GrpObj::DeletePic(void) { | 297 PicBase* GrpObj::DeletePic(void) { |
286 PicBase* p = picture; | 298 PicBase* p = picture; |
287 anm = 0; | 299 anm = 0; |
288 picture = 0; | 300 picture = 0; |
289 src_pos.clear(); | 301 src_pos.clear(); |
290 attr = Attribute(attr & (HIDDEN | HIDDEN_GROUP)); | 302 attr = Attribute(attr & (HIDDEN | HIDDEN_GROUP)); |
291 return p; | 303 return p; |
292 } | 304 } |
305 | |
293 void GrpObj::GetSrcGeom(int& width, int& height) { | 306 void GrpObj::GetSrcGeom(int& width, int& height) { |
294 if (src_pos.empty()) { | 307 if (src_pos.empty()) { |
295 width = 0; height = 0; | 308 width = 0; height = 0; |
296 if (name.length() == 0) { | 309 if (name.length() == 0) { |
297 return; | 310 return; |
299 /* ボタンの位置情報を求める */ | 312 /* ボタンの位置情報を求める */ |
300 /* g00 ファイルのヘッダ部分に位置情報は入っている */ | 313 /* g00 ファイルのヘッダ部分に位置情報は入っている */ |
301 string path(name); | 314 string path(name); |
302 path += ".g00"; | 315 path += ".g00"; |
303 ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, path.c_str(), "g00"); | 316 ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, path.c_str(), "g00"); |
304 if (info == 0) { // ファイルが見つからない | 317 if (info == NULL) { // ファイルが見つからない |
305 fprintf(stderr,"GrpObj::GetSrcGeom : Cannot find file %s\n", path.c_str()); | 318 fprintf(stderr, "GrpObj::GetSrcGeom : Cannot find file %s\n", path.c_str()); |
306 return; | 319 return; |
307 } | 320 } |
308 const char* data = info->Read(); | 321 const char* data = info->Read(); |
309 if (data && *data == 2) { // 画像ファイル内にボタン情報が存在する | 322 if (data != NULL && *data == 2) { // 画像ファイル内にボタン情報が存在する |
310 int srclen = read_little_endian_int(data+5); | 323 int srclen = read_little_endian_int(data+5); |
311 int i; | 324 int i; |
312 for (i=0; i<srclen; i++) { | 325 for (i=0; i<srclen; i++) { |
313 int x1 = read_little_endian_int(data+9+i*24+0); | 326 int x1 = read_little_endian_int(data+9+i*24+0); |
314 int y1 = read_little_endian_int(data+9+i*24+4); | 327 int y1 = read_little_endian_int(data+9+i*24+4); |
329 if (sn < 0 || sn > src_pos.size()) sn = 0; | 342 if (sn < 0 || sn > src_pos.size()) sn = 0; |
330 width = src_pos[sn].width(); | 343 width = src_pos[sn].width(); |
331 height = src_pos[sn].height(); | 344 height = src_pos[sn].height(); |
332 return; | 345 return; |
333 } | 346 } |
347 | |
334 void GrpObj::Update(void) { | 348 void GrpObj::Update(void) { |
335 if (attr & UPDATE_PICTURE) { | 349 if (attr & UPDATE_PICTURE) { |
336 UpdateSurface(); | 350 UpdateSurface(); |
337 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE)); | 351 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE)); |
338 } | 352 } |
374 attr = Attribute(attr | ANM_PLAYING); | 388 attr = Attribute(attr | ANM_PLAYING); |
375 } | 389 } |
376 attr = Attribute(attr & (~ANM_PLAYSTART)); | 390 attr = Attribute(attr & (~ANM_PLAYSTART)); |
377 } | 391 } |
378 } | 392 } |
393 | |
379 void GrpObj::CreateSurface(PicContainer* parent) { | 394 void GrpObj::CreateSurface(PicContainer* parent) { |
380 if (picture) { | 395 if (picture != NULL) { |
381 PicBase* p = DeletePic(); | 396 PicBase* p = DeletePic(); |
382 delete p; | 397 delete p; |
383 } | 398 } |
384 src_pos.clear(); | 399 src_pos.clear(); |
385 // picture を作成 | 400 // picture を作成 |
388 picture->hide(); | 403 picture->hide(); |
389 UpdateSurface(); | 404 UpdateSurface(); |
390 } | 405 } |
391 | 406 |
392 void GrpObj::UpdateSurface(void) { | 407 void GrpObj::UpdateSurface(void) { |
393 if (pic_parent == 0 || picture == 0) return; | 408 if (pic_parent == NULL || picture == NULL) return; |
394 int width = 0, height = 0; | 409 int width = 0, height = 0; |
395 if (gtype == FILE || gtype == GAN) { | 410 if (gtype == FILE || gtype == GAN) { |
396 if (name.length() == 0) return; | 411 if (name.length() == 0) return; |
397 // ファイル名が存在する場合、ファイルを読み込み | 412 // ファイル名が存在する場合、ファイルを読み込み |
398 GetSrcGeom(width, height); | 413 GetSrcGeom(width, height); |
414 UpdateMoji(); | 429 UpdateMoji(); |
415 } else if (gtype == DIGIT) { // 数値を画像表示 | 430 } else if (gtype == DIGIT) { // 数値を画像表示 |
416 UpdateDigit(); | 431 UpdateDigit(); |
417 } | 432 } |
418 } | 433 } |
434 | |
419 void GrpObj::ZoomRotate(void) { | 435 void GrpObj::ZoomRotate(void) { |
420 picture->SetSurface( (Surface*)0,0,0); | 436 picture->SetSurface( (Surface*)0, 0, 0); |
421 | 437 |
422 // 回転、縮小拡大は座標原点が画像の中心になる | 438 // 回転、縮小拡大は座標原点が画像の中心になる |
423 string path(name); | 439 string path(name); |
424 path += ".g00"; | 440 path += ".g00"; |
425 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); | 441 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); |
426 if (surface_orig == 0) return; | 442 if (surface_orig == NULL) return; |
427 | 443 |
428 Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate); | 444 Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate); |
429 Rect zoom_r (*zoom_surface); | 445 Rect zoom_r (*zoom_surface); |
430 picture->SetSurface(zoom_surface, 0, 0); | 446 picture->SetSurface(zoom_surface, 0, 0); |
431 picture->SetSurfaceFreeFlag(); | 447 picture->SetSurfaceFreeFlag(); |
448 ws = 1; | 464 ws = 1; |
449 } | 465 } |
450 if (wc == chr) return (char*)s; | 466 if (wc == chr) return (char*)s; |
451 s += ws; | 467 s += ws; |
452 } | 468 } |
453 return 0; | 469 return NULL; |
454 } | 470 } |
471 | |
472 //TODO: See why it does nothing with font/text_stream.cc:98 | |
455 TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse | 473 TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse |
456 TextStream ts; | 474 TextStream ts; |
457 ts.kanji_type = TextStream::sjis; | 475 ts.kanji_type = TextStream::sjis; |
458 ts.SetColor(def_r, def_g, def_b); | 476 ts.SetColor(def_r, def_g, def_b); |
459 char* copy_str = new char[strlen(str)+1]; | 477 char* copy_str = new char[strlen(str)+1]; |
460 char* next_str; | 478 char* next_str; |
461 char* retptr; | 479 char* retptr; |
462 int var; | 480 int var; |
463 | 481 |
464 while( (next_str = wstrchr(str, '#')) != 0) { | 482 while( (next_str = wstrchr(str, '#')) != NULL) { |
465 int len = next_str - str; | 483 int len = next_str - str; |
466 strncpy(copy_str, str, len); | 484 strncpy(copy_str, str, len); |
467 copy_str[len] = 0; | 485 copy_str[len] = 0; |
468 ts.Add(copy_str); | 486 ts.Add(copy_str); |
469 str = next_str + 1; | 487 str = next_str + 1; |
485 int r,g,b; char key[1024]; | 503 int r,g,b; char key[1024]; |
486 sprintf(key, "#COLOR_TABLE.%03d", var); | 504 sprintf(key, "#COLOR_TABLE.%03d", var); |
487 if (parent_pimpl->config.GetParam(key, 3, &r, &g, &b)) { // color not found | 505 if (parent_pimpl->config.GetParam(key, 3, &r, &g, &b)) { // color not found |
488 r = g = b = 0; | 506 r = g = b = 0; |
489 } | 507 } |
490 ts.SetColor(r,g,b); | 508 ts.SetColor(r, g, b); |
491 str = next_str; | 509 str = next_str; |
492 } | 510 } |
493 break; | 511 break; |
494 case 'S': case 's': // size | 512 case 'S': case 's': // size |
495 str += 1; | 513 str += 1; |
511 } | 529 } |
512 ts.Add(str); | 530 ts.Add(str); |
513 delete[] copy_str; | 531 delete[] copy_str; |
514 return ts; | 532 return ts; |
515 } | 533 } |
534 | |
516 void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更 | 535 void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更 |
517 if (print_moji.length() == 0 || print_size <= 2) return; | 536 if (print_moji.length() == 0 || print_size <= 2) return; |
518 if (pic_parent == 0) return; | 537 if (pic_parent == 0) return; |
519 /* テキストの大きさを得る */ | 538 /* テキストの大きさを得る */ |
520 int r, g, b; | 539 int r, g, b; |
537 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0, 0, width, height), surface, Rect(0,0)); | 556 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0, 0, width, height), surface, Rect(0,0)); |
538 picture->SetSurface(surface, 0, 0); | 557 picture->SetSurface(surface, 0, 0); |
539 picture->SetSurfaceRect(Rect(0,0,width,height)); | 558 picture->SetSurfaceRect(Rect(0,0,width,height)); |
540 picture->SetSurfaceFreeFlag(); | 559 picture->SetSurfaceFreeFlag(); |
541 } | 560 } |
561 | |
542 void GrpObj::UpdateDigit(void) { | 562 void GrpObj::UpdateDigit(void) { |
543 // 画像表示の数値文字列を表示する | 563 // 画像表示の数値文字列を表示する |
544 if (name.length() == 0) return; | 564 if (name.length() == 0) return; |
545 // ファイル名が存在する場合、ファイルを読み込み | 565 // ファイル名が存在する場合、ファイルを読み込み |
546 string path(name); | 566 string path(name); |
547 path += ".g00"; | 567 path += ".g00"; |
548 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); | 568 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); |
549 if (surface_orig == 0) return; | 569 if (surface_orig == NULL) return; |
550 | 570 |
551 int width, height; | 571 int width, height; |
552 int i; | 572 int i; |
553 GetSrcGeom(width, height); | 573 GetSrcGeom(width, height); |
554 if (width <= 0 || height <= 0) return; | 574 if (width <= 0 || height <= 0) return; |
610 picture->SetSurfaceRect(Rect(0,0,width*total_count,height)); | 630 picture->SetSurfaceRect(Rect(0,0,width*total_count,height)); |
611 picture->SetSurfaceFreeFlag(); | 631 picture->SetSurfaceFreeFlag(); |
612 | 632 |
613 pic_parent->Root().DeleteSurface(surface_orig); | 633 pic_parent->Root().DeleteSurface(surface_orig); |
614 } | 634 } |
635 | |
615 void GrpObj::CreateGan(Event::Container& event, int event_number) { | 636 void GrpObj::CreateGan(Event::Container& event, int event_number) { |
616 if (picture == 0) { | 637 if (picture == NULL) { |
617 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); | 638 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); |
618 return; | 639 return; |
619 } | 640 } |
620 if (anm) { | 641 if (anm) { |
621 anm->Abort(); | 642 anm->Abort(); |
624 if (gan_name.empty()) return; | 645 if (gan_name.empty()) return; |
625 /* アニーメション情報 (.GAN ファイル)を求める */ | 646 /* アニーメション情報 (.GAN ファイル)を求める */ |
626 string path(gan_name); | 647 string path(gan_name); |
627 path += ".gan"; | 648 path += ".gan"; |
628 ARCINFO* info = file_searcher.Find(FILESEARCH::GAN, path.c_str(), "gan"); | 649 ARCINFO* info = file_searcher.Find(FILESEARCH::GAN, path.c_str(), "gan"); |
629 if (info == 0) { | 650 if (info == NULL) { |
630 fprintf(stderr,"GrpObj::CreateGan: Cannot Find 'GAN' file %s\n", path.c_str()); | 651 fprintf(stderr,"GrpObj::CreateGan: Cannot Find 'GAN' file %s\n", path.c_str()); |
631 return; | 652 return; |
632 } | 653 } |
633 const char* data = info->Read(); | 654 const char* data = info->Read(); |
634 if (read_little_endian_int(data) != 10000 || read_little_endian_int(data+4) != 10000) { | 655 if (read_little_endian_int(data) != 10000 || read_little_endian_int(data+4) != 10000) { |
676 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), src_pos[p], a, total_time)); | 697 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), src_pos[p], a, total_time)); |
677 } | 698 } |
678 wid->SetPtn(); // パターン登録終了 | 699 wid->SetPtn(); // パターン登録終了 |
679 attr = Attribute(attr | ANM_PLAYSTART); | 700 attr = Attribute(attr | ANM_PLAYSTART); |
680 anm = wid; | 701 anm = wid; |
681 }; | 702 } |
703 | |
682 void GrpObj::CreateGanSpecial(Event::Container& event, int event_number, int time) { | 704 void GrpObj::CreateGanSpecial(Event::Container& event, int event_number, int time) { |
683 if (picture == 0) { | 705 if (picture == NULL) { |
684 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); | 706 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); |
685 return; | 707 return; |
686 } | 708 } |
687 if (anm) { | 709 if (anm) { |
688 anm->Abort(); | 710 anm->Abort(); |
692 // アニメーションを行う実体を作成 | 714 // アニメーションを行う実体を作成 |
693 AnmAlphaMove* wid = new AnmAlphaMove(event, picture); | 715 AnmAlphaMove* wid = new AnmAlphaMove(event, picture); |
694 | 716 |
695 int i; | 717 int i; |
696 switch(event_number) { | 718 switch(event_number) { |
697 case 0: // pattern を 0 から最後まで変化させる | 719 case 0: // pattern を 0 から最後まで変化させる |
698 for (i=0; i<src_pos.size(); i++) { | 720 for (i=0; i<src_pos.size(); i++) { |
699 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(PosX(), PosY()), src_pos[i], 255, time*i)); | 721 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(PosX(), PosY()), src_pos[i], 255, time*i)); |
700 } | 722 } |
701 wid->SetPtn(); // パターン登録終了 | 723 wid->SetPtn(); // パターン登録終了 |
702 anm = wid; | 724 anm = wid; |
703 attr = Attribute(attr | ANM_PLAYSTART); | 725 attr = Attribute(attr | ANM_PLAYSTART); |
704 break; | 726 break; |
705 default: | 727 default: |
706 break; | 728 break; |
707 } | 729 } |
708 return; | 730 } |
709 }; | |
710 | 731 |
711 void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) { | 732 void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) { |
712 if (zoom == new_zoom && rotate == new_rotate) return; | 733 if (zoom == new_zoom && rotate == new_rotate) return; |
713 if ( zoom == -1 || new_zoom == -1) { | 734 if ( zoom == -1 || new_zoom == -1) { |
714 attr = Attribute(attr | UPDATE_POS); // centering する | 735 attr = Attribute(attr | UPDATE_POS); // centering する |
718 if (zoom < 0) zoom = 256; | 739 if (zoom < 0) zoom = 256; |
719 if (rotate < 0) rotate = 0; | 740 if (rotate < 0) rotate = 0; |
720 else if (rotate > 360) rotate %= 360; | 741 else if (rotate > 360) rotate %= 360; |
721 | 742 |
722 attr = Attribute(attr | UPDATE_PICTURE); | 743 attr = Attribute(attr | UPDATE_PICTURE); |
723 return; | |
724 } | 744 } |
725 /****************************************************************** | 745 /****************************************************************** |
726 ** | 746 ** |
727 ** class ScnGrp* | 747 ** class ScnGrp* |
728 */ | 748 */ |
744 if (dy < 0) dy = -dy; | 764 if (dy < 0) dy = -dy; |
745 if (dx < dy) dx = dy; | 765 if (dx < dy) dx = dy; |
746 if (dx == 0) dx = 1; | 766 if (dx == 0) dx = 1; |
747 SetAllCount(dx); | 767 SetAllCount(dx); |
748 } | 768 } |
769 | |
749 void ScnGrpMove::Exec(int count) { | 770 void ScnGrpMove::Exec(int count) { |
750 Rect r(0,0,dest_r.width(),dest_r.height()); | 771 Rect r(0,0,dest_r.width(),dest_r.height()); |
751 int dx = to.lx - from.lx; | 772 int dx = to.lx - from.lx; |
752 int dy = to.ty - from.ty; | 773 int dy = to.ty - from.ty; |
753 int x = dx*count/all_count + from.lx; | 774 int x = dx*count/all_count + from.lx; |
764 struct ScnGrpAnmAtom { | 785 struct ScnGrpAnmAtom { |
765 string name; | 786 string name; |
766 int time; | 787 int time; |
767 ScnGrpAnmAtom(const char* _n, int _t) : name(_n), time(_t) {} | 788 ScnGrpAnmAtom(const char* _n, int _t) : name(_n), time(_t) {} |
768 }; | 789 }; |
790 | |
769 struct ScnGrpAnm : public WidAnmTime, vector<ScnGrpAnmAtom> { | 791 struct ScnGrpAnm : public WidAnmTime, vector<ScnGrpAnmAtom> { |
770 GrpImpl& owner; | 792 GrpImpl& owner; |
771 ScnGrpAnm(Event::Container& container, PicBase* _pic, GrpImpl& _owner) : | 793 ScnGrpAnm(Event::Container& container, PicBase* _pic, GrpImpl& _owner) : |
772 WidAnmTime(container, _pic, 0), owner(_owner) { | 794 WidAnmTime(container, _pic, 0), owner(_owner) { |
773 } | 795 } |
774 void CalcTotal(void); | 796 void CalcTotal(void); |
775 void Exec(int count); | 797 void Exec(int count); |
776 }; | 798 }; |
799 | |
777 void ScnGrpAnm::CalcTotal(void) { | 800 void ScnGrpAnm::CalcTotal(void) { |
778 /* total time を計算 */ | 801 /* total time を計算 */ |
779 if (empty()) return; | 802 if (empty()) return; |
780 int tm = 0; | 803 int tm = 0; |
781 vector<ScnGrpAnmAtom>::iterator it; | 804 vector<ScnGrpAnmAtom>::iterator it; |
782 for (it=begin(); it != end(); it++) tm += it->time; | 805 for (it=begin(); it != end(); it++) tm += it->time; |
783 total_time = tm; | 806 total_time = tm; |
784 SetAllCount(tm); | 807 SetAllCount(tm); |
785 } | 808 } |
809 | |
786 void ScnGrpAnm::Exec(int count) { | 810 void ScnGrpAnm::Exec(int count) { |
787 int tm = 0; vector<ScnGrpAnmAtom>::iterator it; | 811 int tm = 0; vector<ScnGrpAnmAtom>::iterator it; |
788 for (it=begin(); it != end(); it++) { | 812 for (it=begin(); it != end(); it++) { |
789 tm += it->time; | 813 tm += it->time; |
790 if (count < tm) break; | 814 if (count < tm) break; |
798 * | 822 * |
799 * GrpImpl(implementation) : 定義 | 823 * GrpImpl(implementation) : 定義 |
800 * | 824 * |
801 */ | 825 */ |
802 | 826 |
803 #include"music2/music.h" | 827 #include "music2/music.h" |
804 | 828 |
805 GrpImpl::GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm_data, class MuSys& _mu, AyuSysConfig& _config) : | 829 GrpImpl::GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm_data, class MuSys& _mu, AyuSysConfig& _config) : |
806 event(_event), | 830 event(_event), |
807 flags(f), | 831 flags(f), |
808 parent(_parent), | 832 parent(_parent), |
867 parent.Root().DeleteSurface(ssurface[pdt]); | 891 parent.Root().DeleteSurface(ssurface[pdt]); |
868 ssurface[pdt] = 0; | 892 ssurface[pdt] = 0; |
869 } | 893 } |
870 return dsurface[pdt]; | 894 return dsurface[pdt]; |
871 } | 895 } |
872 #include<SDL.h> | 896 |
897 #include <SDL.h> | |
873 Surface* GrpImpl::Ssurface(int pdt) { | 898 Surface* GrpImpl::Ssurface(int pdt) { |
874 if (pdt == 0) return surface; | 899 if (pdt == 0) return surface; |
875 if (ssurface[pdt]) { | 900 if (ssurface[pdt]) { |
876 return ssurface[pdt]; | 901 return ssurface[pdt]; |
877 } | 902 } |
882 string s = str; | 907 string s = str; |
883 if (cgm_info.find(s) != cgm_info.end()) { | 908 if (cgm_info.find(s) != cgm_info.end()) { |
884 cgm_data.insert(cgm_info[s]); | 909 cgm_data.insert(cgm_info[s]); |
885 } | 910 } |
886 Surface* bg = parent.Root().NewSurface(s.c_str()); | 911 Surface* bg = parent.Root().NewSurface(s.c_str()); |
887 if (bg == 0) { | 912 if (bg == NULL) { |
888 s += ".g00"; | 913 s += ".g00"; |
889 bg = parent.Root().NewSurface(s.c_str()); | 914 bg = parent.Root().NewSurface(s.c_str()); |
890 } | 915 } |
891 if (bg) { | 916 if (bg) { |
892 if (ssurface[pdt]) parent.Root().DeleteSurface(ssurface[pdt]); | 917 if (ssurface[pdt]) parent.Root().DeleteSurface(ssurface[pdt]); |
897 Rect dr(*surface); | 922 Rect dr(*surface); |
898 int x = (dr.width()-r.width())/2; | 923 int x = (dr.width()-r.width())/2; |
899 int y = (dr.height()-r.height())/2; | 924 int y = (dr.height()-r.height())/2; |
900 DSurfaceMove(ssurface[0], r, surface, Rect(x,y)); | 925 DSurfaceMove(ssurface[0], r, surface, Rect(x,y)); |
901 parent.Root().DeleteSurface(ssurface[0]); | 926 parent.Root().DeleteSurface(ssurface[0]); |
902 ssurface[0] = 0; | 927 ssurface[0] = NULL; |
903 screen->SetSurface(surface, 0, 0); | 928 screen->SetSurface(surface, 0, 0); |
904 } | 929 } |
905 } else { | 930 } else { |
906 if (str[0] != 0) | 931 if (str[0] != 0) |
907 fprintf(stderr,"Cannot find surface %d <- '%s'\n",pdt,str); | 932 fprintf(stderr,"Cannot find surface %d <- '%s'\n",pdt,str); |
908 } | 933 } |
909 return; | 934 return; |
910 } | 935 } |
936 | |
911 void GrpImpl::InitSel(AyuSysConfig& config) { | 937 void GrpImpl::InitSel(AyuSysConfig& config) { |
912 int i; int args[16]; char key[1024]; | 938 int i; |
939 int args[16]; | |
940 char key[1024]; | |
913 for (i=0; i<999; i++) { | 941 for (i=0; i<999; i++) { |
914 sprintf(key, "#SEL.%03d",i); | 942 sprintf(key, "#SEL.%03d",i); |
915 if (config.GetParam(key, 15, &args[0], &args[1], | 943 if (config.GetParam(key, 15, &args[0], &args[1], |
916 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], | 944 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], |
917 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13], | 945 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13], |
928 s.to = Rect(args[4], args[5]); | 956 s.to = Rect(args[4], args[5]); |
929 s.time = args[6]; | 957 s.time = args[6]; |
930 s.sel_no = args[7]; | 958 s.sel_no = args[7]; |
931 int j; for (j=0; j<8; j++) s.args[j] = args[8+j]; | 959 int j; for (j=0; j<8; j++) s.args[j] = args[8+j]; |
932 } | 960 } |
933 return; | 961 } |
934 } | 962 |
935 void GrpImpl::SetSkipMode(SkipMode _mode) { | 963 void GrpImpl::SetSkipMode(SkipMode _mode) { |
936 if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) { | 964 if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) { |
937 RefreshObj(); | 965 RefreshObj(); |
938 } else if ( (skip_mode & SKIP_IN_MENU) == 0 && (_mode & SKIP_IN_MENU) ) { | 966 } else if ( (skip_mode & SKIP_IN_MENU) == 0 && (_mode & SKIP_IN_MENU) ) { |
939 } | 967 } |
940 skip_mode = _mode; | 968 skip_mode = _mode; |
941 } | 969 } |
970 | |
942 void GrpImpl::SetObjChanged(int num) { | 971 void GrpImpl::SetObjChanged(int num) { |
943 changed_obj.insert(num); | 972 changed_obj.insert(num); |
944 } | 973 } |
974 | |
945 void GrpImpl::SetObjChangedGroup(int num) { | 975 void GrpImpl::SetObjChangedGroup(int num) { |
946 if (num % 1000 != 0) { | 976 if (num % 1000 != 0) { |
947 SetObjChanged(num); | 977 SetObjChanged(num); |
948 return; | 978 return; |
949 } | 979 } |
952 end = grpobj.lower_bound(num+1000); | 982 end = grpobj.lower_bound(num+1000); |
953 for (it=begin;it!=end;it++) { | 983 for (it=begin;it!=end;it++) { |
954 changed_obj.insert(it->first); | 984 changed_obj.insert(it->first); |
955 } | 985 } |
956 } | 986 } |
987 | |
957 void GrpImpl::RefreshObj(void) { | 988 void GrpImpl::RefreshObj(void) { |
958 if (!deleted_pic.empty()) { | 989 if (!deleted_pic.empty()) { |
959 vector<PicBase*>::iterator it; | 990 vector<PicBase*>::iterator it; |
960 for (it=deleted_pic.begin(); it!=deleted_pic.end(); it++) { | 991 for (it=deleted_pic.begin(); it!=deleted_pic.end(); it++) { |
961 if (*it) delete *it; | 992 if (*it) delete *it; |
988 } | 1019 } |
989 screen->ReBlit(); | 1020 screen->ReBlit(); |
990 } | 1021 } |
991 | 1022 |
992 | 1023 |
993 #include<SDL.h> | 1024 #include <SDL.h> |
994 void GrpImpl::StartAnm(int type) { | 1025 void GrpImpl::StartAnm(int type) { |
995 SEL sel; | 1026 SEL sel; |
996 | 1027 |
997 if (anmtype.find(type) == anmtype.end()) { | 1028 if (anmtype.find(type) == anmtype.end()) { |
998 if (anmtype.find(0) == anmtype.end()) { | 1029 if (anmtype.find(0) == anmtype.end()) { |
1004 sel = anmtype[0]; | 1035 sel = anmtype[0]; |
1005 } | 1036 } |
1006 } else { | 1037 } else { |
1007 sel = anmtype[type]; | 1038 sel = anmtype[type]; |
1008 } | 1039 } |
1009 if (anm1) { | 1040 if (anm1 != NULL) { |
1010 fprintf(stderr,"Warning: StartAnm() called before anm1 finished\n"); | 1041 fprintf(stderr,"Warning: StartAnm() called before anm1 finished\n"); |
1011 anm1->Abort(); | 1042 anm1->Abort(); |
1012 delete anm1; | 1043 delete anm1; |
1013 anm1 = 0; | 1044 anm1 = NULL; |
1014 } | 1045 } |
1015 map<int,GrpObj>::iterator it; | 1046 map<int,GrpObj>::iterator it; |
1016 // 現在表示中のobjectを消去 | 1047 // 現在表示中のobjectを消去 |
1017 deleted_pic.push_back(screen); | 1048 deleted_pic.push_back(screen); |
1018 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | 1049 for (it=grpobj.begin(); it!=grpobj.end(); it++) { |
1071 break; | 1102 break; |
1072 } | 1103 } |
1073 if (anm1) anm1->Play(); | 1104 if (anm1) anm1->Play(); |
1074 if (skip_mode & SKIP_GRP_NOEFFEC) AbortAnm(); | 1105 if (skip_mode & SKIP_GRP_NOEFFEC) AbortAnm(); |
1075 } | 1106 } |
1107 | |
1076 void GrpImpl::StartShake(int total, const int* pattern) { | 1108 void GrpImpl::StartShake(int total, const int* pattern) { |
1077 if (anm2) { | 1109 if (anm2) { |
1078 fprintf(stderr,"Warning: StartShake() called before another animation finished\n"); | 1110 fprintf(stderr,"Warning: StartShake() called before another animation finished\n"); |
1079 anm2->Abort(); | 1111 anm2->Abort(); |
1080 delete anm2; | 1112 delete anm2; |
1081 anm2 = 0; | 1113 anm2 = NULL; |
1082 } | 1114 } |
1083 if (skip_mode & SKIP_GRP_NOEFFEC) return; | 1115 if (skip_mode & SKIP_GRP_NOEFFEC) return; |
1084 AnmAlphaMove* new_anm = new AnmAlphaMove(event, &parent); // shake screen では元画面の座標を揺らす | 1116 AnmAlphaMove* new_anm = new AnmAlphaMove(event, &parent); // shake screen では元画面の座標を揺らす |
1085 int i; int tm = 0; | 1117 int i; |
1118 int tm = 0; | |
1086 for (i=0; i<total; i+=3) { | 1119 for (i=0; i<total; i+=3) { |
1087 int x = pattern[i]; | 1120 int x = pattern[i]; |
1088 int y = pattern[i+1]; | 1121 int y = pattern[i+1]; |
1089 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), Rect(0,0), 255, tm)); | 1122 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), Rect(0,0), 255, tm)); |
1090 tm += pattern[i+2]; | 1123 tm += pattern[i+2]; |
1092 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(0,0), Rect(0,0), 255, tm)); | 1125 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(0,0), Rect(0,0), 255, tm)); |
1093 new_anm->SetPtn(); // パターン登録終了 | 1126 new_anm->SetPtn(); // パターン登録終了 |
1094 new_anm->Play(); | 1127 new_anm->Play(); |
1095 anm2 = new_anm; | 1128 anm2 = new_anm; |
1096 } | 1129 } |
1130 | |
1097 void GrpImpl::AbortAnm(void) { | 1131 void GrpImpl::AbortAnm(void) { |
1098 if (anm1 == 0) return; | 1132 if (anm1 == NULL) return; |
1099 anm1->Abort(); | 1133 anm1->Abort(); |
1100 delete anm1; | 1134 delete anm1; |
1101 anm1 = 0; | 1135 anm1 = NULL; |
1102 /* 画像効果終了 */ | 1136 /* 画像効果終了 */ |
1103 /* 古い画面への画像効果があれば消去 */ | 1137 /* 古い画面への画像効果があれば消去 */ |
1104 if (anm2 && anm2->pic[0] != screen) { | 1138 if (anm2 && anm2->pic[0] != screen) { |
1105 anm2->Abort(); | 1139 anm2->Abort(); |
1106 delete anm2; | 1140 delete anm2; |
1107 anm2 = 0; | 1141 anm2 = NULL; |
1108 } | 1142 } |
1109 /* pdt1 -> pdt0 へコピー */ | 1143 /* pdt1 -> pdt0 へコピー */ |
1110 DSurfaceMove(dsurface[1], Rect(*dsurface[1]), surface, Rect(0,0)); | 1144 DSurfaceMove(dsurface[1], Rect(*dsurface[1]), surface, Rect(0,0)); |
1111 screen->SetSurface(surface, 0, 0); | 1145 screen->SetSurface(surface, 0, 0); |
1112 // 画像効果開始時に存在したobjectを消去 | 1146 // 画像効果開始時に存在したobjectを消去 |
1113 // 新しい object 表示 | 1147 // 新しい object 表示 |
1114 RefreshObj(); | 1148 RefreshObj(); |
1115 return; | 1149 return; |
1116 } | 1150 } |
1151 | |
1117 void GrpImpl::LoadSurface(const char* str) { | 1152 void GrpImpl::LoadSurface(const char* str) { |
1118 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | 1153 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 |
1119 LoadSurface(str, 1); | 1154 LoadSurface(str, 1); |
1120 bg_name = str; | 1155 bg_name = str; |
1121 } | 1156 } |
1157 | |
1122 void GrpImpl::LoadSurface(void) { | 1158 void GrpImpl::LoadSurface(void) { |
1123 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | 1159 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 |
1124 LoadSurface(bg_name.c_str(), 1); | 1160 LoadSurface(bg_name.c_str(), 1); |
1125 } | 1161 } |
1162 | |
1126 void GrpImpl::AddSurface(const char* str) { | 1163 void GrpImpl::AddSurface(const char* str) { |
1127 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 | 1164 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 |
1128 LoadSurface(bg_name.c_str()); | 1165 LoadSurface(bg_name.c_str()); |
1129 | 1166 |
1130 string s = str; | 1167 string s = str; |
1131 Surface* front = parent.Root().NewSurface(s.c_str()); | 1168 Surface* front = parent.Root().NewSurface(s.c_str()); |
1132 if (front == 0) { | 1169 if (front == NULL) { |
1133 s += ".g00"; | 1170 s += ".g00"; |
1134 front = parent.Root().NewSurface(s.c_str()); | 1171 front = parent.Root().NewSurface(s.c_str()); |
1135 } | 1172 } |
1136 if (front) { | 1173 if (front != NULL) { |
1137 parent.Root().BlitSurface(front, Rect(*front), Dsurface(1), Rect(0,0)); | 1174 parent.Root().BlitSurface(front, Rect(*front), Dsurface(1), Rect(0,0)); |
1138 parent.Root().DeleteSurface(front); | 1175 parent.Root().DeleteSurface(front); |
1139 } else { | 1176 } else { |
1140 fprintf(stderr,"Cannot find surface %s\n",str); | 1177 fprintf(stderr,"Cannot find surface %s\n",str); |
1141 } | 1178 } |
1145 std::map<int, GrpObj>::iterator cur = grpobj.find(index); | 1182 std::map<int, GrpObj>::iterator cur = grpobj.find(index); |
1146 if (cur == grpobj.end()) return; | 1183 if (cur == grpobj.end()) return; |
1147 GrpObj& g = grpobj[index]; | 1184 GrpObj& g = grpobj[index]; |
1148 g.CreateSurface(&parent); | 1185 g.CreateSurface(&parent); |
1149 g.order = index; | 1186 g.order = index; |
1150 if (g.picture == 0) return; // エラー:surface が存在しない | 1187 if (g.picture == NULL) return; // エラー:surface が存在しない |
1151 g.picture->hide(); | 1188 g.picture->hide(); |
1152 SetObjChanged(index); | 1189 SetObjChanged(index); |
1153 ZMoveObj(index); | 1190 ZMoveObj(index); |
1154 return; | 1191 } |
1155 } | 1192 |
1156 void GrpImpl::ZMoveObj(int index) { | 1193 void GrpImpl::ZMoveObj(int index) { |
1157 std::map<int, GrpObj>::iterator cur = grpobj.find(index); | 1194 std::map<int, GrpObj>::iterator cur = grpobj.find(index); |
1158 if (cur == grpobj.end()) return; | 1195 if (cur == grpobj.end()) return; |
1159 GrpObj& g = grpobj[index]; | 1196 GrpObj& g = grpobj[index]; |
1160 if (g.picture == 0) return; | 1197 if (g.picture == NULL) return; |
1161 // 自分より前に object があれば、その前に表示 | 1198 // 自分より前に object があれば、その前に表示 |
1162 // そうでなければ screen の前に表示 | 1199 // そうでなければ screen の前に表示 |
1163 std::map<int, GrpObj>::iterator cur_backobj = grpobj.end(); | 1200 std::map<int, GrpObj>::iterator cur_backobj = grpobj.end(); |
1164 std::map<int, GrpObj>::iterator it; | 1201 std::map<int, GrpObj>::iterator it; |
1165 for (it = grpobj.begin(); it != grpobj.end(); it++) { | 1202 for (it = grpobj.begin(); it != grpobj.end(); it++) { |
1166 if (it == cur) continue; | 1203 if (it == cur) continue; |
1167 if (it->second.picture == 0) continue; | 1204 if (it->second.picture == NULL) continue; |
1168 if (it->second.order < g.order) { | 1205 if (it->second.order < g.order) { |
1169 if (cur_backobj == grpobj.end()) { | 1206 if (cur_backobj == grpobj.end()) { |
1170 cur_backobj = it; | 1207 cur_backobj = it; |
1171 } else if (cur_backobj->second.order < it->second.order) { | 1208 } else if (cur_backobj->second.order < it->second.order) { |
1172 cur_backobj = it; | 1209 cur_backobj = it; |
1176 if (cur_backobj == grpobj.end()) { | 1213 if (cur_backobj == grpobj.end()) { |
1177 g.picture->ZMove(screen); | 1214 g.picture->ZMove(screen); |
1178 } else { | 1215 } else { |
1179 g.picture->ZMove(cur_backobj->second.picture); | 1216 g.picture->ZMove(cur_backobj->second.picture); |
1180 } | 1217 } |
1181 return; | 1218 } |
1182 } | 1219 |
1183 void GrpImpl::SwapObj(int index1, int index2) { | 1220 void GrpImpl::SwapObj(int index1, int index2) { |
1184 // デフォルト値から order が変更されていた場合のみ、order は保存される | 1221 // デフォルト値から order が変更されていた場合のみ、order は保存される |
1185 // まずは両方のobjectをswap | 1222 // まずは両方のobjectをswap |
1186 if (grpobj.find(index1) == grpobj.end()) { | 1223 if (grpobj.find(index1) == grpobj.end()) { |
1187 if (grpobj.find(index2) == grpobj.end()) return; // どちらの object も存在しない | 1224 if (grpobj.find(index2) == grpobj.end()) return; // どちらの object も存在しない |
1219 GrpImpl* g = (GrpImpl*)pointer; | 1256 GrpImpl* g = (GrpImpl*)pointer; |
1220 if (g->status == WAIT_MOVIE) | 1257 if (g->status == WAIT_MOVIE) |
1221 g->music.StopMovie(); | 1258 g->music.StopMovie(); |
1222 if (g->status == WAIT_ANM) | 1259 if (g->status == WAIT_ANM) |
1223 g->AbortAnm(); | 1260 g->AbortAnm(); |
1224 if (g->status == WAIT_SHAKE && g->anm2 != 0) { | 1261 if (g->status == WAIT_SHAKE && g->anm2 != NULL) { |
1225 g->anm2->Abort(); | 1262 g->anm2->Abort(); |
1226 delete g->anm2; | 1263 delete g->anm2; |
1227 g->anm2 = 0; | 1264 g->anm2 = NULL; |
1228 } | 1265 } |
1229 return false; // event deleted | 1266 return false; // event deleted |
1230 } | 1267 } |
1231 | 1268 |
1232 /* mode.cgm の decode 用 */ | 1269 /* mode.cgm の decode 用 */ |
1266 }; | 1303 }; |
1267 | 1304 |
1268 void GrpImpl::LoadCgm(AyuSysConfig& config) { | 1305 void GrpImpl::LoadCgm(AyuSysConfig& config) { |
1269 /* cgm ファイル読み込み */ | 1306 /* cgm ファイル読み込み */ |
1270 const char* fname = config.GetParaStr("#CGTABLE_FILE"); | 1307 const char* fname = config.GetParaStr("#CGTABLE_FILE"); |
1271 if (fname == 0) return; | 1308 if (fname == NULL) return; |
1272 ARCINFO* info = file_searcher.Find(FILESEARCH::ALL, fname, ""); | 1309 ARCINFO* info = file_searcher.Find(FILESEARCH::ALL, fname, ""); |
1273 if (info == 0) return; | 1310 if (info == NULL) return; |
1274 char* data = info->CopyRead(); | 1311 char* data = info->CopyRead(); |
1275 int sz = info->Size(); | 1312 int sz = info->Size(); |
1276 delete info; | 1313 delete info; |
1277 | 1314 |
1278 | 1315 |
1280 delete[] data; | 1317 delete[] data; |
1281 return; | 1318 return; |
1282 } | 1319 } |
1283 cgm_size = read_little_endian_int(data+0x10); | 1320 cgm_size = read_little_endian_int(data+0x10); |
1284 | 1321 |
1285 int i,j; | 1322 int i, j; |
1286 // xor 解除 | 1323 // xor 解除 |
1287 for (i=0;i<sz-0x20; i++) { | 1324 for (i=0; i < sz-0x20; i++) { |
1288 data[i+0x20]^=decode_char[i&0xff]; | 1325 data[i+0x20]^=decode_char[i&0xff]; |
1289 } | 1326 } |
1290 // 展開 | 1327 // 展開 |
1291 int dest_size = cgm_size * 36; | 1328 int dest_size = cgm_size * 36; |
1292 char* dest = new char[dest_size+1024]; | 1329 char* dest = new char[dest_size+1024]; |
1308 * GrpImpl :: Save, Load : セーブファイル処理 | 1345 * GrpImpl :: Save, Load : セーブファイル処理 |
1309 * | 1346 * |
1310 */ | 1347 */ |
1311 void GrpImpl::Save(std::string& str) { | 1348 void GrpImpl::Save(std::string& str) { |
1312 } | 1349 } |
1350 | |
1313 void GrpImpl::Load(const char* str) { | 1351 void GrpImpl::Load(const char* str) { |
1314 status = NORMAL; | 1352 status = NORMAL; |
1315 if (anm1) { | 1353 if (anm1 != NULL) { |
1316 AbortAnm(); | 1354 AbortAnm(); |
1317 } | 1355 } |
1318 if (anm2) { | 1356 if (anm2 != NULL) { |
1319 anm2->Abort(); | 1357 anm2->Abort(); |
1320 delete anm2; | 1358 delete anm2; |
1321 anm2 = 0; | 1359 anm2 = NULL; |
1322 } | 1360 } |
1323 map<int,GrpObj>::iterator it; | 1361 map<int,GrpObj>::iterator it; |
1324 for (it=grpobj.begin(); it!=grpobj.end(); it++) { | 1362 for (it=grpobj.begin(); it!=grpobj.end(); it++) { |
1325 PicBase* p = it->second.DeletePic(); | 1363 PicBase* p = it->second.DeletePic(); |
1326 delete p; | 1364 delete p; |
1328 grpobj.clear(); | 1366 grpobj.clear(); |
1329 | 1367 |
1330 bg_name = ""; | 1368 bg_name = ""; |
1331 music.StopCDROM(100); | 1369 music.StopCDROM(100); |
1332 } | 1370 } |
1371 | |
1333 void GrpImpl::SaveSys(string& save) { | 1372 void GrpImpl::SaveSys(string& save) { |
1334 char buf[1024]; | 1373 char buf[1024]; |
1335 save = "\n[Graphics]\n"; | 1374 save = "\n[Graphics]\n"; |
1336 save += "CGM_CG="; | 1375 save += "CGM_CG="; |
1337 | 1376 |
1340 sprintf(buf,"%d,",*it); | 1379 sprintf(buf,"%d,",*it); |
1341 save += buf; | 1380 save += buf; |
1342 } | 1381 } |
1343 save += "\n"; | 1382 save += "\n"; |
1344 } | 1383 } |
1384 | |
1345 void GrpImpl::LoadSys(const char* save) { | 1385 void GrpImpl::LoadSys(const char* save) { |
1346 cgm_data.clear(); | 1386 cgm_data.clear(); |
1347 save = strstr(save, "\n[Graphics]\n"); | 1387 save = strstr(save, "\n[Graphics]\n"); |
1348 | 1388 |
1349 if (save) { | 1389 if (save) { |
1433 drawn_images.clear(); | 1473 drawn_images.clear(); |
1434 } | 1474 } |
1435 } | 1475 } |
1436 #endif | 1476 #endif |
1437 if (status == WAIT_ANM) { | 1477 if (status == WAIT_ANM) { |
1438 if (anm1) { | 1478 if (anm1 != NULL) { |
1439 if (!anm1->IsEnd()) return true; | 1479 if (!anm1->IsEnd()) return true; |
1440 AbortAnm(); | 1480 AbortAnm(); |
1441 } | 1481 } |
1442 } else if (status == WAIT_SHAKE) { | 1482 } else if (status == WAIT_SHAKE) { |
1443 if (anm2) { | 1483 if (anm2 != NULL) { |
1444 if (!anm2->IsEnd()) return true; | 1484 if (!anm2->IsEnd()) return true; |
1445 delete anm2; | 1485 delete anm2; |
1446 anm2 = 0; | 1486 anm2 = NULL; |
1447 } | 1487 } |
1448 status = NORMAL; | 1488 status = NORMAL; |
1449 } else if (status == WAIT_SE) { | 1489 } else if (status == WAIT_SE) { |
1450 if (music.IsStopSE()) status = NORMAL; | 1490 if (music.IsStopSE()) status = NORMAL; |
1451 return true; | 1491 return true; |
1455 status = NORMAL; | 1495 status = NORMAL; |
1456 screen->ReBlit(); | 1496 screen->ReBlit(); |
1457 } | 1497 } |
1458 return true; | 1498 return true; |
1459 } | 1499 } |
1460 if (anm2) { | 1500 if (anm2 != NULL) { |
1461 if (anm2->IsEnd()) { | 1501 if (anm2->IsEnd()) { |
1462 delete anm2; | 1502 delete anm2; |
1463 anm2 = 0; | 1503 anm2 = NULL; |
1464 } | 1504 } |
1465 } | 1505 } |
1466 return false; | 1506 return false; |
1467 } | 1507 } |
1468 | 1508 |
1469 void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除 | 1509 void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除 |
1470 if (grpobj.find(num) == grpobj.end()) return; | 1510 if (grpobj.find(num) == grpobj.end()) return; |
1471 deleted_pic.push_back(grpobj[num].DeletePic()); | 1511 deleted_pic.push_back(grpobj[num].DeletePic()); |
1472 } | 1512 } |
1513 | |
1473 void GrpImpl::DeleteObj(int num) { | 1514 void GrpImpl::DeleteObj(int num) { |
1474 if (grpobj.find(num) == grpobj.end()) return; | 1515 if (grpobj.find(num) == grpobj.end()) return; |
1475 deleted_pic.push_back(grpobj[num].DeletePic()); | 1516 deleted_pic.push_back(grpobj[num].DeletePic()); |
1476 grpobj.erase(num); | 1517 grpobj.erase(num); |
1477 } | 1518 } |
1519 | |
1478 void GrpImpl::DeleteObjRange(int num_first, int num_end) { | 1520 void GrpImpl::DeleteObjRange(int num_first, int num_end) { |
1479 std::map<int, GrpObj>::iterator begin,end,it; | 1521 std::map<int, GrpObj>::iterator begin,end,it; |
1480 begin = grpobj.lower_bound(num_first); | 1522 begin = grpobj.lower_bound(num_first); |
1481 end = grpobj.lower_bound(num_end); | 1523 end = grpobj.lower_bound(num_end); |
1482 for (it=begin;it!=end;it++) { | 1524 for (it=begin;it!=end;it++) { |
1483 deleted_pic.push_back(it->second.DeletePic()); | 1525 deleted_pic.push_back(it->second.DeletePic()); |
1484 } | 1526 } |
1485 grpobj.erase(begin, end); | 1527 grpobj.erase(begin, end); |
1486 } | 1528 } |
1529 | |
1487 void GrpImpl::Exec(Cmd& cmd) { | 1530 void GrpImpl::Exec(Cmd& cmd) { |
1488 if (cmd.cmd_type == CMD_TEXTEND) { | 1531 if (cmd.cmd_type == CMD_TEXTEND) { |
1489 music.StopKoe(500); // テキスト終了で声を止める | 1532 music.StopKoe(500); // テキスト終了で声を止める |
1490 cmd.clear(); | 1533 cmd.clear(); |
1491 return; | 1534 return; |
1924 cmd.cmd_type = CMD_SAVECMDGRP; | 1967 cmd.cmd_type = CMD_SAVECMDGRP; |
1925 } | 1968 } |
1926 } else if (cmd.cmd2 == 0x49) { | 1969 } else if (cmd.cmd2 == 0x49) { |
1927 if (cmd.cmd3 == 0) { // アニメーションを強制終了 | 1970 if (cmd.cmd3 == 0) { // アニメーションを強制終了 |
1928 GrpObj& g = grpobj[cmd.args[0].value]; | 1971 GrpObj& g = grpobj[cmd.args[0].value]; |
1929 if (g.anm == 0 || g.anm->IsEnd()) ; | 1972 if (g.anm == NULL || g.anm->IsEnd()) ; |
1930 else g.anm->Abort(); | 1973 else g.anm->Abort(); |
1931 } else if (cmd.cmd3 == 3) { // アニメーション中か? | 1974 } else if (cmd.cmd3 == 3) { // アニメーション中か? |
1932 GrpObj& g = grpobj[cmd.args[0].value]; | 1975 GrpObj& g = grpobj[cmd.args[0].value]; |
1933 if (g.anm == 0 || g.anm->IsEnd()) { | 1976 if (g.anm == NULL || g.anm->IsEnd()) { |
1934 cmd.SetSysvar(0); | 1977 cmd.SetSysvar(0); |
1935 } else { | 1978 } else { |
1936 cmd.SetSysvar(1); | 1979 cmd.SetSysvar(1); |
1937 } | 1980 } |
1938 } else if (cmd.cmd3 == 1000) { | 1981 } else if (cmd.cmd3 == 1000) { |
1939 // アニメーションを途中で停止した状態にする | 1982 // アニメーションを途中で停止した状態にする |
1940 GrpObj& g = grpobj[cmd.args[0].value]; | 1983 GrpObj& g = grpobj[cmd.args[0].value]; |
1941 if (g.anm == 0 || g.anm->IsEnd()) { | 1984 if (g.anm == NULL || g.anm->IsEnd()) { |
1942 // fprintf(stderr,"AnimPause : no animation in %d (%d)\n",cmd.args[0].value, cmd.args[1].value); | 1985 // fprintf(stderr,"AnimPause : no animation in %d (%d)\n",cmd.args[0].value, cmd.args[1].value); |
1943 g.SetSurfaceNum(cmd.args[1].value); | 1986 g.SetSurfaceNum(cmd.args[1].value); |
1944 } else { | 1987 } else { |
1945 g.anm->Abort(); | 1988 g.anm->Abort(); |
1946 g.SetSurfaceNum(cmd.args[1].value); | 1989 g.SetSurfaceNum(cmd.args[1].value); |
2275 ** class Grp | 2318 ** class Grp |
2276 */ | 2319 */ |
2277 | 2320 |
2278 Grp::Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm,class MuSys& mu, AyuSysConfig& config) { | 2321 Grp::Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm,class MuSys& mu, AyuSysConfig& config) { |
2279 pimpl = new GrpImpl(_event, _parent, f, _cgm, mu, config); | 2322 pimpl = new GrpImpl(_event, _parent, f, _cgm, mu, config); |
2280 }; | 2323 } |
2324 | |
2281 Grp::~Grp() { | 2325 Grp::~Grp() { |
2282 delete pimpl; | 2326 delete pimpl; |
2283 } | 2327 } |
2284 | 2328 |
2285 bool Grp::Wait(unsigned int current_time, Cmd& cmd) { | 2329 bool Grp::Wait(unsigned int current_time, Cmd& cmd) { |
2286 return pimpl->Wait(current_time, cmd); | 2330 return pimpl->Wait(current_time, cmd); |
2287 } | 2331 } |
2332 | |
2288 void Grp::Exec(Cmd& cmd) { | 2333 void Grp::Exec(Cmd& cmd) { |
2289 pimpl->Exec(cmd); | 2334 pimpl->Exec(cmd); |
2290 } | 2335 } |
2336 | |
2291 void Grp::SetSkipMode(SkipMode mode) { | 2337 void Grp::SetSkipMode(SkipMode mode) { |
2292 pimpl->SetSkipMode(mode); | 2338 pimpl->SetSkipMode(mode); |
2293 } | 2339 } |
2340 | |
2294 void Grp::InitSel(AyuSysConfig& config) { | 2341 void Grp::InitSel(AyuSysConfig& config) { |
2295 pimpl->InitSel(config); | 2342 pimpl->InitSel(config); |
2296 } | 2343 } |
2344 | |
2297 void Grp::Save(std::string& str) { | 2345 void Grp::Save(std::string& str) { |
2298 pimpl->Save(str); | 2346 pimpl->Save(str); |
2299 } | 2347 } |
2300 | 2348 |
2301 void Grp::Load(const char* str) { | 2349 void Grp::Load(const char* str) { |