Compare commits

...

4 Commits

6 changed files with 124 additions and 35 deletions

View File

@ -19,6 +19,8 @@
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
@ -43,7 +45,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class Ernie implements ActionListener, Runnable {
public class Ernie implements ActionListener {
// Base URL for Gitea API
public static final String gitapi = "https://git.worlio.com/api/v1/repos/bonkmaykr/firestar";
public static final String changelog = "https://bonkmaykr.worlio.com/http/firestar/changelog.htm";
@ -61,14 +63,17 @@ public class Ernie implements ActionListener, Runnable {
public boolean backgroundDone = false;
private BufferedImage windowIcon;
public void run() {
private JFrame parent;
public Ernie(JFrame parent) {
this.parent = parent;
try {
windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png"));
frame.setIconImage(windowIcon);
} catch (IOException e) {
System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon.");
}
byte[] urlraw = new Ernie().getFile(gitapi+"/releases?draft=false&pre-release=false");
byte[] urlraw = getFile(gitapi+"/releases?draft=false&pre-release=false");
if (urlraw.length <= 0) {
JOptionPane.showMessageDialog(frame, "Internal Error: Couldn't check for updates.", "Fatal Error", JOptionPane.ERROR_MESSAGE);
} else {
@ -89,6 +94,16 @@ public class Ernie implements ActionListener, Runnable {
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
parent.setEnabled(false);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e)
{
parent.setEnabled(true);
e.getWindow().dispose();
}
});
frame.setVisible(true);
} else { System.out.println("Updater: No updates."); }
} catch (IOException ex) {
@ -101,12 +116,16 @@ public class Ernie implements ActionListener, Runnable {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if (actionEvent.getSource() == notnowbtn) {frame.dispose();} else
if (actionEvent.getSource() == notnowbtn) {
parent.setEnabled(true);
frame.dispose();
} else
if (actionEvent.getSource() == surebtn) {
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
String releasepage = "https://git.worlio.com/bonkmaykr/firestar/releases";
try {
Desktop.getDesktop().browse(new URI(releasepage));
parent.setEnabled(true);
frame.dispose();
} catch (Exception ex) {
JOptionPane.showMessageDialog(frame, "Couldn't open your web browser!\nYou can check out the latest release at the URL below:\n"+releasepage, "Error", JOptionPane.ERROR_MESSAGE);

View File

@ -42,7 +42,7 @@ public class Main {
public static boolean repatch; //are we in compat mode?
public static boolean windows; //True = windows
public static int confvint = vint;
public static boolean checkUpdates;
public static boolean checkUpdates = true;
//public static String psarc; //sdk location
public enum ArcTarget { // install target for 2048, type used by downloader
@ -138,7 +138,7 @@ public class Main {
container.put("HDpath", "TODO"); // proposed hd/fury support for ps3, will use very simplified Fast Mode due to less difficulty installing
container.put("safemode", repatch);
container.put("isWin32", windows);
container.put("checkUpdates", checkUpdates);
container.put("checkUpdates", checkUpdates);
container.put("currentPlaylist", "TODO"); // proposed feature: store separate mod lists in lists/ to load/save later?
try {

View File

@ -30,21 +30,29 @@
<color color="-1"/>
</border>
<children>
<component id="a9cee" class="javax.swing.JTextPane" binding="descriptionField">
<scrollpane id="6e7e5">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-15128227"/>
<editable value="false"/>
<focusable value="false"/>
<font name="Exo 2"/>
<foreground color="-1"/>
<text value="Select a mod from the list on the right to view more details, or to make changes to your installation."/>
<opaque value="false"/>
</properties>
</component>
<border type="empty"/>
<children>
<component id="d55bf" class="javax.swing.JTextPane" binding="descriptionField">
<constraints/>
<properties>
<background color="-15128227"/>
<editable value="false"/>
<focusable value="false"/>
<font name="Exo 2"/>
<foreground color="-1"/>
<text value="Select a mod from the list on the right to view more details, or to make changes to your installation."/>
</properties>
</component>
</children>
</scrollpane>
</children>
</grid>
<scrollpane id="ecc63" binding="modListScrollContainer">

View File

@ -312,8 +312,12 @@ public class MissPiggy implements ActionListener {
}
private void StartErnie() {
Ernie e = new Ernie();
new Thread(e).start();
new Thread(new Runnable() {
@Override
public void run() {
new Ernie(frame); // changed away from runnable in order to pass params to constructor -bonk
}
}).start();
}
private ListSelectionListener whenItemSelected() {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Waldorf">
<grid id="27dc6" binding="frameContainer" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="frameContainer" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="25" bottom="10" right="25"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@ -16,7 +16,7 @@
<children>
<component id="3d88f" class="javax.swing.JButton" binding="okbtn">
<constraints>
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
@ -27,14 +27,6 @@
<text value="Save"/>
</properties>
</component>
<component id="86775" class="javax.swing.JTextField" binding="fOutpath">
<constraints>
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="db731" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
@ -47,7 +39,7 @@
</component>
<component id="50d13" class="javax.swing.JButton" binding="cancelbtn">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
@ -60,7 +52,7 @@
</component>
<component id="252b3" class="javax.swing.JButton" binding="resetbtn">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="2" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
@ -146,6 +138,55 @@
</component>
</children>
</grid>
<grid id="b015e" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<opaque value="false"/>
</properties>
<border type="none"/>
<children>
<component id="18770" class="javax.swing.JLabel" binding="fOutpath">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Exo 2"/>
<foreground color="-1"/>
<text value="Deploys Go Here"/>
</properties>
</component>
<component id="fa1ee" class="javax.swing.JButton" binding="fOutpathChangebtn">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
<borderPainted value="false"/>
<focusPainted value="false"/>
<font name="Exo 2"/>
<foreground color="-1"/>
<text value="Change"/>
</properties>
</component>
</children>
</grid>
<component id="73ca5" class="javax.swing.JCheckBox" binding="checkUpdatesToggle">
<constraints>
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusPainted value="false"/>
<font name="Exo 2"/>
<foreground color="-1"/>
<label value="Automatically check for updates on startup"/>
<opaque value="false"/>
<rolloverEnabled value="false"/>
<text value="Automatically check for updates on startup"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@ -34,12 +34,16 @@ public class Waldorf implements ActionListener {
private JPanel frameContainer;
private JButton okbtn;
private JButton cancelbtn;
private JTextField fOutpath;
private JLabel fOutpath;
private JButton resetbtn;
private JButton bOpenFolder;
private JButton dwnSDKbtn;
private JButton dwnARCbtn;
private JButton fOutpathChangebtn;
private JCheckBox checkUpdatesToggle;
MissPiggy invoker;
private String tOutPath = Main.outpath;
public void Action(MissPiggy inv) {
invoker = inv;
@ -51,7 +55,7 @@ public class Waldorf implements ActionListener {
} catch (IOException e) {
System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon.");
}
frame.setSize(600, 200); // 1280 800
frame.setSize(600, 300); // 1280 800
frame.setMinimumSize(new Dimension(200,100));
frame.setTitle("Options");
frame.setResizable(false);
@ -64,11 +68,12 @@ public class Waldorf implements ActionListener {
okbtn.addActionListener(this);
resetbtn.addActionListener(this);
bOpenFolder.addActionListener(this);
dwnARCbtn.addActionListener(this);
dwnSDKbtn.addActionListener(this);
fOutpathChangebtn.addActionListener(this);
fOutpath.setText(Main.outpath);
checkUpdatesToggle.setSelected(Main.checkUpdates);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
@ -88,7 +93,8 @@ public class Waldorf implements ActionListener {
frame.dispose();
} else
if (actionEvent.getSource() == okbtn) {
Main.outpath = fOutpath.getText();
Main.outpath = tOutPath;
Main.checkUpdates = checkUpdatesToggle.isSelected();
Main.writeConf();
Main.loadConf();
@ -133,6 +139,17 @@ public class Waldorf implements ActionListener {
});
downloaderPopupThread.start();
frame.dispose();
}
} else
if (actionEvent.getSource() == fOutpathChangebtn) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = fileChooser.showOpenDialog(frame);
if (result == JFileChooser.APPROVE_OPTION) {
if (fileChooser.getSelectedFile().isDirectory()) {
tOutPath = fileChooser.getSelectedFile().getAbsolutePath();
fOutpath.setText(tOutPath);
}
}
}
}
}