mapeditor.cpp
changeset 514 497fab7d1404
parent 505 244e309b4047
child 517 b525fdd445c4
     1.1 --- a/mapeditor.cpp	Tue Jun 19 14:20:29 2007 +0000
     1.2 +++ b/mapeditor.cpp	Tue Jun 19 14:20:30 2007 +0000
     1.3 @@ -483,6 +483,7 @@
     1.4  	QString com=parser.getCommand();
     1.5  	
     1.6  	// External commands
     1.7 +	/////////////////////////////////////////////////////////////////////
     1.8  	if (com=="addBranch")
     1.9  	{
    1.10  		if (xelection.isEmpty())
    1.11 @@ -495,9 +496,9 @@
    1.12  		{	
    1.13  			QList <int> pl;
    1.14  			pl << 0 <<1;
    1.15 -			if (parser.checkParamCount(pl))
    1.16 +			if (parser.checkParCount(pl))
    1.17  			{
    1.18 -				if (parser.paramCount()==0)
    1.19 +				if (parser.parCount()==0)
    1.20  					addNewBranchInt (-2);
    1.21  				else
    1.22  				{
    1.23 @@ -506,6 +507,7 @@
    1.24  				}
    1.25  			}
    1.26  		}
    1.27 +	/////////////////////////////////////////////////////////////////////
    1.28  	} else if (com=="addBranchBefore")
    1.29  	{
    1.30  		if (xelection.isEmpty())
    1.31 @@ -516,11 +518,12 @@
    1.32  			parser.setError (Aborted,"Type of selection is not a branch");
    1.33  		} else 
    1.34  		{	
    1.35 -			if (parser.paramCount()==0)
    1.36 +			if (parser.parCount()==0)
    1.37  			{
    1.38  				addNewBranchBefore ();
    1.39  			}	
    1.40  		}
    1.41 +	/////////////////////////////////////////////////////////////////////
    1.42  	} else if (com==QString("addMapReplace"))
    1.43  	{
    1.44  		if (xelection.isEmpty())
    1.45 @@ -529,13 +532,14 @@
    1.46  		} else if (! selb )
    1.47  		{				  
    1.48  			parser.setError (Aborted,"Type of selection is not a branch");
    1.49 -		} else if (parser.checkParamCount(1))
    1.50 +		} else if (parser.checkParCount(1))
    1.51  		{
    1.52  			//s=parser.parString (ok,0);	// selection
    1.53  			t=parser.parString (ok,0);	// path to map
    1.54  			if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
    1.55  			addMapReplaceInt(selb->getSelectString(),t);	
    1.56  		}
    1.57 +	/////////////////////////////////////////////////////////////////////
    1.58  	} else if (com==QString("addMapInsert"))
    1.59  	{
    1.60  		if (xelection.isEmpty())
    1.61 @@ -546,7 +550,7 @@
    1.62  			parser.setError (Aborted,"Type of selection is not a branch");
    1.63  		} else 
    1.64  		{	
    1.65 -			if (parser.checkParamCount(2))
    1.66 +			if (parser.checkParCount(2))
    1.67  			{
    1.68  				t=parser.parString (ok,0);	// path to map
    1.69  				y=parser.parInt(ok,1);		// position
    1.70 @@ -554,6 +558,7 @@
    1.71  				addMapInsertInt(t,y);	
    1.72  			}
    1.73  		}
    1.74 +	/////////////////////////////////////////////////////////////////////
    1.75  	} else if (com=="clearFlags")
    1.76  	{
    1.77  		if (xelection.isEmpty() )
    1.78 @@ -562,11 +567,12 @@
    1.79  		} else if (! selb )
    1.80  		{				  
    1.81  			parser.setError (Aborted,"Type of selection is not a branch");
    1.82 -		} else if (parser.checkParamCount(0))
    1.83 +		} else if (parser.checkParCount(0))
    1.84  		{
    1.85  			selb->clearStandardFlags();	
    1.86  			selb->updateFlagsToolbar();
    1.87  		}
    1.88 +	/////////////////////////////////////////////////////////////////////
    1.89  	} else if (com=="colorBranch")
    1.90  	{
    1.91  		if (xelection.isEmpty())
    1.92 @@ -575,11 +581,12 @@
    1.93  		} else if (! selb )
    1.94  		{				  
    1.95  			parser.setError (Aborted,"Type of selection is not a branch");
    1.96 -		} else if (parser.checkParamCount(1))
    1.97 +		} else if (parser.checkParCount(1))
    1.98  		{	
    1.99  			QColor c=parser.parColor (ok,0);
   1.100  			if (ok) colorBranch (c);
   1.101  		}	
   1.102 +	/////////////////////////////////////////////////////////////////////
   1.103  	} else if (com=="colorSubtree")
   1.104  	{
   1.105  		if (xelection.isEmpty())
   1.106 @@ -588,11 +595,12 @@
   1.107  		} else if (! selb )
   1.108  		{				  
   1.109  			parser.setError (Aborted,"Type of selection is not a branch");
   1.110 -		} else if (parser.checkParamCount(1))
   1.111 +		} else if (parser.checkParCount(1))
   1.112  		{	
   1.113  			QColor c=parser.parColor (ok,0);
   1.114  			if (ok) colorSubtree (c);
   1.115  		}	
   1.116 +	/////////////////////////////////////////////////////////////////////
   1.117  	} else if (com=="copy")
   1.118  	{
   1.119  		if (xelection.isEmpty())
   1.120 @@ -601,10 +609,11 @@
   1.121  		} else if (! selb )
   1.122  		{				  
   1.123  			parser.setError (Aborted,"Type of selection is not a branch");
   1.124 -		} else if (parser.checkParamCount(0))
   1.125 +		} else if (parser.checkParCount(0))
   1.126  		{	
   1.127  			//FIXME missing action for copy
   1.128  		}	
   1.129 +	/////////////////////////////////////////////////////////////////////
   1.130  	} else if (com=="cut")
   1.131  	{
   1.132  		if (xelection.isEmpty())
   1.133 @@ -615,10 +624,11 @@
   1.134  					xelection.type()!=Selection::FloatImage )
   1.135  		{				  
   1.136  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.137 -		} else if (parser.checkParamCount(0))
   1.138 +		} else if (parser.checkParCount(0))
   1.139  		{	
   1.140  			cut();
   1.141  		}	
   1.142 +	/////////////////////////////////////////////////////////////////////
   1.143  	} else if (com=="delete")
   1.144  	{
   1.145  		if (xelection.isEmpty())
   1.146 @@ -627,10 +637,11 @@
   1.147  		} else if (xelection.type() != Selection::Branch && xelection.type() != Selection::FloatImage )
   1.148  		{
   1.149  			parser.setError (Aborted,"Type of selection is wrong.");
   1.150 -		} else if (parser.checkParamCount(0))
   1.151 +		} else if (parser.checkParCount(0))
   1.152  		{	
   1.153  			deleteSelection();
   1.154  		}	
   1.155 +	/////////////////////////////////////////////////////////////////////
   1.156  	} else if (com=="deleteKeepChilds")
   1.157  	{
   1.158  		if (xelection.isEmpty())
   1.159 @@ -639,10 +650,11 @@
   1.160  		} else if (! selb )
   1.161  		{
   1.162  			parser.setError (Aborted,"Type of selection is not a branch");
   1.163 -		} else if (parser.checkParamCount(0))
   1.164 +		} else if (parser.checkParCount(0))
   1.165  		{	
   1.166  			deleteKeepChilds();
   1.167  		}	
   1.168 +	/////////////////////////////////////////////////////////////////////
   1.169  	} else if (com=="deleteChilds")
   1.170  	{
   1.171  		if (xelection.isEmpty())
   1.172 @@ -651,10 +663,63 @@
   1.173  		} else if (! selb)
   1.174  		{
   1.175  			parser.setError (Aborted,"Type of selection is not a branch");
   1.176 -		} else if (parser.checkParamCount(0))
   1.177 +		} else if (parser.checkParCount(0))
   1.178  		{	
   1.179  			deleteChilds();
   1.180  		}	
   1.181 +	/////////////////////////////////////////////////////////////////////
   1.182 +	} else if (com=="export")
   1.183 +	{
   1.184 +	/*
   1.185 +		if (xelection.isEmpty())
   1.186 +		{
   1.187 +			parser.setError (Aborted,"Nothing selected");
   1.188 +		} else if (! selb)
   1.189 +		{
   1.190 +			parser.setError (Aborted,"Type of selection is not a branch");
   1.191 +		} else 
   1.192 +	*/
   1.193 +		if (parser.parCount()==0)
   1.194 +		{	
   1.195 +			parser.setError (Aborted,"No output format given");
   1.196 +		} else
   1.197 +		{
   1.198 +			// At least one parameter, which is the outFormat
   1.199 +			QString outFormat=parser.parString (ok,0);
   1.200 +			if (!ok)
   1.201 +			{
   1.202 +				parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat));
   1.203 +			} else
   1.204 +			{
   1.205 +				QString fname="";
   1.206 +				ok=true;
   1.207 +				if (parser.parCount()>=2)
   1.208 +					// Hey, we even have a filename
   1.209 +					fname=parser.parString(ok,1); 
   1.210 +				if (!ok)
   1.211 +				{
   1.212 +					parser.setError (Aborted,"Could not read filename");
   1.213 +				} else
   1.214 +				{
   1.215 +					if (outFormat == "ascii")
   1.216 +					{
   1.217 +						exportASCII (fname,false);
   1.218 +					} else if (outFormat == "image")
   1.219 +					{
   1.220 +						QString format="PNG";
   1.221 +						if (parser.parCount()>2)
   1.222 +						{
   1.223 +							format=parser.parString(ok,2);
   1.224 +						}
   1.225 +						exportImage (fname,false,format);
   1.226 +					} else
   1.227 +					{
   1.228 +						parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat));
   1.229 +					}
   1.230 +				}
   1.231 +			}
   1.232 +		}	
   1.233 +	/////////////////////////////////////////////////////////////////////
   1.234  	} else if (com=="importDir")
   1.235  	{
   1.236  		if (xelection.isEmpty())
   1.237 @@ -663,11 +728,12 @@
   1.238  		} else if (! selb )
   1.239  		{				  
   1.240  			parser.setError (Aborted,"Type of selection is not a branch");
   1.241 -		} else if (parser.checkParamCount(1))
   1.242 +		} else if (parser.checkParCount(1))
   1.243  		{
   1.244  			s=parser.parString(ok,0);
   1.245  			if (ok) importDirInt(s);
   1.246  		}	
   1.247 +	/////////////////////////////////////////////////////////////////////
   1.248  	} else if (com=="linkTo")
   1.249  	{
   1.250  		if (xelection.isEmpty())
   1.251 @@ -675,7 +741,7 @@
   1.252  			parser.setError (Aborted,"Nothing selected");
   1.253  		} else if ( selb)
   1.254  		{
   1.255 -			if (parser.checkParamCount(4))
   1.256 +			if (parser.checkParCount(4))
   1.257  			{
   1.258  				// 0	selectstring of parent
   1.259  				// 1	num in parent (for branches)
   1.260 @@ -705,7 +771,7 @@
   1.261  			}	
   1.262  		} else if ( xelection.type() == Selection::FloatImage) 
   1.263  		{
   1.264 -			if (parser.checkParamCount(1))
   1.265 +			if (parser.checkParCount(1))
   1.266  			{
   1.267  				// 0	selectstring of parent
   1.268  				s=parser.parString(ok,0);
   1.269 @@ -720,6 +786,7 @@
   1.270  			}		
   1.271  		} else
   1.272  			parser.setError (Aborted,"Type of selection is not a floatimage or branch");
   1.273 +	/////////////////////////////////////////////////////////////////////
   1.274  	} else if (com=="loadImage")
   1.275  	{
   1.276  		if (xelection.isEmpty())
   1.277 @@ -728,11 +795,12 @@
   1.278  		} else if (! selb )
   1.279  		{				  
   1.280  			parser.setError (Aborted,"Type of selection is not a branch");
   1.281 -		} else if (parser.checkParamCount(1))
   1.282 +		} else if (parser.checkParCount(1))
   1.283  		{
   1.284  			s=parser.parString(ok,0);
   1.285  			if (ok) loadFloatImageInt (s);
   1.286  		}	
   1.287 +	/////////////////////////////////////////////////////////////////////
   1.288  	} else if (com=="moveBranchUp")
   1.289  	{
   1.290  		if (xelection.isEmpty() )
   1.291 @@ -741,10 +809,11 @@
   1.292  		} else if (! selb )
   1.293  		{				  
   1.294  			parser.setError (Aborted,"Type of selection is not a branch");
   1.295 -		} else if (parser.checkParamCount(0))
   1.296 +		} else if (parser.checkParCount(0))
   1.297  		{
   1.298  			moveBranchUp();
   1.299  		}	
   1.300 +	/////////////////////////////////////////////////////////////////////
   1.301  	} else if (com=="moveBranchDown")
   1.302  	{
   1.303  		if (xelection.isEmpty() )
   1.304 @@ -753,10 +822,11 @@
   1.305  		} else if (! selb )
   1.306  		{				  
   1.307  			parser.setError (Aborted,"Type of selection is not a branch");
   1.308 -		} else if (parser.checkParamCount(0))
   1.309 +		} else if (parser.checkParCount(0))
   1.310  		{
   1.311  			moveBranchDown();
   1.312  		}	
   1.313 +	/////////////////////////////////////////////////////////////////////
   1.314  	} else if (com=="move")
   1.315  	{
   1.316  		if (xelection.isEmpty() )
   1.317 @@ -767,7 +837,7 @@
   1.318  					xelection.type()!=Selection::FloatImage )
   1.319  		{				  
   1.320  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.321 -		} else if (parser.checkParamCount(2))
   1.322 +		} else if (parser.checkParCount(2))
   1.323  		{	
   1.324  			x=parser.parInt (ok,0);
   1.325  			if (ok)
   1.326 @@ -776,6 +846,7 @@
   1.327  				if (ok) move (x,y);
   1.328  			}
   1.329  		}	
   1.330 +	/////////////////////////////////////////////////////////////////////
   1.331  	} else if (com=="moveRel")
   1.332  	{
   1.333  		if (xelection.isEmpty() )
   1.334 @@ -786,7 +857,7 @@
   1.335  					xelection.type()!=Selection::Selection::FloatImage )
   1.336  		{				  
   1.337  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.338 -		} else if (parser.checkParamCount(2))
   1.339 +		} else if (parser.checkParCount(2))
   1.340  		{	
   1.341  			x=parser.parInt (ok,0);
   1.342  			if (ok)
   1.343 @@ -795,8 +866,10 @@
   1.344  				if (ok) moveRel (x,y);
   1.345  			}
   1.346  		}	
   1.347 +	/////////////////////////////////////////////////////////////////////
   1.348  	} else if (com=="nop")
   1.349  	{
   1.350 +	/////////////////////////////////////////////////////////////////////
   1.351  	} else if (com=="paste")
   1.352  	{
   1.353  		if (xelection.isEmpty() )
   1.354 @@ -805,7 +878,7 @@
   1.355  		} else if (! selb )
   1.356  		{				  
   1.357  			parser.setError (Aborted,"Type of selection is not a branch");
   1.358 -		} else if (parser.checkParamCount(1))
   1.359 +		} else if (parser.checkParCount(1))
   1.360  		{	
   1.361  			x=parser.parInt (ok,0);
   1.362  			if (ok) pasteNoSave(x);
   1.363 @@ -819,7 +892,7 @@
   1.364  		} else if (! selb )
   1.365  		{				  
   1.366  			parser.setError (Aborted,"Type of selection is not a branch");
   1.367 -		} else if (parser.checkParamCount(4))
   1.368 +		} else if (parser.checkParCount(4))
   1.369  		{	
   1.370  			QString c,u;
   1.371  			c=parser.parString (ok,0);
   1.372 @@ -876,13 +949,14 @@
   1.373  				} 
   1.374  			}
   1.375  		}	
   1.376 +	/////////////////////////////////////////////////////////////////////
   1.377  	} else if (com=="saveImage")
   1.378  	{
   1.379  		FloatImageObj *fio=xelection.getFloatImage();
   1.380  		if (!fio)
   1.381  		{
   1.382  			parser.setError (Aborted,"Type of selection is not an image");
   1.383 -		} else if (parser.checkParamCount(2))
   1.384 +		} else if (parser.checkParCount(2))
   1.385  		{
   1.386  			s=parser.parString(ok,0);
   1.387  			if (ok)
   1.388 @@ -891,6 +965,7 @@
   1.389  				if (ok) saveFloatImageInt (fio,t,s);
   1.390  			}
   1.391  		}	
   1.392 +	/////////////////////////////////////////////////////////////////////
   1.393  	} else if (com=="scroll")
   1.394  	{
   1.395  		if (xelection.isEmpty() )
   1.396 @@ -899,18 +974,20 @@
   1.397  		} else if (! selb )
   1.398  		{				  
   1.399  			parser.setError (Aborted,"Type of selection is not a branch");
   1.400 -		} else if (parser.checkParamCount(0))
   1.401 +		} else if (parser.checkParCount(0))
   1.402  		{	
   1.403  			if (!scrollBranch (selb))	
   1.404  				parser.setError (Aborted,"Could not scroll branch");
   1.405  		}	
   1.406 +	/////////////////////////////////////////////////////////////////////
   1.407  	} else if (com=="select")
   1.408  	{
   1.409 -		if (parser.checkParamCount(1))
   1.410 +		if (parser.checkParCount(1))
   1.411  		{
   1.412  			s=parser.parString(ok,0);
   1.413  			if (ok) select (s);
   1.414  		}	
   1.415 +	/////////////////////////////////////////////////////////////////////
   1.416  	} else if (com=="selectLastBranch")
   1.417  	{
   1.418  		if (xelection.isEmpty() )
   1.419 @@ -919,7 +996,7 @@
   1.420  		} else if (! selb )
   1.421  		{				  
   1.422  			parser.setError (Aborted,"Type of selection is not a branch");
   1.423 -		} else if (parser.checkParamCount(0))
   1.424 +		} else if (parser.checkParCount(0))
   1.425  		{	
   1.426  			BranchObj *bo=selb->getLastBranch();
   1.427  			if (!bo)
   1.428 @@ -927,6 +1004,7 @@
   1.429  			selectInt (bo);	
   1.430  				
   1.431  		}	
   1.432 +	/////////////////////////////////////////////////////////////////////
   1.433  	} else if (com=="selectLastImage")
   1.434  	{
   1.435  		if (xelection.isEmpty() )
   1.436 @@ -935,7 +1013,7 @@
   1.437  		} else if (! selb )
   1.438  		{				  
   1.439  			parser.setError (Aborted,"Type of selection is not a branch");
   1.440 -		} else if (parser.checkParamCount(0))
   1.441 +		} else if (parser.checkParCount(0))
   1.442  		{	
   1.443  			FloatImageObj *fio=selb->getLastFloatImage();
   1.444  			if (!fio)
   1.445 @@ -943,75 +1021,83 @@
   1.446  			selectInt (fio);	
   1.447  				
   1.448  		}	
   1.449 +	/////////////////////////////////////////////////////////////////////
   1.450  	} else if (com=="setFrameType")
   1.451  	{
   1.452  		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.453  		{
   1.454  			parser.setError (Aborted,"Type of selection does not allow setting frame type");
   1.455  		}
   1.456 -		else if (parser.checkParamCount(1))
   1.457 +		else if (parser.checkParCount(1))
   1.458  		{
   1.459  			s=parser.parString(ok,0);
   1.460  			if (ok) setFrameType (s);
   1.461  		}	
   1.462 +	/////////////////////////////////////////////////////////////////////
   1.463  	} else if (com=="setFramePenColor")
   1.464  	{
   1.465  		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.466  		{
   1.467  			parser.setError (Aborted,"Type of selection does not allow setting of pen color");
   1.468  		}
   1.469 -		else if (parser.checkParamCount(1))
   1.470 +		else if (parser.checkParCount(1))
   1.471  		{
   1.472  			QColor c=parser.parColor(ok,0);
   1.473  			if (ok) setFramePenColor (c);
   1.474  		}	
   1.475 +	/////////////////////////////////////////////////////////////////////
   1.476  	} else if (com=="setFrameBrushColor")
   1.477  	{
   1.478  		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.479  		{
   1.480  			parser.setError (Aborted,"Type of selection does not allow setting brush color");
   1.481  		}
   1.482 -		else if (parser.checkParamCount(1))
   1.483 +		else if (parser.checkParCount(1))
   1.484  		{
   1.485  			QColor c=parser.parColor(ok,0);
   1.486  			if (ok) setFrameBrushColor (c);
   1.487  		}	
   1.488 +	/////////////////////////////////////////////////////////////////////
   1.489  	} else if (com=="setFramePadding")
   1.490  	{
   1.491  		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.492  		{
   1.493  			parser.setError (Aborted,"Type of selection does not allow setting frame padding");
   1.494  		}
   1.495 -		else if (parser.checkParamCount(1))
   1.496 +		else if (parser.checkParCount(1))
   1.497  		{
   1.498  			x=parser.parInt(ok,0);
   1.499  			if (ok) setFramePadding(x);
   1.500  		}	
   1.501 +	/////////////////////////////////////////////////////////////////////
   1.502  	} else if (com=="setFrameBorderWidth")
   1.503  	{
   1.504  		if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.505  		{
   1.506  			parser.setError (Aborted,"Type of selection does not allow setting frame border width");
   1.507  		}
   1.508 -		else if (parser.checkParamCount(1))
   1.509 +		else if (parser.checkParCount(1))
   1.510  		{
   1.511  			x=parser.parInt(ok,0);
   1.512  			if (ok) setFrameBorderWidth (x);
   1.513  		}	
   1.514 +	/////////////////////////////////////////////////////////////////////
   1.515  	} else if (com=="setMapAuthor")
   1.516  	{
   1.517 -		if (parser.checkParamCount(1))
   1.518 +		if (parser.checkParCount(1))
   1.519  		{
   1.520  			s=parser.parString(ok,0);
   1.521  			if (ok) setMapAuthor (s);
   1.522  		}	
   1.523 +	/////////////////////////////////////////////////////////////////////
   1.524  	} else if (com=="setMapComment")
   1.525  	{
   1.526 -		if (parser.checkParamCount(1))
   1.527 +		if (parser.checkParCount(1))
   1.528  		{
   1.529  			s=parser.parString(ok,0);
   1.530  			if (ok) setMapComment(s);
   1.531  		}	
   1.532 +	/////////////////////////////////////////////////////////////////////
   1.533  	} else if (com=="setMapBackgroundColor")
   1.534  	{
   1.535  		if (xelection.isEmpty() )
   1.536 @@ -1020,11 +1106,12 @@
   1.537  		} else if (! xelection.getBranch() )
   1.538  		{				  
   1.539  			parser.setError (Aborted,"Type of selection is not a branch");
   1.540 -		} else if (parser.checkParamCount(1))
   1.541 +		} else if (parser.checkParCount(1))
   1.542  		{
   1.543  			QColor c=parser.parColor (ok,0);
   1.544  			if (ok) setMapBackgroundColor (c);
   1.545  		}	
   1.546 +	/////////////////////////////////////////////////////////////////////
   1.547  	} else if (com=="setMapDefLinkColor")
   1.548  	{
   1.549  		if (xelection.isEmpty() )
   1.550 @@ -1033,18 +1120,20 @@
   1.551  		} else if (! selb )
   1.552  		{				  
   1.553  			parser.setError (Aborted,"Type of selection is not a branch");
   1.554 -		} else if (parser.checkParamCount(1))
   1.555 +		} else if (parser.checkParCount(1))
   1.556  		{
   1.557  			QColor c=parser.parColor (ok,0);
   1.558  			if (ok) setMapDefLinkColor (c);
   1.559  		}	
   1.560 +	/////////////////////////////////////////////////////////////////////
   1.561  	} else if (com=="setMapLinkStyle")
   1.562  	{
   1.563 -		if (parser.checkParamCount(1))
   1.564 +		if (parser.checkParCount(1))
   1.565  		{
   1.566  			s=parser.parString (ok,0);
   1.567  			if (ok) setMapLinkStyle(s);
   1.568  		}	
   1.569 +	/////////////////////////////////////////////////////////////////////
   1.570  	} else if (com=="setHeading")
   1.571  	{
   1.572  		if (xelection.isEmpty() )
   1.573 @@ -1053,12 +1142,13 @@
   1.574  		} else if (! selb )
   1.575  		{				  
   1.576  			parser.setError (Aborted,"Type of selection is not a branch");
   1.577 -		} else if (parser.checkParamCount(1))
   1.578 +		} else if (parser.checkParCount(1))
   1.579  		{
   1.580  			s=parser.parString (ok,0);
   1.581  			if (ok) 
   1.582  				setHeading (s);
   1.583  		}	
   1.584 +	/////////////////////////////////////////////////////////////////////
   1.585  	} else if (com=="setHideExport")
   1.586  	{
   1.587  		if (xelection.isEmpty() )
   1.588 @@ -1067,11 +1157,12 @@
   1.589  		} else if (xelection.type()!=Selection::Branch && xelection.type() != Selection::MapCenter &&xelection.type()!=Selection::FloatImage)
   1.590  		{				  
   1.591  			parser.setError (Aborted,"Type of selection is not a branch or floatimage");
   1.592 -		} else if (parser.checkParamCount(1))
   1.593 +		} else if (parser.checkParCount(1))
   1.594  		{
   1.595  			b=parser.parBool(ok,0);
   1.596  			if (ok) setHideExport (b);
   1.597  		}
   1.598 +	/////////////////////////////////////////////////////////////////////
   1.599  	} else if (com=="setIncludeImagesHorizontally")
   1.600  	{ 
   1.601  		if (xelection.isEmpty() )
   1.602 @@ -1080,11 +1171,12 @@
   1.603  		} else if (! selb)
   1.604  		{				  
   1.605  			parser.setError (Aborted,"Type of selection is not a branch");
   1.606 -		} else if (parser.checkParamCount(1))
   1.607 +		} else if (parser.checkParCount(1))
   1.608  		{
   1.609  			b=parser.parBool(ok,0);
   1.610  			if (ok) setIncludeImagesHor(b);
   1.611  		}
   1.612 +	/////////////////////////////////////////////////////////////////////
   1.613  	} else if (com=="setIncludeImagesVertically")
   1.614  	{
   1.615  		if (xelection.isEmpty() )
   1.616 @@ -1093,11 +1185,12 @@
   1.617  		} else if (! selb)
   1.618  		{				  
   1.619  			parser.setError (Aborted,"Type of selection is not a branch");
   1.620 -		} else if (parser.checkParamCount(1))
   1.621 +		} else if (parser.checkParCount(1))
   1.622  		{
   1.623  			b=parser.parBool(ok,0);
   1.624  			if (ok) setIncludeImagesVer(b);
   1.625  		}
   1.626 +	/////////////////////////////////////////////////////////////////////
   1.627  	} else if (com=="setHideLinkUnselected")
   1.628  	{
   1.629  		if (xelection.isEmpty() )
   1.630 @@ -1106,18 +1199,20 @@
   1.631  		} else if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage)
   1.632  		{				  
   1.633  			parser.setError (Aborted,"Type of selection does not allow hiding the link");
   1.634 -		} else if (parser.checkParamCount(1))
   1.635 +		} else if (parser.checkParCount(1))
   1.636  		{
   1.637  			b=parser.parBool(ok,0);
   1.638  			if (ok) setHideLinkUnselected(b);
   1.639  		}
   1.640 +	/////////////////////////////////////////////////////////////////////
   1.641  	} else if (com=="setSelectionColor")
   1.642  	{
   1.643 -		if (parser.checkParamCount(1))
   1.644 +		if (parser.checkParCount(1))
   1.645  		{
   1.646  			QColor c=parser.parColor (ok,0);
   1.647  			if (ok) setSelectionColorInt (c);
   1.648  		}	
   1.649 +	/////////////////////////////////////////////////////////////////////
   1.650  	} else if (com=="setURL")
   1.651  	{
   1.652  		if (xelection.isEmpty() )
   1.653 @@ -1126,11 +1221,12 @@
   1.654  		} else if (! selb )
   1.655  		{				  
   1.656  			parser.setError (Aborted,"Type of selection is not a branch");
   1.657 -		} else if (parser.checkParamCount(1))
   1.658 +		} else if (parser.checkParCount(1))
   1.659  		{
   1.660  			s=parser.parString (ok,0);
   1.661  			if (ok) setURL(s);
   1.662  		}	
   1.663 +	/////////////////////////////////////////////////////////////////////
   1.664  	} else if (com=="setVymLink")
   1.665  	{
   1.666  		if (xelection.isEmpty() )
   1.667 @@ -1139,12 +1235,13 @@
   1.668  		} else if (! selb )
   1.669  		{				  
   1.670  			parser.setError (Aborted,"Type of selection is not a branch");
   1.671 -		} else if (parser.checkParamCount(1))
   1.672 +		} else if (parser.checkParCount(1))
   1.673  		{
   1.674  			s=parser.parString (ok,0);
   1.675  			if (ok) setVymLinkInt(s);
   1.676  		}	
   1.677  	}
   1.678 +	/////////////////////////////////////////////////////////////////////
   1.679  	else if (com=="setFlag")
   1.680  	{
   1.681  		if (xelection.isEmpty() )
   1.682 @@ -1153,7 +1250,7 @@
   1.683  		} else if (! selb )
   1.684  		{				  
   1.685  			parser.setError (Aborted,"Type of selection is not a branch");
   1.686 -		} else if (parser.checkParamCount(1))
   1.687 +		} else if (parser.checkParCount(1))
   1.688  		{
   1.689  			s=parser.parString(ok,0);
   1.690  			if (ok) 
   1.691 @@ -1162,6 +1259,7 @@
   1.692  				selb->updateFlagsToolbar();
   1.693  			}	
   1.694  		}
   1.695 +	/////////////////////////////////////////////////////////////////////
   1.696  	} else if (com=="setFrameType")
   1.697  	{
   1.698  		if (xelection.isEmpty() )
   1.699 @@ -1170,12 +1268,13 @@
   1.700  		} else if (! selb )
   1.701  		{				  
   1.702  			parser.setError (Aborted,"Type of selection is not a branch");
   1.703 -		} else if (parser.checkParamCount(1))
   1.704 +		} else if (parser.checkParCount(1))
   1.705  		{
   1.706  			s=parser.parString(ok,0);
   1.707  			if (ok) 
   1.708  				setFrameType (s);
   1.709  		}
   1.710 +	/////////////////////////////////////////////////////////////////////
   1.711  	} else if (com=="toggleFlag")
   1.712  	{
   1.713  		if (xelection.isEmpty() )
   1.714 @@ -1184,7 +1283,7 @@
   1.715  		} else if (! selb )
   1.716  		{				  
   1.717  			parser.setError (Aborted,"Type of selection is not a branch");
   1.718 -		} else if (parser.checkParamCount(1))
   1.719 +		} else if (parser.checkParCount(1))
   1.720  		{
   1.721  			s=parser.parString(ok,0);
   1.722  			if (ok) 
   1.723 @@ -1193,6 +1292,7 @@
   1.724  				selb->updateFlagsToolbar();
   1.725  			}	
   1.726  		}
   1.727 +	/////////////////////////////////////////////////////////////////////
   1.728  	} else if (com=="unscroll")
   1.729  	{
   1.730  		if (xelection.isEmpty() )
   1.731 @@ -1201,11 +1301,12 @@
   1.732  		} else if (! selb )
   1.733  		{				  
   1.734  			parser.setError (Aborted,"Type of selection is not a branch");
   1.735 -		} else if (parser.checkParamCount(0))
   1.736 +		} else if (parser.checkParCount(0))
   1.737  		{	
   1.738  			if (!unscrollBranch (selb))	
   1.739  				parser.setError (Aborted,"Could not unscroll branch");
   1.740  		}	
   1.741 +	/////////////////////////////////////////////////////////////////////
   1.742  	} else if (com=="unscrollChilds")
   1.743  	{
   1.744  		if (xelection.isEmpty() )
   1.745 @@ -1214,10 +1315,11 @@
   1.746  		} else if (! selb )
   1.747  		{				  
   1.748  			parser.setError (Aborted,"Type of selection is not a branch");
   1.749 -		} else if (parser.checkParamCount(0))
   1.750 +		} else if (parser.checkParCount(0))
   1.751  		{	
   1.752  			unscrollChilds ();
   1.753  		}	
   1.754 +	/////////////////////////////////////////////////////////////////////
   1.755  	} else if (com=="unsetFlag")
   1.756  	{
   1.757  		if (xelection.isEmpty() )
   1.758 @@ -1226,7 +1328,7 @@
   1.759  		} else if (! selb )
   1.760  		{				  
   1.761  			parser.setError (Aborted,"Type of selection is not a branch");
   1.762 -		} else if (parser.checkParamCount(1))
   1.763 +		} else if (parser.checkParCount(1))
   1.764  		{
   1.765  			s=parser.parString(ok,0);
   1.766  			if (ok) 
   1.767 @@ -1616,14 +1718,6 @@
   1.768  	return hidemode;
   1.769  }
   1.770  
   1.771 -void MapEditor::exportImage(QString fn)
   1.772 -{
   1.773 -	setExportMode (true);
   1.774 -	QPixmap pix (getPixmap());
   1.775 -	pix.save(fn, "PNG");
   1.776 -	setExportMode (false);
   1.777 -}
   1.778 -
   1.779  void MapEditor::setExportMode (bool b)
   1.780  {
   1.781  	// should be called before and after exports
   1.782 @@ -1634,11 +1728,57 @@
   1.783  		setHideTmpMode (BranchObj::HideNone);
   1.784  }
   1.785  
   1.786 -void MapEditor::exportImage(QString fn, QString format)
   1.787 +void MapEditor::exportASCII(QString fname,bool askName)
   1.788  {
   1.789 +	ExportASCII ex;
   1.790 +	ex.setMapCenter(mapCenter);
   1.791 +	if (fname=="") 
   1.792 +		ex.setFile (mapName+".txt");	
   1.793 +	else
   1.794 +		ex.setFile (fname);
   1.795 +
   1.796 +	if (askName)
   1.797 +	{
   1.798 +		//ex.addFilter ("TXT (*.txt)");
   1.799 +		ex.setDir(lastImageDir);
   1.800 +		//ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
   1.801 +		ex.execDialog() ; 
   1.802 +	} 
   1.803 +	if (!ex.canceled())
   1.804 +	{
   1.805 +		setExportMode(true);
   1.806 +		ex.doExport();
   1.807 +		setExportMode(false);
   1.808 +	}
   1.809 +}
   1.810 +
   1.811 +void MapEditor::exportImage(QString fname, bool askName, QString format)
   1.812 +{
   1.813 +	if (fname=="")
   1.814 +	{
   1.815 +		fname=mapName+".png";
   1.816 +		format="PNG";
   1.817 +	} 	
   1.818 +
   1.819 +	if (askName)
   1.820 +	{
   1.821 +		QStringList fl;
   1.822 +		QFileDialog *fd=new QFileDialog (this);
   1.823 +		fd->setCaption (tr("Export map as image"));
   1.824 +		fd->setDirectory (lastImageDir);
   1.825 +		fd->setFileMode(QFileDialog::AnyFile);
   1.826 +		fd->setFilters  (imageIO.getFilters() );
   1.827 +		if (fd->exec())
   1.828 +		{
   1.829 +			fl=fd->selectedFiles();
   1.830 +			fname=fl.first();
   1.831 +			format=imageIO.getType(fd->selectedFilter());
   1.832 +		} 
   1.833 +	}
   1.834 +
   1.835  	setExportMode (true);
   1.836  	QPixmap pix (getPixmap());
   1.837 -	pix.save(fn, format);
   1.838 +	pix.save(fname, format);
   1.839  	setExportMode (false);
   1.840  }
   1.841  
   1.842 @@ -1684,7 +1824,7 @@
   1.843  	file.close();
   1.844  
   1.845  	// Now write image, too
   1.846 -	exportImage (dir+"/images/"+mapName+".png");
   1.847 +	exportImage (dir+"/images/"+mapName+".png","PNG");
   1.848  
   1.849  	setExportMode (false);
   1.850  }