new layout icon; plumbing added for switching between different keywords screens.
parent
7a4bc032ca
commit
5733457602
Binary file not shown.
After Width: | Height: | Size: 522 B |
|
@ -176,6 +176,9 @@ public class GeneralConfig {
|
|||
private static final String CUSTOM_SCROLLBAR = "customScrollBar";
|
||||
private boolean isCustomScrollBar = true;
|
||||
|
||||
private static final String KEYWORDS_SCREEN = "keywordsScreen";
|
||||
private String keywordsScreen;
|
||||
|
||||
private boolean isStatsVisible = true;
|
||||
|
||||
private GeneralConfig() { }
|
||||
|
@ -585,6 +588,7 @@ public class GeneralConfig {
|
|||
gameVolume = Integer.parseInt(properties.getProperty(GAME_VOLUME, "" + gameVolume));
|
||||
imagesOnDemand = Boolean.parseBoolean(properties.getProperty(IMAGES_ON_DEMAND, "" + imagesOnDemand));
|
||||
isCustomScrollBar = Boolean.parseBoolean(properties.getProperty(CUSTOM_SCROLLBAR, "" + isCustomScrollBar));
|
||||
keywordsScreen = properties.getProperty(KEYWORDS_SCREEN, "");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
@ -638,12 +642,13 @@ public class GeneralConfig {
|
|||
properties.setProperty(GAME_VOLUME, String.valueOf(gameVolume));
|
||||
properties.setProperty(IMAGES_ON_DEMAND, String.valueOf(imagesOnDemand));
|
||||
properties.setProperty(CUSTOM_SCROLLBAR, String.valueOf(isCustomScrollBar));
|
||||
properties.setProperty(KEYWORDS_SCREEN, keywordsScreen);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
final Properties properties=new SortedProperties();
|
||||
final Properties properties = new SortedProperties();
|
||||
save(properties);
|
||||
try { //save config
|
||||
try {
|
||||
FileIO.toFile(getConfigFile(), properties, "General configuration");
|
||||
} catch (final IOException ex) {
|
||||
System.err.println("ERROR! Unable to save general config");
|
||||
|
@ -724,4 +729,12 @@ public class GeneralConfig {
|
|||
return isCustomScrollBar;
|
||||
}
|
||||
|
||||
public void setKeywordsSettings(String text) {
|
||||
keywordsScreen = text;
|
||||
}
|
||||
|
||||
public String getKeywordsSettings() {
|
||||
return keywordsScreen;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public enum MagicIcon {
|
|||
INSTANTS("ui/w_instants.png"),
|
||||
KEY("ui/w_key16.png"),
|
||||
LANDS("ui/w_lands.png"),
|
||||
LAYOUT("ui/w-layout.png"),
|
||||
LAYOUT("ui/w_layout32D.png"),
|
||||
LEGAL("ui/card_legal.png"),
|
||||
LIFE("ui/w_life.png"),
|
||||
LOG_FILE("ui/w_log16.png"),
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package magic.ui.screen.keywords;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import magic.data.GeneralConfig;
|
||||
import magic.translate.UiString;
|
||||
import magic.ui.ScreenController;
|
||||
import magic.ui.helpers.KeyEventAction;
|
||||
import magic.ui.screen.HeaderFooterScreen;
|
||||
import magic.ui.screen.widget.MenuButton;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class KeywordsScreen extends HeaderFooterScreen {
|
||||
|
@ -15,7 +17,28 @@ public class KeywordsScreen extends HeaderFooterScreen {
|
|||
public KeywordsScreen() {
|
||||
super(UiString.get(_S1));
|
||||
setDefaultProperties();
|
||||
setMainContent(new KeywordsContentPanel());
|
||||
setContent();
|
||||
}
|
||||
|
||||
private void doSaveSettings() {
|
||||
final GeneralConfig config = GeneralConfig.getInstance();
|
||||
config.setKeywordsSettings(ScreenLayout.getLayout().name());
|
||||
|
||||
}
|
||||
|
||||
private void setContent() {
|
||||
setMainContent(ScreenLayout.getLayout() == ScreenLayout.Layout1
|
||||
? new KeywordsContentPanel()
|
||||
: new KeywordsContentPanel()
|
||||
);
|
||||
clearFooterButtons();
|
||||
addToFooter(MenuButton.buildLayoutButton(this::doChangeLayout));
|
||||
doSaveSettings();
|
||||
}
|
||||
|
||||
private void doChangeLayout() {
|
||||
ScreenLayout.setNextLayout();
|
||||
setContent();
|
||||
}
|
||||
|
||||
private void setDefaultProperties() {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package magic.ui.screen.keywords;
|
||||
|
||||
import magic.data.GeneralConfig;
|
||||
|
||||
enum ScreenLayout {
|
||||
|
||||
/**
|
||||
* Original two column text only on light background.
|
||||
*/
|
||||
Layout1,
|
||||
|
||||
/**
|
||||
* Multi-column list of keywords on dark translucent background.
|
||||
* Can show sample card image for selected keyword.
|
||||
*/
|
||||
Layout2A,
|
||||
|
||||
/**
|
||||
* Multi-column list of keywords on dark translucent background.
|
||||
* Can multiple sample card thumbnail images for selected keyword.
|
||||
*/
|
||||
Layout2B;
|
||||
|
||||
private static ScreenLayout layout;
|
||||
static {
|
||||
try {
|
||||
final String setting = GeneralConfig.getInstance().getKeywordsSettings();
|
||||
layout = setting.isEmpty() ? Layout1 : valueOf(setting);
|
||||
} catch (Exception ex) {
|
||||
System.err.println(ex);
|
||||
layout = Layout1;
|
||||
}
|
||||
}
|
||||
|
||||
private ScreenLayout next() {
|
||||
return values()[(this.ordinal()+1) % values().length];
|
||||
}
|
||||
|
||||
static void setNextLayout() {
|
||||
layout = layout.next();
|
||||
}
|
||||
|
||||
static ScreenLayout getLayout() {
|
||||
return layout;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import magic.ui.ScreenController;
|
|||
import magic.ui.helpers.ImageHelper;
|
||||
import magic.ui.utility.MagicStyle;
|
||||
import magic.ui.FontsAndBorders;
|
||||
import magic.ui.widget.button.LayoutButton;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class MenuButton extends JButton {
|
||||
|
@ -232,4 +233,12 @@ public class MenuButton extends JButton {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Action bar button used to change screen layout.
|
||||
*/
|
||||
public static MenuButton buildLayoutButton(final Runnable action) {
|
||||
return new LayoutButton(action);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package magic.ui.widget.button;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.AbstractAction;
|
||||
import magic.data.MagicIcon;
|
||||
import magic.ui.MagicImages;
|
||||
import magic.ui.screen.widget.ActionBarButton;
|
||||
|
||||
/**
|
||||
* Action bar button used to change screen layout.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class LayoutButton extends ActionBarButton {
|
||||
|
||||
private static final String _S7 = "Screen layout";
|
||||
private static final String _S8 = "Cycles through different screen layouts.";
|
||||
|
||||
public LayoutButton(final Runnable action) {
|
||||
super(MagicImages.getIcon(MagicIcon.LAYOUT), _S7, _S8,
|
||||
new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue