Mercurial > otakunoraifu
comparison scn2k/scn2k_grp.cc @ 71:1fd20d231376
Fix objScale with 2D zoom; implement objWidth and objHeight.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 01 Apr 2011 23:49:12 +0200 |
parents | 4416cfac86ae |
children | f9eb96a4cce0 |
comparison
equal
deleted
inserted
replaced
70:281dcd7217df | 71:1fd20d231376 |
---|---|
40 GrpObj::GrpObj(void) : | 40 GrpObj::GrpObj(void) : |
41 name(""), gan_name(""), pic_parent(0), picture(0), anm(0), | 41 name(""), gan_name(""), pic_parent(0), picture(0), anm(0), |
42 _posx(0), _posy(0), clip_area(0,0,0,0), | 42 _posx(0), _posy(0), clip_area(0,0,0,0), |
43 alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1), | 43 alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1), |
44 dig_number(0), dig_digit(0), | 44 dig_number(0), dig_digit(0), |
45 zoom(-1), rotate(-1), attr(GrpObj::HIDDEN) { | 45 zoomx(-1), zoomy(-1), rotate(-1), attr(GrpObj::HIDDEN) { |
46 int i; | 46 int i; |
47 for (i=0; i<9; i++) { | 47 for (i=0; i<9; i++) { |
48 posx[i] = posy[i] = 0; | 48 posx[i] = posy[i] = 0; |
49 } | 49 } |
50 } | 50 } |
166 UpdateSurface(); | 166 UpdateSurface(); |
167 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE)); | 167 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE)); |
168 } | 168 } |
169 if (picture == NULL) return; | 169 if (picture == NULL) return; |
170 if (attr & UPDATE_POS) { | 170 if (attr & UPDATE_POS) { |
171 if (zoom != -1) { | 171 if (zoomx != -1 || zoomy != -1) { |
172 int w=0, h=0; | 172 int w=0, h=0; |
173 GetSrcGeom(w,h); | 173 GetSrcGeom(w,h); |
174 picture->Move(_posx-w/2, _posy-h/2); | 174 picture->Move(_posx-w/2, _posy-h/2); |
175 } else { | 175 } else { |
176 picture->Move(_posx, _posy); | 176 picture->Move(_posx, _posy); |
227 if (name.length() == 0) return; | 227 if (name.length() == 0) return; |
228 // ファイル名が存在する場合、ファイルを読み込み | 228 // ファイル名が存在する場合、ファイルを読み込み |
229 GetSrcGeom(width, height); | 229 GetSrcGeom(width, height); |
230 if (width <= 0 || height <= 0) return; | 230 if (width <= 0 || height <= 0) return; |
231 // surface の設定 | 231 // surface の設定 |
232 if (surface_num == 0 && ( (zoom > 0 && zoom != 256) || rotate > 0)) { | 232 if (surface_num == 0 && ( ((zoomx > 0 && zoomx != 256) || (zoomy > 0 && zoomy != 256)) || rotate > 0)) { |
233 ZoomRotate(); | 233 ZoomRotate(); |
234 } else { | 234 } else { |
235 // 普通に surface を設定 | 235 // 普通に surface を設定 |
236 string path(name); | 236 string path(name); |
237 path += ".g00"; | 237 path += ".g00"; |
255 string path(name); | 255 string path(name); |
256 path += ".g00"; | 256 path += ".g00"; |
257 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); | 257 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); |
258 if (surface_orig == NULL) return; | 258 if (surface_orig == NULL) return; |
259 | 259 |
260 Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate); | 260 Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoomx)/256.0, double(zoomy)/256.0, rotate); |
261 Rect zoom_r (*zoom_surface); | 261 Rect zoom_r (*zoom_surface); |
262 picture->SetSurface(zoom_surface, 0, 0); | 262 picture->SetSurface(zoom_surface, 0, 0); |
263 picture->SetSurfaceFreeFlag(); | 263 picture->SetSurfaceFreeFlag(); |
264 //picture->Move(PosX() + - zoom_r.width()/2, PosY() + - zoom_r.height()/2); | 264 //picture->Move(PosX() + - zoom_r.width()/2, PosY() + - zoom_r.height()/2); |
265 // 中心座標がわからん・・・ | 265 // 中心座標がわからん・・・ |
465 default: | 465 default: |
466 break; | 466 break; |
467 } | 467 } |
468 } | 468 } |
469 | 469 |
470 void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) { | 470 void GrpObj::SetZoomRotate(int new_zoom_x, int new_zoom_y, int new_rotate) { |
471 if (zoom == new_zoom && rotate == new_rotate) return; | 471 if (zoomx == new_zoom_x && zoomy == new_zoom_y && rotate == new_rotate) return; |
472 if ( zoom == -1 || new_zoom == -1) { | 472 if (zoomx == -1 || zoomy == -1 || new_zoom_x == -1 || new_zoom_y == -1) { |
473 attr = Attribute(attr | UPDATE_POS); // centering する | 473 attr = Attribute(attr | UPDATE_POS); // centering する |
474 } | 474 } |
475 zoom = new_zoom; | 475 zoomx = new_zoom_x; |
476 zoomy = new_zoom_y; | |
476 if (new_rotate != -1) rotate = new_rotate; | 477 if (new_rotate != -1) rotate = new_rotate; |
477 if (zoom < 0) zoom = 256; | 478 if (zoomx < 0) zoomx = 256; |
479 if (zoomy < 0) zoomy = 256; | |
478 if (rotate < 0) rotate = 0; | 480 if (rotate < 0) rotate = 0; |
479 else if (rotate > 360) rotate %= 360; | 481 else if (rotate > 360) rotate %= 360; |
480 | 482 |
481 attr = Attribute(attr | UPDATE_PICTURE); | 483 attr = Attribute(attr | UPDATE_PICTURE); |
482 } | 484 } |
747 RegisterCommand(1, 82, 1037, "objBgSetDigits", (CmdImpl) &Grp::impl_objSetDigits); | 749 RegisterCommand(1, 82, 1037, "objBgSetDigits", (CmdImpl) &Grp::impl_objSetDigits); |
748 RegisterCommand(1, 81, 1038, "objNumOpts", (CmdImpl) &Grp::impl_objNumOpts); | 750 RegisterCommand(1, 81, 1038, "objNumOpts", (CmdImpl) &Grp::impl_objNumOpts); |
749 RegisterCommand(1, 82, 1038, "objBgNumOpts", (CmdImpl) &Grp::impl_objNumOpts); | 751 RegisterCommand(1, 82, 1038, "objBgNumOpts", (CmdImpl) &Grp::impl_objNumOpts); |
750 RegisterCommand(1, 81, 1039, "objPattNo", (CmdImpl) &Grp::impl_objPattNo); | 752 RegisterCommand(1, 81, 1039, "objPattNo", (CmdImpl) &Grp::impl_objPattNo); |
751 RegisterCommand(1, 82, 1039, "objBgPattNo", (CmdImpl) &Grp::impl_objPattNo); | 753 RegisterCommand(1, 82, 1039, "objBgPattNo", (CmdImpl) &Grp::impl_objPattNo); |
752 RegisterCommand(1, 81, 1046, "objScale", (CmdImpl) &Grp::impl_objScale); //FIXME: Broken behaviour | 754 RegisterCommand(1, 81, 1046, "objScale", (CmdImpl) &Grp::impl_objScale); |
753 RegisterCommand(1, 82, 1046, "objBgScale", (CmdImpl) &Grp::impl_objScale); | 755 RegisterCommand(1, 82, 1046, "objBgScale", (CmdImpl) &Grp::impl_objScale); |
754 RegisterCommand(1, 81, 1047, "objWidth", NULL); | 756 RegisterCommand(1, 81, 1047, "objWidth", (CmdImpl) &Grp::impl_objWidth); |
755 RegisterCommand(1, 82, 1047, "objBgWidth", NULL); | 757 RegisterCommand(1, 82, 1047, "objBgWidth", (CmdImpl) &Grp::impl_objWidth); |
758 RegisterCommand(1, 81, 1048, "objHeight", (CmdImpl) &Grp::impl_objHeight); | |
759 RegisterCommand(1, 82, 1048, "objBgHeight", (CmdImpl) &Grp::impl_objHeight); | |
756 RegisterCommand(1, 81, 1049, "objRotate", (CmdImpl) &Grp::impl_objRotate); | 760 RegisterCommand(1, 81, 1049, "objRotate", (CmdImpl) &Grp::impl_objRotate); |
757 RegisterCommand(1, 82, 1049, "objBgRotate", (CmdImpl) &Grp::impl_objRotate); | 761 RegisterCommand(1, 82, 1049, "objBgRotate", (CmdImpl) &Grp::impl_objRotate); |
758 | 762 |
759 RegisterCommand(2, 81, 1000, "childObjMove", (CmdImpl) &Grp::impl_objSetPos); | 763 RegisterCommand(2, 81, 1000, "childObjMove", (CmdImpl) &Grp::impl_objSetPos); |
760 RegisterCommand(2, 82, 1000, "childObjBgMove", (CmdImpl) &Grp::impl_objSetPos); | 764 RegisterCommand(2, 82, 1000, "childObjBgMove", (CmdImpl) &Grp::impl_objSetPos); |