refactor, preferences: min/max permanents size settings replaced by single size, removed un-used code, fixed starting tab on game preferences use;

This commit is contained in:
Oleg Agafonov 2024-08-13 00:08:13 +04:00
parent 754e5fc41a
commit bc64ebca14
5 changed files with 15 additions and 52 deletions

View file

@ -64,16 +64,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_GAME_USE_PROFANITY_FILTER = "gameUseProfanityFilter"; public static final String KEY_GAME_USE_PROFANITY_FILTER = "gameUseProfanityFilter";
// size settings // size settings
public static final String KEY_GUI_CHAT_FONT_SIZE = "guiChatFontSize"; public static final String KEY_GUI_CARD_BATTLEFIELD_SIZE = "guiCardBattlefieldSize";
public static final String KEY_GUI_CARD_HAND_SIZE = "guiCardHandSize"; public static final String KEY_GUI_CARD_HAND_SIZE = "guiCardHandSize";
public static final String KEY_GUI_CARD_EDITOR_SIZE = "guiCardEditorSize"; public static final String KEY_GUI_CARD_EDITOR_SIZE = "guiCardEditorSize";
public static final String KEY_GUI_STACK_WIDTH = "guiStackWidth";
public static final String KEY_GUI_TOOLTIP_SIZE = "guiTooltipSize";
public static final String KEY_GUI_DIALOG_FONT_SIZE = "guiDialogFontSize";
public static final String KEY_GUI_CARD_OTHER_ZONES_SIZE = "guiCardOtherZonesSize"; public static final String KEY_GUI_CARD_OTHER_ZONES_SIZE = "guiCardOtherZonesSize";
public static final String KEY_GUI_CARD_BATTLEFIELD_MIN_SIZE = "guiCardBattlefieldMinSize"; public static final String KEY_GUI_DIALOG_FONT_SIZE = "guiDialogFontSize";
public static final String KEY_GUI_CARD_BATTLEFIELD_MAX_SIZE = "guiCardBattlefieldMaxSize"; public static final String KEY_GUI_CHAT_FONT_SIZE = "guiChatFontSize";
public static final String KEY_GUI_PLAYER_PANEL_SIZE = "guiPlayerPanelSize"; public static final String KEY_GUI_PLAYER_PANEL_SIZE = "guiPlayerPanelSize";
public static final String KEY_GUI_TOOLTIP_SIZE = "guiTooltipSize";
public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave"; public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave";
public static final String KEY_DRAFT_LOG_AUTO_SAVE = "draftLogAutoSave"; public static final String KEY_DRAFT_LOG_AUTO_SAVE = "draftLogAutoSave";
@ -568,11 +566,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
createSizeSetting(4, KEY_GUI_TOOLTIP_SIZE,17, true, "Size of popup card hint", "The size of the tooltip window for cards or permanents (use mouse wheel to switch text/image mode)"); createSizeSetting(4, KEY_GUI_TOOLTIP_SIZE,17, true, "Size of popup card hint", "The size of the tooltip window for cards or permanents (use mouse wheel to switch text/image mode)");
// Game's elements (from position 8) // Game's elements (from position 8)
createSizeSetting(8, KEY_GUI_PLAYER_PANEL_SIZE,14, false, "Size of player panel", "The size of the player panels on battlefield"); createSizeSetting(8, KEY_GUI_PLAYER_PANEL_SIZE,14, false, "Size of player panel", "The size of the player panels on battlefield");
createSizeSetting(9, KEY_GUI_CARD_HAND_SIZE,14, false, "Size of cards in hand and stack", "The size of the card images in hand and on the stack"); createSizeSetting(9, KEY_GUI_CARD_BATTLEFIELD_SIZE,14, false, "Size of permanents in battlefield", "Average permanents size on battlefield (app will auto-size it depends on free space");
createSizeSetting(10, KEY_GUI_STACK_WIDTH,14, false, "Size of stack zone (right of the hand)", "The % size of the stack object area in relation to the hand card area size."); // TODO: delete createSizeSetting(10, KEY_GUI_CARD_HAND_SIZE,14, false, "Size of cards in hand and stack", "The size of the card images in hand and on the stack");
createSizeSetting(11, KEY_GUI_CARD_OTHER_ZONES_SIZE,14, false, "Size of cards in other zones", "The size of card in other game zone (e.g. graveyard, revealed cards etc.)"); createSizeSetting(11, KEY_GUI_CARD_OTHER_ZONES_SIZE,14, false, "Size of cards in other zones", "The size of card in other game zone (e.g. graveyard, revealed cards etc.)");
createSizeSetting(12, KEY_GUI_CARD_BATTLEFIELD_MIN_SIZE,10, false, "Size of permanents (min)", "The minimum size of permanents on the battlefield");
createSizeSetting(13, KEY_GUI_CARD_BATTLEFIELD_MAX_SIZE,14, false, "Size of permanents (max)", "The maximum size of permanents on the battlefield");
// hide unused controls // hide unused controls
hideUnusedSizeSettings(); hideUnusedSizeSettings();
@ -3162,11 +3158,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
int param = 0; int param = 0;
if (args.length > 0) { if (args.length > 0) {
String param1 = args[0]; String param1 = args[0];
if (param1.equals(OPEN_CONNECTION_TAB)) {
param = 8;
}
if (param1.equals(OPEN_PHASES_TAB)) { if (param1.equals(OPEN_PHASES_TAB)) {
param = 6; param = 5;
}
if (param1.equals(OPEN_CONNECTION_TAB)) {
param = 5 + 3;
} }
} }
final int openedTab = param; final int openedTab = param;

