Skip to content
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
14 changes: 8 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Set up JDK
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '21'
java-version: '25'
distribution: 'temurin'
- uses: Trass3r/setup-cpp@master
- uses: gradle/actions/setup-gradle@v6
with:
add-job-summary: 'on-failure'
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v4
run: ./gradlew build --no-daemon
- uses: actions/upload-artifact@v7
with:
name: distribution
path: build/distributions/OpenKeeper.zip
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/toniarts/openkeeper/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public final class Main extends SimpleApplication {
private static boolean conversionOk = false;
public static final String VERSION = "*ALPHA*";
public static final String TITLE = "OpenKeeper";
private static final String USER_HOME_FOLDER = System.getProperty("user.home").concat(File.separator).concat(".").concat(TITLE).concat(File.separator);
private static final String SCREENSHOTS_FOLDER = USER_HOME_FOLDER.concat("SCRSHOTS").concat(File.separator);
private static final String USER_HOME_FOLDER = System.getProperty("user.home") + "/." + TITLE + '/';
private static final String SCREENSHOTS_FOLDER = USER_HOME_FOLDER + "SCRSHOTS/";
private static final Object LOCK = new Object();
private static Map<String, String> params;
private static boolean debug;
Expand Down Expand Up @@ -242,6 +242,16 @@ private static void initSettings(Main app) {

// Init the user settings (which in JME are app settings)
app.settings = Settings.getInstance().getAppSettings();
if (isAudioDisabled())
app.settings.setAudioRenderer(null);
}

// returns true when all three audio categories (Music, Voice, SFX) are disabled
public static boolean isAudioDisabled() {
var s = getUserSettings();
return !s.getBoolean(Settings.Setting.MUSIC_ENABLED)
&& !s.getBoolean(Settings.Setting.VOICE_ENABLED)
&& !s.getBoolean(Settings.Setting.SFX_ENABLED);
}

/**
Expand Down Expand Up @@ -342,7 +352,12 @@ public void simpleInitApp() {
((GLRenderer)renderer).setDebugEnabled(true); // get debug names for GL objects
if (GL.getCapabilities().OpenGL43) {
GLUtil.setupDebugMessageCallback();
GL43C.glDebugMessageControl(GL43.GL_DEBUG_SOURCE_APPLICATION, GL43.GL_DONT_CARE, GL43.GL_DONT_CARE, (int[]) null, false);
GL43C.glDebugMessageControl(GL43C.GL_DONT_CARE, GL43C.GL_DEBUG_TYPE_PUSH_GROUP, GL43C.GL_DONT_CARE, (int[]) null, false);
GL43C.glDebugMessageControl(GL43C.GL_DONT_CARE, GL43C.GL_DEBUG_TYPE_POP_GROUP, GL43C.GL_DONT_CARE, (int[]) null, false);
final int[] noisyIds = {
0x20071, // Nvidia: BO resides in VIDEO memory
};
GL43C.glDebugMessageControl(GL43C.GL_DEBUG_SOURCE_API, GL43C.GL_DEBUG_TYPE_OTHER, GL43C.GL_DONT_CARE, noisyIds, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ public SoundCategory(String name, boolean useGlobal) {
throw new RuntimeException("Sound category is empty");
}

if (useGlobal) {
if (useGlobal)
this.folder = PathUtils.DKII_SFX_GLOBAL_FOLDER;
} else {
this.folder = PathUtils.DKII_SFX_FOLDER + name.toLowerCase() + File.separator;
}
else
this.folder = PathUtils.DKII_SFX_FOLDER + name.toLowerCase() + '/';

this.name = name;
parseGroups();
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/toniarts/openkeeper/game/sound/SoundGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
*/
package toniarts.openkeeper.game.sound;

import java.io.File;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import toniarts.openkeeper.tools.convert.sound.BankMapFile;
import toniarts.openkeeper.tools.convert.sound.SdtFile;
import toniarts.openkeeper.tools.convert.sound.sfx.SfxEEEntry;
import toniarts.openkeeper.tools.convert.sound.sfx.SfxGroupEntry;
import toniarts.openkeeper.tools.convert.sound.sfx.SfxSoundEntry;
import toniarts.openkeeper.tools.convert.sound.sfx.*;
import toniarts.openkeeper.utils.PathUtils;

/**
Expand Down Expand Up @@ -82,11 +79,12 @@ private void parseFiles() {
.relativize(sdt.getFile()).toString();

try {
String soundFilename = relative.substring(0, relative.length() - 4) + File.separator
+ SdtFile.fixFileExtension(sdt.getEntries()[soundId]);
var sdtFileEntry = sdt.getEntries()[soundId];
if (sdtFileEntry == null)
continue; // some entries are just "Blank"

SoundFile sf = new SoundFile(this, soundId, soundFilename);
files.add(sf);
String soundFilename = relative.substring(0, relative.length() - 4) + '/' + SdtFile.fixFileExtension(sdtFileEntry);
files.add(new SoundFile(this, soundId, soundFilename));
} catch (Exception ex) {
logger.log(Level.ERROR, () -> {
return "Error in file " + sdt.getFile().toString() + " with id " + soundId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ public MainMenuScreenController(MainMenuState state, Nifty nifty) {
this.state = state;
this.nifty = nifty;

if (Main.isAudioDisabled())
return;
SoundCategory sc = SoundsLoader.load(GlobalCategory.FRONT_END);
String filename = sc.getGroup(GlobalType.FRONT_END_CKICK).getFiles().get(0).getFilename();
this.nifty.registerSound(SOUND_MENU_ID, AssetsConverter.SOUNDS_FOLDER + File.separator + filename);
this.nifty.registerSound(SOUND_MENU_ID, AssetsConverter.SOUNDS_FOLDER + filename);
this.nifty.registerSound(SOUND_BUTTON_ID, "Sounds/Global/FrontEndHD/FE BUTTON BIG 5.mp2");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,12 @@ public void doDebriefing(GameResult result) {
protected String getMapThumbnail(KwdFile map) {

// See if the map thumbnail exist, otherwise create one
String asset = AssetsConverter.MAP_THUMBNAILS_FOLDER + File.separator + PathUtils.stripFileName(map.getGameLevel().getName()) + ".png";
String asset = AssetsConverter.THUMBNAILS_FOLDER + PathUtils.stripFileName(map.getGameLevel().getName()) + ".png";
if (assetManager.locateAsset(new TextureKey(asset)) == null) {

// Generate
try {
AssetsConverter.genererateMapThumbnail(map, AssetsConverter.getAssetsFolder() + AssetsConverter.MAP_THUMBNAILS_FOLDER + File.separator);
AssetsConverter.genererateMapThumbnail(map, AssetsConverter.getAssetsFolder() + AssetsConverter.THUMBNAILS_FOLDER);
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to generate map file out of {0}!", map);
asset = "Textures/Unique_NoTextureName.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ public void populateSpellTab() {
ResearchEffectControl researchControl = new ControlBuilder(ResearchEffectControl.CONTROL_NAME) {
{
parameter("color", spell.isDiscovered() ? "" : Integer.toString(RESEARCH_COLOR.getRGB()));
parameter("image", spell.isDiscovered() ? AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + File.separator + "GUI/Icons/Gold_Frame.png") : "");
parameter("image", spell.isDiscovered() ? AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + "GUI/Icons/Gold_Frame.png") : "");
}
}.build(element).getControl(ResearchEffectControl.class);
researchControl.initJme(state.app);
Expand Down Expand Up @@ -999,13 +999,11 @@ private ImageBuilder createCreatureAbilityIcon(final String name, final int inde
marginRight("6px");
focusable(true);
id("creature-ability_" + index);
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + name + ".png"));
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + name + ".png"));
valignCenter();
onFocusEffect(new EffectBuilder("imageOverlay") {
{
effectParameter("filename", AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + "GUI/Icons/selected-creature.png"));
effectParameter("filename", AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + "GUI/Icons/selected-creature.png"));
post(true);
}
});
Expand All @@ -1016,8 +1014,7 @@ private ImageBuilder createCreatureAbilityIcon(final String name, final int inde
private ImageBuilder createCreatureIcon(final String name) {
return new ImageBuilder() {
{
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + name + ".png"));
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + name + ".png"));
valignCenter();
}
};
Expand All @@ -1026,16 +1023,14 @@ private ImageBuilder createCreatureIcon(final String name) {
private ImageBuilder createCreatureMeleeIcon(final String name) {
return new ImageBuilder() {
{
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + name + ".png"));
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + name + ".png"));
valignCenter();
marginLeft("6px");
focusable(true);
id("creature-melee");
onFocusEffect(new EffectBuilder("imageOverlay") {
{
effectParameter("filename", AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + "GUI/Icons/selected-creature.png"));
effectParameter("filename", AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + "GUI/Icons/selected-creature.png"));
post(true);
}
});
Expand All @@ -1046,16 +1041,14 @@ private ImageBuilder createCreatureMeleeIcon(final String name) {
private ImageBuilder createCreatureSpellIcon(final CreatureSpell cs, final int index) {
return new ImageBuilder() {
{
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + cs.getGuiIcon().getName() + ".png"));
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + cs.getGuiIcon().getName() + ".png"));
valignCenter();
marginLeft("6px");
focusable(true);
id("creature-spell_" + index);
onFocusEffect(new EffectBuilder("imageOverlay") {
{
effectParameter("filename", AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + "GUI/Icons/selected-spell.png"));
effectParameter("filename", AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + "GUI/Icons/selected-spell.png"));
post(true);
}
});
Expand All @@ -1074,7 +1067,7 @@ private ControlBuilder createRoomIcon(final ResearchableEntity roomInfo) {
}

return createIcon(room.getId(),
"room", "gui\\rooms\\tba", null, null, false, false);
"room", "GUI/Rooms/tba", null, null, false, false);
}

private ControlBuilder createSpellIcon(final ResearchableEntity spell) {
Expand All @@ -1086,7 +1079,7 @@ private ControlBuilder createSpellIcon(final ResearchableEntity spell) {
return createIcon(keeperSpell.getKeeperSpellId(), "spell", spell.isUpgraded() ? keeperSpell.getGuiIcon().getName() + "-2" : keeperSpell.getGuiIcon().getName(), tip, hint, true, spell.isUpgraded());
}
return createIcon(keeperSpell.getKeeperSpellId(),
"spell", "gui\\spells\\s-tba", null, null, false, false);
"spell", "GUI/Spells/s-tba", null, null, false, false);
}

private ControlBuilder createDoorIcon(final ResearchableEntity doorInfo) {
Expand All @@ -1100,7 +1093,7 @@ private ControlBuilder createDoorIcon(final ResearchableEntity doorInfo) {
}

return createIcon(door.getId(),
"door", "gui\\traps\\w-tba", null, null, false, false);
"door", "GUI/Traps/w-tba", null, null, false, false);
}

private ControlBuilder createTrapIcon(final ResearchableEntity trapInfo) {
Expand All @@ -1113,7 +1106,7 @@ private ControlBuilder createTrapIcon(final ResearchableEntity trapInfo) {
}

return createIcon(trap.getId(),
"trap", "gui\\traps\\w-tba", null, null, false, false);
"trap", "GUI/Traps/w-tba", null, null, false, false);
}

public ControlBuilder createIcon(final int id, final String type, final ArtResource guiIcon, final String tooltip, final String hint, final boolean allowSelect, final boolean hilightGold) {
Expand All @@ -1122,9 +1115,9 @@ public ControlBuilder createIcon(final int id, final String type, final ArtResou

public ControlBuilder createIcon(final int id, final String type, final String guiIcon, final String tooltip, final String hint, final boolean allowSelect, final boolean hilightGold) {
ControlBuilder cb = new GuiIconBuilder(type + "_" + id,
AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + File.separator + guiIcon + ".png"),
AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + File.separator + (hilightGold ? "GUI/Icons/Hilight-2.png" : "GUI/Icons/hilight.png")),
AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + File.separator + "GUI/Icons/selected-" + type + ".png"),
AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + guiIcon + ".png"),
AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + (hilightGold ? "GUI/Icons/Hilight-2.png" : "GUI/Icons/hilight.png")),
AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + "GUI/Icons/selected-" + type + ".png"),
hint != null ? hint : "",
tooltip != null ? tooltip : "",
"select(" + type + ", " + id + ")");
Expand All @@ -1136,6 +1129,8 @@ public ControlBuilder createIcon(final int id, final String type, final String g

@Override
public void playSound(String category, String id) {
if (Main.isAudioDisabled())
return;
SoundHandle soundHandler = NiftyUtils.getSoundHandler(nifty, category, Integer.parseInt(id));
if (soundHandler != null) {
soundHandler.play();
Expand Down Expand Up @@ -1331,8 +1326,7 @@ private boolean isValidEntity(Entity entity) {
private CreatureCardControl createPlayerCreatureIcon(Creature creature, Screen hud, Element parent) {
ControlBuilder cb = new ControlBuilder("creature") {
{
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER
+ File.separator + creature.getPortraitResource().getName() + ".png"));
filename(AssetUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER + creature.getPortraitResource().getName() + ".png"));
parameter("creatureId", Integer.toString(creature.getCreatureId()));
id("creature_" + creature.getCreatureId());
}
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/toniarts/openkeeper/game/state/SoundState.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ private void attachSpeech(String soundCategory, int speechId, ISpeechListener li
throw new RuntimeException("Sound category " + soundCategory + " not found");
}

String file = AssetsConverter.SOUNDS_FOLDER + File.separator
+ sc.getGroup(speechId).getFiles().get(0).getFilename();
String file = AssetsConverter.SOUNDS_FOLDER + sc.getGroup(speechId).getFiles().get(0).getFilename();
speechQueue.add(new Speech(speechId, file, listener));
} catch (RuntimeException e) {
logger.log(Level.WARNING, "Failed to attach speech from category " + soundCategory + " with id " + speechId, e);
Expand Down Expand Up @@ -203,7 +202,10 @@ private void playBackground() {
return;
}

String file = AssetsConverter.SOUNDS_FOLDER + File.separator + backgroundState.getNext();
String file = backgroundState.getNext();
if (file == null)
return;
file = AssetsConverter.SOUNDS_FOLDER + file;

backgroundNode = new AudioNode(app.getAssetManager(), file, DataType.Buffer);
if (backgroundNode == null) {
Expand Down Expand Up @@ -273,25 +275,21 @@ public final synchronized void setCategory(String category) {
}

public synchronized String getNext() {
if (itGroup == null) {
if (itGroup == null)
itGroup = sc.getGroups().values().iterator();
}

if (itFile == null) {
while (itFile == null || !itFile.hasNext()) {
if (itGroup.hasNext()) {
itFile = itGroup.next().getFiles().iterator();
} else {
itGroup = null;
return this.getNext();
// Exhausted all groups, start over if there are files
itGroup = sc.getGroups().values().iterator();
if (!itGroup.hasNext())
return null;
}
}

if (itFile.hasNext()) {
return itFile.next().getFilename();
} else {
itFile = null;
return this.getNext();
}
return itFile.next().getFilename();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/toniarts/openkeeper/gui/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Cursor(AssetManager assetManager, String Filename, int hotspotx, int hots
throw new IllegalArgumentException("The cursor needs at least a framecount of 1.");
}

Texture tex = assetManager.loadTexture(PathUtils.convertFileSeparators(AssetsConverter.MOUSE_CURSORS_FOLDER.concat(File.separator).concat(Filename)));
Texture tex = assetManager.loadTexture(PathUtils.convertFileSeparators(AssetsConverter.MOUSE_CURSORS_FOLDER + Filename));
Image img = tex.getImage();
// width must be a multiple of 16, otherwise the cursor gets distorted
int width = img.getWidth() % 16 == 0 ? img.getWidth() : (img.getWidth() - img.getWidth() % 16) + 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static SoundHandle getSoundHandler(Nifty nifty, String category, int id)

SoundHandle soundHandler = nifty.getSoundSystem().getSound(file.toString());
if (soundHandler == null) {
String filename = AssetsConverter.SOUNDS_FOLDER + File.separator + file.getFilename();
String filename = AssetsConverter.SOUNDS_FOLDER + file.getFilename();
if (nifty.getSoundSystem().addSound(file.toString(), filename)) {
soundHandler = nifty.getSoundSystem().getSound(file.toString());
}
Expand Down
Loading