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.event.config.ProfileChangedEvent;
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.MessageBox;
import org.jackhuang.hmcl.util.UpdateChecker;
@ -56,6 +57,7 @@ public final class Settings {
static {
SETTINGS = initSettings();
DownloadType.setSuggestedDownloadType(SETTINGS.getDownloadSource().name());
AnimationController.ENABLE_ANIMATION = SETTINGS.isEnableAnimation();
if (!getProfiles().containsKey(DEFAULT_PROFILE))
getProfiles().put(DEFAULT_PROFILE, new Profile(DEFAULT_PROFILE));

View File

@ -17,6 +17,7 @@
*/
package org.jackhuang.hmcl.ui;
import java.awt.Font;
import java.io.PrintStream;
import javax.swing.SwingUtilities;
import javax.swing.text.Document;
@ -53,6 +54,11 @@ public class LogWindow extends javax.swing.JFrame {
SwingUtilities.invokeLater(() -> {
setLocationRelativeTo(null);
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() {
initComponents();
animationEnabled = Settings.getInstance().isEnableAnimation();
pnlButtons = new javax.swing.JPanel();
pnlButtons.setLayout(null);

View File

@ -60,6 +60,8 @@ import org.jackhuang.hmcl.laf.utils.TMSchema.Part;
* @author Igor Kushnirskiy
*/
public class AnimationController implements ActionListener, PropertyChangeListener {
public static boolean ENABLE_ANIMATION = true;
private static AnimationController INSTANCE = new 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,
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);
synchronized (controller) {
AnimationState animationState = null;