Hedgeroid: Don't update the map preview just for a theme change
authorMedo <smaxein@googlemail.com>
Sat, 18 Aug 2012 13:39:24 +0200
changeset 7560 e7ab89ab86f6
parent 7558 983ff426f91e
child 7561 5f0b1829b16f
Hedgeroid: Don't update the map preview just for a theme change
project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MapFragment.java
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MapFragment.java	Sat Aug 18 13:39:05 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MapFragment.java	Sat Aug 18 13:39:24 2012 +0200
@@ -50,6 +50,7 @@
 	 */
 	private boolean previewGenerationInProgress;
 	private MapRecipe newPreviewRequest;
+	private MapRecipe currentMap; // kept for reference on every change to find out what changed
 	
 	@Override
 	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -90,9 +91,9 @@
 		mazeSizeSpinner = prepareSpinner(v, R.id.spinMazeSize, Arrays.asList(getResources().getStringArray(R.array.map_maze_sizes)), mazeSizeSelectedListener);
 
 		stateManager.registerObserver(this);
-		MapRecipe map = stateManager.getMapRecipe();
-		if(map != null) {
-			updateDisplay(map);
+		currentMap = stateManager.getMapRecipe();
+		if(currentMap != null) {
+			updateDisplay(currentMap);
 		}
 		setChiefState(stateManager.getChiefStatus());
 		mapPreviewHandler.activity();
@@ -218,8 +219,17 @@
 	}
 	
 	public void onMapChanged(MapRecipe recipe) {
+		if(currentMap==null
+				|| currentMap.mapgen != recipe.mapgen
+				|| currentMap.mazeSize != recipe.mazeSize
+				|| !currentMap.name.equals(recipe.name)
+				|| !currentMap.seed.equals(recipe.seed)
+				|| currentMap.templateFilter != recipe.templateFilter
+				|| !Arrays.equals(currentMap.getDrawData(), recipe.getDrawData())) {
+			mapPreviewHandler.activity();
+		}
 		updateDisplay(recipe);
-		mapPreviewHandler.activity();
+		currentMap = recipe;
 	}
 	
 	public void onGameStyleChanged(String gameStyle) { }