Restored animations
This commit is contained in:
@@ -55,6 +55,8 @@ public final class Config implements Cloneable {
|
||||
private boolean enableShadow;
|
||||
@SerializedName("enableBlur")
|
||||
private boolean enableBlur;
|
||||
@SerializedName("enableAnimation")
|
||||
private boolean enableAnimation;
|
||||
@SerializedName("decorated")
|
||||
private boolean decorated;
|
||||
@SerializedName("theme")
|
||||
@@ -110,6 +112,15 @@ public final class Config implements Cloneable {
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public boolean isEnableAnimation() {
|
||||
return enableAnimation;
|
||||
}
|
||||
|
||||
public void setEnableAnimation(boolean enableAnimation) {
|
||||
this.enableAnimation = enableAnimation;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public boolean isEnableBlur() {
|
||||
return enableBlur;
|
||||
}
|
||||
@@ -194,7 +205,7 @@ public final class Config implements Cloneable {
|
||||
public Config() {
|
||||
clientToken = UUID.randomUUID().toString();
|
||||
logintype = downloadtype = 0;
|
||||
enableBlur = enableShadow = true;
|
||||
enableAnimation = enableBlur = enableShadow = true;
|
||||
theme = 4;
|
||||
decorated = OS.os() == OS.LINUX;
|
||||
auth = new HashMap<>();
|
||||
|
||||
@@ -93,8 +93,6 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
initComponents();
|
||||
|
||||
dropTarget = new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
|
||||
setBackground(GraphicsUtils.getWebColorWithAlpha("FFFFFF7F"));
|
||||
setOpaque(true);
|
||||
|
||||
for (int i = 0; i < InstallerType.values().length; i++)
|
||||
installerPanels[i] = new InstallerPanel(this, InstallerType.values()[i]);
|
||||
|
||||
@@ -71,6 +71,8 @@
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkEnableBlur" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkEnableAnimation" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="chkDecorated" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -121,6 +123,7 @@
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="chkEnableShadow" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkEnableBlur" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkEnableAnimation" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
@@ -354,5 +357,15 @@
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkEnableBlurItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkEnableAnimation">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="launcher.enable_animation" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkEnableAnimationItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||
import org.jackhuang.hellominecraft.util.sys.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.lang.SupportedLocales;
|
||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.JSystemFileChooser;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
@@ -46,8 +45,6 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
|
||||
void initGui() {
|
||||
initComponents();
|
||||
setBackground(GraphicsUtils.getWebColorWithAlpha("FFFFFF7F"));
|
||||
setOpaque(true);
|
||||
|
||||
DefaultComboBoxModel<String> d = new DefaultComboBoxModel<>();
|
||||
for (DownloadType type : DownloadType.values())
|
||||
@@ -73,6 +70,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
cboTheme.setSelectedIndex(Settings.getInstance().getTheme().ordinal());
|
||||
chkEnableShadow.setSelected(Settings.getInstance().isEnableShadow());
|
||||
chkEnableBlur.setSelected(Settings.getInstance().isEnableBlur());
|
||||
chkEnableAnimation.setSelected(Settings.getInstance().isEnableAnimation());
|
||||
chkDecorated.setSelected(Settings.getInstance().isDecorated());
|
||||
}
|
||||
|
||||
@@ -117,6 +115,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
lblRestart = new javax.swing.JLabel();
|
||||
btnMCBBS = new javax.swing.JButton();
|
||||
chkEnableBlur = new javax.swing.JCheckBox();
|
||||
chkEnableAnimation = new javax.swing.JCheckBox();
|
||||
|
||||
cboDownloadSource.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
@@ -244,6 +243,13 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
}
|
||||
});
|
||||
|
||||
chkEnableAnimation.setText(C.i18n("launcher.enable_animation")); // NOI18N
|
||||
chkEnableAnimation.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
chkEnableAnimationItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -290,13 +296,15 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(btnCheckUpdate)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCBBS))
|
||||
.addComponent(lblAbout)
|
||||
.addComponent(lblModpack)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblRestart)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableBlur))
|
||||
.addComponent(chkEnableBlur)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableAnimation))
|
||||
.addComponent(chkDecorated))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
@@ -335,7 +343,8 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(chkEnableShadow)
|
||||
.addComponent(chkEnableBlur))
|
||||
.addComponent(chkEnableBlur)
|
||||
.addComponent(chkEnableAnimation))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkDecorated)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
|
||||
@@ -345,9 +354,9 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblRestart)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblModpack)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblAbout)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
@@ -432,6 +441,10 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
Settings.getInstance().setEnableBlur(chkEnableBlur.isSelected());
|
||||
}//GEN-LAST:event_chkEnableBlurItemStateChanged
|
||||
|
||||
private void chkEnableAnimationItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkEnableAnimationItemStateChanged
|
||||
Settings.getInstance().setEnableAnimation(chkEnableAnimation.isSelected());
|
||||
}//GEN-LAST:event_chkEnableAnimationItemStateChanged
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCheckUpdate;
|
||||
private javax.swing.JButton btnMCBBS;
|
||||
@@ -440,6 +453,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
private javax.swing.JComboBox cboLang;
|
||||
private javax.swing.JComboBox cboTheme;
|
||||
private javax.swing.JCheckBox chkDecorated;
|
||||
private javax.swing.JCheckBox chkEnableAnimation;
|
||||
private javax.swing.JCheckBox chkEnableBlur;
|
||||
private javax.swing.JCheckBox chkEnableShadow;
|
||||
private javax.swing.JLabel lblAbout;
|
||||
|
||||
@@ -330,6 +330,7 @@ public final class MainFrame extends DraggableFrame implements IRepaint {
|
||||
if (background != null) {
|
||||
if (backgroundLabel == null) {
|
||||
backgroundLabel = new GaussionPanel();
|
||||
backgroundLabel.setDrawBackgroundLayer(true);
|
||||
backgroundLabel.addAeroObject(backgroundLabel);
|
||||
backgroundLabel.setBounds(0, 0, 800, 480);
|
||||
centralPanel.add(backgroundLabel, -1);
|
||||
|
||||
@@ -301,4 +301,4 @@
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
</Form>
|
||||
|
||||
@@ -60,6 +60,8 @@ public class MainPagePanel extends Page {
|
||||
|
||||
void initGui() {
|
||||
initComponents();
|
||||
|
||||
animationEnabled = false;
|
||||
|
||||
pnlButtons = new javax.swing.JPanel();
|
||||
pnlButtons.setLayout(null);
|
||||
|
||||
@@ -17,7 +17,13 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.ui;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,6 +40,8 @@ public class Page extends JPanel implements Selectable {
|
||||
|
||||
@Override
|
||||
public void onSelect() {
|
||||
if (!selected)
|
||||
animate();
|
||||
selected = true;
|
||||
}
|
||||
|
||||
@@ -53,4 +61,60 @@ public class Page extends JPanel implements Selectable {
|
||||
public boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
// Animation
|
||||
// -------------------
|
||||
private static final int ANIMATION_LENGTH = 10;
|
||||
|
||||
public Page() {
|
||||
timer = new Timer(1, (e) -> {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
Page.this.repaint();
|
||||
offsetX += 0.15;
|
||||
if (offsetX >= ANIMATION_LENGTH) {
|
||||
timer.stop();
|
||||
Page.this.repaint();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
if (!(g instanceof Graphics2D)) {
|
||||
super.paint(g);
|
||||
return;
|
||||
}
|
||||
double pgs = 1 - Math.sin(Math.PI / 2 / ANIMATION_LENGTH * offsetX);
|
||||
if (Math.abs(ANIMATION_LENGTH - offsetX) < 0.1) {
|
||||
super.paint(g);
|
||||
return;
|
||||
}
|
||||
if (pgs > 1)
|
||||
pgs = 1;
|
||||
if (pgs < 0)
|
||||
pgs = 0;
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
if (isOpaque()) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
} else
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) (1 - pgs)));
|
||||
g.translate((int) (pgs * 50), 0);
|
||||
super.paint(g);
|
||||
}
|
||||
|
||||
double offsetX = ANIMATION_LENGTH;
|
||||
|
||||
Timer timer;
|
||||
|
||||
boolean animationEnabled = true;
|
||||
|
||||
public void animate() {
|
||||
if (Settings.getInstance().isEnableAnimation() && animationEnabled) {
|
||||
offsetX = 0;
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.jackhuang.hellominecraft.util.ui;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
@@ -40,6 +41,15 @@ public class GaussionPanel extends JPanel {
|
||||
private static final int RADIUS = 10;
|
||||
private transient final StackBlurFilter stackBlurFilter = new StackBlurFilter(RADIUS);
|
||||
private transient BufferedImage cache = null;
|
||||
private boolean drawBackgroundLayer = false;
|
||||
|
||||
public boolean isDrawBackgroundLayer() {
|
||||
return drawBackgroundLayer;
|
||||
}
|
||||
|
||||
public void setDrawBackgroundLayer(boolean drawBackgroundLayer) {
|
||||
this.drawBackgroundLayer = drawBackgroundLayer;
|
||||
}
|
||||
|
||||
public void setBackgroundImage(Image backgroundImage) {
|
||||
this.backgroundImage = backgroundImage;
|
||||
@@ -81,10 +91,16 @@ public class GaussionPanel extends JPanel {
|
||||
aeroGraphics.drawImage(backgroundImage, 0, 0, aeroBuffer.getWidth(), aeroBuffer.getHeight(), aeroRect.x, aeroRect.y, aeroRect.x + aeroRect.width, aeroRect.y + aeroRect.height, null);
|
||||
aeroBuffer = stackBlurFilter.filter(aeroBuffer, null);
|
||||
g2.drawImage(aeroBuffer, aeroRect.x, aeroRect.y, aeroRect.x + aeroRect.width, aeroRect.y + aeroRect.height, RADIUS / 2, RADIUS / 2, RADIUS / 2 + aeroRect.width, RADIUS / 2 + aeroRect.height, null);
|
||||
|
||||
if (drawBackgroundLayer) {
|
||||
g2.setColor(Color.white);
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f));
|
||||
g2.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
g2.dispose();
|
||||
}
|
||||
g.drawImage(cache, 0, 0, getWidth(), getHeight(), null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user