Add option to switch on/off animation in card flow screen (on by default).
parent
6555972ec3
commit
b4de9f2030
|
@ -446,7 +446,12 @@ class CardFlowPanel extends JPanel implements TimelineCallback {
|
|||
flowDirection = FlowDirection.RIGHT;
|
||||
activeImageIndex = activeImageIndex - 1;
|
||||
timelinePulse = 0.0f;
|
||||
timeline.play();
|
||||
if (settings.isAnimationEnabled()) {
|
||||
timeline.play();
|
||||
} else {
|
||||
onTimelinePulse(0, 1.0f);
|
||||
notifyOnNewActiveImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +462,12 @@ class CardFlowPanel extends JPanel implements TimelineCallback {
|
|||
flowDirection = FlowDirection.LEFT;
|
||||
activeImageIndex = activeImageIndex + 1;
|
||||
timelinePulse = 0.0f;
|
||||
timeline.play();
|
||||
if (settings.isAnimationEnabled()) {
|
||||
timeline.play();
|
||||
} else {
|
||||
onTimelinePulse(0, 1.0f);
|
||||
notifyOnNewActiveImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -503,4 +513,8 @@ class CardFlowPanel extends JPanel implements TimelineCallback {
|
|||
repaintCardFlowImage();
|
||||
}
|
||||
|
||||
void setAnimation(boolean b) {
|
||||
settings.setAnimationEnabled(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import magic.data.MagicIcon;
|
|||
import magic.model.IRenderableCard;
|
||||
import magic.model.MagicCardDefinition;
|
||||
import magic.model.MagicRandom;
|
||||
import magic.translate.MText;
|
||||
import magic.ui.MagicImages;
|
||||
import magic.ui.ScreenController;
|
||||
import magic.ui.dialog.prefs.ImageSizePresets;
|
||||
|
@ -155,6 +156,11 @@ public class CardFlowScreen extends HeaderFooterScreen
|
|||
flashOverlay.flashText(preset.name().replaceAll("SIZE_", "").replaceAll("x", " x "));
|
||||
}
|
||||
|
||||
void setAnimateSetting(boolean b) {
|
||||
cardFlowPanel.setAnimation(b);
|
||||
flashOverlay.flashText(b ? MText.get("On") : MText.get("Off"));
|
||||
}
|
||||
|
||||
void setImageSize(ImageSizePresets preset) {
|
||||
cardFlowPanel.setImageSize(preset);
|
||||
flashImageSizePreset(preset);
|
||||
|
|
|
@ -57,6 +57,7 @@ public class FlashTextOverlay extends TexturedPanel {
|
|||
this.text = text;
|
||||
timer.restart();
|
||||
setVisible(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void paintFlashText(Graphics2D g2d) {
|
||||
|
|
|
@ -15,8 +15,10 @@ class OptionsPanel extends ScreenOptionsPanel {
|
|||
|
||||
// translatable UI text (prefix with _S).
|
||||
private static final String _S1 = "Scale";
|
||||
private static final String _S2 = "Animate";
|
||||
|
||||
private final BigDialButton scaleButton;
|
||||
private final BigDialButton animateButton;
|
||||
private ImageSizePresets sizePreset;
|
||||
private final ScreenSettings settings;
|
||||
private final CardFlowScreen screen;
|
||||
|
@ -26,6 +28,7 @@ class OptionsPanel extends ScreenOptionsPanel {
|
|||
this.settings = settings;
|
||||
sizePreset = settings.getImageSizePreset();
|
||||
scaleButton = new BigDialButton(getScaleOptionHandler());
|
||||
animateButton = new BigDialButton(getAnimateOptionHandler());
|
||||
setLayout();
|
||||
}
|
||||
|
||||
|
@ -66,10 +69,43 @@ class OptionsPanel extends ScreenOptionsPanel {
|
|||
};
|
||||
}
|
||||
|
||||
private IDialButtonHandler getAnimateOptionHandler() {
|
||||
return new IDialButtonHandler() {
|
||||
private void doDialClickAction(int position) {
|
||||
settings.setAnimationEnabled(position == 0);
|
||||
screen.setAnimateSetting(settings.isAnimationEnabled());
|
||||
}
|
||||
@Override
|
||||
public int getDialPositionsCount() {
|
||||
return 2;
|
||||
}
|
||||
@Override
|
||||
public int getDialPosition() {
|
||||
return settings.isAnimationEnabled() ? 0 : 1;
|
||||
}
|
||||
@Override
|
||||
public boolean doLeftClickAction(int dialPosition) {
|
||||
doDialClickAction(dialPosition);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean doRightClickAction(int dialPosition) {
|
||||
doDialClickAction(dialPosition);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void onMouseEntered(int dialPosition) {
|
||||
screen.setAnimateSetting(settings.isAnimationEnabled());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setLayout() {
|
||||
removeAll();
|
||||
if (isMenuOpen) {
|
||||
add(getLabel(MText.get(_S2)), "ax center, w 60!");
|
||||
add(animateButton, "ax center, h 24!, w 24!, gapbottom 2");
|
||||
add(getLabel(MText.get(_S1)), "ax center, w 60!");
|
||||
add(scaleButton, "ax center, h 24!, w 24!, gapbottom 2");
|
||||
add(closeButton, "spany 2, h 32!, w 32!");
|
||||
|
|
|
@ -10,11 +10,25 @@ class ScreenSettings {
|
|||
|
||||
private ImageSizePresets sizePreset;
|
||||
private final boolean useOpaqueCardFlowImage;
|
||||
private boolean isAnimationEnabled;
|
||||
|
||||
public ScreenSettings() {
|
||||
String settings = GeneralConfig.get(StringSetting.CARDFLOW_SETTINGS);
|
||||
sizePreset = getImageSizePreset(settings);
|
||||
useOpaqueCardFlowImage = getUseOpaqueImageFlag(settings);
|
||||
isAnimationEnabled = isAnimationEnabled(settings);
|
||||
}
|
||||
|
||||
private boolean isAnimationEnabled(String settings) {
|
||||
try {
|
||||
return Boolean.valueOf(settings.split(DELIM)[2]);
|
||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void setAnimationEnabled(boolean b) {
|
||||
isAnimationEnabled = b;
|
||||
}
|
||||
|
||||
private boolean getUseOpaqueImageFlag(String settings) {
|
||||
|
@ -45,6 +59,7 @@ class ScreenSettings {
|
|||
GeneralConfig.set(StringSetting.CARDFLOW_SETTINGS,
|
||||
sizePreset.name() + DELIM
|
||||
+ useOpaqueCardFlowImage + DELIM
|
||||
+ isAnimationEnabled + DELIM
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -52,4 +67,8 @@ class ScreenSettings {
|
|||
return useOpaqueCardFlowImage;
|
||||
}
|
||||
|
||||
boolean isAnimationEnabled() {
|
||||
return isAnimationEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue