diff 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
line wrap: on
line diff
--- a/scn2k/scn2k_grp.cc
+++ b/scn2k/scn2k_grp.cc
@@ -42,7 +42,7 @@ GrpObj::GrpObj(void) :
 	_posx(0), _posy(0), clip_area(0,0,0,0),
 	alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1),
 	dig_number(0), dig_digit(0),
-	zoom(-1), rotate(-1), attr(GrpObj::HIDDEN) {
+	zoomx(-1), zoomy(-1), rotate(-1), attr(GrpObj::HIDDEN) {
 	int i;
 	for (i=0; i<9; i++) {
 		posx[i] = posy[i] = 0;
@@ -168,7 +168,7 @@ void GrpObj::Update(void) {
 	}
 	if (picture == NULL) return;
 	if (attr & UPDATE_POS) {
-		if (zoom != -1) {
+		if (zoomx != -1 || zoomy != -1) {
 			int w=0, h=0;
 			GetSrcGeom(w,h);
 			picture->Move(_posx-w/2, _posy-h/2);
@@ -229,7 +229,7 @@ void GrpObj::UpdateSurface(void) {
 		GetSrcGeom(width, height);
 		if (width <= 0 || height <= 0) return;
 		// surface の設定
-		if (surface_num == 0 && ( (zoom > 0 && zoom != 256) || rotate > 0)) {
+		if (surface_num == 0 && ( ((zoomx > 0 && zoomx != 256) || (zoomy > 0 && zoomy != 256)) || rotate > 0)) {
 			ZoomRotate();
 		} else {
 			// 普通に surface を設定
@@ -257,7 +257,7 @@ void GrpObj::ZoomRotate(void) {
 	Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str());
 	if (surface_orig == NULL) return;
 
-	Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate);
+	Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoomx)/256.0, double(zoomy)/256.0, rotate);
 	Rect zoom_r (*zoom_surface);
 	picture->SetSurface(zoom_surface, 0, 0);
 	picture->SetSurfaceFreeFlag();
@@ -467,14 +467,16 @@ void GrpObj::CreateGanSpecial(Event::Con
 	}
 }
 
-void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) {
-	if (zoom == new_zoom && rotate == new_rotate) return;
-	if ( zoom == -1 || new_zoom == -1) {
+void GrpObj::SetZoomRotate(int new_zoom_x, int new_zoom_y, int new_rotate) {
+	if (zoomx == new_zoom_x && zoomy == new_zoom_y && rotate == new_rotate) return;
+	if (zoomx == -1 || zoomy == -1 || new_zoom_x == -1 || new_zoom_y == -1) {
 		attr = Attribute(attr | UPDATE_POS); // centering する
 	}
-	zoom = new_zoom;
+	zoomx = new_zoom_x;
+	zoomy = new_zoom_y;
 	if (new_rotate != -1) rotate = new_rotate;
-	if (zoom < 0) zoom = 256;
+	if (zoomx < 0) zoomx = 256;
+	if (zoomy < 0) zoomy = 256;
 	if (rotate < 0) rotate = 0;
 	else if (rotate > 360) rotate %= 360;
 
@@ -749,10 +751,12 @@ Grp::Grp(Event::Container& _event, PicCo
 	RegisterCommand(1, 82, 1038, "objBgNumOpts", (CmdImpl) &Grp::impl_objNumOpts);
 	RegisterCommand(1, 81, 1039, "objPattNo", (CmdImpl) &Grp::impl_objPattNo);
 	RegisterCommand(1, 82, 1039, "objBgPattNo", (CmdImpl) &Grp::impl_objPattNo);
-	RegisterCommand(1, 81, 1046, "objScale", (CmdImpl) &Grp::impl_objScale); //FIXME: Broken behaviour
+	RegisterCommand(1, 81, 1046, "objScale", (CmdImpl) &Grp::impl_objScale);
 	RegisterCommand(1, 82, 1046, "objBgScale", (CmdImpl) &Grp::impl_objScale);
-	RegisterCommand(1, 81, 1047, "objWidth", NULL);
-	RegisterCommand(1, 82, 1047, "objBgWidth", NULL);
+	RegisterCommand(1, 81, 1047, "objWidth", (CmdImpl) &Grp::impl_objWidth);
+	RegisterCommand(1, 82, 1047, "objBgWidth", (CmdImpl) &Grp::impl_objWidth);
+	RegisterCommand(1, 81, 1048, "objHeight", (CmdImpl) &Grp::impl_objHeight);
+	RegisterCommand(1, 82, 1048, "objBgHeight", (CmdImpl) &Grp::impl_objHeight);
 	RegisterCommand(1, 81, 1049, "objRotate", (CmdImpl) &Grp::impl_objRotate);
 	RegisterCommand(1, 82, 1049, "objBgRotate", (CmdImpl) &Grp::impl_objRotate);