Skip to content

Commit 732927d

Browse files
committed
How to run/debug in IDE and load icons from data source
1 parent 7804df3 commit 732927d

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,43 @@ https://discord.com/invite/ucjftZ7x7H
2020
5. Remove the duplicate "META-INF/services/javax.imageio.spi.ImageReaderSpi" files that share the same name located in META-INF so that only the BLP related file is present
2121
6. Save the JAR and exit 7zip
2222
*(This process will hopefully become easier in the future)*
23+
24+
## How to run/debug in IDE
25+
1. Use a working directory (e. g. the project root directory) to run Warsmash from the IDE.
26+
1. Copy [warsmash.ini](./core/assets/warsmash.ini) file into the working directory.
27+
2. Adapt all the file paths in section`[DataSources]` to your local Warcraft installation or other data sources and make sure that they all do exist and add the project directories [.\core\assets\resources](.\core\assets\resources) and [.\resources](.\resources) are included since they contain required files.
28+
All relative paths must work for your working directory:
29+
30+
````
31+
[DataSources]
32+
Count=8
33+
// Reforged
34+
Type00=CASC
35+
Path00="C:\Program Files (x86)\Warcraft III"
36+
Prefixes00=war3.w3mod,war3.w3mod\_deprecated.w3mod,war3.w3mod\_locales\enus.w3mod
37+
// Warcraft III: Reign of Chaos
38+
Type01=MPQ
39+
Path01="D:\Warcraft III\war3.mpq"
40+
// Warcraft III: The Frozen Throne
41+
Type02=MPQ
42+
Path02="D:\Warcraft III\War3x.mpq"
43+
// Warcraft III: The Frozen Throne Language
44+
Type03=MPQ
45+
Path03="D:\Warcraft III\War3xlocal.mpq"
46+
// Warcraft III: The Frozen Throne Patch
47+
Type04=MPQ
48+
Path04="D:\Warcraft III\War3Patch.mpq"
49+
// Warsmash
50+
Type05=Folder
51+
Path05=".\core\assets\"
52+
Type06=Folder
53+
Path06=".\resources\"
54+
Type07=Folder
55+
Path07="."
56+
````
57+
58+
4. Run/debug the method `com.etheller.warsmash.desktop.DesktopLauncher.main` with the options `-nolog -window -loadfile <path to your .w3x file>` from your IDE to load your custom map file in windowed mode and print the logs into the console instead of a log file.
59+
If the path to your .w3x file is relative, it has to be found from your working directory.
2360

2461
## Background and History
2562
My current codebase is running on Java 8 and the LibGDX game engine coupled with the port of the mdx-m3-viewer's engine. It contains:

desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.io.PrintStream;
1313
import java.nio.FloatBuffer;
1414

15+
import com.etheller.warsmash.WarsmashGdxMapScreen;
16+
import com.etheller.warsmash.datasources.DataSource;
1517
import org.lwjgl.BufferUtils;
1618
import org.lwjgl.openal.AL;
1719
import org.lwjgl.opengl.GL11;
@@ -45,17 +47,13 @@
4547

4648
public class DesktopLauncher {
4749
public static void main(final String[] arg) {
48-
System.out.println("You ran it.");
50+
System.out.println("You ran it in working directory " + System.getProperty("user.dir"));
4951
final LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
5052
config.useGL30 = true;
5153
config.gles30ContextMajorVersion = 3;
5254
config.gles30ContextMinorVersion = 3;
5355
// config.samples = 16;
5456
// config.vSyncEnabled = false;
55-
config.addIcon("resources/Icon16.png", Files.FileType.Internal);
56-
config.addIcon("resources/Icon32.png", Files.FileType.Internal);
57-
config.addIcon("resources/Icon64.png", Files.FileType.Internal);
58-
config.addIcon("resources/Icon128.png", Files.FileType.Internal);
5957
// config.foregroundFPS = 0;
6058
// config.backgroundFPS = 0;
6159
final DisplayMode desktopDisplayMode = LwjglApplicationConfiguration.getDesktopDisplayMode();
@@ -100,7 +98,26 @@ else if ((arg.length > (argIndex + 1)) && "-ini".equals(arg[argIndex])) {
10098
}
10199
loadExtensions();
102100
final DataTable warsmashIni = loadWarsmashIni(iniPath);
101+
102+
// Load icons:
103+
DataSource codebase = WarsmashGdxMapScreen.parseDataSources(warsmashIni);
104+
try {
105+
config.addIcon(codebase.getFile("resources/Icon16.png").getAbsolutePath(), Files.FileType.Internal);
106+
config.addIcon(codebase.getFile("resources/Icon32.png").getAbsolutePath(), Files.FileType.Internal);
107+
config.addIcon(codebase.getFile("resources/Icon64.png").getAbsolutePath(), Files.FileType.Internal);
108+
config.addIcon(codebase.getFile("resources/Icon128.png").getAbsolutePath(), Files.FileType.Internal);
109+
} catch (final IOException e) {
110+
e.printStackTrace();
111+
}
112+
103113
final Element emulatorConstants = warsmashIni.get("Emulator");
114+
115+
if (emulatorConstants == null) {
116+
System.err.println("Missing entry \"Emulator\" in .ini file.");
117+
118+
return;
119+
}
120+
104121
WarsmashConstants.loadConstants(emulatorConstants, warsmashIni);
105122

106123
if (fileToLoad != null) {

0 commit comments

Comments
 (0)