]> www.infradead.org Git - users/mchehab/andors-trail.git/commitdiff
Added setting "Optimized drawing" to change the behaviour of how the map is redrawn...
authoroskar.wiksten <oskar.wiksten@08aca716-68be-ccc6-4d58-36f5abd142ac>
Fri, 14 Oct 2011 17:24:24 +0000 (17:24 +0000)
committeroskar.wiksten <oskar.wiksten@08aca716-68be-ccc6-4d58-36f5abd142ac>
Fri, 14 Oct 2011 17:24:24 +0000 (17:24 +0000)
git-svn-id: https://andors-trail.googlecode.com/svn/trunk@180 08aca716-68be-ccc6-4d58-36f5abd142ac

AndorsTrail/res/values/strings.xml
AndorsTrail/res/xml/preferences.xml
AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailPreferences.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java

index 9144a96937f31e471bae6f0e1eea88dcd7980d10..d64d83df2d9b02f2d597441d97d9f59882b5b63c 100644 (file)
        <string name="traitsinfo_base_max_hp">Max HP:</string>
        <string name="traitsinfo_base_max_ap">Max AP:</string>
        <string name="menu_save_saving_not_allowed_in_combat">Cannot save the game while in combat.</string>
+       
+       <string name="preferences_optimized_drawing_title">Optimized drawing</string>
+       <string name="preferences_optimized_drawing">Disable this if you see graphical artifacts. Enabling this option will make the game only redraw changed parts of the screen every frame.</string>
+       
 </resources>
index 96c8feb6c20918985fb1651a37e6ba90a360e3d0..1102f6a2b85de38d8f161b90c5dc2b7cf4cc04ab 100644 (file)
                        android:defaultValue="1.0f"
                        android:entries="@array/preferences_display_scaling_factor"
                        android:entryValues="@array/preferences_display_scaling_factor_values" />
+               <CheckBoxPreference
+                       android:title="@string/preferences_optimized_drawing_title"
+                       android:defaultValue="false"
+                       android:summary="@string/preferences_optimized_drawing"
+                       android:key="optimized_drawing" />
        </PreferenceCategory>
        <PreferenceCategory
                android:title="@string/preferences_dialog_category">
index 4d841d03a5f96bb65601a46161a0e75cfda41e0d..0e84f3ec5222e987d9d37494591c0e3a0c4e3b4a 100644 (file)
@@ -33,6 +33,7 @@ public class AndorsTrailPreferences {
        public float scalingFactor = 1.0f;\r
        public int dpadPosition;\r
        public boolean dpadMinimizeable = true;\r
+       public boolean optimizedDrawing = false;\r
        \r
        public static void read(final Context androidContext, AndorsTrailPreferences dest) {\r
                try {\r
@@ -46,6 +47,7 @@ public class AndorsTrailPreferences {
                        dest.scalingFactor = Float.parseFloat(prefs.getString("scaling_factor", "1.0f"));\r
                        dest.dpadPosition = Integer.parseInt(prefs.getString("dpadposition", Integer.toString(DPAD_POSITION_DISABLED)));\r
                        dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true);\r
+                       dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false);\r
                        \r
                        // This might be implemented as a skill in the future.\r
                        //dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL)));\r
@@ -60,6 +62,7 @@ public class AndorsTrailPreferences {
                        dest.scalingFactor = 1.0f;\r
                        dest.dpadPosition = DPAD_POSITION_DISABLED;\r
                        dest.dpadMinimizeable = true;\r
+                       dest.optimizedDrawing = false;\r
                }\r
        }\r
        \r
index 2928ff09e07041788f01f70322b303c119393b8b..a906b6ee825e274e0e7ba41a41b8579d78701c1c 100644 (file)
@@ -1,6 +1,7 @@
 package com.gpl.rpg.AndorsTrail.view;
 
 import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
+import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
 import com.gpl.rpg.AndorsTrail.context.ViewContext;
 import com.gpl.rpg.AndorsTrail.controller.InputController;
 import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.VisualEffectAnimation;
@@ -43,6 +44,7 @@ public final class MainView extends SurfaceView implements SurfaceHolder.Callbac
     private final TileStore tiles;
        private final ViewContext view;
        private final InputController inputController;
+       private final AndorsTrailPreferences preferences;
        
     private final SurfaceHolder holder;
     private final Paint mPaint = new Paint();
@@ -59,6 +61,7 @@ public final class MainView extends SurfaceView implements SurfaceHolder.Callbac
        this.tiles = app.world.tileStore;
        this.tileSize = tiles.tileSize;
        this.inputController = view.inputController;
+       this.preferences = app.preferences;
 
        holder.addCallback(this);
        
@@ -156,22 +159,22 @@ public final class MainView extends SurfaceView implements SurfaceHolder.Callbac
     
        public void redrawAll(int why) {
                redrawArea_(mapViewArea);
-       }       
+       }
        public void redrawTile(final Coord p, int why) {
                p1x1.topLeft.set(p);
                redrawArea_(p1x1);
-               //redrawAll(why);
        }
        public void redrawArea(final CoordRect area, int why) {
                redrawArea_(area);
-               //redrawAll(why);
        }
-       private void redrawArea_(final CoordRect area) {
+       private void redrawArea_(CoordRect area) {
                if (!hasSurface) return;
+               if (!preferences.optimizedDrawing) area = mapViewArea;
+        
                final PredefinedMap currentMap = model.currentMap;
         boolean b = currentMap.isOutside(area);
         if (b) return;
-               
+                               
                calculateRedrawRect(area);
                Canvas c = null;
                try {
@@ -192,8 +195,10 @@ public final class MainView extends SurfaceView implements SurfaceHolder.Callbac
        }
        
        private final Rect redrawRect = new Rect();
-       public void redrawAreaWithEffect(final CoordRect area, final VisualEffectAnimation effect) {
+       public void redrawAreaWithEffect(CoordRect area, final VisualEffectAnimation effect) {
                if (!hasSurface) return;
+               if (!preferences.optimizedDrawing) area = mapViewArea;
+               
                final PredefinedMap currentMap = model.currentMap;
         if (currentMap.isOutside(area)) return;