Skip to content

Commit

Permalink
How to run/debug in IDE and load icons from data source
Browse files Browse the repository at this point in the history
  • Loading branch information
tdauth committed Apr 16, 2023
1 parent 7804df3 commit 2f4c00c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 5 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,44 @@ https://discord.com/invite/ucjftZ7x7H
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
6. Save the JAR and exit 7zip
*(This process will hopefully become easier in the future)*

## How to run/debug in IDE
1. Use a working directory (e. g. the project root directory) to run Warsmash from the IDE.
1. Copy [warsmash.ini](./core/assets/warsmash.ini) file into the working directory.
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.
All relative paths must work for your working directory:

````
[DataSources]
Count=8
// Reforged
Type00=CASC
Path00="C:\Program Files (x86)\Warcraft III"
Prefixes00=war3.w3mod,war3.w3mod\_deprecated.w3mod,war3.w3mod\_locales\enus.w3mod
//Prefixes00=war3.w3mod,war3.w3mod\_deprecated.w3mod,war3.w3mod\_locales\enus.w3mod,war3.w3mod\_hd.w3mod,war3.w3mod\_hd.w3mod\_locales\enus.w3mod
// Warcraft III: Reign of Chaos
Type01=MPQ
Path01="D:\Warcraft III\war3.mpq"
// Warcraft III: The Frozen Throne
Type02=MPQ
Path02="D:\Warcraft III\War3x.mpq"
// Warcraft III: The Frozen Throne Language
Type03=MPQ
Path03="D:\Warcraft III\War3xlocal.mpq"
// Warcraft III: The Frozen Throne Patch
Type04=MPQ
Path04="D:\Warcraft III\War3Patch.mpq"
// Warsmash
Type05=Folder
Path05=".\core\assets\"
Type06=Folder
Path06=".\resources\"
Type07=Folder
Path07="."
````

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.
If the path to your .w3x file is relative, it has to be found from your working directory.

## Background and History
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:
Expand Down
27 changes: 22 additions & 5 deletions desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.io.PrintStream;
import java.nio.FloatBuffer;

import com.etheller.warsmash.WarsmashGdxMapScreen;
import com.etheller.warsmash.datasources.DataSource;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL;
import org.lwjgl.opengl.GL11;
Expand Down Expand Up @@ -45,17 +47,13 @@

public class DesktopLauncher {
public static void main(final String[] arg) {
System.out.println("You ran it.");
System.out.println("You ran it in working directory " + System.getProperty("user.dir"));
final LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.useGL30 = true;
config.gles30ContextMajorVersion = 3;
config.gles30ContextMinorVersion = 3;
// config.samples = 16;
// config.vSyncEnabled = false;
config.addIcon("resources/Icon16.png", Files.FileType.Internal);
config.addIcon("resources/Icon32.png", Files.FileType.Internal);
config.addIcon("resources/Icon64.png", Files.FileType.Internal);
config.addIcon("resources/Icon128.png", Files.FileType.Internal);
// config.foregroundFPS = 0;
// config.backgroundFPS = 0;
final DisplayMode desktopDisplayMode = LwjglApplicationConfiguration.getDesktopDisplayMode();
Expand Down Expand Up @@ -100,7 +98,26 @@ else if ((arg.length > (argIndex + 1)) && "-ini".equals(arg[argIndex])) {
}
loadExtensions();
final DataTable warsmashIni = loadWarsmashIni(iniPath);

// Load icons:
DataSource codebase = WarsmashGdxMapScreen.parseDataSources(warsmashIni);
try {
config.addIcon(codebase.getFile("resources/Icon16.png").getAbsolutePath(), Files.FileType.Internal);
config.addIcon(codebase.getFile("resources/Icon32.png").getAbsolutePath(), Files.FileType.Internal);
config.addIcon(codebase.getFile("resources/Icon64.png").getAbsolutePath(), Files.FileType.Internal);
config.addIcon(codebase.getFile("resources/Icon128.png").getAbsolutePath(), Files.FileType.Internal);
} catch (final IOException e) {
e.printStackTrace();
}

final Element emulatorConstants = warsmashIni.get("Emulator");

if (emulatorConstants == null) {
System.err.println("Missing entry \"Emulator\" in .ini file.");

return;
}

WarsmashConstants.loadConstants(emulatorConstants, warsmashIni);

if (fileToLoad != null) {
Expand Down

0 comments on commit 2f4c00c

Please sign in to comment.