Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

Commit

Permalink
Update 3.3
Browse files Browse the repository at this point in the history
Add "File" -> "Run Game"
  • Loading branch information
Leo40Git committed Dec 17, 2017
1 parent 069b3f3 commit 132b974
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
3.2
3.3
Update 3.3:
- Add "File" -> "Run Game"
Update 3.2:
- Add icons for "File" -> "Unload Profile", "Change File", "Unload Game/Mod"
Update 3.1:
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/leo/cse/frontend/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Main extends JFrame implements ExeLoadListener, ProfileListener {
private static final long serialVersionUID = -5073541927297432013L;

public static final Dimension WINDOW_SIZE = new Dimension(867, 686);
public static final Version VERSION = new Version("3.2");
public static final Version VERSION = new Version("3.3");
public static final String UPDATE_CHECK_SITE = "https://raw.githubusercontent.com/Leo40Git/CaveSaveEdit/master/.version";
public static final String DOWNLOAD_SITE = "https://github.com/Leo40Git/CaveSaveEdit/releases/";
public static final Color COLOR_BG = new Color(0, 0, 25);
Expand Down Expand Up @@ -154,7 +154,7 @@ public Dimension getActualSize() {
return getActualSize(true);
}

public static void loadProfile(File file) {
public static void loadProfile(File file, boolean record) {
if (SaveEditorPanel.panel != null)
SaveEditorPanel.panel.setLoading(true);
window.repaint();
Expand Down Expand Up @@ -182,7 +182,8 @@ public static void loadProfile(File file) {
return;
} finally {
System.out.println("loaded profile " + ProfileManager.getLoadedFile());
Config.set(Config.KEY_LAST_PROFIE, file.getAbsolutePath());
if (record)
Config.set(Config.KEY_LAST_PROFIE, file.getAbsolutePath());
SwingUtilities.invokeLater(() -> {
if (SaveEditorPanel.panel != null)
SaveEditorPanel.panel.setLoading(false);
Expand All @@ -191,6 +192,10 @@ public static void loadProfile(File file) {
}
});
}

public static void loadProfile(File file) {
loadProfile(file, true);
}

public static void setTitle(Main window) {
if (window == null)
Expand Down Expand Up @@ -462,7 +467,7 @@ public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
File p = new File(System.getProperty("user.dir") + "/Profile.dat");
if (p.exists())
loadProfile(p);
loadProfile(p, false);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/leo/cse/frontend/Resources.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static void loadImages() {
editorTabIcons = new BufferedImage[7];
for (int i = 0; i < editorTabIcons.length; i++)
editorTabIcons[i] = ui.getSubimage(i * 16, 16, 16, 16);
icons = new BufferedImage[14];
icons = new BufferedImage[15];
int tbx = 0, tby = 16;
for (int i = 0; i < icons.length; i++) {
if (i % 10 == 0) {
Expand Down
38 changes: 35 additions & 3 deletions src/main/java/com/leo/cse/frontend/ui/SaveEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ public SaveEditorPanel() {
}

public void addComponents() {
boolean plus = ExeData.isPlusMode();
menuBars = new ArrayList<>();
List<MenuBarItem> mbiFile = new ArrayList<>();
mbiFile.add(new MenuBarItem("New Profile", Resources.icons[8], () -> {
Expand All @@ -302,7 +301,7 @@ public void addComponents() {
mbiFile.add(new MenuBarItem("Change File", Resources.icons[13], () -> {
addDialogBox(new PlusSlotDialog(true));
}, () -> {
return ProfileManager.isLoaded() && plus;
return ProfileManager.isLoaded() && ExeData.isPlusMode();
}));
mbiFile.add(new MenuBarItem("Unload Profile", Resources.icons[11], () -> {
if (ProfileManager.isLoaded() && ProfileManager.isModified()) {
Expand All @@ -322,6 +321,11 @@ public void addComponents() {
mbiFile.add(new MenuBarItem("Load Game/Mod", "Ctrl+Shift+O", Resources.icons[1], () -> {
loadExe();
}));
mbiFile.add(new MenuBarItem("Run Game", "Ctrl+R", Resources.icons[14], () -> {
runExe();
}, () -> {
return ExeData.isLoaded();
}));
mbiFile.add(new MenuBarItem("Unload Game/Mod", Resources.icons[12], () -> {
ExeData.unload();
loading = true;
Expand Down Expand Up @@ -367,7 +371,8 @@ public void addComponents() {
addDialogBox(new NikuEditDialog());
}));
menuBars.add(new MenuBar("Tools", mbiTools));
boolean var = plus && MCI.getSpecial("VarHack"), eqp = plus && MCI.getSpecial("EquipPlusHack");
boolean plus = ExeData.isPlusMode(), var = plus && MCI.getSpecial("VarHack"),
eqp = plus && MCI.getSpecial("EquipPlusHack");
tabs = new EditorPanel[(var ? 6 : 5)];
tabs[0] = new EditorPanel(EditorTab.GENERAL, new GeneralPanel());
tabs[1] = new EditorPanel(EditorTab.INVENTORY, new InventoryPanel());
Expand Down Expand Up @@ -645,6 +650,30 @@ private void loadExe() {

}

private void runExe() {
if (ExeData.isPlusMode()) {
String path = System.getenv("programfiles(x86)");
if (path == null) {
path = System.getenv("programfiles");
}
try {
Runtime.getRuntime().exec(path + "/Steam/Steam.exe -applaunch 200900");
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Could not run game!\nThe following exception occured: " + e,
"Could not run game", JOptionPane.ERROR_MESSAGE);
}
} else {
try {
Runtime.getRuntime().exec(ExeData.getBase().getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Could not run game! The following exception occured:\n" + e,
"Could not run game", JOptionPane.ERROR_MESSAGE);
}
}
}

private boolean canSave() {
if (!ProfileManager.isLoaded()) {
JOptionPane.showMessageDialog(Main.window, "There is no profile to save!\nPlease load a profile.",
Expand Down Expand Up @@ -1062,6 +1091,9 @@ public void keyReleased(KeyEvent e) {
ProfileManager.redo();
}
break;
case KeyEvent.VK_R:
runExe();
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ public void onKey(int code, boolean shiftDown, boolean ctrlDown) {
return;
if (mapInfo.hasMissingAssets())
return;
System.out.println("MapView.onKey");
updateCamCoords();
int px = playerPos[0], py = playerPos[1];
int amount = 32;
Expand Down
Binary file modified src/main/resources/com/leo/cse/frontend/ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 132b974

Please sign in to comment.