mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Some fixes for the sort setting of deck editor.
This commit is contained in:
parent
9dc1120500
commit
00b03c91b6
5 changed files with 24 additions and 59 deletions
|
|
@ -28,11 +28,6 @@
|
|||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import static mage.client.constants.Constants.SortBy.CASTING_COST;
|
||||
import static mage.client.constants.Constants.SortBy.COLOR;
|
||||
import static mage.client.constants.Constants.SortBy.COLOR_DETAILED;
|
||||
import static mage.client.constants.Constants.SortBy.NAME;
|
||||
import static mage.client.constants.Constants.SortBy.RARITY;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
|
|
@ -45,19 +40,32 @@ public abstract class SortSetting {
|
|||
int sortIndex;
|
||||
boolean ascending;
|
||||
|
||||
String prefSortBy;
|
||||
String prefSortIndex;
|
||||
String prefSortAscending;
|
||||
|
||||
public SortSetting(String prefSortBy, String prefSortIndex, String prefSortAscending) {
|
||||
this.prefSortBy = prefSortBy;
|
||||
this.prefSortIndex = prefSortIndex;
|
||||
this.prefSortAscending = prefSortAscending;
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(this.prefSortBy, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(this.prefSortIndex, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(this.prefSortAscending, "1").equals("1");
|
||||
}
|
||||
|
||||
public void setSortBy(SortBy sortBy) {
|
||||
this.sortBy = sortBy;
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_SORT_BY, sortBy.toString());
|
||||
PreferencesDialog.saveValue(prefSortBy, sortBy.toString());
|
||||
}
|
||||
|
||||
public void setSortIndex(int sortIndex) {
|
||||
this.sortIndex = sortIndex;
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_SORT_INDEX, Integer.toString(sortIndex));
|
||||
PreferencesDialog.saveValue(this.prefSortIndex, Integer.toString(sortIndex));
|
||||
}
|
||||
|
||||
public void setAscending(boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_SORT_ASCENDING, this.ascending ? "1":"0");
|
||||
PreferencesDialog.saveValue(this.prefSortAscending, this.ascending ? "1":"0");
|
||||
}
|
||||
|
||||
public SortBy getSortBy() {
|
||||
|
|
@ -71,35 +79,4 @@ public abstract class SortSetting {
|
|||
public boolean isAscending() {
|
||||
return ascending;
|
||||
}
|
||||
|
||||
public int convertSortByToIndex(SortBy sortBy) {
|
||||
switch(sortBy) {
|
||||
case NAME:
|
||||
return 1;
|
||||
case CASTING_COST:
|
||||
return 2;
|
||||
case COLOR:
|
||||
case COLOR_DETAILED:
|
||||
return 3;
|
||||
case RARITY:
|
||||
return 5;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public SortBy convertIndexToSortBy(int index) {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return SortBy.NAME;
|
||||
case 2:
|
||||
return SortBy.CASTING_COST;
|
||||
case 3:
|
||||
return SortBy.COLOR;
|
||||
case 5:
|
||||
return SortBy.RARITY;
|
||||
default:
|
||||
return SortBy.UNSORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
|
|
@ -37,15 +36,13 @@ import mage.client.dialog.PreferencesDialog;
|
|||
|
||||
public class SortSettingBase extends SortSetting {
|
||||
|
||||
private static SortSettingBase fInstance = new SortSettingBase();
|
||||
private final static SortSettingBase fInstance = new SortSettingBase();
|
||||
|
||||
public static SortSettingBase getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private SortSettingBase() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BASE_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BASE_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BASE_SORT_INDEX, "1").equals("1");
|
||||
super(PreferencesDialog.KEY_BASE_SORT_BY, PreferencesDialog.KEY_BASE_SORT_INDEX, PreferencesDialog.KEY_BASE_SORT_ASCENDING);
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
|
|
@ -37,15 +36,13 @@ import mage.client.dialog.PreferencesDialog;
|
|||
|
||||
public class SortSettingDeck extends SortSetting {
|
||||
|
||||
private static SortSettingDeck fInstance = new SortSettingDeck();
|
||||
private final static SortSettingDeck fInstance = new SortSettingDeck();
|
||||
|
||||
public static SortSettingDeck getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private SortSettingDeck() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DECK_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DECK_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DECK_SORT_INDEX, "1").equals("1");
|
||||
super(PreferencesDialog.KEY_DECK_SORT_BY, PreferencesDialog.KEY_DECK_SORT_INDEX, PreferencesDialog.KEY_DECK_SORT_ASCENDING);
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
|
|
@ -37,15 +36,13 @@ import mage.client.dialog.PreferencesDialog;
|
|||
*/
|
||||
public class SortSettingDraft extends SortSetting {
|
||||
|
||||
private static SortSettingDraft fInstance = new SortSettingDraft();
|
||||
private final static SortSettingDraft fInstance = new SortSettingDraft();
|
||||
|
||||
public static SortSettingDraft getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private SortSettingDraft() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_SORT_INDEX, "1").equals("1");
|
||||
super(PreferencesDialog.KEY_DRAFT_SORT_BY, PreferencesDialog.KEY_DRAFT_SORT_INDEX,PreferencesDialog.KEY_DRAFT_SORT_INDEX );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
|
|
@ -44,8 +43,6 @@ public class SortSettingSideboard extends SortSetting {
|
|||
}
|
||||
|
||||
private SortSettingSideboard() {
|
||||
this.sortBy = SortBy.getByString(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SIDEBOARD_SORT_BY, "Color"));
|
||||
this.sortIndex = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX, "1"));
|
||||
this.ascending = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX, "1").equals("1");
|
||||
super(PreferencesDialog.KEY_SIDEBOARD_SORT_BY, PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX, PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue