Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some How to run in IDE to README and load icons from data source #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@ 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 debug your map in any IDE

It can be useful to debug your map with Warsmash in your IDE using breakpoints and other debugging features to improve Warsmash:

1. Install Warcraft from Blizzard.
2. Install Java 17.
3. Clone the Warsmash repository.
4. Use a working directory (e. g. the project root directory of Warsmash) to run Warsmash from the IDE.
5. Copy [warsmash.ini](./core/assets/warsmash.ini) file into the working directory and 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.
This is an example for Warcraft III: Reforged:

````
[DataSources]
Count=4
// Warcraft III: Reforged
Type00=CASC
Path00="C:\Program Files (x86)\Warcraft III"
Prefixes00=war3.w3mod,war3.w3mod\_deprecated.w3mod,war3.w3mod\_locales\enus.w3mod
// Warsmash
Type01=Folder
Path01=".\core\assets\"
Type02=Folder
Path02=".\resources\"
// Working directory
Type03=Folder
Path03="."
````

7. 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