Skip to content

Commit bfbe6d1

Browse files
committed
Asset rework + loading bar for export
1 parent ab6fd28 commit bfbe6d1

File tree

11 files changed

+72
-50
lines changed

11 files changed

+72
-50
lines changed

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
# KleiCreator
33
KleiCreator is a GUI tool for creating mods for the games made by Klei Entertainment. It uses a the Java Runtime Environment and cross-platform libraries to enable mods to be made on any platform.
44

5-
### Download/Install
6-
There are 3 different versions you can download:
7-
1. Release: This is an official release, so we've spent some time making sure it's stable and the features are implemented well. You can download the latest from: [Releases](https://github.com/deepcoredev/kleicreator/releases)
8-
2. [TO BE SETUP] Master branch: This is a semi-official release. It's built automatically and most likely doesn't have any horrible bugs. You can download it by going [here]() and then click on the dots next to the entry that says "master".
9-
3. [TO BE SETUP] Development branch: This is a working branch. Expect unstable versions, breaking changes, things that can corrupt work. However, this is the most current version. You can download it by going [here]() and then click on the dots next to the entry that says "development".
10-
11-
#### Colours:
12-
Gray: 5b5b5b
13-
Orange: ffb400
5+
## About
6+
KleiCreator runs in the JVM (Java virtual machine), and maintains cross-platform compatibility. Additionally, it supports plugins, allowing anyone to extend its functionality without needing to modify and distribute their own version of KleiCreator.
7+
8+
## Plugins
9+
As with a lot of Java applications, plugins are compiled and packaged as `.jar` files. Currently, there is no official documentation for the process of creating plugins, but it can be reverse-engineered by looking through the source code of the SDK. Documentation, however, is on the way.
10+
11+
## Using
12+
KleiCreator can be downloaded from any release, usually called `app-X.X.X.jar`, with an accompanying SDK. These releases are generally quite stable, and automatically check for updates that are newer than themselves.
13+
14+
## Contributing
15+
KleiCreator is open-source, and as with every OSS project, every contribution counts. If you're contributing by writing code and implementing features, fork this repository, commit your changes, then create a Pull Request to get it merged into the root codebase. If you're contributing through testing, create issues with the problem you've found and hopefully a developer will take a look at them and fix the issue.
16+
17+
### Styles
18+
If you're making any assets for KleiCreator, the colours used in the logo are:
19+
- Gray: 5b5b5b
20+
- Orange: ffb400

app/src/main/java/kleicreator/export/Exporter.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package kleicreator.export;
22

33

4+
import kleicreator.frames.LoadingStartup;
45
import kleicreator.master.Master;
56
import kleicreator.plugin.PluginHandler;
67
import kleicreator.sdk.constants.Constants;
@@ -24,9 +25,10 @@
2425
import java.nio.file.StandardCopyOption;
2526

2627
public class Exporter {
27-
private static ExportDialog exportDialog;
28+
private static LoadingStartup exportDialog;
2829
private static JFrame exportWindowFrame;
29-
private static int points;
30+
private static int maxJobs;
31+
private static int jobs;
3032

3133
public static void Export() {
3234
try {
@@ -107,17 +109,11 @@ private static void CopyResources(String outputLocation) {
107109
}
108110

109111
private static void InitLoading() {
110-
exportDialog = new ExportDialog();
111-
exportWindowFrame = new JFrame("Exporting...");
112+
exportDialog = new LoadingStartup();
112113
Logger.Debug("Exporting...");
113114
Logger.Debug("Starting exporting init");
114-
exportWindowFrame.setIconImage(Master.icon.getImage());
115-
exportWindowFrame.setContentPane(exportDialog.getExportWindowFrame());
116-
exportWindowFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
117-
exportWindowFrame.pack();
118-
exportWindowFrame.setLocationRelativeTo(null);
119-
exportWindowFrame.setVisible(true);
120-
points = 6 + Mod.items.size();
115+
maxJobs = 6 + Mod.items.size();
116+
jobs = 0;
121117
Logger.Debug("Finished Init");
122118
}
123119

@@ -135,21 +131,19 @@ private static void Write(Template toWrite, String fileLocation) {
135131
}
136132

137133
private static void MoveLoading() {
138-
int currentValue = exportDialog.getExportProgressBar().getValue();
139-
float eachPointValue = 100 / points;
140-
exportDialog.getExportProgressBar().setValue(currentValue + (int) eachPointValue);
141-
exportWindowFrame.pack();
134+
jobs++;
135+
exportDialog.SetProgress((int) (((float)jobs/maxJobs)*100), "Exporting...");
142136
}
143137

144138
private static void Done(String finishedLocation) {
145-
JOptionPane.showMessageDialog(ModLoader.modEditorFrame, "Done!");
146-
exportDialog.getExportProgressBar().setValue(100);
147-
exportWindowFrame.dispose();
139+
Logger.Log("Finished export");
140+
exportDialog.SetProgress(100, "Done!");
141+
JOptionPane.showMessageDialog(ModLoader.modEditorFrame, "Successfully completed export!", "Export complete", JOptionPane.INFORMATION_MESSAGE);
142+
exportDialog.Destroy();
148143
try {
149144
Desktop.getDesktop().open(new File(finishedLocation));
150145
} catch (IOException e) {
151146
Logger.Error(e);
152147
}
153-
Logger.Log("Finished export");
154148
}
155149
}

app/src/main/java/kleicreator/frames/LoadingStartup.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,41 @@ public class LoadingStartup {
1414
private JFrame frame;
1515

1616
public LoadingStartup() {
17-
frame = new JFrame("KleiCreator | Loading...");
18-
frame.setContentPane(loadingBar);
19-
frame.setUndecorated(true);
20-
frame.setIconImage(Master.icon.getImage());
21-
frame.setType(Window.Type.UTILITY);
17+
SwingUtilities.invokeLater(new Runnable() {
18+
@Override
19+
public void run() {
20+
frame = new JFrame("KleiCreator | Loading...");
21+
frame.setContentPane(loadingBar);
22+
frame.setUndecorated(true);
23+
frame.setIconImage(Master.icon.getImage());
24+
frame.setType(Window.Type.UTILITY);
2225

23-
frame.pack();
24-
frame.setLocationRelativeTo(null);
25-
frame.setVisible(true);
26+
frame.toFront();
27+
frame.pack();
28+
frame.setLocationRelativeTo(null);
29+
frame.setVisible(true);
30+
}
31+
});
2632
}
2733

2834
public void SetProgress(int value, String text) {
29-
progressBar.setValue(value);
30-
progressBar.setString(text);
31-
frame.pack();
35+
SwingUtilities.invokeLater(new Runnable() {
36+
@Override
37+
public void run() {
38+
progressBar.setValue(value);
39+
progressBar.setString(text);
40+
progressBar.repaint();
41+
}
42+
});
3243
}
3344

3445
public void Destroy() {
35-
frame.dispose();
46+
SwingUtilities.invokeLater(new Runnable() {
47+
@Override
48+
public void run() {
49+
frame.dispose();
50+
}
51+
});
3652
}
3753

3854
{

app/src/main/java/kleicreator/master/Master.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static void Main(String[] args) {
7878
Config.SaveData("kleicreator.copyresources", false, false);
7979

8080
try {
81-
Object o = Config.GetData("kleicreator.theme");
81+
Object o = Dark; //Config.GetData("kleicreator.theme");
8282
if (Light.equals(o)) {
8383
UIManager.setLookAndFeel(new FlatLightLaf());
8484
darkMode = false;
@@ -178,12 +178,12 @@ public void actionPerformed(ActionEvent e) {
178178

179179
panel.add(new JLabel("KleiCreator"));
180180

181-
JComboBox theme = new JComboBox();
182-
panel.add(theme);
183-
for (GlobalTheme t : GlobalTheme.values()) {
184-
theme.addItem(t.toString());
185-
}
186-
theme.setSelectedIndex(((GlobalTheme) Config.GetData("kleicreator.theme")).ordinal());
181+
//JComboBox theme = new JComboBox();
182+
//panel.add(theme);
183+
//for (GlobalTheme t : GlobalTheme.values()) {
184+
// theme.addItem(t.toString());
185+
//}
186+
//theme.setSelectedIndex(((GlobalTheme) Config.GetData("kleicreator.theme")).ordinal());
187187

188188
JCheckBox askSaveOnLeave = new JCheckBox("Ask Save On Leave");
189189
panel.add(askSaveOnLeave);
@@ -198,7 +198,7 @@ public void actionPerformed(ActionEvent e) {
198198
saveButton.addActionListener(new ActionListener() {
199199
@Override
200200
public void actionPerformed(ActionEvent e) {
201-
Config.SaveData("kleicreator.theme", GlobalTheme.valueOf(theme.getSelectedItem().toString()));
201+
//Config.SaveData("kleicreator.theme", GlobalTheme.valueOf(theme.getSelectedItem().toString()));
202202
Config.SaveData("kleicreator.asksaveonleave", askSaveOnLeave.isSelected());
203203
Config.SaveData("kleicreator.copyresources", copyResources.isSelected());
204204
PluginHandler.TriggerEvent("OnConfigSave", configDialogFrame);

app/src/main/java/kleicreator/modloader/ModLoaderActions.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ public static void SetupListeners() {
109109
modEditor.getModItemSelect().addActionListener(e -> Update());
110110

111111
modEditor.getModExport().addActionListener(e -> {
112-
Exporter.Export();
113-
Logger.Debug("Exported");
112+
new Thread(new Runnable() {
113+
@Override
114+
public void run() {
115+
Exporter.Export();
116+
Logger.Debug("Exported");
117+
}
118+
}).start();
114119
});
115120

116121
modEditor.getModSpeechReloadSpeech().addActionListener(e -> {
38 Bytes
Loading
-292 Bytes
Loading
-132 Bytes
Loading
Loading
-17.4 KB
Loading
Loading

0 commit comments

Comments
 (0)