Provide setting to disable UI animations, such as the combat bar.

This commit is contained in:
Oskar Wiksten
2012-10-07 17:25:14 +02:00
parent c90d7c4ef0
commit a358fdf344
6 changed files with 42 additions and 6 deletions

View File

@@ -504,5 +504,8 @@
<string name="skill_longdescription_concussion">When making an attack on a target whose block chance (BC) is at least %1$d lower than your attack chance (AC), there is a %2$d %% chance that the hit will cause a concussion on the target. A concussion will severely lower the target\'s offensive combat abilities, making the target less able to land successful attacks.</string>
<string name="about_button4">About</string>
<string name="preferences_ui_category">Interface</string>
<string name="preferences_ui_enable_animations_title">Enable animations</string>
<string name="preferences_ui_enable_animations">Show animations for various interface elements, such as the combat bar.</string>
</resources>

View File

@@ -72,4 +72,12 @@
android:summary="@string/preferences_movement_dpad_minimizeable"
android:key="dpadMinimizeable" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/preferences_ui_category">
<CheckBoxPreference
android:title="@string/preferences_ui_enable_animations_title"
android:defaultValue="true"
android:summary="@string/preferences_ui_enable_animations"
android:key="enableUiAnimations" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -34,6 +34,7 @@ public class AndorsTrailPreferences {
public int dpadPosition;
public boolean dpadMinimizeable = true;
public boolean optimizedDrawing = false;
public boolean enableUiAnimations = true;
public static void read(final Context androidContext, AndorsTrailPreferences dest) {
try {
@@ -48,6 +49,7 @@ public class AndorsTrailPreferences {
dest.dpadPosition = Integer.parseInt(prefs.getString("dpadposition", Integer.toString(DPAD_POSITION_DISABLED)));
dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true);
dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false);
dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true);
// This might be implemented as a skill in the future.
//dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL)));
@@ -63,6 +65,7 @@ public class AndorsTrailPreferences {
dest.dpadPosition = DPAD_POSITION_DISABLED;
dest.dpadMinimizeable = true;
dest.optimizedDrawing = false;
dest.enableUiAnimations = true;
}
}

View File

@@ -85,7 +85,7 @@ public final class MainActivity extends Activity {
statusview = (StatusView) findViewById(R.id.main_statusview);
combatview = (CombatView) findViewById(R.id.main_combatview);
quickitemview = (QuickitemView) findViewById(R.id.main_quickitemview);
activeConditions = new DisplayActiveActorConditionIcons(world.tileManager, this, (RelativeLayout) findViewById(R.id.statusview_activeconditions));
activeConditions = new DisplayActiveActorConditionIcons(app.preferences, world.tileManager, this, (RelativeLayout) findViewById(R.id.statusview_activeconditions));
dpad = (VirtualDpadView) findViewById(R.id.main_virtual_dpad);
statusText = (TextView) findViewById(R.id.statusview_statustext);

View File

@@ -13,6 +13,7 @@ import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
import com.gpl.rpg.AndorsTrail.Dialogs;
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.R;
@@ -36,17 +37,20 @@ public final class CombatView extends RelativeLayout {
private final WorldContext world;
private final ViewContext view;
private final Resources res;
private final AndorsTrailPreferences preferences;
private final Player player;
private final Animation displayAnimation;
private final Animation hideAnimation;
private Monster currentMonster;
public CombatView(final Context context, AttributeSet attr) {
super(context, attr);
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
this.world = app.world;
this.player = world.model.player;
this.view = app.currentView.get();
this.preferences = app.preferences;
this.res = getResources();
setFocusable(false);
@@ -154,11 +158,16 @@ public final class CombatView extends RelativeLayout {
public void show() {
setVisibility(View.VISIBLE);
bringToFront();
startAnimation(displayAnimation);
if (preferences.enableUiAnimations) {
startAnimation(displayAnimation);
}
}
public void hide() {
startAnimation(hideAnimation);
//setVisibility(View.GONE);
if (preferences.enableUiAnimations) {
startAnimation(hideAnimation);
} else {
setVisibility(View.GONE);
}
}
}

View File

@@ -14,6 +14,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.RelativeLayout.LayoutParams;
import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
import com.gpl.rpg.AndorsTrail.R;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
@@ -23,12 +24,18 @@ import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
public class DisplayActiveActorConditionIcons implements ActorConditionListener {
private final AndorsTrailPreferences preferences;
private final TileManager tileManager;
private final RelativeLayout activeConditions;
private final ArrayList<ActiveConditionIcon> currentConditionIcons = new ArrayList<ActiveConditionIcon>();
private final WeakReference<Context> androidContext;
public DisplayActiveActorConditionIcons(final TileManager tileManager, Context androidContext, RelativeLayout activeConditions) {
public DisplayActiveActorConditionIcons(
final AndorsTrailPreferences preferences,
final TileManager tileManager,
Context androidContext,
RelativeLayout activeConditions) {
this.preferences = preferences;
this.tileManager = tileManager;
this.androidContext = new WeakReference<Context>(androidContext);
this.activeConditions = activeConditions;
@@ -123,7 +130,11 @@ public class DisplayActiveActorConditionIcons implements ActorConditionListener
public void hide(boolean useAnimation) {
if (useAnimation) {
image.startAnimation(onRemovedIconAnimation);
if (preferences.enableUiAnimations) {
image.startAnimation(onRemovedIconAnimation);
} else {
onAnimationEnd(onRemovedIconAnimation);
}
} else {
image.setVisibility(View.GONE);
condition = null;
@@ -131,11 +142,13 @@ public class DisplayActiveActorConditionIcons implements ActorConditionListener
text.setVisibility(View.GONE);
}
public void show() {
if (!preferences.enableUiAnimations) return;
image.startAnimation(onNewIconAnimation);
if (text.getVisibility() == View.VISIBLE) text.startAnimation(onNewIconAnimation);
}
public void pulseAnimate() {
if (!preferences.enableUiAnimations) return;
image.startAnimation(onAppliedEffectAnimation);
}