mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-20 02:21:11 +01:00
Add setting "Show quickslots when toolbox is opened"
This commit is contained in:
@@ -588,6 +588,8 @@ Every skill level increases the attack chance of weapons with %1$d %% of their o
|
||||
<string name="preferences_quickslots_placements_horizontal_bottom_left">Bottom left, along bottom border</string>
|
||||
<string name="preferences_quickslots_placements_horizontal_bottom_right">Bottom right, along bottom border</string>
|
||||
<string name="preferences_quickslots_placements_vertical_bottom_right">Bottom right, along right border</string>
|
||||
<string name="preferences_ui_show_quickslots_when_toolbox_is_visible_title">Show quickslots when toolbox is opened</string>
|
||||
<string name="preferences_ui_show_quickslots_when_toolbox_is_visible">Makes the quickslot buttons be displayed as soon as the toolbox is opened</string>
|
||||
<string name="startscreen_incompatible_savegames">This is a development version of Andor\'s Trail. Savegames produced by this version are incompatible with the release version.</string>
|
||||
<string name="startscreen_non_release_version">This is a prerelease version of Andor\'s Trail. Savegames produced by this version might not be compatible with the release version.</string>
|
||||
<string name="heroinfo_gamestats">Game statistics</string>
|
||||
|
||||
@@ -93,5 +93,10 @@
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/preferences_quickslots_placements"
|
||||
android:entryValues="@array/preferences_quickslots_placements_values" />
|
||||
<CheckBoxPreference
|
||||
android:title="@string/preferences_ui_show_quickslots_when_toolbox_is_visible_title"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/preferences_ui_show_quickslots_when_toolbox_is_visible"
|
||||
android:key="showQuickslotsWhenToolboxIsVisible" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -50,6 +50,7 @@ public final class AndorsTrailPreferences {
|
||||
public boolean enableUiAnimations = true;
|
||||
public int displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
public int quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
public boolean showQuickslotsWhenToolboxIsVisible = false;
|
||||
|
||||
public void read(final Context androidContext) {
|
||||
AndorsTrailPreferences dest = this;
|
||||
@@ -68,6 +69,7 @@ public final class AndorsTrailPreferences {
|
||||
dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true);
|
||||
dest.displayOverwriteSavegame = Integer.parseInt(prefs.getString("display_overwrite_savegame", Integer.toString(CONFIRM_OVERWRITE_SAVEGAME_ALWAYS)));
|
||||
dest.quickslotsPosition = Integer.parseInt(prefs.getString("quickslots_placement", Integer.toString(QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM)));
|
||||
dest.showQuickslotsWhenToolboxIsVisible = prefs.getBoolean("showQuickslotsWhenToolboxIsVisible", false);
|
||||
|
||||
// This might be implemented as a skill in the future.
|
||||
//dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL)));
|
||||
@@ -86,6 +88,7 @@ public final class AndorsTrailPreferences {
|
||||
dest.enableUiAnimations = true;
|
||||
dest.displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS;
|
||||
dest.quickslotsPosition = QUICKSLOTS_POSITION_HORIZONTAL_CENTER_BOTTOM;
|
||||
dest.showQuickslotsWhenToolboxIsVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,9 @@ public final class StatusView extends RelativeLayout implements PlayerStatsListe
|
||||
private final RangeBar healthBar;
|
||||
private final RangeBar expBar;
|
||||
private final ImageButton heroImage;
|
||||
private final ImageButton toggleToolbox;
|
||||
private boolean showingLevelup;
|
||||
private final Drawable levelupDrawable;
|
||||
private ToolboxView toolbox;
|
||||
|
||||
|
||||
public StatusView(final Context context, AttributeSet attr) {
|
||||
super(context, attr);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
@@ -67,24 +65,13 @@ public final class StatusView extends RelativeLayout implements PlayerStatsListe
|
||||
new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(player.iconID))
|
||||
,new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(TileManager.iconID_moveselect))
|
||||
});
|
||||
|
||||
toggleToolbox = (ImageButton) findViewById(R.id.toolbox_toggle);
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleToolbox, TileManager.iconID_boxclosed);
|
||||
toggleToolbox.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toolbox.toggleVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
updateStatus();
|
||||
updateIcon(player.canLevelup());
|
||||
}
|
||||
|
||||
public void registerToolboxViews(ToolboxView toolbox, QuickitemView quickitemView) {
|
||||
this.toolbox = toolbox;
|
||||
toolbox.registerToolboxViews(toggleToolbox, quickitemView);
|
||||
toolbox.updateIcons();
|
||||
toolbox.registerToolboxViews((ImageButton) findViewById(R.id.toolbox_toggle), quickitemView);
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -30,8 +34,11 @@ public final class ToolboxView extends LinearLayout implements OnClickListener {
|
||||
private final ImageButton toolbox_map;
|
||||
private final ImageButton toolbox_save;
|
||||
private final ImageButton toolbox_combatlog;
|
||||
private ImageButton toggleVisibility;
|
||||
private ImageButton toggleToolboxVisibility;
|
||||
private QuickitemView quickitemView;
|
||||
private boolean hideQuickslotsWhenToolboxIsClosed = false;
|
||||
private static final int quickSlotIcon = R.drawable.ui_icon_equipment;
|
||||
private final Drawable quickSlotIconsLockedDrawable;
|
||||
|
||||
public ToolboxView(final Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -60,18 +67,29 @@ public final class ToolboxView extends LinearLayout implements OnClickListener {
|
||||
toolbox_save.setOnClickListener(this);
|
||||
toolbox_combatlog = (ImageButton)findViewById(R.id.toolbox_combatlog);
|
||||
toolbox_combatlog.setOnClickListener(this);
|
||||
|
||||
Resources res = getResources();
|
||||
quickSlotIconsLockedDrawable = new LayerDrawable(new Drawable[] {
|
||||
res.getDrawable(quickSlotIcon)
|
||||
,new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(TileManager.iconID_moveselect))
|
||||
});
|
||||
hideQuickslotsWhenToolboxIsClosed = preferences.showQuickslotsWhenToolboxIsVisible;
|
||||
}
|
||||
|
||||
public void registerToolboxViews(ImageButton toggleVisibility, QuickitemView quickitemView) {
|
||||
this.toggleVisibility = toggleVisibility;
|
||||
this.toggleToolboxVisibility = toggleVisibility;
|
||||
this.quickitemView = quickitemView;
|
||||
toggleVisibility.setOnClickListener(this);
|
||||
updateIcons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View btn) {
|
||||
Context context = getContext();
|
||||
if (btn == toolbox_quickitems) {
|
||||
toggleQuickItemView();
|
||||
if (btn == toggleToolboxVisibility) {
|
||||
toggleVisibility();
|
||||
} else if (btn == toolbox_quickitems) {
|
||||
toggleQuickslotItemView();
|
||||
} else if (btn == toolbox_map) {
|
||||
if (!WorldMapController.displayWorldMap(context, world)) return;
|
||||
setVisibility(View.GONE);
|
||||
@@ -87,29 +105,51 @@ public final class ToolboxView extends LinearLayout implements OnClickListener {
|
||||
if (getVisibility() == View.GONE) setToolboxIcon(false);
|
||||
}
|
||||
|
||||
private void toggleQuickItemView() {
|
||||
if (quickitemView.getVisibility() == View.VISIBLE){
|
||||
quickitemView.setVisibility(View.GONE);
|
||||
private void toggleQuickslotItemView() {
|
||||
if (preferences.showQuickslotsWhenToolboxIsVisible) {
|
||||
hideQuickslotsWhenToolboxIsClosed = !hideQuickslotsWhenToolboxIsClosed;
|
||||
updateToggleQuickSlotItemsIcon();
|
||||
} else {
|
||||
quickitemView.setVisibility(View.VISIBLE);
|
||||
if (quickitemView.getVisibility() == View.VISIBLE) {
|
||||
quickitemView.setVisibility(View.GONE);
|
||||
} else {
|
||||
quickitemView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleVisibility() {
|
||||
if (getVisibility() == View.VISIBLE) {
|
||||
private void toggleVisibility() {
|
||||
if (getVisibility() == View.VISIBLE) hide();
|
||||
else show();
|
||||
}
|
||||
|
||||
private void hide() {
|
||||
if (getVisibility() != View.GONE) {
|
||||
if (preferences.enableUiAnimations) {
|
||||
startAnimation(hideAnimation);
|
||||
} else {
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
setToolboxIcon(false);
|
||||
} else {
|
||||
}
|
||||
if (preferences.showQuickslotsWhenToolboxIsVisible) {
|
||||
if (hideQuickslotsWhenToolboxIsClosed) {
|
||||
quickitemView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
setToolboxIcon(false);
|
||||
}
|
||||
|
||||
private void show() {
|
||||
if (getVisibility() != View.VISIBLE) {
|
||||
setVisibility(View.VISIBLE);
|
||||
if (preferences.enableUiAnimations) {
|
||||
startAnimation(showAnimation);
|
||||
}
|
||||
setToolboxIcon(true);
|
||||
}
|
||||
if (preferences.showQuickslotsWhenToolboxIsVisible) {
|
||||
quickitemView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
setToolboxIcon(true);
|
||||
}
|
||||
|
||||
public void updateIcons() {
|
||||
@@ -118,9 +158,17 @@ public final class ToolboxView extends LinearLayout implements OnClickListener {
|
||||
|
||||
private void setToolboxIcon(boolean opened) {
|
||||
if (opened) {
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleVisibility, TileManager.iconID_boxopened);
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleToolboxVisibility, TileManager.iconID_boxopened);
|
||||
} else {
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleVisibility, TileManager.iconID_boxclosed);
|
||||
world.tileManager.setImageViewTileForUIIcon(toggleToolboxVisibility, TileManager.iconID_boxclosed);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateToggleQuickSlotItemsIcon() {
|
||||
if (preferences.showQuickslotsWhenToolboxIsVisible && !hideQuickslotsWhenToolboxIsClosed) {
|
||||
toolbox_quickitems.setImageDrawable(quickSlotIconsLockedDrawable);
|
||||
return;
|
||||
}
|
||||
toolbox_quickitems.setImageDrawable(getResources().getDrawable(quickSlotIcon));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user