View file

@ -1095,7 +1095,6 @@ public final class GamePanel extends javax.swing.JPanel {
gamePane.setTitle(sb.toString()); gamePane.setTitle(sb.toString());
} }
GameManager.instance.setStackSize(lastGameData.game.getStack().size());
displayStack(lastGameData.game, bigCard, feedbackPanel, gameId); displayStack(lastGameData.game, bigCard, feedbackPanel, gameId);
// auto-show exile views // auto-show exile views

View file

@ -10,7 +10,6 @@ import mage.client.draft.DraftPanel;
import mage.client.game.GamePanel; import mage.client.game.GamePanel;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.DeckUtil; import mage.client.util.DeckUtil;
import mage.client.util.GameManager;
import mage.client.util.IgnoreList; import mage.client.util.IgnoreList;
import mage.client.util.audio.AudioManager; import mage.client.util.audio.AudioManager;
import mage.client.util.object.SaveObjectUtil; import mage.client.util.object.SaveObjectUtil;
@ -112,7 +111,6 @@ public class CallbackClientImpl implements CallbackClient {
case START_GAME: { case START_GAME: {
TableClientMessage message = (TableClientMessage) callback.getData(); TableClientMessage message = (TableClientMessage) callback.getData();
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
gameStarted(callback.getMessageId(), message.getCurrentTableId(), message.getParentTableId(), message.getGameId(), message.getPlayerId()); gameStarted(callback.getMessageId(), message.getCurrentTableId(), message.getParentTableId(), message.getGameId(), message.getPlayerId());
// reconnect fix with miss data, part 2 of 2 // reconnect fix with miss data, part 2 of 2

View file

@ -166,10 +166,11 @@ public final class GUISizeHelper {
otherZonesCardVerticalOffset = otherZonesCardDimension.height / 10; otherZonesCardVerticalOffset = otherZonesCardDimension.height / 10;
} }
int battlefieldCardMinSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_BATTLEFIELD_MIN_SIZE, 10); int battlefieldCardAvgSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_BATTLEFIELD_SIZE, 14);
battlefieldCardMinDimension = new Dimension(CARD_IMAGE_WIDTH * battlefieldCardMinSize / 42, CARD_IMAGE_HEIGHT * battlefieldCardMinSize / 42); int battlefieldMinSize = guiSizeScale(battlefieldCardAvgSize, 0.5f);
int battlefieldCardMaxSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_BATTLEFIELD_MAX_SIZE, 14); int battlefieldMaxSize = guiSizeScale(battlefieldCardAvgSize, 2.0f);
battlefieldCardMaxDimension = new Dimension(CARD_IMAGE_WIDTH * battlefieldCardMaxSize / 42, CARD_IMAGE_HEIGHT * battlefieldCardMaxSize / 42); battlefieldCardMinDimension = new Dimension(CARD_IMAGE_WIDTH * battlefieldMinSize / 42, CARD_IMAGE_HEIGHT * battlefieldMinSize / 42);
battlefieldCardMaxDimension = new Dimension(CARD_IMAGE_WIDTH * battlefieldMaxSize / 42, CARD_IMAGE_HEIGHT * battlefieldMaxSize / 42);
// app - deck editor and draft // app - deck editor and draft
int editorCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_EDITOR_SIZE, 14); int editorCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_EDITOR_SIZE, 14);

View file

@ -1,31 +0,0 @@
package mage.client.util;
import java.util.UUID;
/**
* Controls game state on client side.
*
* @author nantuko
*/
public enum GameManager {
instance;
public void setStackSize(int stackSize) {
this.stackSize = stackSize;
}
public int getStackSize() {
return stackSize;
}
public UUID getCurrentPlayerUUID() {
return currentPlayerUUID;
}
public void setCurrentPlayerUUID(UUID currentPlayerUUID) {
this.currentPlayerUUID = currentPlayerUUID;
}
private int stackSize;
private UUID currentPlayerUUID;
}