- Added an optional play again button for the applet after getdown has launched the application
This commit is contained in:
@@ -182,6 +182,12 @@ public class Application
|
||||
/** The patch notes URL. */
|
||||
public String patchNotesUrl;
|
||||
|
||||
/** The dimensions of the play again button. */
|
||||
public Rectangle playAgain;
|
||||
|
||||
/** The path (relative to the appdir) to a single play again image. */
|
||||
public String playAgainImage;
|
||||
|
||||
/** The global percentages for each step. A step may have more than one, and
|
||||
* the lowest reasonable one is used if a step is revisited. */
|
||||
public Map<Step, List<Integer>> stepPercentages =
|
||||
@@ -195,7 +201,8 @@ public class Application
|
||||
", pi=" + progressImage + ", prect=" + progress + ", pt=" + progressText +
|
||||
", pb=" + progressBar + ", srect=" + status + ", st=" + statusText +
|
||||
", shadow=" + textShadow + ", err=" + installError + ", nrect=" + patchNotes +
|
||||
", notes=" + patchNotesUrl + ", stepPercentages=" + stepPercentages + "]";
|
||||
", notes=" + patchNotesUrl + ", stepPercentages=" + stepPercentages +
|
||||
", parect=" + playAgain + ", paimage=" + playAgainImage + "]";
|
||||
}
|
||||
|
||||
/** Initializer */
|
||||
@@ -685,6 +692,10 @@ public class Application
|
||||
ui.patchNotes = parseRect(cdata, "ui.patch_notes", ui.patchNotes);
|
||||
ui.patchNotesUrl = parseUrl(cdata, "ui.patch_notes_url", null);
|
||||
|
||||
// the play again bits
|
||||
ui.playAgain = parseRect(cdata, "ui.play_again", ui.playAgain);
|
||||
ui.playAgainImage = (String)cdata.get("ui.play_again_image");
|
||||
|
||||
// step progress percentages
|
||||
for (UpdateInterface.Step step : UpdateInterface.Step.values()) {
|
||||
String spec = (String)cdata.get("ui.percents." + step.name());
|
||||
|
||||
@@ -31,10 +31,12 @@ import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
@@ -838,6 +840,9 @@ public abstract class Getdown extends Thread
|
||||
// pump the percent up to 100%
|
||||
setStatus(null, 100, -1L, false);
|
||||
exit(0);
|
||||
if (_playAgain != null) {
|
||||
_playAgain.setVisible(true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warning("launch() failed.", e);
|
||||
@@ -870,6 +875,24 @@ public abstract class Getdown extends Thread
|
||||
});
|
||||
_patchNotes.setFont(StatusPanel.FONT);
|
||||
_layers.add(_patchNotes);
|
||||
|
||||
if (getApplet() != null && _ifc.playAgain != null) {
|
||||
Image image = loadImage(_ifc.playAgainImage);
|
||||
if (image != null) {
|
||||
_playAgain = new JButton(new ImageIcon(image));
|
||||
_playAgain.setBorderPainted(false);
|
||||
} else {
|
||||
_playAgain = new JButton(_msgs.getString("m.play_again"));
|
||||
}
|
||||
_playAgain.addActionListener(new ActionListener() {
|
||||
@Override public void actionPerformed (ActionEvent event) {
|
||||
getdown();
|
||||
_playAgain.setVisible(false);
|
||||
}
|
||||
});
|
||||
_layers.add(_playAgain);
|
||||
}
|
||||
|
||||
_status = new StatusPanel(_msgs);
|
||||
_layers.add(_status);
|
||||
initInterface();
|
||||
@@ -900,6 +923,11 @@ public abstract class Getdown extends Thread
|
||||
_patchNotes.setBounds(_ifc.patchNotes);
|
||||
_patchNotes.setVisible(false);
|
||||
|
||||
if (_playAgain != null) {
|
||||
_playAgain.setBounds(_ifc.playAgain);
|
||||
_playAgain.setVisible(false);
|
||||
}
|
||||
|
||||
// we were displaying progress while the UI wasn't up. Now that it is, whatever progress
|
||||
// is left is scaled into a 0-100 DISPLAYED progress.
|
||||
_uiDisplayPercent = _lastGlobalPercent;
|
||||
@@ -978,7 +1006,7 @@ public abstract class Getdown extends Thread
|
||||
*/
|
||||
protected int stepToGlobalPercent (int percent)
|
||||
{
|
||||
int adjustedMaxPercent =
|
||||
int adjustedMaxPercent =
|
||||
((_stepMaxPercent - _uiDisplayPercent) * 100) / (100 - _uiDisplayPercent);
|
||||
_lastGlobalPercent = Math.max(_lastGlobalPercent,
|
||||
_stepMinPercent + (percent * (adjustedMaxPercent - _stepMinPercent)) / 100);
|
||||
@@ -1155,6 +1183,7 @@ public abstract class Getdown extends Thread
|
||||
protected JLayeredPane _layers;
|
||||
protected StatusPanel _status;
|
||||
protected JButton _patchNotes;
|
||||
protected JButton _playAgain;
|
||||
protected AbortPanel _abort;
|
||||
protected RotatingBackgrounds _background;
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ m.patching = Patching
|
||||
m.launching = Launching
|
||||
|
||||
m.patch_notes = Patch Notes
|
||||
m.play_again = Play Again
|
||||
|
||||
m.complete = {0}% complete
|
||||
m.remain = {0} remaining
|
||||
|
||||
Reference in New Issue
Block a user