Add screen layout button to explorer; add DEFAULT and NO_SIDEBAR layouts.
parent
2090e56109
commit
3b3fa6bf81
Binary file not shown.
After Width: | Height: | Size: 179 B |
|
@ -5,6 +5,7 @@ import java.util.Set;
|
|||
|
||||
public enum MagicIcon {
|
||||
|
||||
LAYOUT_ICON("w-layout.png"),
|
||||
ILLEGAL_ICON("card_illegal.png"),
|
||||
LEGAL_ICON("card_legal.png"),
|
||||
BANNED_ICON("card_banned.png"),
|
||||
|
|
|
@ -37,6 +37,7 @@ public class ExplorerPanel extends JPanel implements ICardSelectionListener, ICa
|
|||
private List<MagicCardDefinition> cardPoolDefs;
|
||||
private ExplorerSidebarPanel sideBarPanel;
|
||||
private final MigLayout migLayout = new MigLayout();
|
||||
private final JPanel rhs = new JPanel();
|
||||
|
||||
public ExplorerPanel() {
|
||||
setupExplorerPanel();
|
||||
|
@ -52,8 +53,7 @@ public class ExplorerPanel extends JPanel implements ICardSelectionListener, ICa
|
|||
sideBarPanel = new ExplorerSidebarPanel();
|
||||
filterPanel = new CardFilterPanel(this);
|
||||
final Container cardsPanel = getMainContentContainer();
|
||||
|
||||
final JPanel rhs = new JPanel();
|
||||
|
||||
rhs.setLayout(new MigLayout("flowy, insets 0, gapy 0"));
|
||||
rhs.add(cardPoolTable.getTitleBar(), "w 100%");
|
||||
rhs.add(filterPanel, "w 100%, h " + FILTERS_PANEL_HEIGHT + "!");
|
||||
|
@ -63,8 +63,7 @@ public class ExplorerPanel extends JPanel implements ICardSelectionListener, ICa
|
|||
|
||||
migLayout.setLayoutConstraints("insets 0, gap 0");
|
||||
setLayout(migLayout);
|
||||
add(sideBarPanel, "h 100%");
|
||||
add(rhs, "w 100%, h 100%");
|
||||
refreshLayout();
|
||||
|
||||
// set initial card image
|
||||
if (cardPoolDefs.isEmpty()) {
|
||||
|
@ -162,4 +161,27 @@ public class ExplorerPanel extends JPanel implements ICardSelectionListener, ICa
|
|||
}
|
||||
}
|
||||
|
||||
private void doDefaultLayout() {
|
||||
removeAll();
|
||||
add(sideBarPanel, "h 100%");
|
||||
add(rhs, "w 100%, h 100%");
|
||||
validate();
|
||||
}
|
||||
|
||||
private void doNoSidebarLayout() {
|
||||
removeAll();
|
||||
add(rhs, "w 100%, h 100%");
|
||||
validate();
|
||||
}
|
||||
|
||||
public void refreshLayout() {
|
||||
final ExplorerScreenLayout layout = ExplorerScreenLayout.getLayout();
|
||||
if (layout == ExplorerScreenLayout.DEFAULT) {
|
||||
doDefaultLayout();
|
||||
} else if (layout == ExplorerScreenLayout.NO_SIDEBAR) {
|
||||
doNoSidebarLayout();
|
||||
} else {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package magic.ui.explorer;
|
||||
|
||||
public enum ExplorerScreenLayout {
|
||||
|
||||
DEFAULT,
|
||||
NO_SIDEBAR;
|
||||
|
||||
private static ExplorerScreenLayout activeLayout = DEFAULT;
|
||||
|
||||
private ExplorerScreenLayout next() {
|
||||
return values()[(this.ordinal()+1) % values().length];
|
||||
}
|
||||
|
||||
public static ExplorerScreenLayout getLayout() {
|
||||
return activeLayout;
|
||||
}
|
||||
|
||||
public static void setNextLayout() {
|
||||
activeLayout = activeLayout.next();
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import magic.ui.MagicImages;
|
|||
import magic.ui.MagicLogs;
|
||||
import magic.ui.ScreenOptionsOverlay;
|
||||
import magic.ui.explorer.ExplorerPanel;
|
||||
import magic.ui.explorer.ExplorerScreenLayout;
|
||||
import magic.ui.screen.interfaces.IActionBar;
|
||||
import magic.ui.screen.interfaces.IOptionsMenu;
|
||||
import magic.ui.screen.interfaces.IStatusBar;
|
||||
|
@ -43,12 +44,14 @@ public class CardExplorerScreen
|
|||
private static final String _S4 = "View the script and groovy files for the selected card.<br>(or double-click row)";
|
||||
private static final String _S5 = "Lucky Dip";
|
||||
private static final String _S6 = "Selects a random card from the list of cards displayed.";
|
||||
private static final String _S7 = "Change layout";
|
||||
private static final String _S8 = "Cycles through a number of different screen layouts.";
|
||||
|
||||
private final ExplorerPanel content;
|
||||
private final ExplorerPanel contentPanel;
|
||||
|
||||
public CardExplorerScreen() {
|
||||
content = new ExplorerPanel();
|
||||
setContent(content);
|
||||
contentPanel = new ExplorerPanel();
|
||||
setContent(contentPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,63 +68,90 @@ public class CardExplorerScreen
|
|||
public MenuButton getRightAction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuButton> getMiddleActions() {
|
||||
final List<MenuButton> buttons = new ArrayList<>();
|
||||
buttons.add(new ActionBarButton(
|
||||
|
||||
private MenuButton getCardScriptButton() {
|
||||
return new ActionBarButton(
|
||||
MagicImages.getIcon(MagicIcon.EDIT_ICON),
|
||||
UiString.get(_S3), UiString.get(_S4),
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
content.showCardScriptScreen();
|
||||
contentPanel.showCardScriptScreen();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
buttons.add(new ActionBarButton(
|
||||
}
|
||||
|
||||
private MenuButton getRandomCardButton() {
|
||||
return new ActionBarButton(
|
||||
MagicImages.getIcon(MagicIcon.RANDOM_ICON),
|
||||
UiString.get(UiString.get(_S5)), UiString.get(UiString.get(_S6)),
|
||||
UiString.get(_S5), UiString.get(_S6),
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
content.selectRandomCard();
|
||||
contentPanel.selectRandomCard();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
if (MagicSystem.isDevMode() || MagicSystem.isDebugMode()) {
|
||||
buttons.add(new ActionBarButton(
|
||||
MagicImages.getIcon(MagicIcon.SAVE_ICON),
|
||||
"Save Missing Cards [DevMode Only]", "Creates CardsMissingInMagarena.txt which can be used by the Scripts Builder.",
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
try {
|
||||
saveMissingCardsList();
|
||||
} catch (IOException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
|
||||
private MenuButton getMissingCardsButton() {
|
||||
return new ActionBarButton(
|
||||
MagicImages.getIcon(MagicIcon.SAVE_ICON),
|
||||
"Save Missing Cards [DevMode Only]", "Creates CardsMissingInMagarena.txt which can be used by the Scripts Builder.",
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
try {
|
||||
saveMissingCardsList();
|
||||
} catch (IOException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
buttons.add(new ActionBarButton(
|
||||
MagicImages.getIcon(MagicIcon.STATS_ICON),
|
||||
"Save Statistics [DevMode Only]", "Creates CardStatistics.txt to view current card completion.",
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
try {
|
||||
MagicSetDefinitions.createSetStatistics();
|
||||
} catch (IOException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private MenuButton getStatsButton() {
|
||||
return new ActionBarButton(
|
||||
MagicImages.getIcon(MagicIcon.STATS_ICON),
|
||||
"Save Statistics [DevMode Only]", "Creates CardStatistics.txt to view current card completion.",
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
try {
|
||||
MagicSetDefinitions.createSetStatistics();
|
||||
} catch (IOException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private MenuButton getLayoutButton() {
|
||||
return new ActionBarButton(
|
||||
MagicImages.getIcon(MagicIcon.LAYOUT_ICON),
|
||||
UiString.get(_S7), UiString.get(_S8),
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ExplorerScreenLayout.setNextLayout();
|
||||
contentPanel.refreshLayout();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuButton> getMiddleActions() {
|
||||
final List<MenuButton> buttons = new ArrayList<>();
|
||||
buttons.add(getCardScriptButton());
|
||||
buttons.add(getRandomCardButton());
|
||||
buttons.add(getLayoutButton());
|
||||
if (MagicSystem.isDevMode()) {
|
||||
buttons.add(getMissingCardsButton());
|
||||
buttons.add(getStatsButton());
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue