Now component animations and MainPagePanel animation can be disabled

This commit is contained in:
huangyuhui
2017-05-20 18:44:26 +08:00
parent 3462123877
commit 30ee33cd66
4 changed files with 14 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ import org.jackhuang.hmcl.util.CollectionUtils;
import org.jackhuang.hmcl.api.HMCLApi; import org.jackhuang.hmcl.api.HMCLApi;
import org.jackhuang.hmcl.api.event.config.ProfileChangedEvent; import org.jackhuang.hmcl.api.event.config.ProfileChangedEvent;
import org.jackhuang.hmcl.api.event.config.ProfileLoadingEvent; import org.jackhuang.hmcl.api.event.config.ProfileLoadingEvent;
import org.jackhuang.hmcl.laf.utils.AnimationController;
import org.jackhuang.hmcl.util.sys.FileUtils; import org.jackhuang.hmcl.util.sys.FileUtils;
import org.jackhuang.hmcl.util.MessageBox; import org.jackhuang.hmcl.util.MessageBox;
import org.jackhuang.hmcl.util.UpdateChecker; import org.jackhuang.hmcl.util.UpdateChecker;
@@ -56,6 +57,7 @@ public final class Settings {
static { static {
SETTINGS = initSettings(); SETTINGS = initSettings();
DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource().name()); DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource().name());
AnimationController.ENABLE_ANIMATION = SETTINGS.isEnableAnimation();
if (!getProfiles().containsKey(DEFAULT_PROFILE)) if (!getProfiles().containsKey(DEFAULT_PROFILE))
getProfiles().put(DEFAULT_PROFILE, new Profile(DEFAULT_PROFILE)); getProfiles().put(DEFAULT_PROFILE, new Profile(DEFAULT_PROFILE));

View File

@@ -17,6 +17,7 @@
*/ */
package org.jackhuang.hmcl.ui; package org.jackhuang.hmcl.ui;
import java.awt.Font;
import java.io.PrintStream; import java.io.PrintStream;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.text.Document; import javax.swing.text.Document;
@@ -53,6 +54,11 @@ public class LogWindow extends javax.swing.JFrame {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
setLocationRelativeTo(null); setLocationRelativeTo(null);
txtLog.setEditable(false); txtLog.setEditable(false);
Font font = Font.decode("Consolas");
if (font == null)
font = Font.decode("Monospace");
if (font != null)
txtLog.setFont(font);
}); });
} }

View File

@@ -68,6 +68,8 @@ public class MainPagePanel extends Page {
void initGui() { void initGui() {
initComponents(); initComponents();
animationEnabled = Settings.getInstance().isEnableAnimation();
pnlButtons = new javax.swing.JPanel(); pnlButtons = new javax.swing.JPanel();
pnlButtons.setLayout(null); pnlButtons.setLayout(null);

View File

@@ -60,6 +60,8 @@ import org.jackhuang.hmcl.laf.utils.TMSchema.Part;
* @author Igor Kushnirskiy * @author Igor Kushnirskiy
*/ */
public class AnimationController implements ActionListener, PropertyChangeListener { public class AnimationController implements ActionListener, PropertyChangeListener {
public static boolean ENABLE_ANIMATION = true;
private static AnimationController INSTANCE = new AnimationController(); private static AnimationController INSTANCE = new AnimationController();
private static final String ANIMATION_CONTROLLER_KEY = "BeautyEye.AnimationController"; private static final String ANIMATION_CONTROLLER_KEY = "BeautyEye.AnimationController";
@@ -205,7 +207,8 @@ public class AnimationController implements ActionListener, PropertyChangeListen
public static void paintSkin(JComponent component, Skin skin, public static void paintSkin(JComponent component, Skin skin,
Graphics g, int dx, int dy, int dw, int dh, State state) { Graphics g, int dx, int dy, int dw, int dh, State state) {
triggerAnimation(component, skin.getPart(component), state); if (ENABLE_ANIMATION)
triggerAnimation(component, skin.getPart(component), state);
AnimationController controller = getAnimationController(component); AnimationController controller = getAnimationController(component);
synchronized (controller) { synchronized (controller) {
AnimationState animationState = null; AnimationState animationState = null;