Soundsystem weiter ausgebaut
BIN
assets/imported/animations/sitting_cycle.glb
Normal file
18
blight-assets/src/main/resources/MatDefs/GaussianBlur.j3md
Normal file
@@ -0,0 +1,18 @@
|
||||
MaterialDef GaussianBlur {
|
||||
|
||||
MaterialParameters {
|
||||
Texture2D Texture
|
||||
Float BlurScale : 6.0
|
||||
Int NumSamples
|
||||
Int NumSamplesDepth
|
||||
Texture2D DepthTexture
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL150: Common/MatDefs/Post/Post15.vert
|
||||
FragmentShader GLSL150: Shaders/GaussianBlur.frag
|
||||
|
||||
WorldParameters {
|
||||
}
|
||||
}
|
||||
}
|
||||
45
blight-assets/src/main/resources/Shaders/GaussianBlur.frag
Normal file
@@ -0,0 +1,45 @@
|
||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||
|
||||
uniform sampler2D m_Texture;
|
||||
uniform float m_BlurScale;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
// 5x5 Gauß-Kernel (σ≈1.2, vollständig normiert)
|
||||
void main() {
|
||||
vec2 ts = m_BlurScale / vec2(textureSize(m_Texture, 0));
|
||||
|
||||
vec4 c = vec4(0.0);
|
||||
|
||||
c += texture2D(m_Texture, texCoord + vec2(-2.0, -2.0) * ts) * 0.00731;
|
||||
c += texture2D(m_Texture, texCoord + vec2(-1.0, -2.0) * ts) * 0.02075;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 0.0, -2.0) * ts) * 0.02936;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 1.0, -2.0) * ts) * 0.02075;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 2.0, -2.0) * ts) * 0.00731;
|
||||
|
||||
c += texture2D(m_Texture, texCoord + vec2(-2.0, -1.0) * ts) * 0.02075;
|
||||
c += texture2D(m_Texture, texCoord + vec2(-1.0, -1.0) * ts) * 0.05890;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 0.0, -1.0) * ts) * 0.08334;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 1.0, -1.0) * ts) * 0.05890;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 2.0, -1.0) * ts) * 0.02075;
|
||||
|
||||
c += texture2D(m_Texture, texCoord + vec2(-2.0, 0.0) * ts) * 0.02936;
|
||||
c += texture2D(m_Texture, texCoord + vec2(-1.0, 0.0) * ts) * 0.08334;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 0.0, 0.0) * ts) * 0.11792;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 1.0, 0.0) * ts) * 0.08334;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 2.0, 0.0) * ts) * 0.02936;
|
||||
|
||||
c += texture2D(m_Texture, texCoord + vec2(-2.0, 1.0) * ts) * 0.02075;
|
||||
c += texture2D(m_Texture, texCoord + vec2(-1.0, 1.0) * ts) * 0.05890;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 0.0, 1.0) * ts) * 0.08334;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 1.0, 1.0) * ts) * 0.05890;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 2.0, 1.0) * ts) * 0.02075;
|
||||
|
||||
c += texture2D(m_Texture, texCoord + vec2(-2.0, 2.0) * ts) * 0.00731;
|
||||
c += texture2D(m_Texture, texCoord + vec2(-1.0, 2.0) * ts) * 0.02075;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 0.0, 2.0) * ts) * 0.02936;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 1.0, 2.0) * ts) * 0.02075;
|
||||
c += texture2D(m_Texture, texCoord + vec2( 2.0, 2.0) * ts) * 0.00731;
|
||||
|
||||
gl_FragColor = c; // Gewichte summieren sich auf 1.0
|
||||
}
|
||||
BIN
blight-assets/src/main/resources/Textures/menu/background.png
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
blight-assets/src/main/resources/Textures/menu/button.png
Normal file
|
After Width: | Height: | Size: 333 B |
BIN
blight-assets/src/main/resources/Textures/menu/button_arrow.png
Normal file
|
After Width: | Height: | Size: 250 B |
|
After Width: | Height: | Size: 335 B |
BIN
blight-assets/src/main/resources/Textures/menu/button_quit.png
Normal file
|
After Width: | Height: | Size: 333 B |
BIN
blight-assets/src/main/resources/Textures/menu/button_save.png
Normal file
|
After Width: | Height: | Size: 337 B |
BIN
blight-assets/src/main/resources/Textures/menu/item_cell.png
Normal file
|
After Width: | Height: | Size: 410 B |
BIN
blight-assets/src/main/resources/Textures/menu/panel.png
Normal file
|
After Width: | Height: | Size: 428 B |
BIN
blight-assets/src/main/resources/Textures/menu/tab_active.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
blight-assets/src/main/resources/Textures/menu/tab_inactive.png
Normal file
|
After Width: | Height: | Size: 226 B |
BIN
blight-assets/src/main/resources/audio/footsteps/dirt/dirt1.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/dirt/dirt2.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/dirt/dirt3.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/dirt/dirt4.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/grass/gras1.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/grass/gras2.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/grass/gras3.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/grass/gras4.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/rock/rock1.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/rock/rock2.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/rock/rock3.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/rock/rock4.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/sand/sand1.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/sand/sand2.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/sand/sand3.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/sand/sand4.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/sand/sand5.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/steps1.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/steps2.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/steps3.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/steps4.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/wood/wood1.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/wood/wood2.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/wood/wood3.ogg
Normal file
BIN
blight-assets/src/main/resources/audio/footsteps/wood/wood4.ogg
Normal file
@@ -1,5 +1,54 @@
|
||||
{
|
||||
"status": "NEUTRAL",
|
||||
"trader": false,
|
||||
"currentOptions": [
|
||||
{
|
||||
"id": "5a9821c8-f0f3-49c2-a570-9b68e819b46a",
|
||||
"label": "First Contact",
|
||||
"requiresChapter": 0,
|
||||
"requiresStatus": "NEUTRAL",
|
||||
"textHero": {
|
||||
"id": "Hi! Ich suche einen Weg von diesem Strand."
|
||||
},
|
||||
"textNpc": {
|
||||
"id": "Woher kommst du?"
|
||||
},
|
||||
"nextOptions": [
|
||||
{
|
||||
"id": "f78aa61f-8532-4b64-8f0e-c90ff0e92760",
|
||||
"label": "Test1",
|
||||
"requiresChapter": 0,
|
||||
"textHero": {
|
||||
"id": "test"
|
||||
},
|
||||
"textNpc": {
|
||||
"id": "test"
|
||||
},
|
||||
"nextOptions": [
|
||||
{
|
||||
"id": "0114af85-986f-4923-b77e-88529b868c0f",
|
||||
"label": "test2",
|
||||
"requiresChapter": 0,
|
||||
"textHero": {
|
||||
"id": "test"
|
||||
},
|
||||
"textNpc": {
|
||||
"id": "test"
|
||||
},
|
||||
"abortsQuests": [],
|
||||
"enablesTrade": false
|
||||
}
|
||||
],
|
||||
"abortsQuests": [],
|
||||
"enablesTrade": false
|
||||
}
|
||||
],
|
||||
"abortsQuests": [],
|
||||
"enablesTrade": false
|
||||
}
|
||||
],
|
||||
"defaultMessages": {},
|
||||
"routines": [],
|
||||
"characterId": "silas",
|
||||
"name": {
|
||||
"id": "silas.name"
|
||||
|
||||
1
blight-assets/src/main/resources/localization/de.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
15
blight-assets/src/main/resources/quests/strandgut.quest
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"count": 1,
|
||||
"xp": 100,
|
||||
"questId": "strandgut",
|
||||
"text": {
|
||||
"id": "strandgut.name"
|
||||
},
|
||||
"description": {
|
||||
"id": "strandgut.description"
|
||||
},
|
||||
"successText": {
|
||||
"id": "strandgut.successmassage"
|
||||
},
|
||||
"type": "ITEM"
|
||||
}
|
||||
@@ -129,6 +129,9 @@ public final class MapData {
|
||||
/** Spawnpunkt Z-Koordinate in Welteinheiten (default: 0 = Kartenmitte). */
|
||||
public float spawnZ = 0f;
|
||||
|
||||
/** Blickrichtung am permanenten Spawnpunkt in Grad (0 = +Z, 90 = +X, Uhrzeigersinn von oben). */
|
||||
public float spawnYaw = 0f;
|
||||
|
||||
/** Terrain-Slot (0-7) für flache Voxel-Flächen (TexFlat), -1 = nicht gesetzt. */
|
||||
public int voxelFlatSlot = -1;
|
||||
/** Terrain-Slot (0-7) für steile Wände (TexSteep), -1 = nicht gesetzt. */
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class MapIO {
|
||||
}
|
||||
|
||||
private static final int MAGIC = 0x424C4947; // "BLIG"
|
||||
private static final int VERSION = 14;
|
||||
private static final int VERSION = 15;
|
||||
|
||||
// Größen älterer Saves (v≤9) – für Migrations-Upsampling
|
||||
private static final int OLD_TERRAIN_VERTS = 4097;
|
||||
@@ -124,6 +124,8 @@ public final class MapIO {
|
||||
// v4: spawnpunkt
|
||||
out.writeFloat(data.spawnX);
|
||||
out.writeFloat(data.spawnZ);
|
||||
// v15: spawn-blickrichtung
|
||||
out.writeFloat(data.spawnYaw);
|
||||
// v5: splatA + texturpfade + gebirge-splatmap
|
||||
out.write(data.splatA);
|
||||
writeStrings(out, data.terrainTextures);
|
||||
@@ -232,6 +234,9 @@ public final class MapIO {
|
||||
data.spawnX = in.readFloat();
|
||||
data.spawnZ = in.readFloat();
|
||||
}
|
||||
if (version >= 15) {
|
||||
data.spawnYaw = in.readFloat();
|
||||
}
|
||||
if (version >= 5) {
|
||||
if (version >= 10) {
|
||||
in.readFully(data.splatA);
|
||||
|
||||
@@ -32,7 +32,8 @@ public record ModelMeta(
|
||||
float interactableOffsetX,
|
||||
float interactableOffsetY,
|
||||
float interactableOffsetZ,
|
||||
float interactableRotY
|
||||
float interactableRotY,
|
||||
String footstepSurface
|
||||
) {
|
||||
/** Lichtquelle relativ zum Modell-Ursprung. */
|
||||
public record AttachedLight(
|
||||
@@ -52,6 +53,6 @@ public record ModelMeta(
|
||||
"", "", 30f, 80f, 120f,
|
||||
List.of(), List.of(),
|
||||
de.blight.common.model.InteractableType.NONE,
|
||||
0f, 0.5f, 0f, 0f);
|
||||
0f, 0.5f, 0f, 0f, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public final class ModelMetaIO {
|
||||
p.setProperty("interactableOffsetY", String.valueOf(m.interactableOffsetY()));
|
||||
p.setProperty("interactableOffsetZ", String.valueOf(m.interactableOffsetZ()));
|
||||
p.setProperty("interactableRotY", String.valueOf(m.interactableRotY()));
|
||||
p.setProperty("footstepSurface", m.footstepSurface() != null ? m.footstepSurface() : "");
|
||||
|
||||
// Anhänge: Lichter
|
||||
List<ModelMeta.AttachedLight> lights = m.attachedLights();
|
||||
@@ -138,7 +139,8 @@ public final class ModelMetaIO {
|
||||
parseFloat(p, "interactableOffsetX", 0f),
|
||||
parseFloat(p, "interactableOffsetY", 0.5f),
|
||||
parseFloat(p, "interactableOffsetZ", 0f),
|
||||
parseFloat(p, "interactableRotY", 0f)
|
||||
parseFloat(p, "interactableRotY", 0f),
|
||||
p.getProperty("footstepSurface", "")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,4 +40,10 @@ public class Bed implements Interactable {
|
||||
public String getDisplayText() {
|
||||
return TextRegistry.resolve(name, id != null ? id : "Bett");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabelKey() {
|
||||
if (name != null && name.id() != null && !name.id().isBlank()) return name.id();
|
||||
return "interactable.bed.name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,4 +41,10 @@ public class Bench implements Interactable {
|
||||
public String getDisplayText() {
|
||||
return TextRegistry.resolve(name, id != null ? id : "Bank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabelKey() {
|
||||
if (name != null && name.id() != null && !name.id().isBlank()) return name.id();
|
||||
return "interactable.bench.name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,8 @@ package de.blight.common.model;
|
||||
|
||||
public interface Interactable {
|
||||
|
||||
public String getDisplayText();
|
||||
String getDisplayText();
|
||||
|
||||
/** Gibt den Lokalisierungsschlüssel für das HUD-Label zurück (z.B. "item.driftwood.name"). */
|
||||
default String getLabelKey() { return ""; }
|
||||
}
|
||||
|
||||
@@ -30,4 +30,10 @@ public class Item implements Interactable {
|
||||
public String getDisplayText() {
|
||||
return TextRegistry.resolve(name, itemId != null ? itemId : "?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabelKey() {
|
||||
if (name != null && name.id() != null && !name.id().isBlank()) return name.id();
|
||||
return itemId != null ? "item." + itemId + ".name" : "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package de.blight.common.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -11,7 +13,7 @@ import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class NPC extends GameCharacter {
|
||||
public class NPC extends GameCharacter implements Interactable {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NPC.class);
|
||||
|
||||
@@ -23,6 +25,15 @@ public class NPC extends GameCharacter {
|
||||
|
||||
private List<DialogOption> currentOptions;
|
||||
|
||||
/** Nur im Editor relevant: Optionen die nicht mit currentOptions verbunden sind, aber erhalten werden sollen. */
|
||||
private List<DialogOption> editorOnlyOptions;
|
||||
|
||||
/**
|
||||
* Standard-Nachrichten je Status, die angezeigt werden wenn keine Dialog-Optionen
|
||||
* verfügbar sind. Schlüssel = Status-Wert des NPCs zum Gesprächszeitpunkt.
|
||||
*/
|
||||
private Map<Status, TextReference> defaultMessages = new EnumMap<>(Status.class);
|
||||
|
||||
/** Tagesabläufe dieses NPCs. Die erste Routine gilt standardmäßig als aktiv. */
|
||||
private List<NpcRoutine> routines = new ArrayList<>();
|
||||
|
||||
@@ -58,6 +69,35 @@ public class NPC extends GameCharacter {
|
||||
this.activeRoutineName = routineName;
|
||||
}
|
||||
|
||||
// ── Interactable ─────────────────────────────────────────────────────────
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return TextRegistry.resolve(getName(), getCharacterId() != null ? getCharacterId() : "NPC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabelKey() {
|
||||
TextReference nameRef = getName();
|
||||
if (nameRef != null && nameRef.id() != null && !nameRef.id().isBlank()) return nameRef.id();
|
||||
return getCharacterId() != null ? "npc." + getCharacterId() + ".name" : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die Default-Nachricht für den aktuellen Status zurück.
|
||||
* Fällt auf den nächst-freundlicheren Status zurück wenn kein Eintrag gefunden wird.
|
||||
*/
|
||||
public TextReference getDefaultMessage() {
|
||||
if (defaultMessages == null || defaultMessages.isEmpty()) return null;
|
||||
Status s = status != null ? status : Status.NEUTRAL;
|
||||
Status[] fallback = {s, Status.NEUTRAL, Status.FRIENDLY, Status.ENRAGED, Status.ENEMY};
|
||||
for (Status candidate : fallback) {
|
||||
TextReference ref = defaultMessages.get(candidate);
|
||||
if (ref != null) return ref;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ── Dialog-Methoden ──────────────────────────────────────────────────────
|
||||
|
||||
public List<DialogOption> getAvailableOptions(MainCharacter character) {
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
package de.blight.editor;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.Clip;
|
||||
import javax.sound.sampled.LineEvent;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Nicht-modales Popup zum Vorhören von OGG-Dateien.
|
||||
* Nutzt javax.sound.sampled + j-ogg-vorbis SPI (bereits transitiv über jme3-jogg
|
||||
* im Classpath). Kein GStreamer, kein javafx.media nötig.
|
||||
*/
|
||||
public class AudioPreviewPopup {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AudioPreviewPopup.class);
|
||||
|
||||
private Stage stage;
|
||||
private Clip clip;
|
||||
private boolean paused = false;
|
||||
private boolean repeat = false;
|
||||
|
||||
private List<Path> playlist = Collections.emptyList();
|
||||
private int idx = 0;
|
||||
|
||||
private Label fileLabel;
|
||||
private Label folderLabel;
|
||||
private Button playPauseBtn;
|
||||
private ToggleButton repeatBtn;
|
||||
|
||||
// ── API ───────────────────────────────────────────────────────────────────
|
||||
|
||||
/** Öffnet das Popup (oder bringt es in den Vordergrund) und lädt die Datei. */
|
||||
public void open(Path file) {
|
||||
if (stage == null) buildStage();
|
||||
loadFile(file);
|
||||
if (!stage.isShowing()) stage.show();
|
||||
stage.toFront();
|
||||
}
|
||||
|
||||
// ── Intern ────────────────────────────────────────────────────────────────
|
||||
|
||||
private void loadFile(Path file) {
|
||||
buildPlaylist(file.getParent());
|
||||
idx = playlist.indexOf(file);
|
||||
if (idx < 0) idx = 0;
|
||||
playIndex(idx);
|
||||
}
|
||||
|
||||
private void buildPlaylist(Path folder) {
|
||||
if (folder == null) { playlist = Collections.emptyList(); return; }
|
||||
try (var s = Files.list(folder)) {
|
||||
playlist = s.filter(p -> Files.isRegularFile(p)
|
||||
&& p.getFileName().toString().toLowerCase().endsWith(".ogg"))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
log.warn("[AudioPreview] Ordner nicht lesbar: {}", folder);
|
||||
playlist = Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private void navigate(int delta) {
|
||||
if (playlist.isEmpty()) return;
|
||||
idx = (idx + delta + playlist.size()) % playlist.size();
|
||||
playIndex(idx);
|
||||
}
|
||||
|
||||
private void playIndex(int i) {
|
||||
if (playlist.isEmpty()) return;
|
||||
Path file = playlist.get(i);
|
||||
|
||||
stopClip();
|
||||
fileLabel.setText(file.getFileName().toString());
|
||||
folderLabel.setText(file.getParent() != null ? shortenPath(file.getParent()) : "");
|
||||
playPauseBtn.setText("⏳");
|
||||
playPauseBtn.setDisable(true);
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
AudioInputStream raw = AudioSystem.getAudioInputStream(file.toFile());
|
||||
AudioFormat src = raw.getFormat();
|
||||
float rate = src.getSampleRate() < 0 ? 44100f : src.getSampleRate();
|
||||
int ch = src.getChannels() < 0 ? 1 : src.getChannels();
|
||||
AudioFormat pcm = new AudioFormat(
|
||||
AudioFormat.Encoding.PCM_SIGNED,
|
||||
rate, 16, ch, ch * 2, rate, false);
|
||||
AudioInputStream pcmStream = AudioSystem.getAudioInputStream(pcm, raw);
|
||||
Clip newClip = AudioSystem.getClip();
|
||||
newClip.open(pcmStream);
|
||||
|
||||
newClip.addLineListener(ev -> {
|
||||
if (ev.getType() == LineEvent.Type.STOP && !paused && !repeat) {
|
||||
Platform.runLater(() -> playPauseBtn.setText("▶"));
|
||||
}
|
||||
});
|
||||
|
||||
Platform.runLater(() -> {
|
||||
clip = newClip;
|
||||
paused = false;
|
||||
playPauseBtn.setDisable(false);
|
||||
if (repeat) {
|
||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
||||
} else {
|
||||
clip.start();
|
||||
}
|
||||
playPauseBtn.setText("⏸");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.warn("[AudioPreview] Nicht ladbar '{}': {}", file.getFileName(), e.getMessage());
|
||||
Platform.runLater(() -> {
|
||||
fileLabel.setText("⚠ " + file.getFileName());
|
||||
playPauseBtn.setText("▶");
|
||||
playPauseBtn.setDisable(false);
|
||||
});
|
||||
}
|
||||
}, "audio-preview-load");
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
private void togglePlay() {
|
||||
if (clip == null) {
|
||||
playIndex(idx);
|
||||
return;
|
||||
}
|
||||
if (clip.isRunning()) {
|
||||
clip.stop();
|
||||
paused = true;
|
||||
playPauseBtn.setText("▶");
|
||||
} else {
|
||||
clip.start();
|
||||
paused = false;
|
||||
playPauseBtn.setText("⏸");
|
||||
}
|
||||
}
|
||||
|
||||
private void stopClip() {
|
||||
if (clip != null) {
|
||||
clip.stop();
|
||||
clip.close();
|
||||
clip = null;
|
||||
}
|
||||
paused = false;
|
||||
}
|
||||
|
||||
private void onRepeatChanged(boolean on) {
|
||||
repeat = on;
|
||||
if (clip == null) return;
|
||||
if (on) {
|
||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
||||
} else {
|
||||
clip.loop(0);
|
||||
}
|
||||
}
|
||||
|
||||
// ── UI-Aufbau ─────────────────────────────────────────────────────────────
|
||||
|
||||
private void buildStage() {
|
||||
stage = new Stage(StageStyle.UTILITY);
|
||||
stage.setTitle("Audio-Vorschau");
|
||||
stage.setAlwaysOnTop(true);
|
||||
stage.setResizable(false);
|
||||
stage.setOnCloseRequest(e -> stopClip());
|
||||
|
||||
fileLabel = new Label("–");
|
||||
fileLabel.setStyle("-fx-font-weight:bold; -fx-text-fill:#eee; -fx-font-size:13;");
|
||||
fileLabel.setWrapText(true);
|
||||
fileLabel.setMaxWidth(340);
|
||||
|
||||
folderLabel = new Label("");
|
||||
folderLabel.setStyle("-fx-text-fill:#777; -fx-font-size:10;");
|
||||
folderLabel.setMaxWidth(340);
|
||||
folderLabel.setWrapText(true);
|
||||
|
||||
Button prevBtn = makeBtn("◀", "Vorherige Datei", () -> navigate(-1));
|
||||
playPauseBtn = makeBtn("▶", "Abspielen / Pausieren", this::togglePlay);
|
||||
Button nextBtn = makeBtn("▶▶", "Nächste Datei", () -> navigate(+1));
|
||||
|
||||
repeatBtn = new ToggleButton("🔁");
|
||||
repeatBtn.setTooltip(new Tooltip("Wiederholen"));
|
||||
styleToggle(repeatBtn, false);
|
||||
repeatBtn.selectedProperty().addListener((o, ov, nv) -> {
|
||||
styleToggle(repeatBtn, nv);
|
||||
onRepeatChanged(nv);
|
||||
});
|
||||
|
||||
HBox controls = new HBox(6, prevBtn, playPauseBtn, nextBtn, repeatBtn);
|
||||
controls.setAlignment(Pos.CENTER);
|
||||
controls.setPadding(new Insets(8, 0, 4, 0));
|
||||
|
||||
VBox root = new VBox(6, fileLabel, folderLabel, controls);
|
||||
root.setPadding(new Insets(12));
|
||||
root.setStyle("-fx-background-color:#2a2a2a;");
|
||||
root.setPrefWidth(360);
|
||||
|
||||
stage.setScene(new Scene(root));
|
||||
}
|
||||
|
||||
private Button makeBtn(String text, String tip, Runnable action) {
|
||||
Button b = new Button(text);
|
||||
b.setTooltip(new Tooltip(tip));
|
||||
styleBtn(b, false, false);
|
||||
b.setOnMouseEntered(e -> styleBtn(b, true, false));
|
||||
b.setOnMouseExited(e -> styleBtn(b, false, false));
|
||||
b.setOnMousePressed(e -> styleBtn(b, true, true));
|
||||
b.setOnMouseReleased(e -> styleBtn(b, true, false));
|
||||
b.setOnAction(e -> action.run());
|
||||
return b;
|
||||
}
|
||||
|
||||
private void styleBtn(Button b, boolean hover, boolean pressed) {
|
||||
String bg = pressed ? "#606060" : hover ? "#4d4d4d" : "#3a3a3a";
|
||||
b.setStyle("-fx-background-color:" + bg + ";" +
|
||||
"-fx-text-fill:#eee;" +
|
||||
"-fx-min-width:36; -fx-min-height:30;" +
|
||||
"-fx-border-color:#555; -fx-border-width:1; -fx-border-radius:3;" +
|
||||
"-fx-background-radius:3; -fx-cursor:hand;");
|
||||
}
|
||||
|
||||
private void styleToggle(ToggleButton b, boolean active) {
|
||||
String bg = active ? "#1565c0" : "#3a3a3a";
|
||||
String border = active ? "#1976d2" : "#555";
|
||||
b.setStyle("-fx-background-color:" + bg + ";" +
|
||||
"-fx-text-fill:#eee;" +
|
||||
"-fx-min-width:36; -fx-min-height:30;" +
|
||||
"-fx-border-color:" + border + "; -fx-border-width:1; -fx-border-radius:3;" +
|
||||
"-fx-background-radius:3; -fx-cursor:hand;");
|
||||
}
|
||||
|
||||
private String shortenPath(Path p) {
|
||||
String s = p.toString();
|
||||
int audio = s.indexOf("/audio/");
|
||||
return audio >= 0 ? s.substring(audio) : s;
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,7 @@ public class EditorApp extends Application {
|
||||
private StackPane plantPreviewPanel; // einmaliges Vorschau-Panel für alle Generatoren
|
||||
private Stage primaryStage;
|
||||
private JmeEditorApp jmeApp;
|
||||
private AudioPreviewPopup audioPreviewPopup;
|
||||
|
||||
// Baum-Generator-Zustand (wird beim Preset-Wechsel neu gesetzt)
|
||||
private TreeParams treeParams = TreeParams.oak();
|
||||
@@ -155,6 +156,7 @@ public class EditorApp extends Application {
|
||||
private String animSetPendingPlayClip = null;
|
||||
private ComboBox<String> animSetModelCombo;
|
||||
private boolean animSetDirty = false;
|
||||
private boolean charDirty = false;
|
||||
private String animSetCurrentName = null;
|
||||
private Path animSetCurrentDir = null;
|
||||
// Anim-Offset-Editor (innerhalb AnimSet-Editor)
|
||||
@@ -163,6 +165,10 @@ public class EditorApp extends Application {
|
||||
javafx.collections.FXCollections.observableArrayList();
|
||||
private java.util.Map<String, de.blight.game.animation.AnimOffset>
|
||||
animSetOffsets = new java.util.LinkedHashMap<>();
|
||||
// Sub-Clip-Editor (innerhalb AnimSet-Editor)
|
||||
private ListView<String> animSetPartsListView;
|
||||
private java.util.Map<String, de.blight.game.animation.AnimSet.SubClipDef>
|
||||
editableSubClips = new java.util.LinkedHashMap<>();
|
||||
|
||||
// Character-Editor-Zustand
|
||||
private de.blight.editor.ui.DialogEditorView dialogEditorView;
|
||||
@@ -173,6 +179,11 @@ public class EditorApp extends Application {
|
||||
private javafx.scene.control.ComboBox<String> charStatusCombo;
|
||||
private javafx.scene.control.CheckBox charTraderCheck;
|
||||
private javafx.scene.control.ListView<String> charTraderItemsView;
|
||||
/** Default-Nachrichten je NPC-Status (TextReference-Schlüssel). */
|
||||
private javafx.scene.control.TextField charMsgFriendly;
|
||||
private javafx.scene.control.TextField charMsgNeutral;
|
||||
private javafx.scene.control.TextField charMsgEnraged;
|
||||
private javafx.scene.control.TextField charMsgEnemy;
|
||||
// Abilities (MainCharacter)
|
||||
private javafx.scene.control.Spinner<Integer> abMagicSpin, abStaffSpin, abSwordSpin,
|
||||
abArcherySpin, abHeavySpin, abCrossbowSpin, abThieverySpin,
|
||||
@@ -211,6 +222,11 @@ public class EditorApp extends Application {
|
||||
// Spiel-Starten-Werkzeug-Zustand
|
||||
private TextField spawnXField;
|
||||
private TextField spawnZField;
|
||||
private Label tempSpawnCoordsLabel;
|
||||
private Label permSpawnCoordsLabel;
|
||||
private Button gameNewBtn;
|
||||
private boolean launchNewGameAfterSave = false;
|
||||
private boolean pendingNewGame = false;
|
||||
|
||||
// Baum-Ordner-Modus
|
||||
private Label randomTreeStatusLabel;
|
||||
@@ -249,6 +265,7 @@ public class EditorApp extends Application {
|
||||
private Spinner<Double> modelEditorInteractableXSpin = null;
|
||||
private Spinner<Double> modelEditorInteractableYSpin = null;
|
||||
private Spinner<Double> modelEditorInteractableZSpin = null;
|
||||
private ComboBox<String> modelEditorFootstepSurfaceCB = null;
|
||||
private boolean updatingInteractableSpinnersFromJme = false;
|
||||
|
||||
// Modell-Import-Zustand
|
||||
@@ -396,6 +413,16 @@ public class EditorApp extends Application {
|
||||
stage.setMinWidth(900);
|
||||
stage.setMinHeight(600);
|
||||
stage.setOnCloseRequest(e -> {
|
||||
if (animSetDirty || charDirty) {
|
||||
Alert confirm = new Alert(Alert.AlertType.CONFIRMATION,
|
||||
"Es gibt ungespeicherte Änderungen.\nTrotzdem beenden?",
|
||||
ButtonType.YES, ButtonType.NO);
|
||||
confirm.setHeaderText("Ungespeicherte Änderungen");
|
||||
confirm.showAndWait().ifPresent(btn -> {
|
||||
if (btn != ButtonType.YES) e.consume();
|
||||
});
|
||||
if (e.isConsumed()) return;
|
||||
}
|
||||
saveCameraPrefs();
|
||||
if (jmeApp != null) jmeApp.stop();
|
||||
Platform.exit();
|
||||
@@ -603,6 +630,11 @@ public class EditorApp extends Application {
|
||||
updateSpawnFields(input.pickedSpawnInfo);
|
||||
}
|
||||
|
||||
if (input.permSpawnChanged) {
|
||||
input.permSpawnChanged = false;
|
||||
if (permSpawnCoordsLabel != null) permSpawnCoordsLabel.setText(permSpawnCoordsText());
|
||||
}
|
||||
|
||||
// Modell-Editor: gebakte Scale aus j3o erkannt → Spinner aktualisieren
|
||||
if (input.modelEditorBakedScaleDetected) {
|
||||
input.modelEditorBakedScaleDetected = false;
|
||||
@@ -3972,6 +4004,10 @@ public class EditorApp extends Application {
|
||||
switchToAnimPreview();
|
||||
input.animPreviewLoadPath = relPath;
|
||||
if (animPreviewStatusLabel != null) animPreviewStatusLabel.setText("Lade…");
|
||||
} else if (cat == audioNode && relPath.endsWith(".ogg")) {
|
||||
if (audioPreviewPopup == null) audioPreviewPopup = new AudioPreviewPopup();
|
||||
audioPreviewPopup.open(p);
|
||||
setStatus("▶ " + relPath);
|
||||
} else if (relPath.endsWith(".animset.json")) {
|
||||
openAnimSetEditor(relPath, p);
|
||||
} else if (relPath.endsWith(".character")) {
|
||||
@@ -4812,7 +4848,12 @@ public class EditorApp extends Application {
|
||||
/** Liest die AnimClip-Namen aus einer J3O-Datei, ohne den JME3-Thread zu benötigen. */
|
||||
private List<String> readAnimClipNames(Path j3oPath) {
|
||||
try {
|
||||
com.jme3.asset.DesktopAssetManager assetManager = new com.jme3.asset.DesktopAssetManager(true);
|
||||
assetManager.registerLocator(
|
||||
de.blight.game.animation.AnimationLibrary.findAssetRoot().toAbsolutePath().toString(),
|
||||
com.jme3.asset.plugins.FileLocator.class);
|
||||
com.jme3.export.binary.BinaryImporter imp = new com.jme3.export.binary.BinaryImporter();
|
||||
imp.setAssetManager(assetManager);
|
||||
com.jme3.scene.Spatial s = (com.jme3.scene.Spatial) imp.load(j3oPath.toFile());
|
||||
com.jme3.anim.AnimComposer ac =
|
||||
de.blight.game.animation.RetargetingSystem.findAnimComposer(s);
|
||||
@@ -6134,6 +6175,26 @@ public class EditorApp extends Application {
|
||||
input.modelInteractableOffsetChanged = true;
|
||||
});
|
||||
|
||||
// ── Fußgeräusch-Untergrund ────────────────────────────────────────────
|
||||
Label footstepTitle = new Label("Fußgeräusch-Untergrund:");
|
||||
footstepTitle.setStyle("-fx-font-weight:bold; -fx-text-fill:#ccc;");
|
||||
|
||||
modelEditorFootstepSurfaceCB = new ComboBox<>();
|
||||
modelEditorFootstepSurfaceCB.getItems().add("");
|
||||
for (de.blight.game.audio.SurfaceType st : de.blight.game.audio.SurfaceType.values()) {
|
||||
modelEditorFootstepSurfaceCB.getItems().add(st.name());
|
||||
}
|
||||
String currentSurface = meta.footstepSurface() != null ? meta.footstepSurface() : "";
|
||||
modelEditorFootstepSurfaceCB.setValue(
|
||||
modelEditorFootstepSurfaceCB.getItems().contains(currentSurface) ? currentSurface : "");
|
||||
modelEditorFootstepSurfaceCB.setMaxWidth(Double.MAX_VALUE);
|
||||
modelEditorFootstepSurfaceCB.setConverter(new javafx.util.StringConverter<>() {
|
||||
@Override public String toString(String s) {
|
||||
return (s == null || s.isEmpty()) ? "(aus Textur)" : s;
|
||||
}
|
||||
@Override public String fromString(String s) { return s; }
|
||||
});
|
||||
|
||||
// ── Buttons ───────────────────────────────────────────────────────────
|
||||
Button saveBtn = new Button("💾 Speichern");
|
||||
saveBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
@@ -6172,7 +6233,10 @@ public class EditorApp extends Application {
|
||||
input.modelInteractableOffsetX,
|
||||
input.modelInteractableOffsetY,
|
||||
input.modelInteractableOffsetZ,
|
||||
input.modelInteractableRotY));
|
||||
input.modelInteractableRotY,
|
||||
modelEditorFootstepSurfaceCB != null
|
||||
? modelEditorFootstepSurfaceCB.getValue()
|
||||
: ""));
|
||||
|
||||
placeBtn.setOnAction(e -> {
|
||||
input.modelEditorCloseRequest = true;
|
||||
@@ -6215,6 +6279,8 @@ public class EditorApp extends Application {
|
||||
new Separator(),
|
||||
interactTitle, modelEditorInteractableCB, restPointBox,
|
||||
new Separator(),
|
||||
footstepTitle, modelEditorFootstepSurfaceCB,
|
||||
new Separator(),
|
||||
saveBtn, placeBtn, closeBtn
|
||||
);
|
||||
return panel;
|
||||
@@ -6667,7 +6733,8 @@ public class EditorApp extends Application {
|
||||
java.util.List<de.blight.common.ModelMeta.AttachedEmitter> emitters,
|
||||
de.blight.common.model.InteractableType interactableType,
|
||||
float interactableOffsetX, float interactableOffsetY,
|
||||
float interactableOffsetZ, float interactableRotY) {
|
||||
float interactableOffsetZ, float interactableRotY,
|
||||
String footstepSurface) {
|
||||
// Scale wird in j3o eingebrannt → Meta bekommt immer 1.0 (kein doppelter Scale beim Laden)
|
||||
de.blight.common.ModelMeta meta = new de.blight.common.ModelMeta(
|
||||
name, category, tags, 1f, 1f, 1f, uniform,
|
||||
@@ -6675,7 +6742,8 @@ public class EditorApp extends Application {
|
||||
lod1Path, lod2Path, 30f, 80f, 120f,
|
||||
lights, emitters,
|
||||
interactableType != null ? interactableType : de.blight.common.model.InteractableType.NONE,
|
||||
interactableOffsetX, interactableOffsetY, interactableOffsetZ, interactableRotY);
|
||||
interactableOffsetX, interactableOffsetY, interactableOffsetZ, interactableRotY,
|
||||
footstepSurface != null ? footstepSurface : "");
|
||||
|
||||
if (absolutePath == null || !absolutePath.toFile().exists()) {
|
||||
setStatus("Fehler: Modell-Datei nicht gefunden – Meta nicht gespeichert");
|
||||
@@ -7008,9 +7076,15 @@ public class EditorApp extends Application {
|
||||
if (bothDown) {
|
||||
stopEditTimer();
|
||||
} else if (e.getButton() == MouseButton.PRIMARY) {
|
||||
if (input.activeLayer == SharedInput.LAYER_PLAY_TOOL) {
|
||||
// Einzel-Klick ohne Edit-Timer (verhindert Dauer-Spam)
|
||||
input.playToolClickQueue.offer(
|
||||
new SharedInput.PlayToolClick((float) e.getX(), (float) e.getY()));
|
||||
} else {
|
||||
editPressX = e.getX(); editPressY = e.getY(); editPressAction = +1;
|
||||
submitEdit(editPressX, editPressY, editPressAction);
|
||||
startEditTimer();
|
||||
}
|
||||
} else if (e.getButton() == MouseButton.SECONDARY) {
|
||||
editPressX = e.getX(); editPressY = e.getY(); editPressAction = -1;
|
||||
submitEdit(editPressX, editPressY, editPressAction);
|
||||
@@ -7030,6 +7104,15 @@ public class EditorApp extends Application {
|
||||
return;
|
||||
}
|
||||
|
||||
// Play-Tool EDIT: Drag-Events an JME3 weiterleiten
|
||||
if (input.activeLayer == SharedInput.LAYER_PLAY_TOOL
|
||||
&& input.playToolMode == SharedInput.PlayToolMode.EDIT
|
||||
&& e.isPrimaryButtonDown()) {
|
||||
input.playToolDragQueue.offer(
|
||||
new SharedInput.PlayToolDrag((float) e.getX(), (float) e.getY()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.isPrimaryButtonDown() || e.isSecondaryButtonDown()) {
|
||||
editPressX = e.getX();
|
||||
editPressY = e.getY();
|
||||
@@ -7041,6 +7124,9 @@ public class EditorApp extends Application {
|
||||
viewport.setOnMouseReleased(e -> {
|
||||
objDragging = false;
|
||||
if (!isObjectMode()) stopEditTimer();
|
||||
if (input.activeLayer == SharedInput.LAYER_PLAY_TOOL) {
|
||||
input.playToolMouseUp = true;
|
||||
}
|
||||
if (input.vertexSnapEnabled
|
||||
&& input.objectSelectionMode == SharedInput.SEL_MODE_VERTEX) {
|
||||
input.vertexSnapTrigger = true;
|
||||
@@ -7141,17 +7227,28 @@ public class EditorApp extends Application {
|
||||
}
|
||||
|
||||
private void launchGame() {
|
||||
if (launchGameAfterSave) return; // bereits ausstehend
|
||||
if (launchGameAfterSave) return;
|
||||
launchGameAfterSave = true;
|
||||
if (gamePlayBtn != null) {
|
||||
gamePlayBtn.setDisable(true);
|
||||
gamePlayBtn.setText("⏳ Startet…");
|
||||
}
|
||||
pendingNewGame = false;
|
||||
if (gamePlayBtn != null) { gamePlayBtn.setDisable(true); gamePlayBtn.setText("⏳ Startet…"); }
|
||||
if (gameNewBtn != null) gameNewBtn.setDisable(true);
|
||||
input.saveRequested = true;
|
||||
setStatus("Karte wird gespeichert, Spiel startet…");
|
||||
}
|
||||
|
||||
private void launchNewGame() {
|
||||
if (launchGameAfterSave) return;
|
||||
launchGameAfterSave = true;
|
||||
pendingNewGame = true;
|
||||
if (gameNewBtn != null) { gameNewBtn.setDisable(true); gameNewBtn.setText("⏳ Startet…"); }
|
||||
if (gamePlayBtn != null) gamePlayBtn.setDisable(true);
|
||||
input.saveRequested = true;
|
||||
setStatus("Karte wird gespeichert, Neues Spiel startet…");
|
||||
}
|
||||
|
||||
private void startGameProcess() {
|
||||
final boolean isNewGame = pendingNewGame;
|
||||
pendingNewGame = false;
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String javaExe = Paths.get(System.getProperty("java.home"), "bin", "java").toString();
|
||||
@@ -7178,9 +7275,12 @@ public class EditorApp extends Application {
|
||||
// Vom Editor gestartet: Hauptmenü überspringen, letzten Stand fortsetzen
|
||||
"-Dblight.autostart=true"));
|
||||
|
||||
if (!Float.isNaN(input.tempSpawnX) && !Float.isNaN(input.tempSpawnZ)) {
|
||||
if (isNewGame) {
|
||||
cmd.add("-Dblight.new.game=true");
|
||||
} else if (!Float.isNaN(input.tempSpawnX) && !Float.isNaN(input.tempSpawnZ)) {
|
||||
cmd.add("-Dblight.temp.spawn.x=" + input.tempSpawnX);
|
||||
cmd.add("-Dblight.temp.spawn.z=" + input.tempSpawnZ);
|
||||
cmd.add("-Dblight.temp.spawn.yaw=" + input.tempSpawnYaw);
|
||||
}
|
||||
|
||||
cmd.addAll(List.of("-cp", classpath, "de.blight.game.BlightGame"));
|
||||
@@ -7191,8 +7291,9 @@ public class EditorApp extends Application {
|
||||
.start();
|
||||
|
||||
Platform.runLater(() -> {
|
||||
setStatus("Spiel gestartet");
|
||||
setStatus(isNewGame ? "Neues Spiel gestartet" : "Spiel gestartet");
|
||||
if (gamePlayBtn != null) gamePlayBtn.setText("🎮 Läuft…");
|
||||
if (gameNewBtn != null) gameNewBtn.setText("🎮 Läuft…");
|
||||
openGameConsole();
|
||||
});
|
||||
|
||||
@@ -7205,22 +7306,18 @@ public class EditorApp extends Application {
|
||||
consoleBuffer.offer(line);
|
||||
}
|
||||
}
|
||||
// Spiel beendet → Button freigeben
|
||||
// Spiel beendet → Buttons freigeben
|
||||
consoleBuffer.offer("--- Spiel beendet ---");
|
||||
Platform.runLater(() -> {
|
||||
if (gamePlayBtn != null) {
|
||||
gamePlayBtn.setText("▶ Spielen");
|
||||
gamePlayBtn.setDisable(false);
|
||||
}
|
||||
if (gamePlayBtn != null) { gamePlayBtn.setText("▶ Spielen"); gamePlayBtn.setDisable(false); }
|
||||
if (gameNewBtn != null) { gameNewBtn.setText("🆕 Neues Spiel"); gameNewBtn.setDisable(false); }
|
||||
});
|
||||
|
||||
} catch (IOException ex) {
|
||||
Platform.runLater(() -> {
|
||||
setStatus("Spielstart fehlgeschlagen: " + ex.getMessage());
|
||||
if (gamePlayBtn != null) {
|
||||
gamePlayBtn.setText("▶ Spielen");
|
||||
gamePlayBtn.setDisable(false);
|
||||
}
|
||||
if (gamePlayBtn != null) { gamePlayBtn.setText("▶ Spielen"); gamePlayBtn.setDisable(false); }
|
||||
if (gameNewBtn != null) { gameNewBtn.setText("🆕 Neues Spiel"); gameNewBtn.setDisable(false); }
|
||||
});
|
||||
}
|
||||
}, "game-launcher").start();
|
||||
@@ -7809,47 +7906,63 @@ public class EditorApp extends Application {
|
||||
private VBox buildPlayToolPanel() {
|
||||
VBox inner = new VBox(8);
|
||||
inner.setPadding(new Insets(10));
|
||||
inner.getChildren().addAll(
|
||||
sectionTitle("Spiel starten"),
|
||||
new Separator(),
|
||||
bold("Temporärer Spawnpunkt:"),
|
||||
styledHint("L-Klick im Viewport → Spawnpunkt setzen"));
|
||||
|
||||
Label coordHint = new Label("oder manuell eingeben:");
|
||||
coordHint.setStyle("-fx-text-fill: #444;");
|
||||
inner.getChildren().add(coordHint);
|
||||
// ── Abschnitt: Spawnpunkte setzen ────────────────────────────────────
|
||||
inner.getChildren().addAll(sectionTitle("Spawnpunkte"), new Separator());
|
||||
|
||||
spawnXField = new TextField(Float.isNaN(input.tempSpawnX) ? "" : String.valueOf(input.tempSpawnX));
|
||||
spawnZField = new TextField(Float.isNaN(input.tempSpawnZ) ? "" : String.valueOf(input.tempSpawnZ));
|
||||
spawnXField.setPromptText("X");
|
||||
spawnZField.setPromptText("Z");
|
||||
|
||||
Runnable applyFields = () -> {
|
||||
try {
|
||||
input.tempSpawnX = Float.parseFloat(spawnXField.getText().trim());
|
||||
input.tempSpawnZ = Float.parseFloat(spawnZField.getText().trim());
|
||||
} catch (NumberFormatException ignored2) {}
|
||||
};
|
||||
spawnXField.setOnAction(e -> applyFields.run());
|
||||
spawnZField.setOnAction(e -> applyFields.run());
|
||||
spawnXField.focusedProperty().addListener((o, ov, nv) -> { if (!nv) applyFields.run(); });
|
||||
spawnZField.focusedProperty().addListener((o, ov, nv) -> { if (!nv) applyFields.run(); });
|
||||
|
||||
HBox coordRow = new HBox(6, new Label("X:"), spawnXField, new Label("Z:"), spawnZField);
|
||||
coordRow.setAlignment(Pos.CENTER_LEFT);
|
||||
HBox.setHgrow(spawnXField, Priority.ALWAYS);
|
||||
HBox.setHgrow(spawnZField, Priority.ALWAYS);
|
||||
|
||||
Button clearSpawn = new Button("✕ Spawnpunkt löschen");
|
||||
clearSpawn.setMaxWidth(Double.MAX_VALUE);
|
||||
clearSpawn.setOnAction(e -> {
|
||||
input.tempSpawnX = Float.NaN;
|
||||
input.tempSpawnZ = Float.NaN;
|
||||
spawnXField.setText("");
|
||||
spawnZField.setText("");
|
||||
Button setTempBtn = new Button("📍 Temp. Spawn hier setzen");
|
||||
setTempBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
setTempBtn.setTooltip(new javafx.scene.control.Tooltip(
|
||||
"Setzt Yaw = Kamera-Blickrichtung und aktiviert Klick-Modus im Viewport"));
|
||||
setTempBtn.setOnAction(e -> {
|
||||
input.tempSpawnYaw = camYawToSpawnYaw(input.camYaw);
|
||||
input.playToolMode = SharedInput.PlayToolMode.SET_TEMP;
|
||||
setStatus("L-Klick im Viewport → temporären Spawnpunkt setzen");
|
||||
});
|
||||
|
||||
inner.getChildren().addAll(coordRow, clearSpawn, new Separator());
|
||||
Button setPermBtn = new Button("🏁 Perm. Spawn hier setzen");
|
||||
setPermBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
setPermBtn.setTooltip(new javafx.scene.control.Tooltip(
|
||||
"Setzt Yaw = Kamera-Blickrichtung und aktiviert Klick-Modus im Viewport"));
|
||||
setPermBtn.setOnAction(e -> {
|
||||
input.permSpawnYaw = camYawToSpawnYaw(input.camYaw);
|
||||
input.playToolMode = SharedInput.PlayToolMode.SET_PERM;
|
||||
setStatus("L-Klick im Viewport → permanenten Spawnpunkt setzen");
|
||||
});
|
||||
|
||||
ToggleButton editModeBtn = new ToggleButton("✎ Bearbeiten");
|
||||
editModeBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
editModeBtn.setTooltip(new javafx.scene.control.Tooltip(
|
||||
"Drag auf Marker → Position; Drag auf Pfeilspitze → Richtung drehen"));
|
||||
editModeBtn.setOnAction(e -> {
|
||||
input.playToolMode = editModeBtn.isSelected()
|
||||
? SharedInput.PlayToolMode.EDIT
|
||||
: SharedInput.PlayToolMode.NONE;
|
||||
});
|
||||
|
||||
inner.getChildren().addAll(setTempBtn, setPermBtn, editModeBtn, new Separator());
|
||||
|
||||
// ── Koordinatenanzeige ────────────────────────────────────────────────
|
||||
tempSpawnCoordsLabel = new Label(tempSpawnCoordsText());
|
||||
tempSpawnCoordsLabel.setStyle("-fx-font-family: monospace; -fx-font-size: 11; -fx-text-fill: #333;");
|
||||
permSpawnCoordsLabel = new Label(permSpawnCoordsText());
|
||||
permSpawnCoordsLabel.setStyle("-fx-font-family: monospace; -fx-font-size: 11; -fx-text-fill: #333;");
|
||||
|
||||
Button clearTempBtn = new Button("✕ Temp. Spawn löschen");
|
||||
clearTempBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
clearTempBtn.setOnAction(e -> {
|
||||
input.tempSpawnX = Float.NaN;
|
||||
input.tempSpawnZ = Float.NaN;
|
||||
if (tempSpawnCoordsLabel != null) tempSpawnCoordsLabel.setText("(nicht gesetzt)");
|
||||
});
|
||||
|
||||
inner.getChildren().addAll(
|
||||
bold("Temp. Spawn:"), tempSpawnCoordsLabel, clearTempBtn,
|
||||
bold("Perm. Spawn:"), permSpawnCoordsLabel,
|
||||
new Separator());
|
||||
|
||||
// ── Abschnitt: Spielen ────────────────────────────────────────────────
|
||||
inner.getChildren().addAll(sectionTitle("Spiel starten"), new Separator());
|
||||
|
||||
Button playBtn = new Button("▶ Spielen");
|
||||
gamePlayBtn = playBtn;
|
||||
@@ -7857,8 +7970,21 @@ public class EditorApp extends Application {
|
||||
playBtn.setStyle(
|
||||
"-fx-background-color: #2d8a3e; -fx-text-fill: white; " +
|
||||
"-fx-font-weight: bold; -fx-padding: 6 12 6 12;");
|
||||
playBtn.setTooltip(new javafx.scene.control.Tooltip(
|
||||
"Startet das Spiel mit dem temp. Spawnpunkt (bzw. gespeicherter Position)"));
|
||||
playBtn.setOnAction(e -> launchGame());
|
||||
inner.getChildren().add(playBtn);
|
||||
|
||||
Button newGameBtn = new Button("🆕 Neues Spiel");
|
||||
gameNewBtn = newGameBtn;
|
||||
newGameBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
newGameBtn.setStyle(
|
||||
"-fx-background-color: #7b3ea4; -fx-text-fill: white; " +
|
||||
"-fx-font-weight: bold; -fx-padding: 6 12 6 12;");
|
||||
newGameBtn.setTooltip(new javafx.scene.control.Tooltip(
|
||||
"Startet ein neues Spiel am perm. Spawnpunkt mit Intro-Sequenz"));
|
||||
newGameBtn.setOnAction(e -> launchNewGame());
|
||||
|
||||
inner.getChildren().addAll(playBtn, newGameBtn);
|
||||
|
||||
ScrollPane scroll = new ScrollPane(inner);
|
||||
scroll.setFitToWidth(true);
|
||||
@@ -7871,12 +7997,28 @@ public class EditorApp extends Application {
|
||||
return panel;
|
||||
}
|
||||
|
||||
/** Konvertiert den Editor-Kamera-Yaw in den Spawnpunkt-Yaw (0=+Z, 90=+X, UZS von oben). */
|
||||
private static float camYawToSpawnYaw(float camYaw) {
|
||||
return ((180f + camYaw) % 360f + 360f) % 360f;
|
||||
}
|
||||
|
||||
private String tempSpawnCoordsText() {
|
||||
if (Float.isNaN(input.tempSpawnX) || Float.isNaN(input.tempSpawnZ)) return "(nicht gesetzt)";
|
||||
return String.format("X=%.1f Z=%.1f Yaw=%.0f°", input.tempSpawnX, input.tempSpawnZ, input.tempSpawnYaw);
|
||||
}
|
||||
|
||||
private String permSpawnCoordsText() {
|
||||
if (Float.isNaN(input.permSpawnX) || Float.isNaN(input.permSpawnZ)) return "(nicht gesetzt)";
|
||||
return String.format("X=%.1f Z=%.1f Yaw=%.0f°", input.permSpawnX, input.permSpawnZ, input.permSpawnYaw);
|
||||
}
|
||||
|
||||
private void updateSpawnFields(String info) {
|
||||
if (spawnXField == null || info == null) return;
|
||||
if (info == null) return;
|
||||
String[] p = info.split("\\|", -1);
|
||||
if (p.length < 2) return;
|
||||
spawnXField.setText(p[0]);
|
||||
spawnZField.setText(p[1]);
|
||||
if (spawnXField != null) spawnXField.setText(p[0]);
|
||||
if (spawnZField != null) spawnZField.setText(p[1]);
|
||||
if (tempSpawnCoordsLabel != null) tempSpawnCoordsLabel.setText(tempSpawnCoordsText());
|
||||
}
|
||||
|
||||
// ── Tripo3D-Generator ────────────────────────────────────────────────────
|
||||
@@ -8280,6 +8422,7 @@ public class EditorApp extends Application {
|
||||
animSetClipListView = new ListView<>();
|
||||
animSetClipListView.getItems().addAll(animSet.getClips());
|
||||
animSetClipListView.setPrefHeight(180);
|
||||
editableSubClips = new java.util.LinkedHashMap<>(animSet.getSubClips());
|
||||
|
||||
Path animRootDir = ASSET_ROOT.resolve("animations");
|
||||
|
||||
@@ -8390,6 +8533,8 @@ public class EditorApp extends Application {
|
||||
animSetClipListView.getItems().remove(sel);
|
||||
if (animSetActionListView != null)
|
||||
animSetActionListView.getItems().removeIf(it -> it.endsWith(" → " + sel));
|
||||
editableSubClips.entrySet().removeIf(en -> sel.equals(en.getValue().source));
|
||||
if (animSetPartsListView != null) animSetPartsListView.getItems().clear();
|
||||
animSetDirty = true;
|
||||
});
|
||||
|
||||
@@ -8398,6 +8543,75 @@ public class EditorApp extends Application {
|
||||
HBox.setHgrow(removeClipBtn, Priority.ALWAYS);
|
||||
inner.getChildren().addAll(animSetClipListView, clipBtns);
|
||||
|
||||
// ── Clip-Teile (Sub-Clips) ────────────────────────────────────────────
|
||||
inner.getChildren().addAll(new Separator(), sectionTitle("Clip-Teile"), new Separator());
|
||||
|
||||
Label partsHint = new Label("Gewählten Clip in benannte Teile aufteilen. Jeder Teil erhält einen Namen und Zeitgrenzen (Sub-Clips).");
|
||||
partsHint.setStyle("-fx-font-size: 10; -fx-text-fill: #888;");
|
||||
partsHint.setWrapText(true);
|
||||
|
||||
animSetPartsListView = new ListView<>();
|
||||
animSetPartsListView.setPrefHeight(120);
|
||||
animSetPartsListView.setPlaceholder(new Label("Clip auswählen oder noch keine Teile definiert"));
|
||||
animSetPartsListView.setDisable(true);
|
||||
|
||||
Button addPartBtn = new Button("+ Teil hinzufügen…");
|
||||
Button removePartBtn = new Button("- Entfernen");
|
||||
addPartBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
removePartBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
addPartBtn.setDisable(true);
|
||||
removePartBtn.setDisable(true);
|
||||
|
||||
animSetPartsListView.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, ov, nv) -> removePartBtn.setDisable(nv == null));
|
||||
|
||||
animSetPartsListView.setOnMouseClicked(ev -> {
|
||||
if (ev.getClickCount() == 2) {
|
||||
String sel = animSetPartsListView.getSelectionModel().getSelectedItem();
|
||||
if (sel == null) return;
|
||||
String selName = sel.substring(0, sel.indexOf(" ["));
|
||||
de.blight.game.animation.AnimSet.SubClipDef def = editableSubClips.get(selName);
|
||||
String source = animSetClipListView.getSelectionModel().getSelectedItem();
|
||||
if (def != null && source != null) showPartDialog(source, selName, def);
|
||||
}
|
||||
});
|
||||
|
||||
// Teile-Liste aktualisieren wenn Clip-Auswahl ändert
|
||||
animSetClipListView.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, ov, nv) -> {
|
||||
animSetPartsListView.getItems().clear();
|
||||
boolean hasClip = nv != null;
|
||||
animSetPartsListView.setDisable(!hasClip);
|
||||
addPartBtn.setDisable(!hasClip);
|
||||
if (hasClip) {
|
||||
for (var en : editableSubClips.entrySet()) {
|
||||
if (nv.equals(en.getValue().source)) {
|
||||
animSetPartsListView.getItems().add(
|
||||
formatPartEntry(en.getKey(), en.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addPartBtn.setOnAction(e -> {
|
||||
String source = animSetClipListView.getSelectionModel().getSelectedItem();
|
||||
if (source != null) showPartDialog(source, null, null);
|
||||
});
|
||||
|
||||
removePartBtn.setOnAction(e -> {
|
||||
String sel = animSetPartsListView.getSelectionModel().getSelectedItem();
|
||||
if (sel == null) return;
|
||||
String name = sel.substring(0, sel.indexOf(" ["));
|
||||
editableSubClips.remove(name);
|
||||
animSetPartsListView.getItems().remove(sel);
|
||||
animSetDirty = true;
|
||||
});
|
||||
|
||||
HBox partsBtns = new HBox(6, addPartBtn, removePartBtn);
|
||||
HBox.setHgrow(addPartBtn, Priority.ALWAYS);
|
||||
HBox.setHgrow(removePartBtn, Priority.ALWAYS);
|
||||
inner.getChildren().addAll(partsHint, animSetPartsListView, partsBtns);
|
||||
|
||||
// ── Aktions-Zuordnung ─────────────────────────────────────────────────
|
||||
inner.getChildren().addAll(new Separator(), sectionTitle("Aktions-Zuordnung"), new Separator());
|
||||
|
||||
@@ -8701,7 +8915,11 @@ public class EditorApp extends Application {
|
||||
actionCombo.getSelectionModel().selectFirst();
|
||||
|
||||
ComboBox<String> clipCombo = new ComboBox<>();
|
||||
clipCombo.getItems().addAll(animSetClipListView.getItems());
|
||||
java.util.List<String> allClipNames = new java.util.ArrayList<>(animSetClipListView.getItems());
|
||||
for (String subName : editableSubClips.keySet()) {
|
||||
if (!allClipNames.contains(subName)) allClipNames.add(subName);
|
||||
}
|
||||
clipCombo.getItems().addAll(allClipNames);
|
||||
clipCombo.setMaxWidth(Double.MAX_VALUE);
|
||||
clipCombo.getSelectionModel().selectFirst();
|
||||
|
||||
@@ -8732,6 +8950,78 @@ public class EditorApp extends Application {
|
||||
});
|
||||
}
|
||||
|
||||
private static String formatPartEntry(String name,
|
||||
de.blight.game.animation.AnimSet.SubClipDef def) {
|
||||
return String.format("%s [%.3fs – %.3fs]", name, def.start, def.end);
|
||||
}
|
||||
|
||||
private void showPartDialog(String source, String existingName,
|
||||
de.blight.game.animation.AnimSet.SubClipDef existing) {
|
||||
boolean isEdit = existingName != null && existing != null;
|
||||
|
||||
javafx.scene.control.TextField nameField = new javafx.scene.control.TextField(
|
||||
isEdit ? existingName : "");
|
||||
nameField.setPromptText("Teil-Name (z. B. sit_down_bench)");
|
||||
nameField.setDisable(isEdit); // Name beim Bearbeiten nicht änderbar
|
||||
|
||||
Spinner<Double> startSpinner = new Spinner<>(0.0, 9999.0,
|
||||
isEdit ? existing.start : 0.0, 0.033);
|
||||
startSpinner.setEditable(true);
|
||||
startSpinner.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
Spinner<Double> endSpinner = new Spinner<>(0.0, 9999.0,
|
||||
isEdit ? existing.end : 1.0, 0.033);
|
||||
endSpinner.setEditable(true);
|
||||
endSpinner.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
javafx.scene.layout.GridPane grid = new javafx.scene.layout.GridPane();
|
||||
grid.setHgap(8); grid.setVgap(6);
|
||||
grid.add(new Label("Name:"), 0, 0); grid.add(nameField, 1, 0);
|
||||
grid.add(new Label("Start:"), 0, 1); grid.add(startSpinner, 1, 1);
|
||||
grid.add(new Label("Ende:"), 0, 2); grid.add(endSpinner, 1, 2);
|
||||
javafx.scene.layout.ColumnConstraints cc = new javafx.scene.layout.ColumnConstraints();
|
||||
cc.setHgrow(Priority.ALWAYS);
|
||||
grid.getColumnConstraints().addAll(new javafx.scene.layout.ColumnConstraints(), cc);
|
||||
|
||||
javafx.scene.control.Dialog<javafx.scene.control.ButtonType> dlg =
|
||||
new javafx.scene.control.Dialog<>();
|
||||
dlg.setTitle(isEdit ? "Clip-Teil bearbeiten" : "Clip-Teil hinzufügen");
|
||||
dlg.setHeaderText((isEdit ? "Bearbeiten: " : "Neuer Teil für: ") + source);
|
||||
javafx.scene.control.ButtonType ok = new javafx.scene.control.ButtonType(
|
||||
isEdit ? "Übernehmen" : "Hinzufügen",
|
||||
javafx.scene.control.ButtonBar.ButtonData.OK_DONE);
|
||||
dlg.getDialogPane().getButtonTypes().addAll(ok, javafx.scene.control.ButtonType.CANCEL);
|
||||
dlg.getDialogPane().setContent(grid);
|
||||
|
||||
javafx.scene.Node okNode = dlg.getDialogPane().lookupButton(ok);
|
||||
Runnable validate = () -> {
|
||||
boolean valid = !nameField.getText().isBlank()
|
||||
&& endSpinner.getValue() > startSpinner.getValue();
|
||||
okNode.setDisable(!valid);
|
||||
};
|
||||
validate.run();
|
||||
nameField.textProperty().addListener((obs, ov, nv) -> validate.run());
|
||||
startSpinner.valueProperty().addListener((obs, ov, nv) -> validate.run());
|
||||
endSpinner.valueProperty().addListener((obs, ov, nv) -> validate.run());
|
||||
|
||||
dlg.showAndWait().ifPresent(bt -> {
|
||||
if (bt != ok) return;
|
||||
String name = isEdit ? existingName : nameField.getText().trim();
|
||||
if (name.isBlank()) return;
|
||||
de.blight.game.animation.AnimSet.SubClipDef def =
|
||||
new de.blight.game.animation.AnimSet.SubClipDef();
|
||||
def.source = source;
|
||||
def.start = startSpinner.getValue().floatValue();
|
||||
def.end = endSpinner.getValue().floatValue();
|
||||
editableSubClips.put(name, def);
|
||||
if (animSetPartsListView != null) {
|
||||
animSetPartsListView.getItems().removeIf(s -> s.startsWith(name + " ["));
|
||||
animSetPartsListView.getItems().add(formatPartEntry(name, def));
|
||||
}
|
||||
animSetDirty = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void saveCurrentAnimSet(String setName, Path setDir) {
|
||||
if (animSetClipListView == null) {
|
||||
return;
|
||||
@@ -8767,6 +9057,7 @@ public class EditorApp extends Application {
|
||||
}
|
||||
}
|
||||
animSet.setAnimOffsets(offsetFinal);
|
||||
animSet.setSubClips(new java.util.LinkedHashMap<>(editableSubClips));
|
||||
// Vorschau-Modell-Pfad beibehalten
|
||||
if (animSetModelCombo != null && animSetModelCombo.getValue() != null && !animSetModelCombo.getValue().isBlank()) {
|
||||
animSet.setPreviewModelPath(animSetModelCombo.getValue());
|
||||
@@ -9511,10 +9802,24 @@ public class EditorApp extends Application {
|
||||
Label npcTraderLbl = new Label("Handel:");
|
||||
Label npcItemsLbl = new Label("Waren:");
|
||||
|
||||
charMsgFriendly = new javafx.scene.control.TextField();
|
||||
charMsgFriendly.setPromptText("TextReference-Schlüssel (z.B. silas.msg.friendly)");
|
||||
charMsgNeutral = new javafx.scene.control.TextField();
|
||||
charMsgNeutral.setPromptText("TextReference-Schlüssel");
|
||||
charMsgEnraged = new javafx.scene.control.TextField();
|
||||
charMsgEnraged.setPromptText("TextReference-Schlüssel");
|
||||
charMsgEnemy = new javafx.scene.control.TextField();
|
||||
charMsgEnemy.setPromptText("TextReference-Schlüssel");
|
||||
|
||||
charNpcSection = new VBox(4,
|
||||
npcStatusLbl, charStatusCombo,
|
||||
npcTraderLbl, charTraderCheck,
|
||||
npcItemsLbl, charTraderItemsView, traderBtns);
|
||||
npcItemsLbl, charTraderItemsView, traderBtns,
|
||||
sectionTitle("Standard-Nachrichten je Status"),
|
||||
new Label("Friendly:"), charMsgFriendly,
|
||||
new Label("Neutral:"), charMsgNeutral,
|
||||
new Label("Enraged:"), charMsgEnraged,
|
||||
new Label("Enemy:"), charMsgEnemy);
|
||||
boolean npcInitial = "NPC".equals(charTypeCombo.getValue());
|
||||
charNpcSection.setVisible(npcInitial);
|
||||
charNpcSection.setManaged(npcInitial);
|
||||
@@ -9666,6 +9971,10 @@ public class EditorApp extends Application {
|
||||
if (charStatusCombo != null) charStatusCombo.setValue("NEUTRAL");
|
||||
if (charTraderCheck != null) charTraderCheck.setSelected(false);
|
||||
if (charTraderItemsView != null) charTraderItemsView.getItems().clear();
|
||||
if (charMsgFriendly != null) charMsgFriendly.clear();
|
||||
if (charMsgNeutral != null) charMsgNeutral.clear();
|
||||
if (charMsgEnraged != null) charMsgEnraged.clear();
|
||||
if (charMsgEnemy != null) charMsgEnemy.clear();
|
||||
if (abMagicSpin != null) resetAbilities();
|
||||
updateCharActionCombosFromSet();
|
||||
if (charEditContainer != null) charEditContainer.setDisable(false);
|
||||
@@ -9710,6 +10019,12 @@ public class EditorApp extends Application {
|
||||
if (npc.getItems() != null)
|
||||
npc.getItems().forEach(it -> charTraderItemsView.getItems().add(it.getItemId()));
|
||||
}
|
||||
java.util.Map<de.blight.common.model.Status, de.blight.common.model.TextReference> msgs =
|
||||
npc.getDefaultMessages();
|
||||
if (charMsgFriendly != null) charMsgFriendly.setText(msgKey(msgs, de.blight.common.model.Status.FRIENDLY));
|
||||
if (charMsgNeutral != null) charMsgNeutral.setText(msgKey(msgs, de.blight.common.model.Status.NEUTRAL));
|
||||
if (charMsgEnraged != null) charMsgEnraged.setText(msgKey(msgs, de.blight.common.model.Status.ENRAGED));
|
||||
if (charMsgEnemy != null) charMsgEnemy.setText(msgKey(msgs, de.blight.common.model.Status.ENEMY));
|
||||
}
|
||||
if (c instanceof de.blight.common.model.MainCharacter mc) {
|
||||
loadAbilities(mc.getAbilities());
|
||||
@@ -9721,6 +10036,7 @@ public class EditorApp extends Application {
|
||||
else dialogEditorView.clear();
|
||||
}
|
||||
if (charEditorStatusLabel != null) charEditorStatusLabel.setText("Geladen: " + id);
|
||||
charDirty = true;
|
||||
} catch (Exception e) {
|
||||
if (charEditorStatusLabel != null) charEditorStatusLabel.setText("Fehler: " + e.getMessage());
|
||||
}
|
||||
@@ -9757,6 +10073,14 @@ public class EditorApp extends Application {
|
||||
catch (IllegalArgumentException ignored) {}
|
||||
}
|
||||
if (charTraderCheck != null) npc.setTrader(charTraderCheck.isSelected());
|
||||
// Default-Nachrichten je Status
|
||||
java.util.Map<de.blight.common.model.Status, de.blight.common.model.TextReference> msgs =
|
||||
new java.util.EnumMap<>(de.blight.common.model.Status.class);
|
||||
putMsg(msgs, de.blight.common.model.Status.FRIENDLY, charMsgFriendly);
|
||||
putMsg(msgs, de.blight.common.model.Status.NEUTRAL, charMsgNeutral);
|
||||
putMsg(msgs, de.blight.common.model.Status.ENRAGED, charMsgEnraged);
|
||||
putMsg(msgs, de.blight.common.model.Status.ENEMY, charMsgEnemy);
|
||||
npc.setDefaultMessages(msgs);
|
||||
if (charTraderItemsView != null && !charTraderItemsView.getItems().isEmpty()) {
|
||||
java.util.List<de.blight.common.model.Item> items = new java.util.ArrayList<>();
|
||||
charTraderItemsView.getItems().forEach(id2 -> {
|
||||
@@ -9775,6 +10099,7 @@ public class EditorApp extends Application {
|
||||
|
||||
try {
|
||||
de.blight.common.model.CharacterIO.save(c, charDir);
|
||||
charDirty = false;
|
||||
refreshCharacterList();
|
||||
if (charEditorStatusLabel != null) charEditorStatusLabel.setText("Gespeichert: " + id);
|
||||
} catch (Exception e) {
|
||||
@@ -9899,6 +10224,23 @@ public class EditorApp extends Application {
|
||||
return ab;
|
||||
}
|
||||
|
||||
private static String msgKey(
|
||||
java.util.Map<de.blight.common.model.Status, de.blight.common.model.TextReference> msgs,
|
||||
de.blight.common.model.Status status) {
|
||||
if (msgs == null) return "";
|
||||
de.blight.common.model.TextReference ref = msgs.get(status);
|
||||
return (ref != null && ref.id() != null) ? ref.id() : "";
|
||||
}
|
||||
|
||||
private static void putMsg(
|
||||
java.util.Map<de.blight.common.model.Status, de.blight.common.model.TextReference> msgs,
|
||||
de.blight.common.model.Status status,
|
||||
javafx.scene.control.TextField field) {
|
||||
if (field == null) return;
|
||||
String s = field.getText().trim();
|
||||
if (!s.isBlank()) msgs.put(status, new de.blight.common.model.TextReference(s));
|
||||
}
|
||||
|
||||
private void switchToLocationEditor() {
|
||||
onF5 = null;
|
||||
currentTool = "locationEditor";
|
||||
|
||||
@@ -521,9 +521,17 @@ public class SharedInput {
|
||||
public volatile boolean cancelZoneDrawing = false;
|
||||
|
||||
// ── Spiel-Starten-Werkzeug ────────────────────────────────────────────────
|
||||
/** Klick im Viewport zum Setzen des temporären Spawnpunkts. */
|
||||
/** Klick/Drag-Ereignisse im Viewport für das Play-Tool. */
|
||||
public record PlayToolClick(float screenX, float screenY) {}
|
||||
public record PlayToolDrag(float screenX, float screenY) {}
|
||||
public final ConcurrentLinkedQueue<PlayToolClick> playToolClickQueue = new ConcurrentLinkedQueue<>();
|
||||
public final ConcurrentLinkedQueue<PlayToolDrag> playToolDragQueue = new ConcurrentLinkedQueue<>();
|
||||
/** JME3 → JavaFX: Maus-Taste wurde losgelassen (EDIT-Modus). */
|
||||
public volatile boolean playToolMouseUp = false;
|
||||
|
||||
/** Sub-Modus des Play-Tools. */
|
||||
public enum PlayToolMode { NONE, SET_TEMP, SET_PERM, EDIT }
|
||||
public volatile PlayToolMode playToolMode = PlayToolMode.NONE;
|
||||
|
||||
/**
|
||||
* JME → JavaFX: Terrain-Treffpunkt nach Spawn-Klick.
|
||||
@@ -531,10 +539,21 @@ public class SharedInput {
|
||||
*/
|
||||
public volatile String pickedSpawnInfo = null;
|
||||
public volatile boolean spawnPickChanged = false;
|
||||
public volatile String pickedPermSpawnInfo = null;
|
||||
public volatile boolean permSpawnChanged = false;
|
||||
|
||||
/** Temporärer Spawnpunkt (NaN = nicht gesetzt). Wird beim Spielstart als System-Property übergeben. */
|
||||
public volatile float tempSpawnX = Float.NaN;
|
||||
public volatile float tempSpawnZ = Float.NaN;
|
||||
public volatile float tempSpawnYaw = 0f;
|
||||
|
||||
/** Permanenter Spawnpunkt (NaN = nicht gesetzt). Wird in MapData.spawnX/Z/Yaw gespeichert. */
|
||||
public volatile float permSpawnX = Float.NaN;
|
||||
public volatile float permSpawnZ = Float.NaN;
|
||||
public volatile float permSpawnYaw = 0f;
|
||||
|
||||
/** Master-Lautstärke (0=stumm, 1=voll) – wird von der Intro-Sequenz gesetzt. */
|
||||
public volatile float masterAudioVolume = 1.0f;
|
||||
|
||||
// ── Animations-Vorschau ──────────────────────────────────────────────────
|
||||
public volatile float animPreviewRotY = 0f;
|
||||
|
||||
@@ -9,12 +9,30 @@ import com.jme3.material.Material;
|
||||
import com.jme3.math.*;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.*;
|
||||
import com.jme3.scene.shape.Cylinder;
|
||||
import com.jme3.scene.shape.*;
|
||||
import com.jme3.terrain.geomipmap.TerrainQuad;
|
||||
import de.blight.editor.SharedInput;
|
||||
|
||||
/**
|
||||
* Rendert Spawn-Marker im Editor (temp=grün, perm=blau) mit Richtungspfeilen.
|
||||
*
|
||||
* Modi:
|
||||
* NONE – Marker sichtbar, aber keine Interaktion
|
||||
* SET_TEMP – Nächster Viewport-Klick setzt temp. Spawnpunkt
|
||||
* SET_PERM – Nächster Viewport-Klick setzt perm. Spawnpunkt
|
||||
* EDIT – Drag auf Marker-Körper → Positionieren;
|
||||
* Drag auf Pfeilspitze → Richtung drehen (via XZ-Projektion)
|
||||
*/
|
||||
public class PlayToolState extends BaseAppState {
|
||||
|
||||
private static final float MARKER_RADIUS = 0.5f;
|
||||
private static final float SHAFT_LEN = 2.0f;
|
||||
private static final float SHAFT_RADIUS = 0.06f;
|
||||
private static final float TIP_LEN = 0.5f;
|
||||
private static final float TIP_RADIUS = 0.18f;
|
||||
|
||||
private enum DragTarget { NONE, POS_TEMP, POS_PERM, ROT_TEMP, ROT_PERM }
|
||||
|
||||
private final SharedInput input;
|
||||
private SimpleApplication app;
|
||||
private Camera cam;
|
||||
@@ -22,7 +40,21 @@ public class PlayToolState extends BaseAppState {
|
||||
private Node rootNode;
|
||||
private TerrainQuad terrain;
|
||||
|
||||
private Geometry spawnMarker;
|
||||
// Marker-Nodes
|
||||
private Node tempMarkerNode;
|
||||
private Node permMarkerNode;
|
||||
private Node tempArrowNode;
|
||||
private Node permArrowNode;
|
||||
|
||||
// Separate Geometrien für Ray-Cast-Erkennung
|
||||
private Geometry tempBodyGeom;
|
||||
private Geometry permBodyGeom;
|
||||
private Geometry tempTipGeom;
|
||||
private Geometry permTipGeom;
|
||||
|
||||
private DragTarget dragTarget = DragTarget.NONE;
|
||||
private float lastDragX;
|
||||
private float lastDragY;
|
||||
|
||||
public PlayToolState(SharedInput input) {
|
||||
this.input = input;
|
||||
@@ -34,9 +66,24 @@ public class PlayToolState extends BaseAppState {
|
||||
cam = app.getCamera();
|
||||
assets = app.getAssetManager();
|
||||
rootNode = app.getRootNode();
|
||||
|
||||
tempMarkerNode = buildMarkerNode(new ColorRGBA(0f, 1f, 0.2f, 1f), "temp");
|
||||
permMarkerNode = buildMarkerNode(new ColorRGBA(0.2f, 0.5f, 1f, 1f), "perm");
|
||||
|
||||
tempArrowNode = (Node) tempMarkerNode.getChild("arrow");
|
||||
permArrowNode = (Node) permMarkerNode.getChild("arrow");
|
||||
tempBodyGeom = (Geometry) tempMarkerNode.getChild("body_temp");
|
||||
permBodyGeom = (Geometry) permMarkerNode.getChild("body_perm");
|
||||
tempTipGeom = (Geometry) tempArrowNode.getChild("tip_temp");
|
||||
permTipGeom = (Geometry) permArrowNode.getChild("tip_perm");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup(Application application) {
|
||||
detachMarker(tempMarkerNode);
|
||||
detachMarker(permMarkerNode);
|
||||
}
|
||||
|
||||
@Override protected void cleanup(Application application) { removeMarker(); }
|
||||
@Override protected void onEnable() {}
|
||||
@Override protected void onDisable() {}
|
||||
|
||||
@@ -46,58 +93,281 @@ public class PlayToolState extends BaseAppState {
|
||||
public void update(float tpf) {
|
||||
if (input.activeLayer != SharedInput.LAYER_PLAY_TOOL) return;
|
||||
|
||||
SharedInput.PlayToolMode mode = input.playToolMode;
|
||||
|
||||
// --- Klick-Auswertung ---
|
||||
SharedInput.PlayToolClick click;
|
||||
while ((click = input.playToolClickQueue.poll()) != null) {
|
||||
handleClick(click);
|
||||
handleClick(click, mode);
|
||||
}
|
||||
|
||||
// Update marker position if spawn changed from text fields
|
||||
if (!Float.isNaN(input.tempSpawnX) && !Float.isNaN(input.tempSpawnZ)) {
|
||||
placeMarkerAt(input.tempSpawnX, input.tempSpawnZ);
|
||||
// --- Drag ---
|
||||
if (mode == SharedInput.PlayToolMode.EDIT) {
|
||||
SharedInput.PlayToolDrag drag;
|
||||
while ((drag = input.playToolDragQueue.poll()) != null) {
|
||||
handleDrag(drag);
|
||||
}
|
||||
if (input.playToolMouseUp) {
|
||||
input.playToolMouseUp = false;
|
||||
dragTarget = DragTarget.NONE;
|
||||
}
|
||||
} else {
|
||||
input.playToolDragQueue.clear();
|
||||
if (input.playToolMouseUp) input.playToolMouseUp = false;
|
||||
dragTarget = DragTarget.NONE;
|
||||
}
|
||||
|
||||
private void handleClick(SharedInput.PlayToolClick click) {
|
||||
// --- Marker aktualisieren ---
|
||||
updateMarker(tempMarkerNode, tempArrowNode, input.tempSpawnX, input.tempSpawnZ, input.tempSpawnYaw);
|
||||
updateMarker(permMarkerNode, permArrowNode, input.permSpawnX, input.permSpawnZ, input.permSpawnYaw);
|
||||
}
|
||||
|
||||
// ── Click-Handler ─────────────────────────────────────────────────────────
|
||||
|
||||
private void handleClick(SharedInput.PlayToolClick click, SharedInput.PlayToolMode mode) {
|
||||
float jmeX = click.screenX() * (float) input.viewportScaleX;
|
||||
float jmeY = cam.getHeight() - click.screenY() * (float) input.viewportScaleY;
|
||||
Vector2f screen = new Vector2f(jmeX, jmeY);
|
||||
|
||||
Vector3f near = cam.getWorldCoordinates(new Vector2f(jmeX, jmeY), 0f);
|
||||
Vector3f far = cam.getWorldCoordinates(new Vector2f(jmeX, jmeY), 1f);
|
||||
Ray ray = new Ray(near, far.subtract(near).normalizeLocal());
|
||||
Ray ray = new Ray(cam.getWorldCoordinates(screen, 0f),
|
||||
cam.getWorldCoordinates(screen, 1f).subtractLocal(
|
||||
cam.getWorldCoordinates(screen, 0f)).normalizeLocal());
|
||||
|
||||
if (terrain == null) return;
|
||||
CollisionResults hits = new CollisionResults();
|
||||
terrain.collideWith(ray, hits);
|
||||
if (hits.size() == 0) return;
|
||||
|
||||
Vector3f pt = hits.getClosestCollision().getContactPoint();
|
||||
if (mode == SharedInput.PlayToolMode.SET_TEMP) {
|
||||
Vector3f pt = hitTerrain(ray);
|
||||
if (pt != null) {
|
||||
input.tempSpawnX = pt.x;
|
||||
input.tempSpawnZ = pt.z;
|
||||
input.pickedSpawnInfo = pt.x + "|" + pt.z;
|
||||
input.spawnPickChanged = true;
|
||||
placeMarkerAt(pt.x, pt.z);
|
||||
input.playToolMode = SharedInput.PlayToolMode.NONE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void placeMarkerAt(float x, float z) {
|
||||
float y = terrain != null ? terrain.getHeight(new Vector2f(x, z)) : 0f;
|
||||
if (Float.isNaN(y)) y = 0f;
|
||||
if (mode == SharedInput.PlayToolMode.SET_PERM) {
|
||||
Vector3f pt = hitTerrain(ray);
|
||||
if (pt != null) {
|
||||
input.permSpawnX = pt.x;
|
||||
input.permSpawnZ = pt.z;
|
||||
input.pickedPermSpawnInfo = pt.x + "|" + pt.z;
|
||||
input.permSpawnChanged = true;
|
||||
input.playToolMode = SharedInput.PlayToolMode.NONE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (spawnMarker == null) {
|
||||
Cylinder cyl = new Cylinder(8, 16, 0.4f, 0.1f, true);
|
||||
spawnMarker = new Geometry("spawn_marker", cyl);
|
||||
if (mode == SharedInput.PlayToolMode.EDIT) {
|
||||
lastDragX = click.screenX();
|
||||
lastDragY = click.screenY();
|
||||
dragTarget = detectDragTarget(ray);
|
||||
}
|
||||
}
|
||||
|
||||
private DragTarget detectDragTarget(Ray ray) {
|
||||
// Pfeilspitzen zuerst prüfen (kleineres Ziel, höhere Priorität)
|
||||
if (tempTipGeom != null && !Float.isNaN(input.tempSpawnX)) {
|
||||
CollisionResults res = new CollisionResults();
|
||||
tempTipGeom.collideWith(ray, res);
|
||||
if (res.size() > 0) return DragTarget.ROT_TEMP;
|
||||
}
|
||||
if (permTipGeom != null && !Float.isNaN(input.permSpawnX)) {
|
||||
CollisionResults res = new CollisionResults();
|
||||
permTipGeom.collideWith(ray, res);
|
||||
if (res.size() > 0) return DragTarget.ROT_PERM;
|
||||
}
|
||||
if (tempBodyGeom != null && !Float.isNaN(input.tempSpawnX)) {
|
||||
CollisionResults res = new CollisionResults();
|
||||
tempBodyGeom.collideWith(ray, res);
|
||||
if (res.size() > 0) return DragTarget.POS_TEMP;
|
||||
}
|
||||
if (permBodyGeom != null && !Float.isNaN(input.permSpawnX)) {
|
||||
CollisionResults res = new CollisionResults();
|
||||
permBodyGeom.collideWith(ray, res);
|
||||
if (res.size() > 0) return DragTarget.POS_PERM;
|
||||
}
|
||||
return DragTarget.NONE;
|
||||
}
|
||||
|
||||
// ── Drag-Handler ──────────────────────────────────────────────────────────
|
||||
|
||||
private void handleDrag(SharedInput.PlayToolDrag drag) {
|
||||
if (dragTarget == DragTarget.NONE) return;
|
||||
|
||||
float jmeX = drag.screenX() * (float) input.viewportScaleX;
|
||||
float jmeY = cam.getHeight() - drag.screenY() * (float) input.viewportScaleY;
|
||||
Vector2f screen = new Vector2f(jmeX, jmeY);
|
||||
Ray ray = new Ray(cam.getWorldCoordinates(screen, 0f),
|
||||
cam.getWorldCoordinates(screen, 1f).subtractLocal(
|
||||
cam.getWorldCoordinates(screen, 0f)).normalizeLocal());
|
||||
|
||||
switch (dragTarget) {
|
||||
case POS_TEMP -> {
|
||||
Vector3f pt = hitTerrain(ray);
|
||||
if (pt != null) {
|
||||
input.tempSpawnX = pt.x;
|
||||
input.tempSpawnZ = pt.z;
|
||||
input.pickedSpawnInfo = pt.x + "|" + pt.z;
|
||||
input.spawnPickChanged = true;
|
||||
}
|
||||
}
|
||||
case POS_PERM -> {
|
||||
Vector3f pt = hitTerrain(ray);
|
||||
if (pt != null) {
|
||||
input.permSpawnX = pt.x;
|
||||
input.permSpawnZ = pt.z;
|
||||
input.pickedPermSpawnInfo = pt.x + "|" + pt.z;
|
||||
input.permSpawnChanged = true;
|
||||
}
|
||||
}
|
||||
case ROT_TEMP -> {
|
||||
float markerY = terrainY(input.tempSpawnX, input.tempSpawnZ);
|
||||
Vector3f proj = projectOnHorizontalPlane(ray, markerY);
|
||||
if (proj != null) {
|
||||
float dx = proj.x - input.tempSpawnX;
|
||||
float dz = proj.z - input.tempSpawnZ;
|
||||
if (dx * dx + dz * dz > 0.01f) {
|
||||
// spawnYaw: 0=+Z, 90=+X → atan2(dx, dz)
|
||||
float yaw = (float) Math.toDegrees(Math.atan2(dx, dz));
|
||||
input.tempSpawnYaw = ((yaw % 360f) + 360f) % 360f;
|
||||
}
|
||||
}
|
||||
}
|
||||
case ROT_PERM -> {
|
||||
float markerY = terrainY(input.permSpawnX, input.permSpawnZ);
|
||||
Vector3f proj = projectOnHorizontalPlane(ray, markerY);
|
||||
if (proj != null) {
|
||||
float dx = proj.x - input.permSpawnX;
|
||||
float dz = proj.z - input.permSpawnZ;
|
||||
if (dx * dx + dz * dz > 0.01f) {
|
||||
float yaw = (float) Math.toDegrees(Math.atan2(dx, dz));
|
||||
input.permSpawnYaw = ((yaw % 360f) + 360f) % 360f;
|
||||
input.permSpawnChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
|
||||
lastDragX = drag.screenX();
|
||||
lastDragY = drag.screenY();
|
||||
}
|
||||
|
||||
// ── Marker aufbauen ───────────────────────────────────────────────────────
|
||||
|
||||
private Node buildMarkerNode(ColorRGBA color, String id) {
|
||||
Node markerNode = new Node("marker_" + id);
|
||||
|
||||
// Basis-Scheibe: JME3-Cylinder liegt entlang Z → rotate(-90°, 0, 0) dreht Z→Y (flach in XZ-Ebene)
|
||||
Cylinder disc = new Cylinder(8, 20, MARKER_RADIUS, 0.05f, true);
|
||||
Geometry body = new Geometry("body_" + id, disc);
|
||||
Material mat = new Material(assets, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", new ColorRGBA(0f, 1f, 0f, 1f));
|
||||
spawnMarker.setMaterial(mat);
|
||||
spawnMarker.rotate(FastMath.HALF_PI, 0, 0);
|
||||
rootNode.attachChild(spawnMarker);
|
||||
}
|
||||
spawnMarker.setLocalTranslation(x, y + 0.05f, z);
|
||||
mat.setColor("Color", color);
|
||||
body.setMaterial(mat);
|
||||
body.rotate(-FastMath.HALF_PI, 0f, 0f);
|
||||
markerNode.attachChild(body);
|
||||
|
||||
// Pfeil-Node (wird nach Yaw rotiert; local Y → Yaw-Richtung, local Z → Terrain-Normal)
|
||||
Node arrowNode = new Node("arrow");
|
||||
markerNode.attachChild(arrowNode);
|
||||
|
||||
// Schaft: JME3-Cylinder entlang Z → rotate(-90°, 0, 0) dreht Z→arrowNode-Y (= Yaw-Richtung)
|
||||
Cylinder shaft = new Cylinder(4, 8, SHAFT_RADIUS, SHAFT_LEN, true);
|
||||
Geometry shaftGeom = new Geometry("shaft_" + id, shaft);
|
||||
shaftGeom.setMaterial(mat);
|
||||
shaftGeom.rotate(-FastMath.HALF_PI, 0f, 0f);
|
||||
shaftGeom.setLocalTranslation(0f, SHAFT_LEN * 0.5f, 0f);
|
||||
arrowNode.attachChild(shaftGeom);
|
||||
|
||||
// Pfeilspitze: Kegel mit breiter Basis bei z=-TIP_LEN/2 → nach rotate: Basis bei y=SHAFT_LEN (Schaft-Ende)
|
||||
Cylinder tip = new Cylinder(4, 8, TIP_RADIUS, 0.001f, TIP_LEN, true, false);
|
||||
Geometry tipGeom = new Geometry("tip_" + id, tip);
|
||||
tipGeom.setMaterial(mat);
|
||||
tipGeom.rotate(-FastMath.HALF_PI, 0f, 0f);
|
||||
tipGeom.setLocalTranslation(0f, SHAFT_LEN + TIP_LEN * 0.5f, 0f);
|
||||
arrowNode.attachChild(tipGeom);
|
||||
|
||||
return markerNode;
|
||||
}
|
||||
|
||||
private void removeMarker() {
|
||||
if (spawnMarker != null) {
|
||||
rootNode.detachChild(spawnMarker);
|
||||
spawnMarker = null;
|
||||
// ── Marker-Positions- / Rotations-Update ─────────────────────────────────
|
||||
|
||||
private void updateMarker(Node markerNode, Node arrowNode, float x, float z, float yawDeg) {
|
||||
if (Float.isNaN(x) || Float.isNaN(z)) {
|
||||
if (markerNode.getParent() != null) rootNode.detachChild(markerNode);
|
||||
return;
|
||||
}
|
||||
if (markerNode.getParent() == null) rootNode.attachChild(markerNode);
|
||||
|
||||
float y = terrainY(x, z);
|
||||
markerNode.setLocalTranslation(x, y + 0.06f, z);
|
||||
|
||||
if (arrowNode == null) return;
|
||||
|
||||
// Terrain-Normale als lokale Oben-Richtung
|
||||
Vector3f up = terrainNormal(x, z);
|
||||
|
||||
// Yaw-Richtung als horizontaler Richtungsvektor (0=+Z, 90=+X)
|
||||
float rad = yawDeg * FastMath.DEG_TO_RAD;
|
||||
Vector3f flatForward = new Vector3f(FastMath.sin(rad), 0f, FastMath.cos(rad));
|
||||
|
||||
// right = up × flatForward (liegt auf der Terrain-Oberfläche, senkrecht zur Richtung)
|
||||
Vector3f right = up.cross(flatForward);
|
||||
if (right.lengthSquared() < 1e-6f) {
|
||||
// Sonderfall: Terrain fast senkrecht → horizontale Rotation als Fallback
|
||||
arrowNode.setLocalRotation(new Quaternion().fromAngles(FastMath.HALF_PI, rad, 0f));
|
||||
return;
|
||||
}
|
||||
right.normalizeLocal();
|
||||
// forward = right × up (auf Terrain-Fläche projiziertes Forward in Yaw-Richtung)
|
||||
Vector3f forward = right.cross(up).normalizeLocal();
|
||||
|
||||
// Rotationsmatrix: local X → right, local Y → forward (Pfeil), local Z → up (Terrain-Normal)
|
||||
Matrix3f rot = new Matrix3f();
|
||||
rot.setColumn(0, right);
|
||||
rot.setColumn(1, forward);
|
||||
rot.setColumn(2, up);
|
||||
arrowNode.setLocalRotation(new Quaternion().fromRotationMatrix(rot));
|
||||
}
|
||||
|
||||
// ── Terrain-Hilfsmethoden ─────────────────────────────────────────────────
|
||||
|
||||
private Vector3f hitTerrain(Ray ray) {
|
||||
if (terrain == null) return null;
|
||||
CollisionResults hits = new CollisionResults();
|
||||
terrain.collideWith(ray, hits);
|
||||
if (hits.size() == 0) return null;
|
||||
return hits.getClosestCollision().getContactPoint();
|
||||
}
|
||||
|
||||
private float terrainY(float x, float z) {
|
||||
if (terrain == null) return 0f;
|
||||
float h = terrain.getHeight(new Vector2f(x, z));
|
||||
return Float.isNaN(h) ? 0f : h;
|
||||
}
|
||||
|
||||
/** Terrain-Normale an (x, z) durch Kreuzprodukt zweier Tangenten. */
|
||||
private Vector3f terrainNormal(float x, float z) {
|
||||
if (terrain == null) return Vector3f.UNIT_Y.clone();
|
||||
float d = 0.5f;
|
||||
float h00 = terrainY(x, z);
|
||||
Vector3f tx = new Vector3f(d, terrainY(x + d, z) - h00, 0f);
|
||||
Vector3f tz = new Vector3f(0f, terrainY(x, z + d) - h00, d);
|
||||
return tz.cross(tx).normalizeLocal();
|
||||
}
|
||||
|
||||
/** Schneidet den Kamera-Ray mit der horizontalen Ebene Y=planeY. Null wenn kein Treffer. */
|
||||
private static Vector3f projectOnHorizontalPlane(Ray ray, float planeY) {
|
||||
float dY = ray.getDirection().y;
|
||||
if (Math.abs(dY) < 1e-6f) return null;
|
||||
float t = (planeY - ray.getOrigin().y) / dY;
|
||||
if (t < 0f) return null;
|
||||
return ray.getOrigin().add(ray.getDirection().mult(t));
|
||||
}
|
||||
|
||||
private void detachMarker(Node markerNode) {
|
||||
if (markerNode != null && markerNode.getParent() != null) {
|
||||
rootNode.detachChild(markerNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,6 +458,10 @@ public class TerrainEditorState extends BaseAppState {
|
||||
input.voxelFlatSlot = loadedMapData.voxelFlatSlot;
|
||||
input.voxelSteepSlot = loadedMapData.voxelSteepSlot;
|
||||
input.voxelCeilSlot = loadedMapData.voxelCeilSlot;
|
||||
input.permSpawnX = loadedMapData.spawnX;
|
||||
input.permSpawnZ = loadedMapData.spawnZ;
|
||||
input.permSpawnYaw = loadedMapData.spawnYaw;
|
||||
input.permSpawnChanged = true;
|
||||
input.voxelTexturesChanged = true;
|
||||
// Alte Gebirge-Splatmap-Migration: R=255 überall war der Gebirge-Standard.
|
||||
// Im neuen 1-Terrain-System bedeutet das: Slot-5-Textur deckt alles ab → auf 0 setzen.
|
||||
@@ -1210,6 +1214,16 @@ public class TerrainEditorState extends BaseAppState {
|
||||
data.voxelFlatSlot = voxelFlatSlot;
|
||||
data.voxelSteepSlot = voxelSteepSlot;
|
||||
data.voxelCeilSlot = voxelCeilSlot;
|
||||
// Permanenten Spawnpunkt übernehmen (falls gesetzt), sonst aus geladenem MapData
|
||||
if (!Float.isNaN(input.permSpawnX) && !Float.isNaN(input.permSpawnZ)) {
|
||||
data.spawnX = input.permSpawnX;
|
||||
data.spawnZ = input.permSpawnZ;
|
||||
data.spawnYaw = input.permSpawnYaw;
|
||||
} else if (loadedMapData != null) {
|
||||
data.spawnX = loadedMapData.spawnX;
|
||||
data.spawnZ = loadedMapData.spawnZ;
|
||||
data.spawnYaw = loadedMapData.spawnYaw;
|
||||
}
|
||||
|
||||
if (grassData != null) {
|
||||
try { GrassTuftIO.save(grassData); }
|
||||
|
||||
@@ -12,9 +12,9 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Crafting-Table-Verwaltung: zwei identische TablePanel-Instanzen nebeneinander.
|
||||
* Crafting-Table-Verwaltung: Liste links, Formular rechts.
|
||||
* Pro CraftingTableType kann genau ein Eintrag existieren — die Liste zeigt
|
||||
* immer alle 5 Typen; nicht konfigurierte Einträge erscheinen grau.
|
||||
* immer alle Typen; nicht konfigurierte Einträge erscheinen grau.
|
||||
*/
|
||||
public class CraftingTableEditorView extends BorderPane {
|
||||
|
||||
@@ -22,83 +22,37 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
new EnumMap<>(CraftingTable.CraftingTableType.class);
|
||||
private final Path tableDir;
|
||||
|
||||
private TablePanel left;
|
||||
private TablePanel right;
|
||||
// ── List ──────────────────────────────────────────────────────────────────
|
||||
|
||||
private ListView<CraftingTable.CraftingTableType> listView;
|
||||
private Button deleteBtn;
|
||||
private CraftingTable.CraftingTableType currentType = null;
|
||||
|
||||
// ── Form fields ───────────────────────────────────────────────────────────
|
||||
|
||||
private Label formTypeLabel;
|
||||
private TextField nameIdField;
|
||||
private TextField objectPathField;
|
||||
private VBox formContainer;
|
||||
|
||||
public CraftingTableEditorView(Path tableDir) {
|
||||
this.tableDir = tableDir;
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
reloadMap();
|
||||
|
||||
left = new TablePanel("Liste 1", shared, tableDir, this::onSaved);
|
||||
right = new TablePanel("Liste 2", shared, tableDir, this::onSaved);
|
||||
|
||||
HBox panels = new HBox(1, left, right);
|
||||
HBox.setHgrow(left, Priority.ALWAYS);
|
||||
HBox.setHgrow(right, Priority.ALWAYS);
|
||||
setCenter(panels);
|
||||
SplitPane split = new SplitPane(buildListPanel(), buildFormPanel());
|
||||
split.setDividerPositions(0.28);
|
||||
setCenter(split);
|
||||
}
|
||||
|
||||
private void reloadMap() {
|
||||
shared.clear();
|
||||
shared.putAll(CraftingTableIO.loadAll(tableDir));
|
||||
}
|
||||
// ── List panel ────────────────────────────────────────────────────────────
|
||||
|
||||
private void onSaved() {
|
||||
reloadMap();
|
||||
left.refresh();
|
||||
right.refresh();
|
||||
}
|
||||
|
||||
// ── Single panel ──────────────────────────────────────────────────────────
|
||||
|
||||
static class TablePanel extends VBox {
|
||||
|
||||
private final Map<CraftingTable.CraftingTableType, CraftingTable> shared;
|
||||
private final Path tableDir;
|
||||
private final Runnable onSaved;
|
||||
|
||||
private final ListView<CraftingTable.CraftingTableType> listView;
|
||||
|
||||
private CraftingTable.CraftingTableType currentType = null;
|
||||
|
||||
// Form fields
|
||||
private TextField nameIdField;
|
||||
private TextField objectPathField;
|
||||
|
||||
private VBox formContainer;
|
||||
private Button deleteBtn;
|
||||
private Label formTypeLabel;
|
||||
|
||||
TablePanel(String title,
|
||||
Map<CraftingTable.CraftingTableType, CraftingTable> shared,
|
||||
Path tableDir, Runnable onSaved) {
|
||||
this.shared = shared;
|
||||
this.tableDir = tableDir;
|
||||
this.onSaved = onSaved;
|
||||
|
||||
setStyle("-fx-background-color: #252535; -fx-border-color: #3a3a4a; -fx-border-width: 0 1 0 0;");
|
||||
|
||||
// ── Header ────────────────────────────────────────────────────────
|
||||
Label titleLbl = new Label(title);
|
||||
titleLbl.setStyle("-fx-font-weight: bold; -fx-font-size: 13; -fx-text-fill: #aaccee;");
|
||||
Button refreshBtn = new Button("↺");
|
||||
refreshBtn.setStyle("-fx-background-color: transparent; -fx-text-fill: #888; -fx-cursor: hand;");
|
||||
refreshBtn.setOnAction(e -> onSaved.run());
|
||||
HBox header = new HBox(8, titleLbl, refreshBtn);
|
||||
header.setPadding(new Insets(8, 10, 8, 10));
|
||||
header.setAlignment(Pos.CENTER_LEFT);
|
||||
header.setStyle("-fx-background-color: #1a1a2a; -fx-border-color: #444;"
|
||||
+ " -fx-border-width: 0 0 1 0;");
|
||||
|
||||
// ── Type list (always 5 fixed entries) ───────────────────────────
|
||||
private VBox buildListPanel() {
|
||||
listView = new ListView<>();
|
||||
listView.getItems().setAll(CraftingTable.CraftingTableType.values());
|
||||
listView.setPrefHeight(160);
|
||||
listView.setStyle("-fx-background-color: #1a1a2a; -fx-control-inner-background: #1a1a2a;");
|
||||
listView.setCellFactory(lv -> new ListCell<>() {
|
||||
@Override
|
||||
protected void updateItem(CraftingTable.CraftingTableType type, boolean empty) {
|
||||
@Override protected void updateItem(CraftingTable.CraftingTableType type, boolean empty) {
|
||||
super.updateItem(type, empty);
|
||||
if (empty || type == null) { setText(null); setStyle(""); return; }
|
||||
boolean configured = shared.containsKey(type);
|
||||
@@ -114,6 +68,7 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
});
|
||||
listView.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, old, nw) -> onTypeSelected(old, nw));
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
|
||||
deleteBtn = new Button("Konfiguration löschen");
|
||||
deleteBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
@@ -121,28 +76,31 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
deleteBtn.setDisable(true);
|
||||
deleteBtn.setOnAction(e -> deleteSelected());
|
||||
|
||||
VBox listSection = new VBox(listView, deleteBtn);
|
||||
listSection.setPadding(new Insets(0, 0, 4, 0));
|
||||
listSection.setStyle("-fx-background-color: #1a1a2a;");
|
||||
VBox.setMargin(deleteBtn, new Insets(4, 8, 4, 8));
|
||||
Button refreshBtn = new Button("↺ Neu laden");
|
||||
refreshBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
refreshBtn.setOnAction(e -> { reloadMap(); refresh(); });
|
||||
|
||||
// ── Form ──────────────────────────────────────────────────────────
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
|
||||
ScrollPane formScroll = new ScrollPane(formContainer);
|
||||
formScroll.setFitToWidth(true);
|
||||
formScroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
VBox.setVgrow(formScroll, Priority.ALWAYS);
|
||||
|
||||
getChildren().addAll(header, listSection, new Separator(), formScroll);
|
||||
VBox panel = new VBox(6, listView, deleteBtn, refreshBtn);
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
panel.setPadding(new Insets(8));
|
||||
panel.setStyle("-fx-background-color: #1a1a2a;");
|
||||
return panel;
|
||||
}
|
||||
|
||||
// ── Form construction ─────────────────────────────────────────────────
|
||||
// ── Form panel ────────────────────────────────────────────────────────────
|
||||
|
||||
private ScrollPane buildFormPanel() {
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
ScrollPane scroll = new ScrollPane(formContainer);
|
||||
scroll.setFitToWidth(true);
|
||||
scroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
return scroll;
|
||||
}
|
||||
|
||||
private VBox buildForm() {
|
||||
VBox form = new VBox(6);
|
||||
form.setPadding(new Insets(10));
|
||||
form.setPadding(new Insets(12));
|
||||
form.setStyle("-fx-background-color: #252535;");
|
||||
|
||||
formTypeLabel = new Label("—");
|
||||
@@ -173,7 +131,7 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
return form;
|
||||
}
|
||||
|
||||
// ── Form load / save ──────────────────────────────────────────────────
|
||||
// ── Form load / save ──────────────────────────────────────────────────────
|
||||
|
||||
private void onTypeSelected(CraftingTable.CraftingTableType old, CraftingTable.CraftingTableType nw) {
|
||||
currentType = nw;
|
||||
@@ -191,8 +149,7 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
private void loadFormFromType(CraftingTable.CraftingTableType type) {
|
||||
String color = typeColor(type);
|
||||
formTypeLabel.setText(type.name());
|
||||
formTypeLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 13;"
|
||||
+ " -fx-text-fill: " + color + ";");
|
||||
formTypeLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 13; -fx-text-fill: " + color + ";");
|
||||
|
||||
CraftingTable t = shared.get(type);
|
||||
if (t != null) {
|
||||
@@ -205,7 +162,6 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
|
||||
private void saveCurrentTable() {
|
||||
if (currentType == null) return;
|
||||
|
||||
CraftingTable t = shared.getOrDefault(currentType, new CraftingTable());
|
||||
t.setType(currentType);
|
||||
|
||||
@@ -221,7 +177,8 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
new Alert(Alert.AlertType.ERROR, "Fehler: " + e.getMessage(), ButtonType.OK).showAndWait();
|
||||
return;
|
||||
}
|
||||
onSaved.run();
|
||||
reloadMap();
|
||||
refresh();
|
||||
listView.getSelectionModel().select(currentType);
|
||||
}
|
||||
|
||||
@@ -233,20 +190,11 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
new Alert(Alert.AlertType.ERROR, "Fehler: " + e.getMessage(), ButtonType.OK).showAndWait();
|
||||
return;
|
||||
}
|
||||
onSaved.run();
|
||||
reloadMap();
|
||||
refresh();
|
||||
listView.getSelectionModel().select(currentType);
|
||||
}
|
||||
|
||||
/** Called by the parent view when shared data has been reloaded. */
|
||||
void refresh() {
|
||||
listView.refresh();
|
||||
if (currentType != null) {
|
||||
deleteBtn.setDisable(!shared.containsKey(currentType));
|
||||
if (formContainer.isDisable()) return;
|
||||
loadFormFromType(currentType);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearForm() {
|
||||
formTypeLabel.setText("—");
|
||||
formTypeLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 13; -fx-text-fill: #ccddff;");
|
||||
@@ -258,7 +206,20 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
objectPathField.clear();
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────
|
||||
private void reloadMap() {
|
||||
shared.clear();
|
||||
shared.putAll(CraftingTableIO.loadAll(tableDir));
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
listView.refresh();
|
||||
if (currentType != null) {
|
||||
deleteBtn.setDisable(!shared.containsKey(currentType));
|
||||
if (!formContainer.isDisable()) loadFormFromType(currentType);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
static String typeColor(CraftingTable.CraftingTableType type) {
|
||||
if (type == null) return "#666666";
|
||||
@@ -290,5 +251,4 @@ public class CraftingTableEditorView extends BorderPane {
|
||||
}
|
||||
|
||||
private static String safe(String s) { return s != null ? s : ""; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@ package de.blight.editor.ui;
|
||||
|
||||
import de.blight.common.model.*;
|
||||
import de.blight.common.model.quests.Quest;
|
||||
import de.blight.common.model.quests.QuestIO;
|
||||
import de.blight.common.model.QuestRef;
|
||||
import de.blight.editor.ProjectRoot;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
@@ -16,6 +19,7 @@ import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Modality;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -89,8 +93,14 @@ public class DialogEditorView extends BorderPane {
|
||||
collectOptions(opt);
|
||||
if (opt.getId() != null) rootIds.add(opt.getId());
|
||||
}
|
||||
normalizeReferences();
|
||||
}
|
||||
// Restore orphaned options that were preserved separately
|
||||
if (npc.getEditorOnlyOptions() != null) {
|
||||
for (DialogOption opt : npc.getEditorOnlyOptions()) {
|
||||
collectOptions(opt);
|
||||
}
|
||||
}
|
||||
normalizeReferences();
|
||||
refreshOptionList();
|
||||
clearDetailForm();
|
||||
}
|
||||
@@ -112,6 +122,26 @@ public class DialogEditorView extends BorderPane {
|
||||
if (opt != null) roots.add(opt);
|
||||
}
|
||||
npc.setCurrentOptions(roots.isEmpty() ? null : roots);
|
||||
|
||||
// Collect orphaned options (not reachable from any root) and preserve them
|
||||
Set<String> reachable = new HashSet<>();
|
||||
for (DialogOption root : roots) collectReachable(root, reachable);
|
||||
List<DialogOption> orphans = new ArrayList<>();
|
||||
for (Map.Entry<String, DialogOption> entry : allOptions.entrySet()) {
|
||||
if (!reachable.contains(entry.getKey())) orphans.add(entry.getValue());
|
||||
}
|
||||
npc.setEditorOnlyOptions(orphans.isEmpty() ? null : orphans);
|
||||
}
|
||||
|
||||
private void collectReachable(DialogOption opt, Set<String> visited) {
|
||||
if (opt == null || opt.getId() == null || visited.contains(opt.getId())) return;
|
||||
visited.add(opt.getId());
|
||||
if (opt.getNextOptions() != null) {
|
||||
for (DialogOption next : opt.getNextOptions()) collectReachable(next, visited);
|
||||
}
|
||||
if (opt.getDisablesOptions() != null) {
|
||||
for (DialogOption dis : opt.getDisablesOptions()) collectReachable(dis, visited);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Top-bar ────────────────────────────────────────────────────────────────
|
||||
@@ -147,7 +177,12 @@ public class DialogEditorView extends BorderPane {
|
||||
private SplitPane buildListPane() {
|
||||
// ── Left: option list ─────────────────────────────────────────────────
|
||||
optionListView = new ListView<>();
|
||||
optionListView.setStyle("-fx-control-inner-background: #2a2a3a; -fx-text-fill: #ddd;"
|
||||
+ " -fx-selection-bar: #3a5a8a; -fx-selection-bar-text: white;");
|
||||
optionListView.setCellFactory(lv -> new ListCell<>() {
|
||||
{
|
||||
selectedProperty().addListener((obs, old, sel) -> applyStyle());
|
||||
}
|
||||
@Override protected void updateItem(String id, boolean empty) {
|
||||
super.updateItem(id, empty);
|
||||
if (empty || id == null) { setText(null); setStyle(""); return; }
|
||||
@@ -155,7 +190,14 @@ public class DialogEditorView extends BorderPane {
|
||||
String lbl = (opt != null && opt.getLabel() != null && !opt.getLabel().isBlank())
|
||||
? opt.getLabel() : id.substring(0, Math.min(8, id.length())) + "…";
|
||||
setText((rootIds.contains(id) ? "★ " : " ") + lbl);
|
||||
setStyle("-fx-text-fill: " + (rootIds.contains(id) ? "#ffdd88" : "#cccccc") + ";");
|
||||
applyStyle();
|
||||
}
|
||||
private void applyStyle() {
|
||||
String id = getItem();
|
||||
if (id == null || isEmpty()) { setStyle(""); return; }
|
||||
String text = rootIds.contains(id) ? "#ffdd88" : "#cccccc";
|
||||
String bg = isSelected() ? "#3a5a8a" : "#2a2a3a";
|
||||
setStyle("-fx-background-color: " + bg + "; -fx-text-fill: " + text + ";");
|
||||
}
|
||||
});
|
||||
optionListView.getSelectionModel().selectedItemProperty().addListener(
|
||||
@@ -236,9 +278,16 @@ public class DialogEditorView extends BorderPane {
|
||||
statusCombo.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
questOpenField = new TextField();
|
||||
questOpenField.setPromptText("Quest-ID");
|
||||
questOpenField.setPromptText("Quest wählen…");
|
||||
questOpenField.setEditable(false);
|
||||
questOpenField.setCursor(Cursor.HAND);
|
||||
questOpenField.setOnMouseClicked(e -> pickQuestId(questOpenField));
|
||||
|
||||
questCompleteField = new TextField();
|
||||
questCompleteField.setPromptText("Quest-ID");
|
||||
questCompleteField.setPromptText("Quest wählen…");
|
||||
questCompleteField.setEditable(false);
|
||||
questCompleteField.setCursor(Cursor.HAND);
|
||||
questCompleteField.setOnMouseClicked(e -> pickQuestId(questCompleteField));
|
||||
|
||||
form.getChildren().addAll(
|
||||
sectionTitle("Voraussetzungen"),
|
||||
@@ -284,16 +333,23 @@ public class DialogEditorView extends BorderPane {
|
||||
|
||||
// Quests
|
||||
recvQuestField = new TextField();
|
||||
recvQuestField.setPromptText("Quest-ID");
|
||||
recvQuestField.setPromptText("Quest wählen…");
|
||||
recvQuestField.setEditable(false);
|
||||
recvQuestField.setCursor(Cursor.HAND);
|
||||
recvQuestField.setOnMouseClicked(e -> pickQuestId(recvQuestField));
|
||||
|
||||
fulfillsQuestField = new TextField();
|
||||
fulfillsQuestField.setPromptText("Quest-ID");
|
||||
fulfillsQuestField.setPromptText("Quest wählen…");
|
||||
fulfillsQuestField.setEditable(false);
|
||||
fulfillsQuestField.setCursor(Cursor.HAND);
|
||||
fulfillsQuestField.setOnMouseClicked(e -> pickQuestId(fulfillsQuestField));
|
||||
|
||||
abortsQuestsView = new ListView<>();
|
||||
abortsQuestsView.setPrefHeight(80);
|
||||
abortsQuestsView.setStyle("-fx-background-color: #1e1e2e; -fx-control-inner-background: #1e1e2e;");
|
||||
Button addAbortsBtn = smallBtn("+");
|
||||
Button delAbortsBtn = smallBtn("−");
|
||||
addAbortsBtn.setOnAction(e -> promptQuestId(abortsQuestsView));
|
||||
addAbortsBtn.setOnAction(e -> pickQuestIdForList(abortsQuestsView));
|
||||
delAbortsBtn.setOnAction(e -> removeSelected(abortsQuestsView));
|
||||
|
||||
form.getChildren().addAll(
|
||||
@@ -518,7 +574,12 @@ public class DialogEditorView extends BorderPane {
|
||||
DialogOption opt = new DialogOption();
|
||||
opt.setLabel("Neue Option");
|
||||
allOptions.put(opt.getId(), opt);
|
||||
if (asRoot) rootIds.add(opt.getId());
|
||||
if (asRoot) {
|
||||
rootIds.add(opt.getId());
|
||||
} else if (selectedId != null) {
|
||||
// Auto-link to currently selected option so no orphans are created
|
||||
nextOptionsView.getItems().add(opt.getId());
|
||||
}
|
||||
refreshOptionList();
|
||||
optionListView.getSelectionModel().select(opt.getId());
|
||||
}
|
||||
@@ -580,14 +641,63 @@ public class DialogEditorView extends BorderPane {
|
||||
});
|
||||
}
|
||||
|
||||
private void promptQuestId(ListView<String> target) {
|
||||
TextInputDialog dlg = new TextInputDialog();
|
||||
dlg.setTitle("Quest-ID");
|
||||
dlg.setHeaderText("Quest-ID eingeben:");
|
||||
private void pickQuestId(TextField target) {
|
||||
String chosen = showQuestPickerDialog();
|
||||
if (chosen != null) target.setText(chosen);
|
||||
}
|
||||
|
||||
private void pickQuestIdForList(ListView<String> target) {
|
||||
String chosen = showQuestPickerDialog();
|
||||
if (chosen != null && !target.getItems().contains(chosen)) target.getItems().add(chosen);
|
||||
}
|
||||
|
||||
private String showQuestPickerDialog() {
|
||||
Path questDir = ProjectRoot.resolve("blight-assets", "src", "main", "resources").resolve("quests");
|
||||
List<Quest> questList = QuestIO.loadAll(questDir);
|
||||
|
||||
Dialog<String> dlg = new Dialog<>();
|
||||
dlg.setTitle("Quest auswählen");
|
||||
dlg.initModality(Modality.APPLICATION_MODAL);
|
||||
dlg.showAndWait().ifPresent(id -> {
|
||||
if (!id.isBlank() && !target.getItems().contains(id)) target.getItems().add(id);
|
||||
|
||||
ListView<Quest> chooser = new ListView<>();
|
||||
chooser.setCellFactory(lv -> new ListCell<>() {
|
||||
@Override protected void updateItem(Quest q, boolean empty) {
|
||||
super.updateItem(q, empty);
|
||||
if (empty || q == null) { setText(null); return; }
|
||||
String id = q.getQuestId() != null ? q.getQuestId() : "—";
|
||||
String name = q.getText() != null ? q.getText().id() : "";
|
||||
setText(name.isBlank() ? id : id + " — " + name);
|
||||
setStyle("-fx-text-fill: #cccccc;");
|
||||
}
|
||||
});
|
||||
chooser.getItems().setAll(questList);
|
||||
chooser.setStyle("-fx-background-color: #1a1a2a; -fx-control-inner-background: #1a1a2a;"
|
||||
+ " -fx-selection-bar: #3a5a8a;");
|
||||
chooser.setPrefSize(380, 300);
|
||||
|
||||
if (questList.isEmpty()) {
|
||||
Label hint = new Label("Keine Quests gefunden.\nQuests im Quest-Editor anlegen.");
|
||||
hint.setStyle("-fx-text-fill: #888; -fx-font-style: italic;");
|
||||
dlg.getDialogPane().setContent(hint);
|
||||
} else {
|
||||
dlg.getDialogPane().setContent(chooser);
|
||||
}
|
||||
dlg.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
|
||||
dlg.getDialogPane().setStyle("-fx-background-color: #252535;");
|
||||
|
||||
Button okBtn = (Button) dlg.getDialogPane().lookupButton(ButtonType.OK);
|
||||
okBtn.setDisable(true);
|
||||
chooser.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, o, n) -> okBtn.setDisable(n == null));
|
||||
chooser.setOnMouseClicked(e -> {
|
||||
if (e.getClickCount() == 2 && !chooser.getSelectionModel().isEmpty()) okBtn.fire();
|
||||
});
|
||||
dlg.setResultConverter(bt -> {
|
||||
if (bt != ButtonType.OK) return null;
|
||||
Quest sel = chooser.getSelectionModel().getSelectedItem();
|
||||
return sel != null ? sel.getQuestId() : null;
|
||||
});
|
||||
return dlg.showAndWait().orElse(null);
|
||||
}
|
||||
|
||||
private static void removeSelected(ListView<String> list) {
|
||||
|
||||
@@ -15,46 +15,23 @@ import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Fraktions-Verwaltung: zwei identische FractionPanel-Instanzen nebeneinander.
|
||||
* Fraktions-Verwaltung: Liste links, Formular rechts.
|
||||
* Sortiert nach Name-ID, dann nach UUID.
|
||||
*/
|
||||
public class FractionEditorView extends BorderPane {
|
||||
|
||||
private final ObservableList<Fraction> sharedFractions = FXCollections.observableArrayList();
|
||||
private final ObservableList<Fraction> fractions = FXCollections.observableArrayList();
|
||||
private final Path fractionDir;
|
||||
|
||||
public FractionEditorView(Path fractionDir) {
|
||||
this.fractionDir = fractionDir;
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
reload();
|
||||
|
||||
FractionPanel left = new FractionPanel("Liste 1", sharedFractions, fractionDir, this::reload);
|
||||
FractionPanel right = new FractionPanel("Liste 2", sharedFractions, fractionDir, this::reload);
|
||||
|
||||
HBox panels = new HBox(1, left, right);
|
||||
HBox.setHgrow(left, Priority.ALWAYS);
|
||||
HBox.setHgrow(right, Priority.ALWAYS);
|
||||
setCenter(panels);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
sharedFractions.setAll(FractionIO.loadAll(fractionDir));
|
||||
}
|
||||
|
||||
// ── Single panel ──────────────────────────────────────────────────────────
|
||||
|
||||
static class FractionPanel extends VBox {
|
||||
|
||||
private final ObservableList<Fraction> fractions;
|
||||
private final Path fractionDir;
|
||||
private final Runnable onSaved;
|
||||
// ── List ──────────────────────────────────────────────────────────────────
|
||||
|
||||
private final SortedList<Fraction> sortedFractions;
|
||||
private final ListView<Fraction> listView;
|
||||
|
||||
private ListView<Fraction> listView;
|
||||
private Button deleteBtn;
|
||||
private Fraction current = null;
|
||||
|
||||
// Form fields
|
||||
// ── Form fields ───────────────────────────────────────────────────────────
|
||||
|
||||
private Label idLabel;
|
||||
private TextField nameField;
|
||||
private TextField maleMemberField;
|
||||
@@ -62,40 +39,29 @@ public class FractionEditorView extends BorderPane {
|
||||
private TextField rank1Field;
|
||||
private TextField rank2Field;
|
||||
private TextField rank3Field;
|
||||
|
||||
private VBox formContainer;
|
||||
private Button deleteBtn;
|
||||
|
||||
FractionPanel(String title, ObservableList<Fraction> fractions, Path fractionDir, Runnable onSaved) {
|
||||
this.fractions = fractions;
|
||||
public FractionEditorView(Path fractionDir) {
|
||||
this.fractionDir = fractionDir;
|
||||
this.onSaved = onSaved;
|
||||
this.sortedFractions = new SortedList<>(fractions, FractionIO.SORT_ORDER);
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
reload();
|
||||
|
||||
setStyle("-fx-background-color: #252535; -fx-border-color: #3a3a4a; -fx-border-width: 0 1 0 0;");
|
||||
SplitPane split = new SplitPane(buildListPanel(), buildFormPanel());
|
||||
split.setDividerPositions(0.28);
|
||||
setCenter(split);
|
||||
}
|
||||
|
||||
// ── Header ────────────────────────────────────────────────────────
|
||||
Label titleLbl = new Label(title);
|
||||
titleLbl.setStyle("-fx-font-weight: bold; -fx-font-size: 13; -fx-text-fill: #aaccee;");
|
||||
Button refreshBtn = new Button("↺");
|
||||
refreshBtn.setStyle("-fx-background-color: transparent; -fx-text-fill: #888; -fx-cursor: hand;");
|
||||
refreshBtn.setOnAction(e -> onSaved.run());
|
||||
HBox header = new HBox(8, titleLbl, refreshBtn);
|
||||
header.setPadding(new Insets(8, 10, 8, 10));
|
||||
header.setAlignment(Pos.CENTER_LEFT);
|
||||
header.setStyle("-fx-background-color: #1a1a2a; -fx-border-color: #444;"
|
||||
+ " -fx-border-width: 0 0 1 0;");
|
||||
// ── List panel ────────────────────────────────────────────────────────────
|
||||
|
||||
// ── Fraction list ─────────────────────────────────────────────────
|
||||
sortedFractions = new SortedList<>(fractions, FractionIO.SORT_ORDER);
|
||||
private VBox buildListPanel() {
|
||||
listView = new ListView<>(sortedFractions);
|
||||
listView.setPrefHeight(180);
|
||||
listView.setStyle("-fx-background-color: #1a1a2a; -fx-control-inner-background: #1a1a2a;");
|
||||
listView.setCellFactory(lv -> new ListCell<>() {
|
||||
@Override protected void updateItem(Fraction f, boolean empty) {
|
||||
super.updateItem(f, empty);
|
||||
if (empty || f == null) { setText(null); setStyle(""); return; }
|
||||
String name = f.getName() != null ? f.getName().id() : "—";
|
||||
String uuid = f.getFractionId() != null ? f.getFractionId().toString().substring(0, 8) + "…" : "?";
|
||||
setText(name);
|
||||
setTooltip(new Tooltip("ID: " + (f.getFractionId() != null ? f.getFractionId() : "?")));
|
||||
setStyle("-fx-text-fill: #dddddd;"
|
||||
@@ -105,6 +71,7 @@ public class FractionEditorView extends BorderPane {
|
||||
});
|
||||
listView.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, old, nw) -> onFractionSelected(old, nw));
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
|
||||
Button newBtn = new Button("Neue Fraktion");
|
||||
newBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
@@ -117,31 +84,36 @@ public class FractionEditorView extends BorderPane {
|
||||
deleteBtn.setDisable(true);
|
||||
deleteBtn.setOnAction(e -> deleteSelected());
|
||||
|
||||
Button refreshBtn = new Button("↺ Neu laden");
|
||||
refreshBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
refreshBtn.setOnAction(e -> reload());
|
||||
|
||||
HBox listButtons = new HBox(6, newBtn, deleteBtn);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
HBox.setHgrow(newBtn, Priority.ALWAYS);
|
||||
HBox.setHgrow(deleteBtn, Priority.ALWAYS);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
|
||||
VBox listSection = new VBox(listView, listButtons);
|
||||
listSection.setStyle("-fx-background-color: #1a1a2a;");
|
||||
|
||||
// ── Form ──────────────────────────────────────────────────────────
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
|
||||
ScrollPane formScroll = new ScrollPane(formContainer);
|
||||
formScroll.setFitToWidth(true);
|
||||
formScroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
VBox.setVgrow(formScroll, Priority.ALWAYS);
|
||||
|
||||
getChildren().addAll(header, listSection, new Separator(), formScroll);
|
||||
VBox panel = new VBox(6, listView, listButtons, refreshBtn);
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
panel.setPadding(new Insets(8));
|
||||
panel.setStyle("-fx-background-color: #1a1a2a;");
|
||||
return panel;
|
||||
}
|
||||
|
||||
// ── Form construction ─────────────────────────────────────────────────
|
||||
// ── Form panel ────────────────────────────────────────────────────────────
|
||||
|
||||
private ScrollPane buildFormPanel() {
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
ScrollPane scroll = new ScrollPane(formContainer);
|
||||
scroll.setFitToWidth(true);
|
||||
scroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
return scroll;
|
||||
}
|
||||
|
||||
private VBox buildForm() {
|
||||
VBox form = new VBox(6);
|
||||
form.setPadding(new Insets(10));
|
||||
form.setPadding(new Insets(12));
|
||||
form.setStyle("-fx-background-color: #252535;");
|
||||
|
||||
idLabel = new Label("—");
|
||||
@@ -179,7 +151,7 @@ public class FractionEditorView extends BorderPane {
|
||||
return form;
|
||||
}
|
||||
|
||||
// ── Form load / save ──────────────────────────────────────────────────
|
||||
// ── Form load / save ──────────────────────────────────────────────────────
|
||||
|
||||
private void onFractionSelected(Fraction old, Fraction nw) {
|
||||
if (old != null) saveFormToFraction(old);
|
||||
@@ -223,7 +195,7 @@ public class FractionEditorView extends BorderPane {
|
||||
rank3Field.clear();
|
||||
}
|
||||
|
||||
// ── List operations ───────────────────────────────────────────────────
|
||||
// ── List operations ───────────────────────────────────────────────────────
|
||||
|
||||
private void createFraction() {
|
||||
Fraction f = new Fraction();
|
||||
@@ -242,13 +214,12 @@ public class FractionEditorView extends BorderPane {
|
||||
clearForm();
|
||||
formContainer.setDisable(true);
|
||||
deleteBtn.setDisable(true);
|
||||
onSaved.run();
|
||||
reload();
|
||||
}
|
||||
|
||||
private void saveCurrentFraction() {
|
||||
if (current == null) return;
|
||||
saveFormToFraction(current);
|
||||
|
||||
if (current.getFractionId() == null) {
|
||||
new Alert(Alert.AlertType.ERROR,
|
||||
"Fraktion hat keine UUID – bitte neu erstellen.", ButtonType.OK).showAndWait();
|
||||
@@ -260,7 +231,7 @@ public class FractionEditorView extends BorderPane {
|
||||
new Alert(Alert.AlertType.ERROR, "Fehler: " + e.getMessage(), ButtonType.OK).showAndWait();
|
||||
return;
|
||||
}
|
||||
onSaved.run();
|
||||
reload();
|
||||
final UUID fid = current.getFractionId();
|
||||
fractions.stream()
|
||||
.filter(f -> fid.equals(f.getFractionId()))
|
||||
@@ -268,7 +239,11 @@ public class FractionEditorView extends BorderPane {
|
||||
.ifPresent(listView.getSelectionModel()::select);
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────
|
||||
public void reload() {
|
||||
fractions.setAll(FractionIO.loadAll(fractionDir));
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static TextReference ref(String text) {
|
||||
String t = text == null ? "" : text.trim();
|
||||
@@ -298,5 +273,4 @@ public class FractionEditorView extends BorderPane {
|
||||
box.setAlignment(Pos.CENTER_LEFT);
|
||||
return box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,77 +15,41 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Locations-Verwaltung: zwei identische LocationPanel-Instanzen nebeneinander.
|
||||
* Locations-Verwaltung: Liste links, Formular rechts.
|
||||
* Alle Locations werden gemeinsam in einer Datei gespeichert (LocationIO).
|
||||
*/
|
||||
public class LocationEditorView extends BorderPane {
|
||||
|
||||
private final ObservableList<Location> sharedLocations = FXCollections.observableArrayList();
|
||||
private final ObservableList<Location> locations = FXCollections.observableArrayList();
|
||||
|
||||
public LocationEditorView() {
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
reload();
|
||||
// ── List ──────────────────────────────────────────────────────────────────
|
||||
|
||||
LocationPanel left = new LocationPanel("Liste 1", sharedLocations, this::saveAll);
|
||||
LocationPanel right = new LocationPanel("Liste 2", sharedLocations, this::saveAll);
|
||||
|
||||
HBox panels = new HBox(1, left, right);
|
||||
HBox.setHgrow(left, Priority.ALWAYS);
|
||||
HBox.setHgrow(right, Priority.ALWAYS);
|
||||
setCenter(panels);
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
try { sharedLocations.setAll(LocationIO.load()); }
|
||||
catch (IOException e) { sharedLocations.clear(); }
|
||||
}
|
||||
|
||||
private void saveAll() {
|
||||
try { LocationIO.save(sharedLocations); }
|
||||
catch (IOException e) {
|
||||
new Alert(Alert.AlertType.ERROR, "Fehler: " + e.getMessage(), ButtonType.OK).showAndWait();
|
||||
}
|
||||
reload();
|
||||
}
|
||||
|
||||
// ── Single panel ──────────────────────────────────────────────────────────
|
||||
|
||||
static class LocationPanel extends VBox {
|
||||
|
||||
private final ObservableList<Location> locations;
|
||||
private final Runnable onSaved;
|
||||
|
||||
private final ListView<Location> listView;
|
||||
private ListView<Location> listView;
|
||||
private Button deleteBtn;
|
||||
private Location current = null;
|
||||
|
||||
// Form fields
|
||||
// ── Form fields ───────────────────────────────────────────────────────────
|
||||
|
||||
private TextField nameIdField;
|
||||
private TextField centerXField;
|
||||
private TextField centerZField;
|
||||
private TextField radiusField;
|
||||
private TriggerListEditor triggerEditor;
|
||||
|
||||
private VBox formContainer;
|
||||
private Button deleteBtn;
|
||||
|
||||
LocationPanel(String title, ObservableList<Location> locations, Runnable onSaved) {
|
||||
this.locations = locations;
|
||||
this.onSaved = onSaved;
|
||||
public LocationEditorView() {
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
reload();
|
||||
|
||||
setStyle("-fx-background-color: #252535; -fx-border-color: #3a3a4a; -fx-border-width: 0 1 0 0;");
|
||||
SplitPane split = new SplitPane(buildListPanel(), buildFormPanel());
|
||||
split.setDividerPositions(0.28);
|
||||
setCenter(split);
|
||||
}
|
||||
|
||||
Label titleLbl = new Label(title);
|
||||
titleLbl.setStyle("-fx-font-weight: bold; -fx-font-size: 13; -fx-text-fill: #aaccee;");
|
||||
Button refreshBtn = new Button("↺");
|
||||
refreshBtn.setStyle("-fx-background-color: transparent; -fx-text-fill: #888; -fx-cursor: hand;");
|
||||
refreshBtn.setOnAction(e -> onSaved.run());
|
||||
HBox header = new HBox(8, titleLbl, refreshBtn);
|
||||
header.setPadding(new Insets(8, 10, 8, 10));
|
||||
header.setAlignment(Pos.CENTER_LEFT);
|
||||
header.setStyle("-fx-background-color: #1a1a2a; -fx-border-color: #444; -fx-border-width: 0 0 1 0;");
|
||||
// ── List panel ────────────────────────────────────────────────────────────
|
||||
|
||||
private VBox buildListPanel() {
|
||||
listView = new ListView<>(locations);
|
||||
listView.setPrefHeight(180);
|
||||
listView.setStyle("-fx-background-color: #1a1a2a; -fx-control-inner-background: #1a1a2a;");
|
||||
listView.setCellFactory(lv -> new ListCell<>() {
|
||||
@Override protected void updateItem(Location loc, boolean empty) {
|
||||
@@ -99,6 +63,7 @@ public class LocationEditorView extends BorderPane {
|
||||
});
|
||||
listView.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, old, nw) -> onSelected(old, nw));
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
|
||||
Button newBtn = new Button("Neue Location");
|
||||
newBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
@@ -111,28 +76,36 @@ public class LocationEditorView extends BorderPane {
|
||||
deleteBtn.setDisable(true);
|
||||
deleteBtn.setOnAction(e -> deleteSelected());
|
||||
|
||||
Button refreshBtn = new Button("↺ Neu laden");
|
||||
refreshBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
refreshBtn.setOnAction(e -> reload());
|
||||
|
||||
HBox listButtons = new HBox(6, newBtn, deleteBtn);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
HBox.setHgrow(newBtn, Priority.ALWAYS);
|
||||
HBox.setHgrow(deleteBtn, Priority.ALWAYS);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
|
||||
VBox listSection = new VBox(listView, listButtons);
|
||||
listSection.setStyle("-fx-background-color: #1a1a2a;");
|
||||
VBox panel = new VBox(6, listView, listButtons, refreshBtn);
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
panel.setPadding(new Insets(8));
|
||||
panel.setStyle("-fx-background-color: #1a1a2a;");
|
||||
return panel;
|
||||
}
|
||||
|
||||
// ── Form panel ────────────────────────────────────────────────────────────
|
||||
|
||||
private ScrollPane buildFormPanel() {
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
|
||||
ScrollPane formScroll = new ScrollPane(formContainer);
|
||||
formScroll.setFitToWidth(true);
|
||||
formScroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
VBox.setVgrow(formScroll, Priority.ALWAYS);
|
||||
|
||||
getChildren().addAll(header, listSection, new Separator(), formScroll);
|
||||
ScrollPane scroll = new ScrollPane(formContainer);
|
||||
scroll.setFitToWidth(true);
|
||||
scroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
return scroll;
|
||||
}
|
||||
|
||||
private VBox buildForm() {
|
||||
VBox form = new VBox(6);
|
||||
form.setPadding(new Insets(10));
|
||||
form.setPadding(new Insets(12));
|
||||
form.setStyle("-fx-background-color: #252535;");
|
||||
|
||||
nameIdField = field("z. B. location.village");
|
||||
@@ -140,7 +113,6 @@ public class LocationEditorView extends BorderPane {
|
||||
centerZField = field("Z-Koordinate");
|
||||
radiusField = field("Radius in Meter");
|
||||
|
||||
// TriggerEditor — placeholder; rebuilt when item selected
|
||||
triggerEditor = new TriggerListEditor(List.of(), () -> {});
|
||||
|
||||
Button saveBtn = new Button("Location speichern");
|
||||
@@ -164,6 +136,8 @@ public class LocationEditorView extends BorderPane {
|
||||
return form;
|
||||
}
|
||||
|
||||
// ── Form load / save ──────────────────────────────────────────────────────
|
||||
|
||||
private void onSelected(Location old, Location nw) {
|
||||
if (old != null) saveFormToLocation(old);
|
||||
current = nw;
|
||||
@@ -178,7 +152,6 @@ public class LocationEditorView extends BorderPane {
|
||||
centerZField.setText(String.valueOf(loc.getCenterZ()));
|
||||
radiusField.setText(String.valueOf(loc.getRadius()));
|
||||
|
||||
// Rebuild trigger editor
|
||||
int idx = formContainer.getChildren().indexOf(triggerEditor);
|
||||
triggerEditor = new TriggerListEditor(
|
||||
loc.getTriggers() != null ? loc.getTriggers() : List.of(), () -> {});
|
||||
@@ -195,9 +168,14 @@ public class LocationEditorView extends BorderPane {
|
||||
}
|
||||
|
||||
private void clearForm() {
|
||||
nameIdField.clear(); centerXField.clear(); centerZField.clear(); radiusField.clear();
|
||||
nameIdField.clear();
|
||||
centerXField.clear();
|
||||
centerZField.clear();
|
||||
radiusField.clear();
|
||||
}
|
||||
|
||||
// ── List operations ───────────────────────────────────────────────────────
|
||||
|
||||
private void createLocation() {
|
||||
Location loc = new Location();
|
||||
loc.setName(new TextReference("location.neu_" + System.currentTimeMillis()));
|
||||
@@ -208,8 +186,12 @@ public class LocationEditorView extends BorderPane {
|
||||
private void deleteSelected() {
|
||||
if (current == null) return;
|
||||
locations.remove(current);
|
||||
current = null; clearForm(); formContainer.setDisable(true); deleteBtn.setDisable(true);
|
||||
onSaved.run();
|
||||
current = null;
|
||||
clearForm();
|
||||
formContainer.setDisable(true);
|
||||
deleteBtn.setDisable(true);
|
||||
persist();
|
||||
reload();
|
||||
}
|
||||
|
||||
private void saveCurrent() {
|
||||
@@ -219,10 +201,29 @@ public class LocationEditorView extends BorderPane {
|
||||
new Alert(Alert.AlertType.ERROR, "Name-ID darf nicht leer sein.", ButtonType.OK).showAndWait();
|
||||
return;
|
||||
}
|
||||
onSaved.run();
|
||||
listView.refresh();
|
||||
String savedId = current.getId();
|
||||
persist();
|
||||
reload();
|
||||
locations.stream()
|
||||
.filter(l -> savedId.equals(l.getId()))
|
||||
.findFirst()
|
||||
.ifPresent(listView.getSelectionModel()::select);
|
||||
}
|
||||
|
||||
private void persist() {
|
||||
try { LocationIO.save(locations); }
|
||||
catch (IOException e) {
|
||||
new Alert(Alert.AlertType.ERROR, "Fehler: " + e.getMessage(), ButtonType.OK).showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
try { locations.setAll(LocationIO.load()); }
|
||||
catch (IOException e) { locations.clear(); }
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static float parseFloat(String s) {
|
||||
try { return Float.parseFloat(s.trim().replace(',', '.')); }
|
||||
catch (NumberFormatException ignored) { return 0f; }
|
||||
@@ -245,7 +246,8 @@ public class LocationEditorView extends BorderPane {
|
||||
}
|
||||
|
||||
private static TextField field(String prompt) {
|
||||
TextField tf = new TextField(); tf.setPromptText(prompt); return tf;
|
||||
}
|
||||
TextField tf = new TextField();
|
||||
tf.setPromptText(prompt);
|
||||
return tf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import de.blight.common.model.quests.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
@@ -21,90 +20,51 @@ import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Quest-Verwaltung: zwei identische QuestPanel-Instanzen nebeneinander.
|
||||
* Beide Panels teilen die gleiche ObservableList und speichern in dasselbe Verzeichnis.
|
||||
* Quest-Verwaltung: Liste links, Formular rechts.
|
||||
*/
|
||||
public class QuestEditorView extends BorderPane {
|
||||
|
||||
private final ObservableList<Quest> sharedQuests = FXCollections.observableArrayList();
|
||||
private final ObservableList<Quest> quests = FXCollections.observableArrayList();
|
||||
private final Path questDir;
|
||||
|
||||
// ── List ──────────────────────────────────────────────────────────────────
|
||||
|
||||
private ListView<Quest> listView;
|
||||
private Button deleteBtn;
|
||||
private Quest current = null;
|
||||
|
||||
// ── Common form fields ────────────────────────────────────────────────────
|
||||
|
||||
private TextField idField;
|
||||
private Spinner<Integer> xpSpinner;
|
||||
private TextField textField;
|
||||
private TextField descField;
|
||||
private TextField successField;
|
||||
private ComboBox<String> typeCombo;
|
||||
private VBox dynamicArea;
|
||||
private VBox formContainer;
|
||||
private Button saveBtn;
|
||||
|
||||
// ── Type-specific fields ──────────────────────────────────────────────────
|
||||
|
||||
private TextField f1, f2, f3;
|
||||
private Spinner<Integer> countSpinner;
|
||||
|
||||
public QuestEditorView(Path questDir) {
|
||||
this.questDir = questDir;
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
|
||||
reload();
|
||||
|
||||
QuestPanel left = new QuestPanel("Liste 1", sharedQuests, questDir, this::reload);
|
||||
QuestPanel right = new QuestPanel("Liste 2", sharedQuests, questDir, this::reload);
|
||||
|
||||
HBox panels = new HBox(1, left, right);
|
||||
HBox.setHgrow(left, Priority.ALWAYS);
|
||||
HBox.setHgrow(right, Priority.ALWAYS);
|
||||
setCenter(panels);
|
||||
SplitPane split = new SplitPane(buildListPanel(), buildFormPanel());
|
||||
split.setDividerPositions(0.28);
|
||||
setCenter(split);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
List<Quest> loaded = QuestIO.loadAll(questDir);
|
||||
sharedQuests.setAll(loaded);
|
||||
}
|
||||
// ── List panel ────────────────────────────────────────────────────────────
|
||||
|
||||
// ── Single panel ──────────────────────────────────────────────────────────
|
||||
|
||||
static class QuestPanel extends VBox {
|
||||
|
||||
private final ObservableList<Quest> quests;
|
||||
private final Path questDir;
|
||||
private final Runnable onSaved;
|
||||
|
||||
private final ListView<Quest> listView;
|
||||
private Quest current = null;
|
||||
|
||||
// Common fields
|
||||
private TextField idField;
|
||||
private Spinner<Integer> xpSpinner;
|
||||
private TextField textField;
|
||||
private TextField descField;
|
||||
private TextField successField;
|
||||
|
||||
// Type selection
|
||||
private ComboBox<String> typeCombo;
|
||||
|
||||
// Dynamic area
|
||||
private VBox dynamicArea;
|
||||
|
||||
// Type-specific fields (lazily filled)
|
||||
private TextField f1, f2, f3;
|
||||
private Spinner<Integer> countSpinner;
|
||||
|
||||
// Form container (disabled when nothing loaded)
|
||||
private VBox formContainer;
|
||||
private Button saveBtn;
|
||||
private Button deleteBtn;
|
||||
|
||||
QuestPanel(String title, ObservableList<Quest> quests, Path questDir, Runnable onSaved) {
|
||||
this.quests = quests;
|
||||
this.questDir = questDir;
|
||||
this.onSaved = onSaved;
|
||||
|
||||
setStyle("-fx-background-color: #252535; -fx-border-color: #3a3a4a; -fx-border-width: 0 1 0 0;");
|
||||
setSpacing(0);
|
||||
|
||||
// ── Header ────────────────────────────────────────────────────────
|
||||
Label titleLbl = new Label(title);
|
||||
titleLbl.setStyle("-fx-font-weight: bold; -fx-font-size: 13; -fx-text-fill: #aaccee;");
|
||||
Button refreshBtn = new Button("↺");
|
||||
refreshBtn.setStyle("-fx-background-color: transparent; -fx-text-fill: #888; -fx-cursor: hand;");
|
||||
refreshBtn.setOnAction(e -> onSaved.run());
|
||||
HBox header = new HBox(8, titleLbl, refreshBtn);
|
||||
header.setPadding(new Insets(8, 10, 8, 10));
|
||||
header.setAlignment(Pos.CENTER_LEFT);
|
||||
header.setStyle("-fx-background-color: #1a1a2a; -fx-border-color: #444;"
|
||||
+ " -fx-border-width: 0 0 1 0;");
|
||||
|
||||
// ── Quest list ────────────────────────────────────────────────────
|
||||
private VBox buildListPanel() {
|
||||
listView = new ListView<>(quests);
|
||||
listView.setPrefHeight(160);
|
||||
listView.setStyle("-fx-background-color: #1a1a2a; -fx-control-inner-background: #1a1a2a;");
|
||||
listView.setCellFactory(lv -> new ListCell<>() {
|
||||
@Override protected void updateItem(Quest q, boolean empty) {
|
||||
@@ -118,6 +78,7 @@ public class QuestEditorView extends BorderPane {
|
||||
});
|
||||
listView.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, old, nw) -> onQuestSelected(old, nw));
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
|
||||
Button newBtn = new Button("Neue Quest");
|
||||
newBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
@@ -130,39 +91,54 @@ public class QuestEditorView extends BorderPane {
|
||||
deleteBtn.setDisable(true);
|
||||
deleteBtn.setOnAction(e -> deleteSelected());
|
||||
|
||||
Button refreshBtn = new Button("↺ Neu laden");
|
||||
refreshBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
refreshBtn.setOnAction(e -> reload());
|
||||
|
||||
HBox listButtons = new HBox(6, newBtn, deleteBtn);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
HBox.setHgrow(newBtn, Priority.ALWAYS);
|
||||
HBox.setHgrow(deleteBtn, Priority.ALWAYS);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
|
||||
VBox listSection = new VBox(listView, listButtons);
|
||||
listSection.setStyle("-fx-background-color: #1a1a2a;");
|
||||
VBox panel = new VBox(6, listView, listButtons, refreshBtn);
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
panel.setPadding(new Insets(8));
|
||||
panel.setStyle("-fx-background-color: #1a1a2a;");
|
||||
return panel;
|
||||
}
|
||||
|
||||
// ── Form ──────────────────────────────────────────────────────────
|
||||
// ── Form panel ────────────────────────────────────────────────────────────
|
||||
|
||||
private ScrollPane buildFormPanel() {
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
|
||||
ScrollPane formScroll = new ScrollPane(formContainer);
|
||||
formScroll.setFitToWidth(true);
|
||||
formScroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
VBox.setVgrow(formScroll, Priority.ALWAYS);
|
||||
|
||||
getChildren().addAll(header, listSection, new Separator(), formScroll);
|
||||
ScrollPane scroll = new ScrollPane(formContainer);
|
||||
scroll.setFitToWidth(true);
|
||||
scroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
return scroll;
|
||||
}
|
||||
|
||||
// ── Form construction ─────────────────────────────────────────────────
|
||||
|
||||
private VBox buildForm() {
|
||||
VBox form = new VBox(6);
|
||||
form.setPadding(new Insets(10));
|
||||
form.setPadding(new Insets(12));
|
||||
form.setStyle("-fx-background-color: #252535;");
|
||||
|
||||
// Common fields
|
||||
// ID field with no-space filter + auto-fill listener
|
||||
idField = new TextField();
|
||||
idField.setPromptText("eindeutige ID");
|
||||
idField.setPromptText("eindeutige ID (keine Leerzeichen)");
|
||||
idField.setTextFormatter(new TextFormatter<>(change -> {
|
||||
change.setText(change.getText().replace(" ", ""));
|
||||
return change;
|
||||
}));
|
||||
idField.focusedProperty().addListener((obs, wasFocused, isFocused) -> {
|
||||
if (!isFocused) autoFillTextRefs();
|
||||
});
|
||||
|
||||
xpSpinner = new Spinner<>(0, 99999, 0);
|
||||
xpSpinner.setEditable(true);
|
||||
xpSpinner.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
textField = new TextField();
|
||||
textField.setPromptText("TextReference-Schlüssel");
|
||||
descField = new TextField();
|
||||
@@ -183,7 +159,6 @@ public class QuestEditorView extends BorderPane {
|
||||
new Separator()
|
||||
);
|
||||
|
||||
// Type selection
|
||||
typeCombo = new ComboBox<>();
|
||||
typeCombo.getItems().addAll("BringQuest", "FollowQuest", "InteractQuest", "ItemQuest", "TalkQuest");
|
||||
typeCombo.setPromptText("Typ auswählen…");
|
||||
@@ -199,7 +174,6 @@ public class QuestEditorView extends BorderPane {
|
||||
new Separator()
|
||||
);
|
||||
|
||||
// Save button
|
||||
saveBtn = new Button("Quest speichern");
|
||||
saveBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
saveBtn.setStyle("-fx-font-weight: bold; -fx-background-color: #3a5a8a; -fx-text-fill: white;");
|
||||
@@ -209,6 +183,14 @@ public class QuestEditorView extends BorderPane {
|
||||
return form;
|
||||
}
|
||||
|
||||
private void autoFillTextRefs() {
|
||||
String id = idField.getText().trim();
|
||||
if (id.isBlank()) return;
|
||||
if (textField.getText().isBlank()) textField.setText(id + ".name");
|
||||
if (descField.getText().isBlank()) descField.setText(id + ".description");
|
||||
if (successField.getText().isBlank()) successField.setText(id + ".successmassage");
|
||||
}
|
||||
|
||||
private void rebuildDynamicArea(String type) {
|
||||
dynamicArea.getChildren().clear();
|
||||
f1 = null; f2 = null; f3 = null; countSpinner = null;
|
||||
@@ -261,7 +243,7 @@ public class QuestEditorView extends BorderPane {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Form load / save ──────────────────────────────────────────────────
|
||||
// ── Form load / save ──────────────────────────────────────────────────────
|
||||
|
||||
private void onQuestSelected(Quest old, Quest nw) {
|
||||
if (old != null) saveFormToQuest(old);
|
||||
@@ -294,7 +276,6 @@ public class QuestEditorView extends BorderPane {
|
||||
});
|
||||
rebuildDynamicArea(typeCombo.getValue());
|
||||
|
||||
// Fill type-specific fields
|
||||
switch (q) {
|
||||
case BringQuest bq -> {
|
||||
if (f1 != null) f1.setText(bq.getBring() != null ? safe(bq.getBring().getCharacterId()) : "");
|
||||
@@ -325,8 +306,6 @@ public class QuestEditorView extends BorderPane {
|
||||
q.setText(ref(textField));
|
||||
q.setDescription(ref(descField));
|
||||
q.setSuccessText(ref(successField));
|
||||
|
||||
// Type-specific fields written when actually saving (buildQuestFromForm)
|
||||
}
|
||||
|
||||
private Quest buildQuestFromForm() {
|
||||
@@ -340,7 +319,9 @@ public class QuestEditorView extends BorderPane {
|
||||
NPC n = new NPC(); n.setCharacterId(f1.getText().trim()); bq.setBring(n);
|
||||
}
|
||||
if (f2 != null && !f2.getText().isBlank()) {
|
||||
Location l = new Location(); l.setName(new de.blight.common.model.TextReference(f2.getText().trim())); bq.setBringTo(l);
|
||||
Location l = new Location();
|
||||
l.setName(new TextReference(f2.getText().trim()));
|
||||
bq.setBringTo(l);
|
||||
}
|
||||
yield bq;
|
||||
}
|
||||
@@ -350,7 +331,9 @@ public class QuestEditorView extends BorderPane {
|
||||
NPC n = new NPC(); n.setCharacterId(f1.getText().trim()); fq.setFollow(n);
|
||||
}
|
||||
if (f2 != null && !f2.getText().isBlank()) {
|
||||
Location l = new Location(); l.setName(new de.blight.common.model.TextReference(f2.getText().trim())); fq.setFollowTo(l);
|
||||
Location l = new Location();
|
||||
l.setName(new TextReference(f2.getText().trim()));
|
||||
fq.setFollowTo(l);
|
||||
}
|
||||
yield fq;
|
||||
}
|
||||
@@ -398,7 +381,7 @@ public class QuestEditorView extends BorderPane {
|
||||
dynamicArea.getChildren().clear();
|
||||
}
|
||||
|
||||
// ── List operations ───────────────────────────────────────────────────
|
||||
// ── List operations ───────────────────────────────────────────────────────
|
||||
|
||||
private void createQuest() {
|
||||
TalkQuest q = new TalkQuest();
|
||||
@@ -420,7 +403,7 @@ public class QuestEditorView extends BorderPane {
|
||||
clearForm();
|
||||
formContainer.setDisable(true);
|
||||
deleteBtn.setDisable(true);
|
||||
onSaved.run();
|
||||
reload();
|
||||
}
|
||||
|
||||
private void saveCurrentQuest() {
|
||||
@@ -433,7 +416,6 @@ public class QuestEditorView extends BorderPane {
|
||||
showError("Quest-ID darf nicht leer sein.");
|
||||
return;
|
||||
}
|
||||
// Replace or add in shared list
|
||||
int idx = quests.indexOf(current);
|
||||
if (idx >= 0) quests.set(idx, built);
|
||||
else quests.add(built);
|
||||
@@ -445,10 +427,15 @@ public class QuestEditorView extends BorderPane {
|
||||
showError("Fehler beim Speichern: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
onSaved.run();
|
||||
reload();
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────
|
||||
public void reload() {
|
||||
List<Quest> loaded = QuestIO.loadAll(questDir);
|
||||
quests.setAll(loaded);
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static Label sectionTitle(String text) {
|
||||
Label l = new Label(text);
|
||||
@@ -483,5 +470,4 @@ public class QuestEditorView extends BorderPane {
|
||||
Alert a = new Alert(Alert.AlertType.ERROR, msg, ButtonType.OK);
|
||||
a.showAndWait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
@@ -17,54 +16,29 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Rezept-Verwaltung: zwei identische RecipePanel-Instanzen nebeneinander.
|
||||
* Rezept-Verwaltung: Liste links, Formular rechts.
|
||||
* Sortiert nach CraftingTableType, dann nach erstelltem Item-ID.
|
||||
*/
|
||||
public class RecipeEditorView extends BorderPane {
|
||||
|
||||
private final ObservableList<Recipe> sharedRecipes = FXCollections.observableArrayList();
|
||||
private final Path recipeDir;
|
||||
|
||||
public RecipeEditorView(Path recipeDir) {
|
||||
this.recipeDir = recipeDir;
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
reload();
|
||||
|
||||
RecipePanel left = new RecipePanel("Liste 1", sharedRecipes, recipeDir, this::reload);
|
||||
RecipePanel right = new RecipePanel("Liste 2", sharedRecipes, recipeDir, this::reload);
|
||||
|
||||
HBox panels = new HBox(1, left, right);
|
||||
HBox.setHgrow(left, Priority.ALWAYS);
|
||||
HBox.setHgrow(right, Priority.ALWAYS);
|
||||
setCenter(panels);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
sharedRecipes.setAll(RecipeIO.loadAll(recipeDir));
|
||||
}
|
||||
|
||||
// ── Single panel ──────────────────────────────────────────────────────────
|
||||
|
||||
static class RecipePanel extends VBox {
|
||||
|
||||
private static final String NO_TABLE = "— kein Tisch —";
|
||||
|
||||
private final ObservableList<Recipe> recipes;
|
||||
private final ObservableList<Recipe> recipes = FXCollections.observableArrayList();
|
||||
private final Path recipeDir;
|
||||
private final Runnable onSaved;
|
||||
|
||||
// ── List ──────────────────────────────────────────────────────────────────
|
||||
|
||||
private final SortedList<Recipe> sortedRecipes;
|
||||
private final ListView<Recipe> listView;
|
||||
|
||||
private ListView<Recipe> listView;
|
||||
private Button deleteBtn;
|
||||
private Recipe current = null;
|
||||
private String oldFileId = null; // for rename-on-save detection
|
||||
private String oldFileId = null;
|
||||
|
||||
// ── Form fields ───────────────────────────────────────────────────────────
|
||||
|
||||
// Form fields
|
||||
private TextField createsField;
|
||||
private ListView<String> componentsList; // "itemId × count"
|
||||
private ListView<String> componentsList;
|
||||
private ComboBox<String> tableCombo;
|
||||
|
||||
// Level-Anforderungs-Zeilen (jeweils Label + Spinner)
|
||||
private HBox alchemyRow;
|
||||
private HBox enchantingRow;
|
||||
private HBox smitheryRow;
|
||||
@@ -73,33 +47,23 @@ public class RecipeEditorView extends BorderPane {
|
||||
private Spinner<Integer> enchantingSpinner;
|
||||
private Spinner<Integer> smitherySpinner;
|
||||
private Spinner<Integer> engineeringSpinner;
|
||||
|
||||
private VBox formContainer;
|
||||
private Button deleteBtn;
|
||||
|
||||
RecipePanel(String title, ObservableList<Recipe> recipes, Path recipeDir, Runnable onSaved) {
|
||||
this.recipes = recipes;
|
||||
public RecipeEditorView(Path recipeDir) {
|
||||
this.recipeDir = recipeDir;
|
||||
this.onSaved = onSaved;
|
||||
this.sortedRecipes = new SortedList<>(recipes, RecipeIO.SORT_ORDER);
|
||||
setStyle("-fx-background-color: #1e1e2e;");
|
||||
reload();
|
||||
|
||||
setStyle("-fx-background-color: #252535; -fx-border-color: #3a3a4a; -fx-border-width: 0 1 0 0;");
|
||||
SplitPane split = new SplitPane(buildListPanel(), buildFormPanel());
|
||||
split.setDividerPositions(0.28);
|
||||
setCenter(split);
|
||||
}
|
||||
|
||||
// ── Header ────────────────────────────────────────────────────────
|
||||
Label titleLbl = new Label(title);
|
||||
titleLbl.setStyle("-fx-font-weight: bold; -fx-font-size: 13; -fx-text-fill: #aaccee;");
|
||||
Button refreshBtn = new Button("↺");
|
||||
refreshBtn.setStyle("-fx-background-color: transparent; -fx-text-fill: #888; -fx-cursor: hand;");
|
||||
refreshBtn.setOnAction(e -> onSaved.run());
|
||||
HBox header = new HBox(8, titleLbl, refreshBtn);
|
||||
header.setPadding(new Insets(8, 10, 8, 10));
|
||||
header.setAlignment(Pos.CENTER_LEFT);
|
||||
header.setStyle("-fx-background-color: #1a1a2a; -fx-border-color: #444;"
|
||||
+ " -fx-border-width: 0 0 1 0;");
|
||||
// ── List panel ────────────────────────────────────────────────────────────
|
||||
|
||||
// ── Recipe list ───────────────────────────────────────────────────
|
||||
sortedRecipes = new SortedList<>(recipes, RecipeIO.SORT_ORDER);
|
||||
private VBox buildListPanel() {
|
||||
listView = new ListView<>(sortedRecipes);
|
||||
listView.setPrefHeight(180);
|
||||
listView.setStyle("-fx-background-color: #1a1a2a; -fx-control-inner-background: #1a1a2a;");
|
||||
listView.setCellFactory(lv -> new ListCell<>() {
|
||||
@Override protected void updateItem(Recipe r, boolean empty) {
|
||||
@@ -118,6 +82,7 @@ public class RecipeEditorView extends BorderPane {
|
||||
});
|
||||
listView.getSelectionModel().selectedItemProperty()
|
||||
.addListener((obs, old, nw) -> onRecipeSelected(old, nw));
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
|
||||
Button newBtn = new Button("Neues Rezept");
|
||||
newBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
@@ -130,38 +95,41 @@ public class RecipeEditorView extends BorderPane {
|
||||
deleteBtn.setDisable(true);
|
||||
deleteBtn.setOnAction(e -> deleteSelected());
|
||||
|
||||
Button refreshBtn = new Button("↺ Neu laden");
|
||||
refreshBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
refreshBtn.setOnAction(e -> reload());
|
||||
|
||||
HBox listButtons = new HBox(6, newBtn, deleteBtn);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
HBox.setHgrow(newBtn, Priority.ALWAYS);
|
||||
HBox.setHgrow(deleteBtn, Priority.ALWAYS);
|
||||
listButtons.setPadding(new Insets(6, 8, 6, 8));
|
||||
|
||||
VBox listSection = new VBox(listView, listButtons);
|
||||
listSection.setStyle("-fx-background-color: #1a1a2a;");
|
||||
|
||||
// ── Form ──────────────────────────────────────────────────────────
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
|
||||
ScrollPane formScroll = new ScrollPane(formContainer);
|
||||
formScroll.setFitToWidth(true);
|
||||
formScroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
VBox.setVgrow(formScroll, Priority.ALWAYS);
|
||||
|
||||
getChildren().addAll(header, listSection, new Separator(), formScroll);
|
||||
VBox panel = new VBox(6, listView, listButtons, refreshBtn);
|
||||
VBox.setVgrow(listView, Priority.ALWAYS);
|
||||
panel.setPadding(new Insets(8));
|
||||
panel.setStyle("-fx-background-color: #1a1a2a;");
|
||||
return panel;
|
||||
}
|
||||
|
||||
// ── Form construction ─────────────────────────────────────────────────
|
||||
// ── Form panel ────────────────────────────────────────────────────────────
|
||||
|
||||
private ScrollPane buildFormPanel() {
|
||||
formContainer = buildForm();
|
||||
formContainer.setDisable(true);
|
||||
ScrollPane scroll = new ScrollPane(formContainer);
|
||||
scroll.setFitToWidth(true);
|
||||
scroll.setStyle("-fx-background-color: #252535; -fx-background: #252535;");
|
||||
return scroll;
|
||||
}
|
||||
|
||||
private VBox buildForm() {
|
||||
VBox form = new VBox(6);
|
||||
form.setPadding(new Insets(10));
|
||||
form.setStyle("-fx-background-color: #252535;");
|
||||
|
||||
// Erstellt
|
||||
createsField = new TextField();
|
||||
createsField.setPromptText("Item-ID des erstellten Items");
|
||||
|
||||
// Zutaten
|
||||
componentsList = new ListView<>();
|
||||
componentsList.setPrefHeight(110);
|
||||
componentsList.setStyle("-fx-background-color: #1e1e2e; -fx-control-inner-background: #1e1e2e;");
|
||||
@@ -181,26 +149,15 @@ public class RecipeEditorView extends BorderPane {
|
||||
});
|
||||
HBox compButtons = new HBox(4, addCompBtn, delCompBtn);
|
||||
|
||||
form.getChildren().addAll(
|
||||
sectionTitle("Ergebnis"),
|
||||
new Separator(),
|
||||
row("Erstellt:", createsField),
|
||||
sectionTitle("Zutaten"),
|
||||
componentsList,
|
||||
compButtons,
|
||||
new Separator()
|
||||
);
|
||||
|
||||
// Crafting Table
|
||||
tableCombo = new ComboBox<>();
|
||||
tableCombo.getItems().add(NO_TABLE);
|
||||
for (CraftingTable.CraftingTableType t : CraftingTable.CraftingTableType.values())
|
||||
for (CraftingTable.CraftingTableType t : CraftingTable.CraftingTableType.values()) {
|
||||
tableCombo.getItems().add(t.name());
|
||||
}
|
||||
tableCombo.setValue(NO_TABLE);
|
||||
tableCombo.setMaxWidth(Double.MAX_VALUE);
|
||||
tableCombo.setOnAction(e -> updateRequirementRows(tableCombo.getValue()));
|
||||
|
||||
// Level-Anforderungen (werden je nach Tischtyp aktiviert)
|
||||
alchemySpinner = lvlSpinner();
|
||||
enchantingSpinner = lvlSpinner();
|
||||
smitherySpinner = lvlSpinner();
|
||||
@@ -211,40 +168,40 @@ public class RecipeEditorView extends BorderPane {
|
||||
smitheryRow = requirementRow("Lvl Schmieden:", smitherySpinner);
|
||||
engineeringRow = requirementRow("Lvl Engineering:", engineeringSpinner);
|
||||
|
||||
Button saveBtn = new Button("Rezept speichern");
|
||||
saveBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
saveBtn.setStyle("-fx-font-weight: bold; -fx-background-color: #3a5a8a; -fx-text-fill: white;");
|
||||
saveBtn.setOnAction(e -> saveCurrentRecipe());
|
||||
|
||||
form.getChildren().addAll(
|
||||
sectionTitle("Ergebnis"),
|
||||
new Separator(),
|
||||
row("Erstellt:", createsField),
|
||||
sectionTitle("Zutaten"),
|
||||
componentsList,
|
||||
compButtons,
|
||||
new Separator(),
|
||||
sectionTitle("Crafting Table"),
|
||||
tableCombo,
|
||||
alchemyRow,
|
||||
enchantingRow,
|
||||
smitheryRow,
|
||||
engineeringRow
|
||||
engineeringRow,
|
||||
new Separator(),
|
||||
saveBtn
|
||||
);
|
||||
|
||||
// Anfangs alle Anforderungen deaktiviert
|
||||
updateRequirementRows(NO_TABLE);
|
||||
|
||||
form.getChildren().add(new Separator());
|
||||
|
||||
Button saveBtn = new Button("Rezept speichern");
|
||||
saveBtn.setMaxWidth(Double.MAX_VALUE);
|
||||
saveBtn.setStyle("-fx-font-weight: bold; -fx-background-color: #3a5a8a; -fx-text-fill: white;");
|
||||
saveBtn.setOnAction(e -> saveCurrentRecipe());
|
||||
form.getChildren().add(saveBtn);
|
||||
|
||||
return form;
|
||||
}
|
||||
|
||||
private void updateRequirementRows(String tableValue) {
|
||||
boolean noTable = tableValue == null || tableValue.equals(NO_TABLE);
|
||||
|
||||
// Alle ausblenden wenn kein Tisch
|
||||
setRowVisible(alchemyRow, false);
|
||||
setRowVisible(enchantingRow, false);
|
||||
setRowVisible(smitheryRow, false);
|
||||
setRowVisible(engineeringRow, false);
|
||||
|
||||
if (noTable) return;
|
||||
|
||||
switch (tableValue) {
|
||||
case "AlchemyTable" -> setRowVisible(alchemyRow, true);
|
||||
case "EnchantmentTable" -> setRowVisible(enchantingRow, true);
|
||||
@@ -259,7 +216,7 @@ public class RecipeEditorView extends BorderPane {
|
||||
row.setManaged(visible);
|
||||
}
|
||||
|
||||
// ── Form load / save ──────────────────────────────────────────────────
|
||||
// ── Form load / save ──────────────────────────────────────────────────────
|
||||
|
||||
private void onRecipeSelected(Recipe old, Recipe nw) {
|
||||
if (old != null) saveFormToRecipe(old);
|
||||
@@ -285,8 +242,9 @@ public class RecipeEditorView extends BorderPane {
|
||||
}
|
||||
|
||||
String tableVal = NO_TABLE;
|
||||
if (r.getTable() != null && r.getTable().getType() != null)
|
||||
if (r.getTable() != null && r.getTable().getType() != null) {
|
||||
tableVal = r.getTable().getType().name();
|
||||
}
|
||||
tableCombo.setValue(tableVal);
|
||||
updateRequirementRows(tableVal);
|
||||
|
||||
@@ -301,7 +259,6 @@ public class RecipeEditorView extends BorderPane {
|
||||
}
|
||||
|
||||
private void saveFormToRecipe(Recipe r) {
|
||||
// creates
|
||||
String cId = createsField.getText().trim();
|
||||
if (!cId.isBlank()) {
|
||||
Item creates = r.getCreates() != null ? r.getCreates() : new Item();
|
||||
@@ -311,7 +268,6 @@ public class RecipeEditorView extends BorderPane {
|
||||
r.setCreates(null);
|
||||
}
|
||||
|
||||
// components
|
||||
Map<Item, Integer> comps = new LinkedHashMap<>();
|
||||
for (String entry : componentsList.getItems()) {
|
||||
int sep = entry.lastIndexOf(" × ");
|
||||
@@ -325,7 +281,6 @@ public class RecipeEditorView extends BorderPane {
|
||||
}
|
||||
r.setComponents(comps.isEmpty() ? null : comps);
|
||||
|
||||
// table
|
||||
String tv = tableCombo.getValue();
|
||||
if (tv == null || tv.equals(NO_TABLE)) {
|
||||
r.setTable(null);
|
||||
@@ -337,7 +292,6 @@ public class RecipeEditorView extends BorderPane {
|
||||
CraftingTable table = r.getTable() != null ? r.getTable() : new CraftingTable();
|
||||
table.setType(CraftingTable.CraftingTableType.valueOf(tv));
|
||||
r.setTable(table);
|
||||
// Nur das relevante Level-Feld setzen, alle anderen null
|
||||
r.setRequiresLvlAlchemy(null);
|
||||
r.setRequiresLvlEngineering(null);
|
||||
r.setRequiresLvlSmithery(null);
|
||||
@@ -363,7 +317,7 @@ public class RecipeEditorView extends BorderPane {
|
||||
engineeringSpinner.getValueFactory().setValue(1);
|
||||
}
|
||||
|
||||
// ── List operations ───────────────────────────────────────────────────
|
||||
// ── List operations ───────────────────────────────────────────────────────
|
||||
|
||||
private void createRecipe() {
|
||||
Recipe r = new Recipe();
|
||||
@@ -385,7 +339,7 @@ public class RecipeEditorView extends BorderPane {
|
||||
clearForm();
|
||||
formContainer.setDisable(true);
|
||||
deleteBtn.setDisable(true);
|
||||
onSaved.run();
|
||||
reload();
|
||||
}
|
||||
|
||||
private void saveCurrentRecipe() {
|
||||
@@ -399,17 +353,16 @@ public class RecipeEditorView extends BorderPane {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Datei umbenennen: alten Eintrag löschen wenn ID sich geändert hat
|
||||
if (oldFileId != null && !oldFileId.equals(newFileId))
|
||||
if (oldFileId != null && !oldFileId.equals(newFileId)) {
|
||||
RecipeIO.delete(oldFileId, recipeDir);
|
||||
}
|
||||
RecipeIO.save(current, recipeDir);
|
||||
oldFileId = newFileId;
|
||||
} catch (IOException e) {
|
||||
new Alert(Alert.AlertType.ERROR, "Fehler: " + e.getMessage(), ButtonType.OK).showAndWait();
|
||||
return;
|
||||
}
|
||||
onSaved.run();
|
||||
// Re-select nach Reload
|
||||
reload();
|
||||
final String fid = newFileId;
|
||||
recipes.stream()
|
||||
.filter(r -> fid.equals(RecipeIO.fileId(r)))
|
||||
@@ -443,12 +396,17 @@ public class RecipeEditorView extends BorderPane {
|
||||
dlg.setResultConverter(bt -> bt == ButtonType.OK
|
||||
? itemIdField.getText().trim() + " × " + countSpin.getValue() : null);
|
||||
dlg.showAndWait().ifPresent(entry -> {
|
||||
if (!componentsList.getItems().contains(entry))
|
||||
if (!componentsList.getItems().contains(entry)) {
|
||||
componentsList.getItems().add(entry);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────
|
||||
public void reload() {
|
||||
recipes.setAll(RecipeIO.loadAll(recipeDir));
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static String tableColor(CraftingTable t) {
|
||||
if (t == null || t.getType() == null) return "#666666";
|
||||
@@ -504,5 +462,4 @@ public class RecipeEditorView extends BorderPane {
|
||||
}
|
||||
|
||||
private static String safe(String s) { return s != null ? s : ""; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.jme3.system.AppSettings;
|
||||
import de.blight.common.BlightHome;
|
||||
import de.blight.common.SaveGameIO;
|
||||
import de.blight.game.config.*;
|
||||
import de.blight.game.state.AudioSettingsState;
|
||||
import de.blight.game.state.SaveGameState;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -31,11 +32,13 @@ public class BlightGame extends SimpleApplication {
|
||||
|
||||
private KeyBindings keyBindings;
|
||||
private GraphicsSettings graphicsSettings;
|
||||
private AudioSettings audioSettings;
|
||||
private ScreenshotAppState screenshotState;
|
||||
private Path screenshotDir;
|
||||
private WorldScene worldScene;
|
||||
private ConfigScreen configScreen;
|
||||
private GraphicsScreen graphicsScreen;
|
||||
private AudioScreen audioScreen;
|
||||
private PauseMenu pauseMenu;
|
||||
private MainMenuState mainMenuState;
|
||||
|
||||
@@ -135,6 +138,8 @@ public class BlightGame extends SimpleApplication {
|
||||
|
||||
keyBindings = KeyBindingStore.load();
|
||||
graphicsSettings = GraphicsStore.load();
|
||||
audioSettings = AudioSettingsStore.load();
|
||||
stateManager.attach(new AudioSettingsState(audioSettings));
|
||||
|
||||
status("Lade Spielstand...");
|
||||
stateManager.attach(new SaveGameState());
|
||||
@@ -164,6 +169,13 @@ public class BlightGame extends SimpleApplication {
|
||||
stateManager.attach(graphicsScreen);
|
||||
graphicsScreen.setEnabled(false);
|
||||
|
||||
audioScreen = new AudioScreen(audioSettings, () -> {
|
||||
audioScreen.setEnabled(false);
|
||||
screenCloseTarget.run();
|
||||
});
|
||||
stateManager.attach(audioScreen);
|
||||
audioScreen.setEnabled(false);
|
||||
|
||||
SaveGameState saveState = stateManager.getState(SaveGameState.class);
|
||||
|
||||
pauseMenu = new PauseMenu(
|
||||
@@ -173,6 +185,11 @@ public class BlightGame extends SimpleApplication {
|
||||
pauseMenu.setEnabled(false);
|
||||
graphicsScreen.setEnabled(true);
|
||||
},
|
||||
() -> {
|
||||
screenCloseTarget = () -> pauseMenu.setEnabled(true);
|
||||
pauseMenu.setEnabled(false);
|
||||
audioScreen.setEnabled(true);
|
||||
},
|
||||
() -> {
|
||||
screenCloseTarget = () -> pauseMenu.setEnabled(true);
|
||||
pauseMenu.setEnabled(false);
|
||||
@@ -237,6 +254,7 @@ public class BlightGame extends SimpleApplication {
|
||||
if (mainMenuState != null && mainMenuState.isEnabled()) return;
|
||||
|
||||
if (graphicsScreen.isEnabled()) return;
|
||||
if (audioScreen.isEnabled()) return;
|
||||
|
||||
if (configScreen.isEnabled()) {
|
||||
if (configScreen.isWaiting()) {
|
||||
|
||||
@@ -28,6 +28,15 @@ public class AnimSet {
|
||||
private String previewModelPath = null;
|
||||
/** Manueller Positions-/Rotations-Versatz pro Clip-Name. */
|
||||
private Map<String, AnimOffset> animOffsets = new LinkedHashMap<>();
|
||||
/** Sub-Clip-Definitionen: Name → Zeitfenster aus einem kombinierten Quell-Clip. */
|
||||
private Map<String, SubClipDef> subClips = new LinkedHashMap<>();
|
||||
|
||||
/** Beschreibt einen Sub-Clip: Zeitfenster [start, end] innerhalb eines kombinierten Quell-Clips. */
|
||||
public static class SubClipDef {
|
||||
public String source;
|
||||
public float start;
|
||||
public float end;
|
||||
}
|
||||
|
||||
public List<String> getClips() { return clips; }
|
||||
public void setClips(List<String> clips) { this.clips = clips; }
|
||||
@@ -41,6 +50,10 @@ public class AnimSet {
|
||||
public void setAnimOffsets(Map<String, AnimOffset> animOffsets) {
|
||||
this.animOffsets = animOffsets;
|
||||
}
|
||||
public Map<String, SubClipDef> getSubClips() {
|
||||
return subClips != null ? subClips : new LinkedHashMap<>();
|
||||
}
|
||||
public void setSubClips(Map<String, SubClipDef> subClips) { this.subClips = subClips; }
|
||||
|
||||
/** Speichert dieses Set als {@code <setName>.animset.json} im Verzeichnis {@code setDir}. */
|
||||
public void save(Path setDir, String setName) throws IOException {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.jme3.scene.Spatial;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -220,6 +221,71 @@ public class AnimationLibrary extends BaseAppState {
|
||||
} else {
|
||||
log.info("[AnimLib] {} Clips geladen: {}", clips.size(), clips.keySet());
|
||||
}
|
||||
|
||||
Path setDir = findAssetRoot().resolve("animations").resolve("sets");
|
||||
try {
|
||||
AnimSet animSet = AnimSet.load(setDir, "human");
|
||||
createSubClips(animSet);
|
||||
} catch (Exception e) {
|
||||
log.warn("[AnimLib] Sub-Clips konnten nicht erstellt werden: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void createSubClips(AnimSet animSet) {
|
||||
for (Map.Entry<String, AnimSet.SubClipDef> entry : animSet.getSubClips().entrySet()) {
|
||||
String subName = entry.getKey();
|
||||
AnimSet.SubClipDef def = entry.getValue();
|
||||
AnimClip source = clips.get(def.source);
|
||||
Armature arm = armatures.get(def.source);
|
||||
if (source == null) {
|
||||
log.warn("[AnimLib] SubClip '{}': Quelle '{}' nicht gefunden – übersprungen", subName, def.source);
|
||||
continue;
|
||||
}
|
||||
AnimClip sub = extractSubClip(source, subName, def.start, def.end);
|
||||
clips.put(subName, sub);
|
||||
if (arm != null) {
|
||||
armatures.put(subName, arm);
|
||||
}
|
||||
log.info("[AnimLib] SubClip '{}' extrahiert [{}-{}s] aus '{}'",
|
||||
subName, def.start, def.end, def.source);
|
||||
}
|
||||
}
|
||||
|
||||
private static AnimClip extractSubClip(AnimClip source, String name, float startSec, float endSec) {
|
||||
List<AnimTrack<?>> newTracks = new ArrayList<>();
|
||||
for (AnimTrack<?> track : source.getTracks()) {
|
||||
if (!(track instanceof TransformTrack tt)) {
|
||||
newTracks.add(track);
|
||||
continue;
|
||||
}
|
||||
float[] times = tt.getTimes();
|
||||
int first = 0;
|
||||
while (first < times.length - 1 && times[first] < startSec - 1e-5f) {
|
||||
first++;
|
||||
}
|
||||
int last = times.length - 1;
|
||||
while (last > 0 && times[last] > endSec + 1e-5f) {
|
||||
last--;
|
||||
}
|
||||
int count = last - first + 1;
|
||||
if (count <= 0) {
|
||||
continue;
|
||||
}
|
||||
float[] newTimes = new float[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
newTimes[i] = times[first + i] - startSec;
|
||||
}
|
||||
Vector3f[] trans = tt.getTranslations();
|
||||
Quaternion[] rots = tt.getRotations();
|
||||
Vector3f[] scales = tt.getScales();
|
||||
Vector3f[] newTrans = trans != null ? Arrays.copyOfRange(trans, first, last + 1) : null;
|
||||
Quaternion[] newRots = rots != null ? Arrays.copyOfRange(rots, first, last + 1) : null;
|
||||
Vector3f[] newScales = scales != null ? Arrays.copyOfRange(scales, first, last + 1) : null;
|
||||
newTracks.add(new TransformTrack(tt.getTarget(), newTimes, newTrans, newRots, newScales));
|
||||
}
|
||||
AnimClip sub = new AnimClip(name);
|
||||
sub.setTracks(newTracks.toArray(new AnimTrack[0]));
|
||||
return sub;
|
||||
}
|
||||
|
||||
private void loadClipFromFile(Path file) {
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
package de.blight.game.audio;
|
||||
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.audio.AudioData;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import com.jme3.scene.Node;
|
||||
import de.blight.game.state.AudioSettingsState;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Dreistufige Fallback-Logik:
|
||||
* 1. audio/footsteps/{surface}/{gait}/*.ogg
|
||||
* 2. audio/footsteps/{surface}/*.ogg (für alle Gangarten, Lautstärke gait-abhängig)
|
||||
* 3. audio/footsteps/*.ogg (Wurzel-Fallback, gleiche Lautstärke-Logik)
|
||||
*
|
||||
* Auf jeder Stufe werden auch Alias-Oberflächen geprüft:
|
||||
* grass ↔ leaves | pavement ↔ rock | dirt ↔ gravel
|
||||
*
|
||||
* Lautstärke nach Gangart: sprinting=100 %, running=80 %, walking=50 % von BASE_VOLUME.
|
||||
*/
|
||||
public class FootstepSystem {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FootstepSystem.class);
|
||||
|
||||
private static final float BASE_VOLUME = 0.70f;
|
||||
private static final float PITCH_CENTER = 1.00f;
|
||||
private static final float PITCH_RANGE = 0.10f;
|
||||
|
||||
private static final String[] GAITS = {"walking", "running", "sprinting"};
|
||||
|
||||
// surface-name → alias surface-names
|
||||
private static final Map<String, List<String>> ALIASES;
|
||||
static {
|
||||
ALIASES = new HashMap<>();
|
||||
ALIASES.put("grass", List.of("leaves"));
|
||||
ALIASES.put("leaves", List.of("grass"));
|
||||
ALIASES.put("pavement", List.of("rock"));
|
||||
ALIASES.put("rock", List.of("pavement"));
|
||||
ALIASES.put("dirt", List.of("gravel"));
|
||||
ALIASES.put("gravel", List.of("dirt"));
|
||||
}
|
||||
|
||||
private final AudioSettingsState audioSettings;
|
||||
private final Random random = new Random();
|
||||
|
||||
/** Stufe 1: surface → gait → AudioNodes */
|
||||
private final Map<String, Map<String, List<AudioNode>>> gaitPools = new HashMap<>();
|
||||
/** Stufe 2: surface → AudioNodes (flach, kein Gait-Unterordner) */
|
||||
private final Map<String, List<AudioNode>> flatPools = new HashMap<>();
|
||||
/** Stufe 3: Dateien direkt in audio/footsteps/ */
|
||||
private final List<AudioNode> rootPool = new ArrayList<>();
|
||||
|
||||
public FootstepSystem(AssetManager am, Node parentNode, AudioSettingsState audioSettings,
|
||||
Path assetRoot) {
|
||||
this.audioSettings = audioSettings;
|
||||
|
||||
String rootDir = "audio/footsteps/";
|
||||
|
||||
for (SurfaceType st : SurfaceType.values()) {
|
||||
String key = st.name().toLowerCase();
|
||||
|
||||
// Stufe 1: gait-Unterordner
|
||||
Map<String, List<AudioNode>> gaitMap = new HashMap<>();
|
||||
for (String gait : GAITS) {
|
||||
List<AudioNode> nodes = scanDir(am, parentNode, assetRoot,
|
||||
rootDir + key + "/" + gait + "/");
|
||||
if (!nodes.isEmpty()) {
|
||||
gaitMap.put(gait, nodes);
|
||||
}
|
||||
}
|
||||
if (!gaitMap.isEmpty()) {
|
||||
gaitPools.put(key, gaitMap);
|
||||
}
|
||||
|
||||
// Stufe 2: Oberflächen-Ordner flach
|
||||
List<AudioNode> flat = scanDir(am, parentNode, assetRoot, rootDir + key + "/");
|
||||
if (!flat.isEmpty()) {
|
||||
flatPools.put(key, flat);
|
||||
}
|
||||
}
|
||||
|
||||
// Stufe 3: Wurzel-Ordner flach
|
||||
rootPool.addAll(scanDir(am, parentNode, assetRoot, rootDir));
|
||||
|
||||
int total = gaitPools.values().stream()
|
||||
.mapToInt(m -> m.values().stream().mapToInt(List::size).sum()).sum()
|
||||
+ flatPools.values().stream().mapToInt(List::size).sum()
|
||||
+ rootPool.size();
|
||||
log.info("[Footstep] Geladen – Gait-Pools: {}, Flat-Pools: {}, Root: {}, Gesamt: {} AudioNodes",
|
||||
gaitPools.size(), flatPools.size(), rootPool.size(), total);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spielt Schrittsounds für alle Oberflächen parallel, deren Anteil ≥ MIN_WEIGHT ist.
|
||||
* Jeder Sound wird mit vol = base_vol × fraction abgespielt.
|
||||
*
|
||||
* @param surfaceWeights Normierte Anteile (0..1) pro SurfaceType.ordinal()
|
||||
* @param gait "walking" / "running" / "sprinting"
|
||||
*/
|
||||
public void play(float[] surfaceWeights, String gait) {
|
||||
float baseVol = BASE_VOLUME * gaitVolumeFactor(gait)
|
||||
* (audioSettings != null ? audioSettings.effectiveEffects() : 1f);
|
||||
float pitch = PITCH_CENTER + (random.nextFloat() - 0.5f) * PITCH_RANGE;
|
||||
|
||||
SurfaceType[] types = SurfaceType.values();
|
||||
for (int i = 0; i < surfaceWeights.length && i < types.length; i++) {
|
||||
float fraction = surfaceWeights[i];
|
||||
if (fraction < MIN_WEIGHT) continue;
|
||||
|
||||
SurfaceType surface = types[i];
|
||||
if (surface == SurfaceType.UNKNOWN) continue;
|
||||
|
||||
String key = surface.name().toLowerCase();
|
||||
List<AudioNode> nodes = resolve(key, gait);
|
||||
if (nodes == null || nodes.isEmpty()) continue;
|
||||
|
||||
AudioNode node = nodes.get(random.nextInt(nodes.size()));
|
||||
node.setVolume(baseVol * fraction);
|
||||
node.setPitch(pitch);
|
||||
node.playInstance();
|
||||
}
|
||||
}
|
||||
|
||||
/** Minimaler Anteil (0..1) damit eine Oberfläche einen eigenen Sound bekommt. */
|
||||
private static final float MIN_WEIGHT = 0.10f;
|
||||
|
||||
// ── Auflösung ──────────────────────────────────────────────────────────────
|
||||
|
||||
private List<AudioNode> resolve(String key, String gait) {
|
||||
// Stufe 1a: exakt surface/gait
|
||||
List<AudioNode> r = fromGaitPool(key, gait);
|
||||
if (r != null) return r;
|
||||
|
||||
// Stufe 1b: Alias/gait
|
||||
for (String alias : aliases(key)) {
|
||||
r = fromGaitPool(alias, gait);
|
||||
if (r != null) return r;
|
||||
}
|
||||
|
||||
// Stufe 2a: surface flach
|
||||
r = fromFlatPool(key);
|
||||
if (r != null) return r;
|
||||
|
||||
// Stufe 2b: Alias flach
|
||||
for (String alias : aliases(key)) {
|
||||
r = fromFlatPool(alias);
|
||||
if (r != null) return r;
|
||||
}
|
||||
|
||||
// Stufe 3: Wurzel
|
||||
if (!rootPool.isEmpty()) return rootPool;
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private List<AudioNode> fromGaitPool(String key, String gait) {
|
||||
Map<String, List<AudioNode>> m = gaitPools.get(key);
|
||||
if (m == null) return null;
|
||||
List<AudioNode> l = m.get(gait);
|
||||
return (l != null && !l.isEmpty()) ? l : null;
|
||||
}
|
||||
|
||||
private List<AudioNode> fromFlatPool(String key) {
|
||||
List<AudioNode> l = flatPools.get(key);
|
||||
return (l != null && !l.isEmpty()) ? l : null;
|
||||
}
|
||||
|
||||
private List<String> aliases(String key) {
|
||||
return ALIASES.getOrDefault(key, Collections.emptyList());
|
||||
}
|
||||
|
||||
// ── Lautstärke ─────────────────────────────────────────────────────────────
|
||||
|
||||
private static float gaitVolumeFactor(String gait) {
|
||||
return switch (gait) {
|
||||
case "sprinting" -> 1.00f;
|
||||
case "running" -> 0.80f;
|
||||
default -> 0.50f; // walking
|
||||
};
|
||||
}
|
||||
|
||||
// ── Laden ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Liest alle .ogg-Dateien direkt (nicht rekursiv) aus relDir.
|
||||
* Unterordner werden ignoriert (die werden separat gescannt).
|
||||
*/
|
||||
private List<AudioNode> scanDir(AssetManager am, Node parentNode,
|
||||
Path assetRoot, String relDir) {
|
||||
Path absDir = assetRoot.resolve(relDir);
|
||||
if (!Files.isDirectory(absDir)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Path> oggFiles;
|
||||
try (var stream = Files.list(absDir)) {
|
||||
oggFiles = stream
|
||||
.filter(p -> Files.isRegularFile(p)
|
||||
&& p.getFileName().toString().toLowerCase().endsWith(".ogg"))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
log.warn("[Footstep] Fehler beim Scannen von {}: {}", absDir, e.getMessage());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<AudioNode> nodes = new ArrayList<>(oggFiles.size());
|
||||
for (Path file : oggFiles) {
|
||||
String assetPath = relDir + file.getFileName().toString();
|
||||
try {
|
||||
AudioNode node = new AudioNode(am, assetPath, AudioData.DataType.Buffer);
|
||||
node.setPositional(false);
|
||||
node.setLooping(false);
|
||||
node.setVolume(BASE_VOLUME);
|
||||
parentNode.attachChild(node);
|
||||
nodes.add(node);
|
||||
} catch (Exception e) {
|
||||
log.warn("[Footstep] Nicht ladbar '{}': {}", assetPath, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!nodes.isEmpty()) {
|
||||
log.debug("[Footstep] {}: {} Sounds", relDir, nodes.size());
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.blight.game.audio;
|
||||
|
||||
public enum SurfaceType {
|
||||
GRASS, DIRT, SAND, ROCK, GRAVEL, LEAVES, PAVEMENT, WOOD, UNKNOWN;
|
||||
|
||||
public static SurfaceType fromTexturePath(String path) {
|
||||
if (path == null || path.isEmpty()) return UNKNOWN;
|
||||
String p = path.toLowerCase();
|
||||
if (p.contains("gras")) return GRASS;
|
||||
if (p.contains("dirt")) return DIRT;
|
||||
if (p.contains("sand")) return SAND;
|
||||
if (p.contains("rock")) return ROCK;
|
||||
if (p.contains("gravel")) return GRAVEL;
|
||||
if (p.contains("leaves")) return LEAVES;
|
||||
if (p.contains("pavement")) return PAVEMENT;
|
||||
if (p.contains("wood")) return WOOD;
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public static SurfaceType fromName(String name) {
|
||||
if (name == null || name.isEmpty()) return UNKNOWN;
|
||||
try {
|
||||
return SurfaceType.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,77 +27,53 @@ import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import de.blight.lang.TextResolver;
|
||||
|
||||
/**
|
||||
* Overlay-AppState der die Tastenbelegungs-Maske anzeigt.
|
||||
*
|
||||
* ESC → Schließen (ohne Speichern)
|
||||
* Klick auf Row → wartet auf neue Taste
|
||||
* ESC während Warten → bricht nur die Zuweisung ab
|
||||
* Speichern → schreibt JSON, ruft onSave-Callback
|
||||
*/
|
||||
public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
|
||||
// Farben
|
||||
private static final ColorRGBA COL_BG = new ColorRGBA(0.05f, 0.05f, 0.08f, 0.88f);
|
||||
private static final ColorRGBA COL_PANEL = new ColorRGBA(0.10f, 0.10f, 0.16f, 1.00f);
|
||||
private static final ColorRGBA COL_ROW = new ColorRGBA(0.18f, 0.18f, 0.28f, 1.00f);
|
||||
private static final ColorRGBA COL_ROW_HOVER = new ColorRGBA(0.25f, 0.25f, 0.40f, 1.00f);
|
||||
private static final ColorRGBA COL_ROW_WAIT = new ColorRGBA(0.50f, 0.30f, 0.10f, 1.00f);
|
||||
private static final ColorRGBA COL_BTN_SAVE = new ColorRGBA(0.15f, 0.40f, 0.15f, 1.00f);
|
||||
private static final ColorRGBA COL_BTN_CANCEL = new ColorRGBA(0.40f, 0.15f, 0.15f, 1.00f);
|
||||
private static final ColorRGBA COL_TEXT = ColorRGBA.White;
|
||||
private static final ColorRGBA COL_TEXT_KEY = new ColorRGBA(0.85f, 0.85f, 0.50f, 1.00f);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
private SimpleApplication app;
|
||||
private Node guiNode;
|
||||
private BitmapFont font;
|
||||
|
||||
private KeyBindings liveBindings; // geteilt mit der ganzen App
|
||||
private KeyBindings editCopy; // wird beim Öffnen geklont
|
||||
private KeyBindings liveBindings;
|
||||
private KeyBindings editCopy;
|
||||
|
||||
private Runnable onSave; // Callback → PlayerInputControl.reloadBindings
|
||||
private Runnable onClose; // Callback → PauseMenu wiederherstellen
|
||||
private Runnable onSave;
|
||||
private Runnable onClose;
|
||||
|
||||
private Node panel;
|
||||
private Node bgLayer;
|
||||
private Node canvasNode;
|
||||
private List<Row> rows = new ArrayList<>();
|
||||
private int waitingRow = -1; // -1 = keine Zuweisung aktiv
|
||||
private int waitingRow = -1;
|
||||
|
||||
// UI-Elemente für Buttons (Bounds in Screen-Koordinaten)
|
||||
private float saveBtnX, saveBtnY, saveBtnW, saveBtnH;
|
||||
private float cancelBtnX, cancelBtnY;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
private static class Row {
|
||||
String field;
|
||||
String label;
|
||||
BitmapText keyText;
|
||||
Geometry bg;
|
||||
float x, y, w, h; // Button-Bounds
|
||||
float x, y, w, h;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public ConfigScreen(KeyBindings liveBindings, Runnable onSave) {
|
||||
this.liveBindings = liveBindings;
|
||||
this.onSave = onSave;
|
||||
}
|
||||
|
||||
public boolean isWaiting() { return waitingRow >= 0; }
|
||||
|
||||
public void setOnClose(Runnable onClose) { this.onClose = onClose; }
|
||||
|
||||
public void cancelWaiting() {
|
||||
if (waitingRow >= 0) { resetRowColor(waitingRow); waitingRow = -1; }
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Lifecycle
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
protected void initialize(Application app) {
|
||||
this.app = (SimpleApplication) app;
|
||||
@@ -118,7 +94,9 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
if (panel != null) { guiNode.detachChild(panel); panel = null; }
|
||||
if (bgLayer != null) { guiNode.detachChild(bgLayer); bgLayer = null; }
|
||||
if (canvasNode != null) { guiNode.detachChild(canvasNode); canvasNode = null; }
|
||||
panel = null;
|
||||
rows.clear();
|
||||
waitingRow = -1;
|
||||
app.getInputManager().removeRawInputListener(this);
|
||||
@@ -128,33 +106,29 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
|
||||
@Override protected void cleanup(Application app) {}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// UI aufbauen
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
private void buildUI() {
|
||||
float sw = app.getCamera().getWidth();
|
||||
float sh = app.getCamera().getHeight();
|
||||
float sw = MenuCanvas.REF_W;
|
||||
float sh = MenuCanvas.REF_H;
|
||||
|
||||
bgLayer = MenuCanvas.createBgLayer(app.getAssetManager(), app.getCamera());
|
||||
canvasNode = MenuCanvas.createCanvas(app.getCamera());
|
||||
guiNode.attachChild(bgLayer);
|
||||
guiNode.attachChild(canvasNode);
|
||||
|
||||
panel = new Node("cfg-panel");
|
||||
|
||||
// Halbdurchsichtiger Overlay über dem Spiel
|
||||
addQuad(panel, 0, 0, sw, sh, COL_BG, -2);
|
||||
|
||||
float pw = 720, ph = 440;
|
||||
float px = (sw - pw) / 2f, py = (sh - ph) / 2f;
|
||||
addQuad(panel, px, py, pw, ph, COL_PANEL, -1);
|
||||
panel.attachChild(NinePatch.panel(app.getAssetManager()).build(px, py, pw, ph, -1));
|
||||
|
||||
// Titel
|
||||
BitmapText title = text("TASTENBELEGUNG", 20, COL_TEXT);
|
||||
BitmapText title = text(t("menu.controls.title"), 20, COL_TEXT);
|
||||
centerText(title, px, py + ph - 40, pw);
|
||||
panel.attachChild(title);
|
||||
|
||||
BitmapText hint = text("Klicke eine Taste um sie neu zu belegen", 14, new ColorRGBA(0.7f, 0.7f, 0.7f, 1f));
|
||||
BitmapText hint = text(t("menu.controls.hint"), 14, new ColorRGBA(0.7f, 0.7f, 0.7f, 1f));
|
||||
centerText(hint, px, py + ph - 70, pw);
|
||||
panel.attachChild(hint);
|
||||
|
||||
// Reihen
|
||||
float rowX = px + 30;
|
||||
float keyX = px + pw - 220;
|
||||
float rowW = 180;
|
||||
@@ -166,7 +140,7 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
String[] entry = KeyBindings.ENTRIES[i];
|
||||
float ry = startY - i * stepY;
|
||||
|
||||
BitmapText lbl = text(entry[1], 16, COL_TEXT);
|
||||
BitmapText lbl = text(t("key." + entry[0]), 16, COL_TEXT);
|
||||
lbl.setLocalTranslation(rowX, ry + rowH - 8, 0);
|
||||
panel.attachChild(lbl);
|
||||
|
||||
@@ -178,14 +152,12 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
|
||||
Row row = new Row();
|
||||
row.field = entry[0];
|
||||
row.label = entry[1];
|
||||
row.keyText = kt;
|
||||
row.bg = bg;
|
||||
row.x = keyX; row.y = ry; row.w = rowW; row.h = rowH;
|
||||
rows.add(row);
|
||||
}
|
||||
|
||||
// Buttons
|
||||
float btnW = 160, btnH = 42;
|
||||
float btnY = py + 25;
|
||||
saveBtnX = px + pw / 2f - btnW - 15;
|
||||
@@ -195,31 +167,26 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
cancelBtnX = px + pw / 2f + 15;
|
||||
cancelBtnY = btnY;
|
||||
|
||||
addQuad(panel, saveBtnX, saveBtnY, btnW, btnH, COL_BTN_SAVE, 0);
|
||||
BitmapText saveLabel = text("Speichern", 16, COL_TEXT);
|
||||
panel.attachChild(NinePatch.buttonSave(app.getAssetManager()).build(saveBtnX, saveBtnY, btnW, btnH, 0));
|
||||
BitmapText saveLabel = text(t("menu.controls.btn.save"), 16, COL_TEXT);
|
||||
centerText(saveLabel, saveBtnX, saveBtnY + btnH - 10, btnW);
|
||||
panel.attachChild(saveLabel);
|
||||
|
||||
addQuad(panel, cancelBtnX, cancelBtnY, btnW, btnH, COL_BTN_CANCEL, 0);
|
||||
BitmapText cancelLabel = text("Abbrechen", 16, COL_TEXT);
|
||||
panel.attachChild(NinePatch.buttonQuit(app.getAssetManager()).build(cancelBtnX, cancelBtnY, btnW, btnH, 0));
|
||||
BitmapText cancelLabel = text(t("menu.controls.btn.cancel"), 16, COL_TEXT);
|
||||
centerText(cancelLabel, cancelBtnX, cancelBtnY + btnH - 10, btnW);
|
||||
panel.attachChild(cancelLabel);
|
||||
|
||||
guiNode.attachChild(panel);
|
||||
canvasNode.attachChild(panel);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Mausklick
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
private final ActionListener clickListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed) return;
|
||||
Vector2f cursor = app.getInputManager().getCursorPosition();
|
||||
float[] v = toVirtual(app.getInputManager().getCursorPosition());
|
||||
|
||||
// Reihen prüfen
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
Row r = rows.get(i);
|
||||
if (hits(cursor, r.x, r.y, r.w, r.h)) {
|
||||
if (hits(v, r.x, r.y, r.w, r.h)) {
|
||||
waitingRow = i;
|
||||
r.bg.getMaterial().setColor("Color", COL_ROW_WAIT);
|
||||
r.keyText.setText("...");
|
||||
@@ -227,8 +194,7 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Speichern
|
||||
if (hits(cursor, saveBtnX, saveBtnY, saveBtnW, saveBtnH)) {
|
||||
if (hits(v, saveBtnX, saveBtnY, saveBtnW, saveBtnH)) {
|
||||
liveBindings.copyFrom(editCopy);
|
||||
KeyBindingStore.save(liveBindings);
|
||||
if (onSave != null) onSave.run();
|
||||
@@ -237,21 +203,16 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Abbrechen
|
||||
if (hits(cursor, cancelBtnX, cancelBtnY, saveBtnW, saveBtnH)) {
|
||||
if (hits(v, cancelBtnX, cancelBtnY, saveBtnW, saveBtnH)) {
|
||||
setEnabled(false);
|
||||
if (onClose != null) onClose.run();
|
||||
}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Tastendruck beim Warten auf Zuweisung (RawInputListener)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void onKeyEvent(KeyInputEvent evt) {
|
||||
if (!evt.isPressed() || waitingRow < 0) return;
|
||||
if (evt.getKeyCode() == KeyInput.KEY_ESCAPE) return; // cancelWaiting() wird von BlightApp aufgerufen
|
||||
if (evt.getKeyCode() == KeyInput.KEY_ESCAPE) return;
|
||||
|
||||
Row r = rows.get(waitingRow);
|
||||
editCopy.set(r.field, evt.getKeyCode());
|
||||
@@ -264,7 +225,16 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
rows.get(idx).bg.getMaterial().setColor("Color", COL_ROW);
|
||||
}
|
||||
|
||||
// RawInputListener-Pflichtmethoden
|
||||
private float[] toVirtual(Vector2f screen) {
|
||||
float scale = Math.min(app.getCamera().getWidth() / MenuCanvas.REF_W,
|
||||
app.getCamera().getHeight() / MenuCanvas.REF_H);
|
||||
float ox = (app.getCamera().getWidth() - MenuCanvas.REF_W * scale) / 2f;
|
||||
float oy = (app.getCamera().getHeight() - MenuCanvas.REF_H * scale) / 2f;
|
||||
return new float[]{ (screen.x - ox) / scale, (screen.y - oy) / scale };
|
||||
}
|
||||
|
||||
private static String t(String id) { return TextResolver.get().resolveId(id); }
|
||||
|
||||
@Override public void beginInput() {}
|
||||
@Override public void endInput() {}
|
||||
@Override public void onMouseMotionEvent(MouseMotionEvent evt) {}
|
||||
@@ -273,10 +243,6 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
@Override public void onJoyButtonEvent(JoyButtonEvent evt) {}
|
||||
@Override public void onTouchEvent(TouchEvent evt) {}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Hilfsmethoden
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
private Geometry addQuad(Node parent, float x, float y, float w, float h, ColorRGBA color, float z) {
|
||||
Geometry geo = new Geometry("q", new Quad(w, h));
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
@@ -303,7 +269,7 @@ public class ConfigScreen extends BaseAppState implements RawInputListener {
|
||||
t.setLocalTranslation(x + (width - t.getLineWidth()) / 2f, y, 1);
|
||||
}
|
||||
|
||||
private boolean hits(Vector2f p, float x, float y, float w, float h) {
|
||||
return p.x >= x && p.x <= x + w && p.y >= y && p.y <= y + h;
|
||||
private boolean hits(float[] v, float x, float y, float w, float h) {
|
||||
return v[0] >= x && v[0] <= x + w && v[1] >= y && v[1] <= y + h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,10 @@ import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.jme3.system.AppSettings;
|
||||
import de.blight.lang.TextResolver;
|
||||
|
||||
public class GraphicsScreen extends BaseAppState {
|
||||
|
||||
private static final ColorRGBA COL_BG = new ColorRGBA(0.05f, 0.05f, 0.08f, 0.88f);
|
||||
private static final ColorRGBA COL_PANEL = new ColorRGBA(0.10f, 0.10f, 0.16f, 1.00f);
|
||||
private static final ColorRGBA COL_ROW = new ColorRGBA(0.18f, 0.18f, 0.28f, 1.00f);
|
||||
private static final ColorRGBA COL_ARROW = new ColorRGBA(0.28f, 0.28f, 0.44f, 1.00f);
|
||||
private static final ColorRGBA COL_BTN_OK = new ColorRGBA(0.15f, 0.40f, 0.15f, 1.00f);
|
||||
private static final ColorRGBA COL_BTN_CANCEL = new ColorRGBA(0.40f, 0.15f, 0.15f, 1.00f);
|
||||
private static final ColorRGBA COL_TEXT = ColorRGBA.White;
|
||||
private static final ColorRGBA COL_TEXT_VAL = new ColorRGBA(0.85f, 0.85f, 0.50f, 1.00f);
|
||||
|
||||
@@ -43,6 +38,8 @@ public class GraphicsScreen extends BaseAppState {
|
||||
private Node guiNode;
|
||||
private BitmapFont font;
|
||||
private Node panel;
|
||||
private Node bgLayer;
|
||||
private Node canvasNode;
|
||||
|
||||
private final GraphicsSettings live;
|
||||
private GraphicsSettings edit;
|
||||
@@ -51,7 +48,6 @@ public class GraphicsScreen extends BaseAppState {
|
||||
private int resIdx;
|
||||
private int samplesIdx;
|
||||
|
||||
// Per-row layout (indexed by ROW_*)
|
||||
private final float[] cellX = new float[4];
|
||||
private final float[] cellY = new float[4];
|
||||
private final float[] cellW = new float[4];
|
||||
@@ -103,7 +99,9 @@ public class GraphicsScreen extends BaseAppState {
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
if (panel != null) { guiNode.detachChild(panel); panel = null; }
|
||||
if (bgLayer != null) { guiNode.detachChild(bgLayer); bgLayer = null; }
|
||||
if (canvasNode != null) { guiNode.detachChild(canvasNode); canvasNode = null; }
|
||||
panel = null;
|
||||
app.getInputManager().deleteMapping("_GfxClick");
|
||||
app.getInputManager().setCursorVisible(false);
|
||||
}
|
||||
@@ -111,20 +109,30 @@ public class GraphicsScreen extends BaseAppState {
|
||||
@Override protected void cleanup(Application app) {}
|
||||
|
||||
private void buildUI() {
|
||||
float sw = app.getCamera().getWidth();
|
||||
float sh = app.getCamera().getHeight();
|
||||
float sw = MenuCanvas.REF_W;
|
||||
float sh = MenuCanvas.REF_H;
|
||||
|
||||
bgLayer = MenuCanvas.createBgLayer(app.getAssetManager(), app.getCamera());
|
||||
canvasNode = MenuCanvas.createCanvas(app.getCamera());
|
||||
guiNode.attachChild(bgLayer);
|
||||
guiNode.attachChild(canvasNode);
|
||||
|
||||
panel = new Node("gfx-panel");
|
||||
addQuad(panel, 0, 0, sw, sh, COL_BG, -2);
|
||||
|
||||
float pw = 640, ph = 400;
|
||||
float px = (sw - pw) / 2f, py = (sh - ph) / 2f;
|
||||
addQuad(panel, px, py, pw, ph, COL_PANEL, -1);
|
||||
panel.attachChild(NinePatch.panel(app.getAssetManager()).build(px, py, pw, ph, -1));
|
||||
|
||||
BitmapText title = txt("GRAFIKEINSTELLUNGEN", 20, COL_TEXT);
|
||||
BitmapText title = txt(t("menu.graphics.title"), 20, COL_TEXT);
|
||||
centerText(title, px, py + ph - 42, pw);
|
||||
panel.attachChild(title);
|
||||
|
||||
String[] labels = {"Auflösung", "Vollbild", "VSync", "Kantenglättung"};
|
||||
String[] labelKeys = {
|
||||
"menu.graphics.row.resolution",
|
||||
"menu.graphics.row.fullscreen",
|
||||
"menu.graphics.row.vsync",
|
||||
"menu.graphics.row.aa"
|
||||
};
|
||||
float lblX = px + 30;
|
||||
float vx = px + pw - 270;
|
||||
float vw = 190;
|
||||
@@ -134,21 +142,18 @@ public class GraphicsScreen extends BaseAppState {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
float ry = startY - i * step;
|
||||
|
||||
BitmapText lbl = txt(labels[i], 16, COL_TEXT);
|
||||
BitmapText lbl = txt(t(labelKeys[i]), 16, COL_TEXT);
|
||||
lbl.setLocalTranslation(lblX, ry + cellH - 8, 0);
|
||||
panel.attachChild(lbl);
|
||||
|
||||
// Left arrow
|
||||
addQuad(panel, vx - arrW - 6, ry, arrW, cellH, COL_ARROW, 0);
|
||||
panel.attachChild(NinePatch.buttonArrow(app.getAssetManager()).build(vx - arrW - 6, ry, arrW, cellH, 0));
|
||||
BitmapText lt = txt("<", 16, COL_TEXT);
|
||||
lt.setLocalTranslation(vx - arrW - 6 + (arrW - lt.getLineWidth()) / 2f, ry + cellH - 8, 1);
|
||||
panel.attachChild(lt);
|
||||
|
||||
// Value cell
|
||||
addQuad(panel, vx, ry, vw, cellH, COL_ROW, 0);
|
||||
panel.attachChild(NinePatch.button(app.getAssetManager()).build(vx, ry, vw, cellH, 0));
|
||||
|
||||
// Right arrow
|
||||
addQuad(panel, vx + vw + 6, ry, arrW, cellH, COL_ARROW, 0);
|
||||
panel.attachChild(NinePatch.buttonArrow(app.getAssetManager()).build(vx + vw + 6, ry, arrW, cellH, 0));
|
||||
BitmapText rt = txt(">", 16, COL_TEXT);
|
||||
rt.setLocalTranslation(vx + vw + 6 + (arrW - rt.getLineWidth()) / 2f, ry + cellH - 8, 1);
|
||||
panel.attachChild(rt);
|
||||
@@ -171,25 +176,27 @@ public class GraphicsScreen extends BaseAppState {
|
||||
cancelX = px + pw / 2f + 10;
|
||||
cancelY = py + 22;
|
||||
|
||||
addQuad(panel, okX, okY, bw, bh, COL_BTN_OK, 0);
|
||||
BitmapText okLbl = txt("Übernehmen", 16, COL_TEXT);
|
||||
panel.attachChild(NinePatch.buttonSave(app.getAssetManager()).build(okX, okY, bw, bh, 0));
|
||||
BitmapText okLbl = txt(t("menu.graphics.btn.apply"), 16, COL_TEXT);
|
||||
centerText(okLbl, okX, okY + bh - 10, bw);
|
||||
panel.attachChild(okLbl);
|
||||
|
||||
addQuad(panel, cancelX, cancelY, bw, bh, COL_BTN_CANCEL, 0);
|
||||
BitmapText cancelLbl = txt("Abbrechen", 16, COL_TEXT);
|
||||
panel.attachChild(NinePatch.buttonQuit(app.getAssetManager()).build(cancelX, cancelY, bw, bh, 0));
|
||||
BitmapText cancelLbl = txt(t("menu.graphics.btn.cancel"), 16, COL_TEXT);
|
||||
centerText(cancelLbl, cancelX, cancelY + bh - 10, bw);
|
||||
panel.attachChild(cancelLbl);
|
||||
|
||||
guiNode.attachChild(panel);
|
||||
canvasNode.attachChild(panel);
|
||||
}
|
||||
|
||||
private void refreshText(int row) {
|
||||
String val = switch (row) {
|
||||
case ROW_RES -> RESOLUTIONS[resIdx][0] + "x" + RESOLUTIONS[resIdx][1];
|
||||
case ROW_FULL -> edit.fullscreen ? "An" : "Aus";
|
||||
case ROW_VSYNC -> edit.vsync ? "An" : "Aus";
|
||||
case ROW_AA -> SAMPLES[samplesIdx] == 0 ? "Aus" : SAMPLES[samplesIdx] + "x MSAA";
|
||||
case ROW_FULL -> edit.fullscreen ? t("menu.graphics.val.on") : t("menu.graphics.val.off");
|
||||
case ROW_VSYNC -> edit.vsync ? t("menu.graphics.val.on") : t("menu.graphics.val.off");
|
||||
case ROW_AA -> SAMPLES[samplesIdx] == 0
|
||||
? t("menu.graphics.val.off")
|
||||
: SAMPLES[samplesIdx] + "x MSAA";
|
||||
default -> "";
|
||||
};
|
||||
BitmapText vt = valTexts[row];
|
||||
@@ -203,14 +210,14 @@ public class GraphicsScreen extends BaseAppState {
|
||||
|
||||
private final ActionListener clickListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed) return;
|
||||
Vector2f c = app.getInputManager().getCursorPosition();
|
||||
float[] v = toVirtual(app.getInputManager().getCursorPosition());
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (hits(c, leftX[i], cellY[i], arrW, cellH)) { cycleRow(i, -1); return; }
|
||||
if (hits(c, rightX[i], cellY[i], arrW, cellH)) { cycleRow(i, +1); return; }
|
||||
if (hits(v, leftX[i], cellY[i], arrW, cellH)) { cycleRow(i, -1); return; }
|
||||
if (hits(v, rightX[i], cellY[i], arrW, cellH)) { cycleRow(i, +1); return; }
|
||||
}
|
||||
if (hits(c, okX, okY, okW, okH)) { applyAndSave(); return; }
|
||||
if (hits(c, cancelX, cancelY, okW, okH)) { close(); }
|
||||
if (hits(v, okX, okY, okW, okH)) { applyAndSave(); return; }
|
||||
if (hits(v, cancelX, cancelY, okW, okH)) { close(); }
|
||||
};
|
||||
|
||||
private void cycleRow(int row, int dir) {
|
||||
@@ -258,21 +265,15 @@ public class GraphicsScreen extends BaseAppState {
|
||||
if (onClose != null) onClose.run();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
private float[] toVirtual(Vector2f screen) {
|
||||
float scale = Math.min(app.getCamera().getWidth() / MenuCanvas.REF_W,
|
||||
app.getCamera().getHeight() / MenuCanvas.REF_H);
|
||||
float ox = (app.getCamera().getWidth() - MenuCanvas.REF_W * scale) / 2f;
|
||||
float oy = (app.getCamera().getHeight() - MenuCanvas.REF_H * scale) / 2f;
|
||||
return new float[]{ (screen.x - ox) / scale, (screen.y - oy) / scale };
|
||||
}
|
||||
|
||||
private Geometry addQuad(Node parent, float x, float y, float w, float h, ColorRGBA color, float z) {
|
||||
Geometry geo = new Geometry("q", new Quad(w, h));
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", color.clone());
|
||||
if (color.a < 1f) {
|
||||
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||
geo.setQueueBucket(RenderQueue.Bucket.Transparent);
|
||||
}
|
||||
geo.setMaterial(mat);
|
||||
geo.setLocalTranslation(x, y, z);
|
||||
parent.attachChild(geo);
|
||||
return geo;
|
||||
}
|
||||
private static String t(String id) { return TextResolver.get().resolveId(id); }
|
||||
|
||||
private BitmapText txt(String s, int size, ColorRGBA color) {
|
||||
BitmapText t = new BitmapText(font);
|
||||
@@ -284,7 +285,7 @@ public class GraphicsScreen extends BaseAppState {
|
||||
t.setLocalTranslation(x + (width - t.getLineWidth()) / 2f, y, 1);
|
||||
}
|
||||
|
||||
private boolean hits(Vector2f p, float x, float y, float w, float h) {
|
||||
return p.x >= x && p.x <= x + w && p.y >= y && p.y <= y + h;
|
||||
private boolean hits(float[] v, float x, float y, float w, float h) {
|
||||
return v[0] >= x && v[0] <= x + w && v[1] >= y && v[1] <= y + h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,21 +12,18 @@ import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import de.blight.game.post.GaussianBlurFilter;
|
||||
import de.blight.game.scene.WorldScene;
|
||||
import de.blight.lang.TextResolver;
|
||||
|
||||
public class PauseMenu extends BaseAppState {
|
||||
|
||||
private static final ColorRGBA COL_BG = new ColorRGBA(0.05f, 0.05f, 0.08f, 0.88f);
|
||||
private static final ColorRGBA COL_PANEL = new ColorRGBA(0.10f, 0.10f, 0.16f, 1.00f);
|
||||
private static final ColorRGBA COL_BTN = new ColorRGBA(0.18f, 0.18f, 0.28f, 1.00f);
|
||||
private static final ColorRGBA COL_BTN_DIS = new ColorRGBA(0.12f, 0.12f, 0.18f, 1.00f);
|
||||
private static final ColorRGBA COL_BTN_QUIT = new ColorRGBA(0.38f, 0.10f, 0.10f, 1.00f);
|
||||
private static final ColorRGBA COL_TEXT = ColorRGBA.White;
|
||||
private static final ColorRGBA COL_TEXT_DIS = new ColorRGBA(0.40f, 0.40f, 0.40f, 1.00f);
|
||||
private static final ColorRGBA COL_TEXT_SUB = new ColorRGBA(0.35f, 0.35f, 0.35f, 1.00f);
|
||||
|
||||
private static final int BTN_GRAFIK = 0;
|
||||
private static final int BTN_AUDIO = 1;
|
||||
@@ -34,23 +31,26 @@ public class PauseMenu extends BaseAppState {
|
||||
private static final int BTN_SPEICHERN = 3;
|
||||
private static final int BTN_BEENDEN = 4;
|
||||
|
||||
private static final ColorRGBA COL_BTN_SAVE = new ColorRGBA(0.12f, 0.28f, 0.14f, 1.00f);
|
||||
|
||||
private SimpleApplication app;
|
||||
private Node guiNode;
|
||||
private BitmapFont font;
|
||||
private Node panel;
|
||||
private Node bgLayer;
|
||||
private Node canvasNode;
|
||||
|
||||
private Runnable onGraphics;
|
||||
private Runnable onControls;
|
||||
private Runnable onSave;
|
||||
private Runnable onGraphics;
|
||||
private Runnable onAudio;
|
||||
private Runnable onControls;
|
||||
|
||||
private GaussianBlurFilter blurFilter;
|
||||
|
||||
// [x, y, w, h] per button
|
||||
private final float[][] btnBounds = new float[5][4];
|
||||
|
||||
public PauseMenu(Runnable onSave, Runnable onGraphics, Runnable onControls) {
|
||||
public PauseMenu(Runnable onSave, Runnable onGraphics, Runnable onAudio, Runnable onControls) {
|
||||
this.onSave = onSave;
|
||||
this.onGraphics = onGraphics;
|
||||
this.onAudio = onAudio;
|
||||
this.onControls = onControls;
|
||||
}
|
||||
|
||||
@@ -67,34 +67,66 @@ public class PauseMenu extends BaseAppState {
|
||||
app.getInputManager().setCursorVisible(true);
|
||||
app.getInputManager().addMapping("_PauseClick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||
app.getInputManager().addListener(clickListener, "_PauseClick");
|
||||
addBlur();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
if (panel != null) { guiNode.detachChild(panel); panel = null; }
|
||||
removeBlur();
|
||||
if (bgLayer != null) { guiNode.detachChild(bgLayer); bgLayer = null; }
|
||||
if (canvasNode != null) { guiNode.detachChild(canvasNode); canvasNode = null; }
|
||||
panel = null;
|
||||
app.getInputManager().deleteMapping("_PauseClick");
|
||||
app.getInputManager().setCursorVisible(false);
|
||||
}
|
||||
|
||||
private void addBlur() {
|
||||
WorldScene ws = getApplication().getStateManager().getState(WorldScene.class);
|
||||
if (ws == null) return;
|
||||
FilterPostProcessor fpp = ws.getSharedFPP();
|
||||
if (fpp == null) return;
|
||||
blurFilter = new GaussianBlurFilter(6f);
|
||||
fpp.addFilter(blurFilter);
|
||||
}
|
||||
|
||||
private void removeBlur() {
|
||||
if (blurFilter == null) return;
|
||||
WorldScene ws = getApplication().getStateManager().getState(WorldScene.class);
|
||||
if (ws != null) {
|
||||
FilterPostProcessor fpp = ws.getSharedFPP();
|
||||
if (fpp != null) fpp.removeFilter(blurFilter);
|
||||
}
|
||||
blurFilter = null;
|
||||
}
|
||||
|
||||
@Override protected void cleanup(Application app) {}
|
||||
|
||||
private void buildUI() {
|
||||
float sw = app.getCamera().getWidth();
|
||||
float sh = app.getCamera().getHeight();
|
||||
float sw = MenuCanvas.REF_W;
|
||||
float sh = MenuCanvas.REF_H;
|
||||
|
||||
bgLayer = MenuCanvas.createPauseBgLayer(app.getAssetManager(), app.getCamera());
|
||||
canvasNode = MenuCanvas.createFixedCanvas(app.getCamera());
|
||||
guiNode.attachChild(bgLayer);
|
||||
guiNode.attachChild(canvasNode);
|
||||
|
||||
panel = new Node("pause-panel");
|
||||
addQuad(panel, 0, 0, sw, sh, COL_BG, -2);
|
||||
|
||||
float pw = 320, ph = 430;
|
||||
float px = (sw - pw) / 2f, py = (sh - ph) / 2f;
|
||||
addQuad(panel, px, py, pw, ph, COL_PANEL, -1);
|
||||
panel.attachChild(NinePatch.panel(app.getAssetManager()).build(px, py, pw, ph, -1));
|
||||
|
||||
BitmapText title = txt("PAUSE", 26, COL_TEXT);
|
||||
BitmapText title = txt(t("menu.pause.title"), 26, COL_TEXT);
|
||||
centerText(title, px, py + ph - 48, pw);
|
||||
panel.attachChild(title);
|
||||
|
||||
String[] labels = {"Grafik", "Audio", "Steuerung", "Speichern", "Beenden"};
|
||||
boolean[] enabled = {true, false, true, true, true};
|
||||
ColorRGBA[] bgCols = {COL_BTN, COL_BTN_DIS, COL_BTN, COL_BTN_SAVE, COL_BTN_QUIT};
|
||||
String[] labelKeys = {
|
||||
"menu.pause.btn.graphics",
|
||||
"menu.pause.btn.audio",
|
||||
"menu.pause.btn.controls",
|
||||
"menu.pause.btn.save",
|
||||
"menu.pause.btn.quit"
|
||||
};
|
||||
|
||||
float bw = 260, bh = 52;
|
||||
float bx = px + (pw - bw) / 2f;
|
||||
@@ -103,37 +135,38 @@ public class PauseMenu extends BaseAppState {
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
float by = startY - i * step;
|
||||
ColorRGBA txCol = enabled[i] ? COL_TEXT : COL_TEXT_DIS;
|
||||
NinePatch btnPatch = switch (i) {
|
||||
case 3 -> NinePatch.buttonSave(app.getAssetManager());
|
||||
case 4 -> NinePatch.buttonQuit(app.getAssetManager());
|
||||
default -> NinePatch.button(app.getAssetManager());
|
||||
};
|
||||
panel.attachChild(btnPatch.build(bx, by, bw, bh, 0));
|
||||
|
||||
addQuad(panel, bx, by, bw, bh, bgCols[i], 0);
|
||||
|
||||
BitmapText lbl = txt(labels[i], 18, txCol);
|
||||
if (!enabled[i]) {
|
||||
lbl.setLocalTranslation(bx + (bw - lbl.getLineWidth()) / 2f, by + bh - 12, 1);
|
||||
BitmapText hint = txt("Bald verfügbar", 12, COL_TEXT_SUB);
|
||||
hint.setLocalTranslation(bx + (bw - hint.getLineWidth()) / 2f, by + 14, 1);
|
||||
panel.attachChild(hint);
|
||||
} else {
|
||||
BitmapText lbl = txt(t(labelKeys[i]), 18, COL_TEXT);
|
||||
centerText(lbl, bx, by + bh - 16, bw);
|
||||
}
|
||||
panel.attachChild(lbl);
|
||||
|
||||
btnBounds[i][0] = bx; btnBounds[i][1] = by;
|
||||
btnBounds[i][2] = bw; btnBounds[i][3] = bh;
|
||||
}
|
||||
|
||||
guiNode.attachChild(panel);
|
||||
canvasNode.attachChild(panel);
|
||||
}
|
||||
|
||||
private final ActionListener clickListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed) return;
|
||||
Vector2f c = app.getInputManager().getCursorPosition();
|
||||
// Kein Scaling – einfach den Zentrumversatz abziehen
|
||||
float ox = (app.getCamera().getWidth() - MenuCanvas.REF_W) / 2f;
|
||||
float oy = (app.getCamera().getHeight() - MenuCanvas.REF_H) / 2f;
|
||||
float vx = c.x - ox;
|
||||
float vy = c.y - oy;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (!hits(c, btnBounds[i][0], btnBounds[i][1], btnBounds[i][2], btnBounds[i][3])) continue;
|
||||
if (!hits(vx, vy, btnBounds[i][0], btnBounds[i][1], btnBounds[i][2], btnBounds[i][3])) continue;
|
||||
switch (i) {
|
||||
case BTN_GRAFIK -> { if (onGraphics != null) onGraphics.run(); }
|
||||
case BTN_AUDIO -> { /* Bald verfügbar */ }
|
||||
case BTN_AUDIO -> { if (onAudio != null) onAudio.run(); }
|
||||
case BTN_STEUERUNG -> { if (onControls != null) onControls.run(); }
|
||||
case BTN_SPEICHERN -> { if (onSave != null) onSave.run(); }
|
||||
case BTN_BEENDEN -> app.stop();
|
||||
@@ -142,21 +175,7 @@ public class PauseMenu extends BaseAppState {
|
||||
}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
private Geometry addQuad(Node parent, float x, float y, float w, float h, ColorRGBA color, float z) {
|
||||
Geometry geo = new Geometry("q", new Quad(w, h));
|
||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.setColor("Color", color.clone());
|
||||
if (color.a < 1f) {
|
||||
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||
geo.setQueueBucket(RenderQueue.Bucket.Transparent);
|
||||
}
|
||||
geo.setMaterial(mat);
|
||||
geo.setLocalTranslation(x, y, z);
|
||||
parent.attachChild(geo);
|
||||
return geo;
|
||||
}
|
||||
private static String t(String id) { return TextResolver.get().resolveId(id); }
|
||||
|
||||
private BitmapText txt(String s, int size, ColorRGBA color) {
|
||||
BitmapText t = new BitmapText(font);
|
||||
@@ -168,7 +187,7 @@ public class PauseMenu extends BaseAppState {
|
||||
t.setLocalTranslation(x + (width - t.getLineWidth()) / 2f, y, 1);
|
||||
}
|
||||
|
||||
private boolean hits(Vector2f p, float x, float y, float w, float h) {
|
||||
return p.x >= x && p.x <= x + w && p.y >= y && p.y <= y + h;
|
||||
private boolean hits(float px, float py, float x, float y, float w, float h) {
|
||||
return px >= x && px <= x + w && py >= y && py <= y + h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,19 @@ public class PlayerInputControl {
|
||||
private String runningClip;
|
||||
|
||||
private com.jme3.anim.SkinningControl skinningControl = null;
|
||||
private com.jme3.anim.Armature armature = null;
|
||||
|
||||
// ── Fußgeräusche ─────────────────────────────────────────────────────────
|
||||
// Bone-Namen nach Phase-0-Bone-Log eintragen:
|
||||
private static final String BONE_LEFT_FOOT = "mixamorig:LeftFoot";
|
||||
private static final String BONE_RIGHT_FOOT = "mixamorig:RightFoot";
|
||||
// Y-Schwelle im Model-Space: Fuß gilt als am Boden wenn Y < FOOT_GROUND_Y
|
||||
private static final float FOOT_GROUND_Y = 0.05f;
|
||||
|
||||
private de.blight.game.audio.FootstepSystem footstepSystem;
|
||||
private java.util.function.BiFunction<Float, Float, float[]> surfaceQuery;
|
||||
private float lastLeftFootY = Float.MAX_VALUE;
|
||||
private float lastRightFootY = Float.MAX_VALUE;
|
||||
|
||||
// ── Anim-Offsets ─────────────────────────────────────────────────────────
|
||||
private Map<String, AnimOffset> animOffsets = new LinkedHashMap<>();
|
||||
@@ -141,6 +154,10 @@ public class PlayerInputControl {
|
||||
log.info("[AnimCtx] AnimComposer gefunden: {}", animComposer != null);
|
||||
skinningControl = findSkinningControl(visual);
|
||||
log.info("[AnimCtx] SkinningControl gefunden: {}", skinningControl != null);
|
||||
if (skinningControl != null) {
|
||||
armature = skinningControl.getArmature();
|
||||
logJointNames(armature);
|
||||
}
|
||||
if (visual != null) {
|
||||
visualBaseTranslation = visual.getLocalTranslation().clone();
|
||||
}
|
||||
@@ -281,6 +298,76 @@ public class PlayerInputControl {
|
||||
|
||||
public boolean isLockedInPlace() { return lockedInPlace; }
|
||||
|
||||
// ── Neues-Spiel-Intro ────────────────────────────────────────────────────
|
||||
|
||||
private boolean inputsBlocked = false;
|
||||
private com.jme3.anim.tween.action.Action frozenReviveAction = null;
|
||||
|
||||
/** Setzt Blickrichtung (Yaw in Grad, 0=+Z, 90=+X, Uhrzeigersinn von oben). */
|
||||
public void setInitialFacing(float yawDegrees) {
|
||||
if (visual == null) return;
|
||||
float rad = -yawDegrees * com.jme3.math.FastMath.DEG_TO_RAD;
|
||||
visual.setLocalRotation(new Quaternion().fromAngles(0f, rad, 0f));
|
||||
}
|
||||
|
||||
/**
|
||||
* Blockiert alle Eingaben für das Neues-Spiel-Intro (ohne Animation zu wechseln).
|
||||
* Wird in NewGameIntroState.initialize() aufgerufen, damit der Spieler
|
||||
* während der BLACK-Phase nicht steuern kann.
|
||||
*/
|
||||
public void blockForIntro() {
|
||||
lockInPlace();
|
||||
inputsBlocked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die REVIVE-Animation und friert sie bei Frame 0 ein (speed=0).
|
||||
* Wird unmittelbar vor dem Einblenden aufgerufen (BLACK→FADING_IN).
|
||||
*/
|
||||
public void startFrozenRevive(String reviveClip) {
|
||||
lockInPlace();
|
||||
inputsBlocked = true;
|
||||
if (animComposer != null) {
|
||||
if (animLib != null && visual != null) animLib.ensureApplied(reviveClip, visual);
|
||||
// transitionLength=0: verhindert den 0.4 s Überblend-Effekt bei speed=0.
|
||||
// Ohne diesen Fix wäre transitionWeight=time/0.4=0 → Charakter zeigt Idle-Pose.
|
||||
com.jme3.anim.tween.action.Action reviveAction = animComposer.action(reviveClip);
|
||||
if (reviveAction instanceof com.jme3.anim.tween.action.BlendableAction ba) {
|
||||
ba.setTransitionLength(0.0);
|
||||
}
|
||||
frozenReviveAction = animComposer.setCurrentAction(reviveClip);
|
||||
if (frozenReviveAction != null) {
|
||||
frozenReviveAction.setSpeed(0f);
|
||||
log.info("[Intro] REVIVE '{}' eingefroren (frame 0)", reviveClip);
|
||||
} else {
|
||||
log.warn("[Intro] setCurrentAction('{}') → null – REVIVE nicht eingefroren", reviveClip);
|
||||
}
|
||||
} else {
|
||||
log.warn("[Intro] animComposer null – REVIVE kann nicht eingefroren werden");
|
||||
}
|
||||
}
|
||||
|
||||
/** Gibt die REVIVE-Animation mit normaler Geschwindigkeit frei. */
|
||||
public void unfreezeRevive() {
|
||||
if (frozenReviveAction != null) {
|
||||
frozenReviveAction.setSpeed(1f);
|
||||
frozenReviveAction = null;
|
||||
log.info("[Intro] REVIVE freigegeben – Animation läuft");
|
||||
}
|
||||
}
|
||||
|
||||
/** Hebt die Input-Blockade auf und gibt Bewegungseingaben wieder frei. */
|
||||
public void unblockInputs() {
|
||||
inputsBlocked = false;
|
||||
unlockFromPlace();
|
||||
currentAnim = null; // erzwingt Neubewertung in update() (z.B. IDLE nach REVIVE)
|
||||
}
|
||||
|
||||
/** Liefert die Clipdauer der REVIVE-Animation in Sekunden, oder 3 s als Fallback. */
|
||||
public float getReviveClipLength() {
|
||||
return resolveClipLength(AnimationAction.REVIVE, 3f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet die Navigation zum angegebenen Welt-Punkt.
|
||||
* Während der Navigation werden WASD-Eingaben ignoriert.
|
||||
@@ -363,6 +450,8 @@ public class PlayerInputControl {
|
||||
visual.setLocalTranslation(visualBaseTranslation.clone().addLocal(animOffsetCurrent));
|
||||
}
|
||||
|
||||
if (inputsBlocked) return;
|
||||
|
||||
if (paused) {
|
||||
if (autopilotDir != null) {
|
||||
autopilotDir = null;
|
||||
@@ -502,6 +591,8 @@ public class PlayerInputControl {
|
||||
playAction(target);
|
||||
currentAnim = target;
|
||||
}
|
||||
|
||||
pollFootsteps();
|
||||
}
|
||||
|
||||
private void playAction(AnimationAction action) {
|
||||
@@ -521,6 +612,69 @@ public class PlayerInputControl {
|
||||
}
|
||||
}
|
||||
|
||||
public void setFootstepSystem(de.blight.game.audio.FootstepSystem fs,
|
||||
java.util.function.BiFunction<Float, Float, float[]> query) {
|
||||
this.footstepSystem = fs;
|
||||
this.surfaceQuery = query;
|
||||
}
|
||||
|
||||
private void logJointNames(com.jme3.anim.Armature arm) {
|
||||
if (arm == null) return;
|
||||
StringBuilder sb = new StringBuilder("[Footstep] Joint-Namen (").append(arm.getJointCount()).append("):");
|
||||
for (int i = 0; i < arm.getJointCount(); i++) {
|
||||
sb.append("\n [").append(i).append("] ").append(arm.getJoint(i).getName());
|
||||
}
|
||||
log.info("{}", sb);
|
||||
}
|
||||
|
||||
private void pollFootsteps() {
|
||||
if (armature == null || footstepSystem == null || surfaceQuery == null) return;
|
||||
if (!physicsChar.onGround() || blockingAnimActive || lockedInPlace) {
|
||||
lastLeftFootY = Float.MAX_VALUE;
|
||||
lastRightFootY = Float.MAX_VALUE;
|
||||
return;
|
||||
}
|
||||
float speed = physicsChar.getWalkDirection().length();
|
||||
if (speed < 0.001f) {
|
||||
lastLeftFootY = Float.MAX_VALUE;
|
||||
lastRightFootY = Float.MAX_VALUE;
|
||||
return;
|
||||
}
|
||||
String gait = currentAnimToGait(currentAnim);
|
||||
if (gait == null) {
|
||||
return;
|
||||
}
|
||||
com.jme3.anim.Joint lf = armature.getJoint(BONE_LEFT_FOOT);
|
||||
com.jme3.anim.Joint rf = armature.getJoint(BONE_RIGHT_FOOT);
|
||||
if (lf != null) {
|
||||
float y = lf.getModelTransform().getTranslation().y;
|
||||
if (y < FOOT_GROUND_Y && lastLeftFootY >= FOOT_GROUND_Y) {
|
||||
triggerStep(gait);
|
||||
}
|
||||
lastLeftFootY = y;
|
||||
}
|
||||
if (rf != null) {
|
||||
float y = rf.getModelTransform().getTranslation().y;
|
||||
if (y < FOOT_GROUND_Y && lastRightFootY >= FOOT_GROUND_Y) {
|
||||
triggerStep(gait);
|
||||
}
|
||||
lastRightFootY = y;
|
||||
}
|
||||
}
|
||||
|
||||
private String currentAnimToGait(AnimationAction anim) {
|
||||
if (anim == AnimationAction.WALK) return "walking";
|
||||
if (anim == AnimationAction.RUN) return "running";
|
||||
if (anim == AnimationAction.SPRINT) return "sprinting";
|
||||
return null;
|
||||
}
|
||||
|
||||
private void triggerStep(String gait) {
|
||||
Vector3f pos = physicsChar.getPhysicsLocation();
|
||||
float[] weights = surfaceQuery.apply(pos.x, pos.z);
|
||||
footstepSystem.play(weights, gait);
|
||||
}
|
||||
|
||||
/** Durchsucht den Szenegraphen rekursiv nach dem ersten SkinningControl. */
|
||||
private com.jme3.anim.SkinningControl findSkinningControl(Spatial s) {
|
||||
if (s == null) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package de.blight.game.post;
|
||||
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.post.Filter;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
|
||||
/** Einfacher 5×5-Gauß-Unschärfe-Filter für das Pause-/Inventar-Menü. */
|
||||
public class GaussianBlurFilter extends Filter {
|
||||
|
||||
private final float blurScale;
|
||||
|
||||
public GaussianBlurFilter(float blurScale) {
|
||||
super("GaussianBlur");
|
||||
this.blurScale = blurScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initFilter(AssetManager manager, RenderManager renderManager,
|
||||
ViewPort vp, int w, int h) {
|
||||
material = new Material(manager, "MatDefs/GaussianBlur.j3md");
|
||||
material.setFloat("BlurScale", blurScale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
}
|
||||
@@ -44,10 +44,12 @@ import de.blight.game.state.SculptedMeshState;
|
||||
import de.blight.game.state.WaterBodyState;
|
||||
import de.blight.game.state.DayNightState;
|
||||
import de.blight.game.state.WeatherState;
|
||||
import de.blight.game.state.DialogHudState;
|
||||
import de.blight.game.state.InteractionHudState;
|
||||
import de.blight.game.state.InventoryState;
|
||||
import de.blight.game.state.WorldInteractableState;
|
||||
import de.blight.game.state.WorldItemsState;
|
||||
import de.blight.game.state.WorldNpcsState;
|
||||
import de.blight.game.state.StoneWorldState;
|
||||
import de.blight.game.state.WorldObjectsState;
|
||||
import de.blight.game.state.WorldLightState;
|
||||
@@ -86,12 +88,86 @@ public class WorldScene extends BaseAppState {
|
||||
private float spawnX = 0f;
|
||||
private float spawnY = 5f;
|
||||
private float spawnZ = 0f;
|
||||
private float spawnYaw = 0f;
|
||||
private de.blight.game.state.OceanSoundState oceanSound;
|
||||
private de.blight.game.state.AmbientSoundSystem ambientSounds;
|
||||
private de.blight.game.audio.FootstepSystem footstepSystem;
|
||||
|
||||
public WorldScene(KeyBindings keyBindings) {
|
||||
this.keyBindings = keyBindings;
|
||||
}
|
||||
|
||||
public InventoryState getInventoryState() { return inventoryState; }
|
||||
public com.jme3.post.FilterPostProcessor getSharedFPP() { return sharedFPP; }
|
||||
|
||||
/**
|
||||
* Gibt für jede SurfaceType einen normierten Blend-Anteil (0..1) zurück,
|
||||
* proportional zu den Splatmap-Gewichten an dieser Position.
|
||||
* Indiziert über SurfaceType.ordinal().
|
||||
*/
|
||||
public float[] querySurfaceWeights(float worldX, float worldZ) {
|
||||
float[] result = new float[de.blight.game.audio.SurfaceType.values().length];
|
||||
if (loadedMapData == null) return result;
|
||||
|
||||
int size = de.blight.common.MapData.SPLAT_SIZE;
|
||||
int px = Math.max(0, Math.min(size - 1, Math.round((worldX + 2048f) / 2f)));
|
||||
// Z ist im Splatmap gespiegelt (Editor: pz = (size-1) - round((z+2048)/2))
|
||||
int pz = Math.max(0, Math.min(size - 1, (size - 1) - Math.round((worldZ + 2048f) / 2f)));
|
||||
int idx = pz * size + px;
|
||||
|
||||
// Upper/Third-Splatmap unterdrücken die Basistextur visuell (Overlay-Modell).
|
||||
int maxOverlay = Math.max(
|
||||
Math.max(loadedMapData.upperSplatR[idx] & 0xFF, loadedMapData.upperSplatG[idx] & 0xFF),
|
||||
Math.max(
|
||||
Math.max(loadedMapData.upperSplatB[idx] & 0xFF, loadedMapData.upperSplatA[idx] & 0xFF),
|
||||
Math.max(
|
||||
Math.max(loadedMapData.thirdSplatR[idx] & 0xFF, loadedMapData.thirdSplatG[idx] & 0xFF),
|
||||
Math.max(loadedMapData.thirdSplatB[idx] & 0xFF, loadedMapData.thirdSplatA[idx] & 0xFF)
|
||||
)
|
||||
)
|
||||
);
|
||||
float baseScale = Math.max(0f, (255 - maxOverlay) / 255f);
|
||||
|
||||
int splatR = loadedMapData.splatR[idx] & 0xFF;
|
||||
if (splatR == 0) splatR = 255; // Alte Maps: wie im Shader auf 255 normieren
|
||||
|
||||
int[] slotW = {
|
||||
(int)(splatR * baseScale), // slot 0: gras1
|
||||
(int)((loadedMapData.splatG[idx] & 0xFF) * baseScale), // slot 1
|
||||
(int)((loadedMapData.splatB[idx] & 0xFF) * baseScale), // slot 2
|
||||
(int)((loadedMapData.splatA[idx] & 0xFF) * baseScale), // slot 3
|
||||
loadedMapData.upperSplatR[idx] & 0xFF, // slot 4
|
||||
loadedMapData.upperSplatG[idx] & 0xFF, // slot 5
|
||||
loadedMapData.upperSplatB[idx] & 0xFF, // slot 6
|
||||
loadedMapData.upperSplatA[idx] & 0xFF, // slot 7
|
||||
loadedMapData.thirdSplatR[idx] & 0xFF, // slot 8
|
||||
loadedMapData.thirdSplatG[idx] & 0xFF, // slot 9
|
||||
loadedMapData.thirdSplatB[idx] & 0xFF, // slot 10
|
||||
loadedMapData.thirdSplatA[idx] & 0xFF, // slot 11
|
||||
};
|
||||
|
||||
// Gewichte auf SurfaceTypes akkumulieren
|
||||
int total = 0;
|
||||
for (int i = 0; i < slotW.length; i++) {
|
||||
if (slotW[i] <= 0) continue;
|
||||
String path;
|
||||
if (i < 4) {
|
||||
path = (loadedMapData.terrainTextures.length > i) ? loadedMapData.terrainTextures[i] : "";
|
||||
} else if (i < 8) {
|
||||
path = (loadedMapData.upperTextures.length > i - 4) ? loadedMapData.upperTextures[i - 4] : "";
|
||||
} else {
|
||||
path = (loadedMapData.thirdTextures.length > i - 8) ? loadedMapData.thirdTextures[i - 8] : "";
|
||||
}
|
||||
de.blight.game.audio.SurfaceType st = de.blight.game.audio.SurfaceType.fromTexturePath(path);
|
||||
result[st.ordinal()] += slotW[i];
|
||||
total += slotW[i];
|
||||
}
|
||||
|
||||
if (total > 0) {
|
||||
for (int i = 0; i < result.length; i++) result[i] /= total;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Wird von ConfigScreen nach dem Speichern aufgerufen. */
|
||||
public void reloadBindings(KeyBindings kb) {
|
||||
@@ -173,6 +249,12 @@ public class WorldScene extends BaseAppState {
|
||||
playerInput.setPhysicsCharacter(physicsChar);
|
||||
playerInput.setVisual(characterVisual != null ? characterVisual : character);
|
||||
|
||||
de.blight.game.state.AudioSettingsState audioSettings =
|
||||
app.getStateManager().getState(de.blight.game.state.AudioSettingsState.class);
|
||||
footstepSystem = new de.blight.game.audio.FootstepSystem(assetManager, rootNode, audioSettings,
|
||||
AnimationLibrary.findAssetRoot());
|
||||
playerInput.setFootstepSystem(footstepSystem, this::querySurfaceWeights);
|
||||
|
||||
// Navigation: PathFinder + Terrain bereitstellen (Navigator wird in setAnimationContext erstellt)
|
||||
try {
|
||||
de.blight.game.navigation.PathFinder pf = de.blight.game.navigation.PathFinder.load();
|
||||
@@ -197,6 +279,9 @@ public class WorldScene extends BaseAppState {
|
||||
new WorldItemsState(keyBindings, physicsChar, mc, playerInput));
|
||||
app.getStateManager().attach(
|
||||
new WorldInteractableState(keyBindings, physicsChar, playerInput));
|
||||
app.getStateManager().attach(new DialogHudState());
|
||||
app.getStateManager().attach(
|
||||
new WorldNpcsState(keyBindings, physicsChar, playerInput, mc));
|
||||
app.getStateManager().attach(new InteractionHudState());
|
||||
inventoryState = new InventoryState(mc, keyBindings);
|
||||
inventoryState.setEnabled(false);
|
||||
@@ -225,12 +310,26 @@ public class WorldScene extends BaseAppState {
|
||||
}
|
||||
|
||||
if (!animContextReady && animLib != null && animLib.isInitialized()) {
|
||||
animContextReady = true; // zuerst setzen – verhindert endlose Wiederholung bei Exception
|
||||
try {
|
||||
setupAnimationContext();
|
||||
animContextReady = true;
|
||||
} catch (Exception e) {
|
||||
log.error("[WorldScene] setupAnimationContext() fehlgeschlagen – Character trotzdem eingeblendet", e);
|
||||
if (characterVisual != null) characterVisual.setCullHint(Spatial.CullHint.Inherit);
|
||||
}
|
||||
}
|
||||
playerInput.update(tpf);
|
||||
thirdPersonCam.update(tpf);
|
||||
|
||||
if (physicsChar != null) {
|
||||
com.jme3.math.Vector3f pos = physicsChar.getPhysicsLocation();
|
||||
// Audio-Listener folgt dem Spieler (Ohr-Position + Kamera-Orientierung)
|
||||
app.getListener().setLocation(pos);
|
||||
app.getListener().setRotation(app.getCamera().getRotation());
|
||||
if (oceanSound != null) oceanSound.setPlayerPosition(pos);
|
||||
if (ambientSounds != null) ambientSounds.setPlayerPosition(pos);
|
||||
}
|
||||
|
||||
// Terrain-Shader mit DayNightState-Licht synchronisieren (Richtung + Farben)
|
||||
if (terrainMaterial != null && dayNight != null
|
||||
&& dayNight.getSunLight() != null) {
|
||||
@@ -319,6 +418,16 @@ public class WorldScene extends BaseAppState {
|
||||
if (characterVisual != null) {
|
||||
characterVisual.setCullHint(Spatial.CullHint.Inherit);
|
||||
}
|
||||
|
||||
playerInput.setInitialFacing(spawnYaw);
|
||||
|
||||
if ("true".equals(System.getProperty("blight.new.game"))) {
|
||||
String reviveClip = de.blight.game.animation.AnimationLibrary.getClipForAction(
|
||||
AnimationLibrary.findAssetRoot(), setName, de.blight.game.animation.AnimationAction.REVIVE);
|
||||
float reviveLength = playerInput.getReviveClipLength();
|
||||
app.getStateManager().attach(
|
||||
new de.blight.game.state.NewGameIntroState(playerInput, reviveClip, reviveLength));
|
||||
}
|
||||
}
|
||||
|
||||
// CharacterControl setzt den Spatial auf den Kapsel-Mittelpunkt: radius=0.4, halfCyl=0.5 → 0.9m über dem Boden.
|
||||
@@ -500,22 +609,28 @@ public class WorldScene extends BaseAppState {
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn-Priorität: 1) Editor-Property 2) Spielstand 3) Karten-Default
|
||||
// Spawn-Priorität: 1) Temp-Editor-Property 2) Spielstand (außer Neues Spiel) 3) Karten-Default
|
||||
String propX = System.getProperty("blight.temp.spawn.x");
|
||||
String propZ = System.getProperty("blight.temp.spawn.z");
|
||||
String propYaw = System.getProperty("blight.temp.spawn.yaw");
|
||||
boolean isNewGame = "true".equals(System.getProperty("blight.new.game"));
|
||||
|
||||
if (propX != null) {
|
||||
spawnX = Float.parseFloat(propX);
|
||||
spawnZ = propZ != null ? Float.parseFloat(propZ) : (loadedMapData != null ? loadedMapData.spawnZ : 0f);
|
||||
spawnYaw = propYaw != null ? Float.parseFloat(propYaw) : 0f;
|
||||
} else {
|
||||
de.blight.game.state.SaveGameState saveState =
|
||||
de.blight.game.state.SaveGameState saveState = isNewGame ? null :
|
||||
app.getStateManager().getState(de.blight.game.state.SaveGameState.class);
|
||||
if (saveState != null && saveState.getSave().character.positionSaved) {
|
||||
spawnX = saveState.getSave().character.x;
|
||||
spawnY = saveState.getSave().character.y;
|
||||
spawnZ = saveState.getSave().character.z;
|
||||
spawnYaw = loadedMapData != null ? loadedMapData.spawnYaw : 0f;
|
||||
} else if (loadedMapData != null) {
|
||||
spawnX = loadedMapData.spawnX;
|
||||
spawnZ = loadedMapData.spawnZ;
|
||||
spawnYaw = loadedMapData.spawnYaw;
|
||||
}
|
||||
}
|
||||
log.info("[WorldScene] SpawnXZ: X={} Z={}", spawnX, spawnZ);
|
||||
@@ -545,6 +660,12 @@ public class WorldScene extends BaseAppState {
|
||||
terrainChunkState.setSpawnHint(spawnX, spawnZ);
|
||||
|
||||
app.getStateManager().attach(new SculptedMeshState(bulletAppState, loadedMapData));
|
||||
|
||||
oceanSound = new de.blight.game.state.OceanSoundState(terrainChunkState);
|
||||
app.getStateManager().attach(oceanSound);
|
||||
|
||||
ambientSounds = new de.blight.game.state.AmbientSoundSystem();
|
||||
app.getStateManager().attach(ambientSounds);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -816,7 +937,11 @@ public class WorldScene extends BaseAppState {
|
||||
for (int i = 0; i < 4; i++) diffFb[4+i] = new ColorRGBA(0.45f, 0.32f, 0.25f, 1f);
|
||||
for (int i = 0; i < 4; i++) diffFb[8+i] = new ColorRGBA(0.45f, 0.32f, 0.25f, 1f);
|
||||
debugSlot0Path = diffPaths[0];
|
||||
log.info("[Terrain] Slot-0 Textur = '{}' Slot-1 = '{}'", diffPaths[0], diffPaths[1]);
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (diffPaths[i] != null && !diffPaths[i].isEmpty()) {
|
||||
log.info("[Terrain] Slot-{} = '{}'", i, diffPaths[i]);
|
||||
}
|
||||
}
|
||||
mat.setParam("DiffuseArray", com.jme3.shader.VarType.TextureArray,
|
||||
buildTextureArray(diffPaths, diffFb, assetManager));
|
||||
|
||||
|
||||
@@ -18,15 +18,20 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Distanzbasierter Ambient-Sound pro Polygon-Bereich.
|
||||
* Innerhalb des Polygons: volle Lautstärke.
|
||||
* Außerhalb: lineares Fade bis zur Reichweite (volume * CROSSFADE_SCALE Einheiten).
|
||||
* Distanzbasierter Ambient-Sound pro Polygon-Bereich, jetzt mit Stereo-Panning:
|
||||
* - Innerhalb des Polygons: nicht-positional (Rundum-Klang).
|
||||
* - Außerhalb: AudioNode am nächsten Polygon-Rand → OpenAL panst aus der richtigen Richtung.
|
||||
* Lautstärke-Fading bleibt manuell; OpenAL's Distanz-Dämpfung wird mit großem
|
||||
* refDistance deaktiviert, damit es keine Doppeldämpfung gibt.
|
||||
*/
|
||||
public class AmbientSoundSystem extends BaseAppState {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AmbientSoundSystem.class);
|
||||
private static final float CROSSFADE_SCALE = 30f; // Einheiten Reichweite außerhalb bei volume=1.0
|
||||
private static final float FADE_DURATION = 2f; // Sekunden für vollen Lautstärke-Hub
|
||||
private static final float CROSSFADE_SCALE = 30f;
|
||||
private static final float FADE_DURATION = 2f;
|
||||
/** RefDistance > jede denkbare Spieler-AudioNode-Distanz → OpenAL dämpft nicht. */
|
||||
private static final float NO_ATTN_REF = 1000f;
|
||||
private static final float NO_ATTN_MAX = 2000f;
|
||||
|
||||
private SimpleApplication app;
|
||||
private AssetManager assets;
|
||||
@@ -35,6 +40,7 @@ public class AmbientSoundSystem extends BaseAppState {
|
||||
private final List<PlacedSoundArea> data = new ArrayList<>();
|
||||
private final List<AudioNode> sounds = new ArrayList<>();
|
||||
private final List<Boolean> attached = new ArrayList<>();
|
||||
private final List<Boolean> wasInside = new ArrayList<>();
|
||||
|
||||
private final Vector3f playerPos = new Vector3f();
|
||||
|
||||
@@ -51,10 +57,14 @@ public class AmbientSoundSystem extends BaseAppState {
|
||||
AudioNode node = new AudioNode(assets, area.soundPath(), AudioData.DataType.Stream);
|
||||
node.setLooping(true);
|
||||
node.setVolume(0f);
|
||||
node.setPositional(false);
|
||||
// Positional-Modus: refDistance sehr groß → OpenAL dämpft nicht selbst
|
||||
node.setPositional(true);
|
||||
node.setRefDistance(NO_ATTN_REF);
|
||||
node.setMaxDistance(NO_ATTN_MAX);
|
||||
data.add(area);
|
||||
sounds.add(node);
|
||||
attached.add(false);
|
||||
wasInside.add(false);
|
||||
} catch (Exception e) {
|
||||
log.warn("[AmbientSoundSystem] Sound nicht ladbar '{}': {}", area.soundPath(), e.getMessage());
|
||||
}
|
||||
@@ -77,6 +87,7 @@ public class AmbientSoundSystem extends BaseAppState {
|
||||
data.clear();
|
||||
sounds.clear();
|
||||
attached.clear();
|
||||
wasInside.clear();
|
||||
}
|
||||
|
||||
@Override protected void onEnable() {}
|
||||
@@ -95,9 +106,8 @@ public class AmbientSoundSystem extends BaseAppState {
|
||||
AudioNode node = sounds.get(i);
|
||||
float target = computeTarget(area);
|
||||
float cur = node.getVolume();
|
||||
boolean wasOn = attached.get(i);
|
||||
|
||||
if (target > 0f && !wasOn) {
|
||||
if (target > 0f && !attached.get(i)) {
|
||||
node.setVolume(0f);
|
||||
rootNode.attachChild(node);
|
||||
node.play();
|
||||
@@ -106,6 +116,9 @@ public class AmbientSoundSystem extends BaseAppState {
|
||||
}
|
||||
|
||||
if (attached.get(i)) {
|
||||
// Stereo-Panning: AudioNode zur richtigen Richtung verschieben
|
||||
updateNodePosition(node, area, i);
|
||||
|
||||
float step = area.volume() * tpf / FADE_DURATION;
|
||||
float nv = target > cur
|
||||
? Math.min(cur + step, target)
|
||||
@@ -122,11 +135,33 @@ public class AmbientSoundSystem extends BaseAppState {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zielvolumen basierend auf signiertem Abstand zur Polygongrenze.
|
||||
* Innen (≥0): volle Lautstärke.
|
||||
* Außen: linear von voll (Grenze) auf null (hearRange = volume * CROSSFADE_SCALE).
|
||||
*/
|
||||
// ── AudioNode-Position für Stereo-Panning ────────────────────────────────
|
||||
|
||||
private void updateNodePosition(AudioNode node, PlacedSoundArea area, int i) {
|
||||
float px = playerPos.x, pz = playerPos.z;
|
||||
boolean inside = pointInPolygon(px, pz, area.pointsX(), area.pointsZ());
|
||||
|
||||
if (inside) {
|
||||
// Innerhalb: nicht-positional → Rundum-Klang
|
||||
if (!wasInside.get(i)) {
|
||||
node.setPositional(false);
|
||||
wasInside.set(i, true);
|
||||
}
|
||||
} else {
|
||||
// Außerhalb: positional am nächsten Rand-Punkt
|
||||
if (wasInside.get(i)) {
|
||||
node.setPositional(true);
|
||||
node.setRefDistance(NO_ATTN_REF);
|
||||
node.setMaxDistance(NO_ATTN_MAX);
|
||||
wasInside.set(i, false);
|
||||
}
|
||||
float[] nearest = nearestPointOnPolygon(px, pz, area.pointsX(), area.pointsZ());
|
||||
node.setLocalTranslation(nearest[0], playerPos.y, nearest[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Polygon-Berechnungen ─────────────────────────────────────────────────
|
||||
|
||||
private float computeTarget(PlacedSoundArea area) {
|
||||
float signedDist = signedDistToPolygon(playerPos.x, playerPos.z, area.pointsX(), area.pointsZ());
|
||||
if (signedDist >= 0f) return area.volume();
|
||||
@@ -135,15 +170,35 @@ public class AmbientSoundSystem extends BaseAppState {
|
||||
return area.volume() * (1f + signedDist / hearRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Positiv = Spieler ist innen (Distanz zur nächsten Kante).
|
||||
* Negativ = Spieler ist außen (negierte Distanz zur nächsten Kante).
|
||||
*/
|
||||
/** Positiv = Spieler ist innen, Negativ = Spieler ist außen. */
|
||||
private static float signedDistToPolygon(float px, float pz, float[] xs, float[] zs) {
|
||||
float edgeDist = minDistToPolygonEdge(px, pz, xs, zs);
|
||||
return pointInPolygon(px, pz, xs, zs) ? edgeDist : -edgeDist;
|
||||
}
|
||||
|
||||
/** Nächster Punkt auf einer Polygon-Kante (x, z) als float[2]. */
|
||||
private static float[] nearestPointOnPolygon(float px, float pz, float[] xs, float[] zs) {
|
||||
int n = xs.length;
|
||||
float minD2 = Float.MAX_VALUE;
|
||||
float bestX = xs[0], bestZ = zs[0];
|
||||
for (int i = 0, j = n - 1; i < n; j = i++) {
|
||||
float ax = xs[j], az = zs[j];
|
||||
float bx = xs[i], bz = zs[i];
|
||||
float dx = bx - ax, dz = bz - az;
|
||||
float lenSq = dx * dx + dz * dz;
|
||||
float t = lenSq == 0f ? 0f : Math.max(0f, Math.min(1f, ((px - ax) * dx + (pz - az) * dz) / lenSq));
|
||||
float cx = ax + t * dx;
|
||||
float cz = az + t * dz;
|
||||
float d2 = (cx - px) * (cx - px) + (cz - pz) * (cz - pz);
|
||||
if (d2 < minD2) {
|
||||
minD2 = d2;
|
||||
bestX = cx;
|
||||
bestZ = cz;
|
||||
}
|
||||
}
|
||||
return new float[]{bestX, bestZ};
|
||||
}
|
||||
|
||||
private static float minDistToPolygonEdge(float px, float pz, float[] xs, float[] zs) {
|
||||
int n = xs.length;
|
||||
float minD2 = Float.MAX_VALUE;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package de.blight.game.state;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.state.BaseAppState;
|
||||
import de.blight.game.config.AudioSettings;
|
||||
|
||||
/**
|
||||
* Hält die Audio-Einstellungen zur Laufzeit. Sound-Systeme lesen daraus
|
||||
* ihre effektiven Lautstärken (master × kategorie).
|
||||
*/
|
||||
public class AudioSettingsState extends BaseAppState {
|
||||
|
||||
private final AudioSettings settings;
|
||||
|
||||
public AudioSettingsState(AudioSettings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override protected void initialize(Application application) {}
|
||||
@Override protected void cleanup(Application application) {}
|
||||
@Override protected void onEnable() {}
|
||||
@Override protected void onDisable() {}
|
||||
|
||||
public AudioSettings getSettings() { return settings; }
|
||||
|
||||
public float getMaster() { return clamp(settings.master); }
|
||||
public float getMusic() { return clamp(settings.music); }
|
||||
public float getSpeech() { return clamp(settings.speech); }
|
||||
public float getEffects() { return clamp(settings.effects); }
|
||||
public float getAmbient() { return clamp(settings.ambient); }
|
||||
|
||||
public float effectiveAmbient() { return getMaster() * getAmbient(); }
|
||||
public float effectiveMusic() { return getMaster() * getMusic(); }
|
||||
public float effectiveEffects() { return getMaster() * getEffects(); }
|
||||
public float effectiveSpeech() { return getMaster() * getSpeech(); }
|
||||
|
||||
private static float clamp(float v) { return Math.max(0f, Math.min(1f, v)); }
|
||||
}
|
||||
@@ -0,0 +1,578 @@
|
||||
package de.blight.game.state;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.BaseAppState;
|
||||
import com.jme3.font.BitmapFont;
|
||||
import com.jme3.font.BitmapText;
|
||||
import com.jme3.input.KeyInput;
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import de.blight.common.model.DialogOption;
|
||||
import de.blight.common.model.MainCharacter;
|
||||
import de.blight.common.model.NPC;
|
||||
import de.blight.common.model.TextReference;
|
||||
import de.blight.game.config.MenuCanvas;
|
||||
import de.blight.game.config.NinePatch;
|
||||
import de.blight.lang.TextResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Dialog-HUD: zeigt am unteren Bildschirmrand Gesprächstexte und wählbare
|
||||
* Antwortoptionen im Stil des Pausemenüs an.
|
||||
*
|
||||
* <h2>Phasen</h2>
|
||||
* <pre>
|
||||
* HIDDEN
|
||||
* → TEXT_NPC : Begrüßungstext des NPC (Default-Message) oder NPC-Antwort
|
||||
* → TEXT_HERO : Was der Spieler sagt (textHero der gewählten Option)
|
||||
* → OPTIONS : Auswahl der verfügbaren Dialog-Optionen
|
||||
* → HIDDEN : nach "Verlassen"
|
||||
* </pre>
|
||||
*
|
||||
* Navigation: Pfeiltasten hoch/runter + Enter ODER Mausklick.
|
||||
* Rechtsklick: Text überspringen / zur nächsten Seite.
|
||||
*/
|
||||
public class DialogHudState extends BaseAppState {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DialogHudState.class);
|
||||
|
||||
// ── Layout-Konstanten (virtuelle Koordinaten 1376 × 768) ─────────────────
|
||||
|
||||
private static final float PNL_X = 63f;
|
||||
private static final float PNL_Y = 20f;
|
||||
private static final float PNL_W = 1250f;
|
||||
private static final float PNL_H = 255f;
|
||||
|
||||
private static final float MARGIN_X = 20f;
|
||||
private static final float FONT_NAME = 18f;
|
||||
private static final float FONT_TEXT = 16f;
|
||||
private static final float FONT_OPT = 15f;
|
||||
private static final float LINE_H_TXT = 26f;
|
||||
private static final float LINE_H_OPT = 26f;
|
||||
|
||||
private static final int MAX_TEXT_LINES = 3;
|
||||
private static final int MAX_CHARS_LINE = 82;
|
||||
private static final int MAX_OPTIONS = 5;
|
||||
|
||||
private static final ColorRGBA COL_NAME = new ColorRGBA(1.00f, 0.90f, 0.55f, 1f);
|
||||
private static final ColorRGBA COL_TEXT = ColorRGBA.White;
|
||||
private static final ColorRGBA COL_OPT = new ColorRGBA(0.80f, 0.80f, 0.80f, 1f);
|
||||
private static final ColorRGBA COL_OPT_SEL = new ColorRGBA(1.00f, 0.90f, 0.45f, 1f);
|
||||
private static final ColorRGBA COL_HINT = new ColorRGBA(0.55f, 0.55f, 0.55f, 1f);
|
||||
|
||||
private static final String EXIT_KEY = "dialog.exit";
|
||||
|
||||
// ── Input-Action-Namen ────────────────────────────────────────────────────
|
||||
|
||||
private static final String ACT_UP = "_DlgUp";
|
||||
private static final String ACT_DOWN = "_DlgDown";
|
||||
private static final String ACT_CONFIRM = "_DlgConfirm";
|
||||
private static final String ACT_SKIP = "_DlgSkip";
|
||||
private static final String ACT_CLICK = "_DlgClick";
|
||||
|
||||
// ── Zustände ─────────────────────────────────────────────────────────────
|
||||
|
||||
private enum Phase { HIDDEN, TEXT_NPC, TEXT_HERO, OPTIONS }
|
||||
|
||||
private Phase phase = Phase.HIDDEN;
|
||||
|
||||
// ── Dialog-Daten ─────────────────────────────────────────────────────────
|
||||
|
||||
private NPC currentNpc;
|
||||
private MainCharacter mainChar;
|
||||
private Runnable onClose;
|
||||
|
||||
/** Alle Seiten des aktuellen Textes. */
|
||||
private List<List<String>> textPages = new ArrayList<>();
|
||||
private int pageIdx = 0;
|
||||
|
||||
/** Aktuelle Option, die nach dem Text gezeigt werden soll (für Option-Text). */
|
||||
private DialogOption pendingOption;
|
||||
|
||||
/** Verfügbare Optionen (inkl. Exit). */
|
||||
private List<DisplayOption> displayOptions = new ArrayList<>();
|
||||
private int selectedOpt = 0;
|
||||
|
||||
/** Panel-Bounds für Maus-Hit-Tests. */
|
||||
private float[][] optBounds = new float[MAX_OPTIONS][4]; // x,y,w,h
|
||||
|
||||
// ── JME3 UI-Knoten ────────────────────────────────────────────────────────
|
||||
|
||||
private SimpleApplication app;
|
||||
private BitmapFont font;
|
||||
private Node guiNode;
|
||||
private Node canvasNode;
|
||||
private Node panel;
|
||||
|
||||
private BitmapText nameText;
|
||||
private BitmapText[] lineTexts = new BitmapText[MAX_TEXT_LINES];
|
||||
private BitmapText hintText;
|
||||
private BitmapText[] optTexts = new BitmapText[MAX_OPTIONS];
|
||||
|
||||
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
||||
|
||||
@Override
|
||||
protected void initialize(Application app) {
|
||||
this.app = (SimpleApplication) app;
|
||||
this.guiNode = this.app.getGuiNode();
|
||||
this.font = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnable() {}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
if (phase != Phase.HIDDEN) closePanel();
|
||||
}
|
||||
|
||||
@Override protected void cleanup(Application app) {}
|
||||
|
||||
// ── Public API ────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Startet den Dialog mit dem gegebenen NPC.
|
||||
*
|
||||
* @param npc der angesprochene NPC
|
||||
* @param mc der Hauptcharakter
|
||||
* @param onCloseCallback wird aufgerufen wenn der Dialog endet
|
||||
*/
|
||||
public void startDialog(NPC npc, MainCharacter mc, Runnable onCloseCallback) {
|
||||
this.currentNpc = npc;
|
||||
this.mainChar = mc;
|
||||
this.onClose = onCloseCallback;
|
||||
|
||||
buildPanel();
|
||||
registerInput();
|
||||
|
||||
// Erst: Default-Message anzeigen (falls vorhanden), dann Optionen
|
||||
TextReference greeting = npc.getDefaultMessage();
|
||||
String greetText = greeting != null ? TextResolver.get().resolve(greeting) : null;
|
||||
|
||||
List<DialogOption> available = resolveOptions(npc, mc);
|
||||
|
||||
if (greetText != null && !greetText.isBlank()) {
|
||||
showText(Phase.TEXT_NPC, resolveNpcName(npc), greetText, () -> {
|
||||
if (available.isEmpty()) {
|
||||
closeDialog();
|
||||
} else {
|
||||
showOptions(available);
|
||||
}
|
||||
});
|
||||
} else if (!available.isEmpty()) {
|
||||
showOptions(available);
|
||||
} else {
|
||||
// Keine Nachricht, keine Optionen → sofort schließen
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return phase != Phase.HIDDEN;
|
||||
}
|
||||
|
||||
// ── Text-Anzeige ─────────────────────────────────────────────────────────
|
||||
|
||||
private Runnable afterText;
|
||||
|
||||
private void showText(Phase textPhase, String speaker, String rawText, Runnable after) {
|
||||
this.phase = textPhase;
|
||||
this.afterText = after;
|
||||
this.textPages = paginate(wrapText(rawText, MAX_CHARS_LINE), MAX_TEXT_LINES);
|
||||
this.pageIdx = 0;
|
||||
renderCurrentTextPage(speaker);
|
||||
}
|
||||
|
||||
private void renderCurrentTextPage(String speaker) {
|
||||
nameText.setText(speaker);
|
||||
nameText.setCullHint(Spatial.CullHint.Inherit);
|
||||
|
||||
List<String> page = (pageIdx < textPages.size()) ? textPages.get(pageIdx) : List.of();
|
||||
for (int i = 0; i < MAX_TEXT_LINES; i++) {
|
||||
lineTexts[i].setText(i < page.size() ? page.get(i) : "");
|
||||
lineTexts[i].setCullHint(Spatial.CullHint.Inherit);
|
||||
}
|
||||
|
||||
boolean more = (pageIdx + 1) < textPages.size();
|
||||
hintText.setText(more
|
||||
? t("dialog.hint.advance")
|
||||
: t("dialog.hint.continue"));
|
||||
hintText.setCullHint(Spatial.CullHint.Inherit);
|
||||
|
||||
for (BitmapText o : optTexts) o.setCullHint(Spatial.CullHint.Always);
|
||||
}
|
||||
|
||||
// ── Optionen-Anzeige ─────────────────────────────────────────────────────
|
||||
|
||||
private void showOptions(List<DialogOption> options) {
|
||||
phase = Phase.OPTIONS;
|
||||
displayOptions.clear();
|
||||
selectedOpt = 0;
|
||||
|
||||
for (DialogOption opt : options) {
|
||||
String label = TextResolver.get().resolveId(opt.getLabel() != null ? opt.getLabel() : "");
|
||||
if (label.isBlank()) label = opt.getId() != null
|
||||
? opt.getId().substring(0, Math.min(opt.getId().length(), 20)) : "?";
|
||||
displayOptions.add(new DisplayOption(label, opt));
|
||||
}
|
||||
displayOptions.add(new DisplayOption(t(EXIT_KEY), null));
|
||||
|
||||
nameText.setText(resolveNpcName(currentNpc));
|
||||
nameText.setCullHint(Spatial.CullHint.Inherit);
|
||||
for (BitmapText l : lineTexts) l.setCullHint(Spatial.CullHint.Always);
|
||||
hintText.setCullHint(Spatial.CullHint.Always);
|
||||
|
||||
renderOptions();
|
||||
}
|
||||
|
||||
private void renderOptions() {
|
||||
float baseY = PNL_Y + PNL_H - 80f;
|
||||
|
||||
for (int i = 0; i < MAX_OPTIONS; i++) {
|
||||
if (i < displayOptions.size()) {
|
||||
DisplayOption do_ = displayOptions.get(i);
|
||||
boolean sel = (i == selectedOpt);
|
||||
String prefix = sel ? "► " : " ";
|
||||
optTexts[i].setText(prefix + (i + 1) + ". " + do_.label());
|
||||
optTexts[i].setColor(sel ? COL_OPT_SEL : COL_OPT);
|
||||
optTexts[i].setCullHint(Spatial.CullHint.Inherit);
|
||||
|
||||
float ty = baseY - i * LINE_H_OPT;
|
||||
optTexts[i].setLocalTranslation(PNL_X + MARGIN_X, ty, 2f);
|
||||
|
||||
optBounds[i][0] = PNL_X + MARGIN_X;
|
||||
optBounds[i][1] = ty - FONT_OPT;
|
||||
optBounds[i][2] = PNL_W - MARGIN_X * 2;
|
||||
optBounds[i][3] = FONT_OPT + 4;
|
||||
} else {
|
||||
optTexts[i].setCullHint(Spatial.CullHint.Always);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Input-Handler ─────────────────────────────────────────────────────────
|
||||
|
||||
private void onUp() {
|
||||
if (phase != Phase.OPTIONS) return;
|
||||
selectedOpt = Math.max(0, selectedOpt - 1);
|
||||
renderOptions();
|
||||
}
|
||||
|
||||
private void onDown() {
|
||||
if (phase != Phase.OPTIONS) return;
|
||||
selectedOpt = Math.min(displayOptions.size() - 1, selectedOpt + 1);
|
||||
renderOptions();
|
||||
}
|
||||
|
||||
private void onConfirm() {
|
||||
if (phase == Phase.TEXT_NPC || phase == Phase.TEXT_HERO) {
|
||||
advanceText();
|
||||
} else if (phase == Phase.OPTIONS) {
|
||||
confirmOption(selectedOpt);
|
||||
}
|
||||
}
|
||||
|
||||
private void onSkip() {
|
||||
if (phase == Phase.TEXT_NPC || phase == Phase.TEXT_HERO) {
|
||||
// Alle verbleibenden Seiten überspringen
|
||||
pageIdx = textPages.size();
|
||||
if (afterText != null) { Runnable cb = afterText; afterText = null; cb.run(); }
|
||||
} else if (phase == Phase.OPTIONS) {
|
||||
confirmOption(selectedOpt);
|
||||
}
|
||||
}
|
||||
|
||||
private void onMouseClick(Vector2f cursor) {
|
||||
if (phase != Phase.OPTIONS) { onConfirm(); return; }
|
||||
|
||||
// Kursorenanpassung auf virtuelle Koordinaten
|
||||
float ox = (app.getCamera().getWidth() - MenuCanvas.REF_W) / 2f;
|
||||
float oy = (app.getCamera().getHeight() - MenuCanvas.REF_H) / 2f;
|
||||
float scale = Math.min(
|
||||
app.getCamera().getWidth() / MenuCanvas.REF_W,
|
||||
app.getCamera().getHeight() / MenuCanvas.REF_H);
|
||||
|
||||
float ox2 = (app.getCamera().getWidth() - MenuCanvas.REF_W * scale) / 2f;
|
||||
float oy2 = (app.getCamera().getHeight() - MenuCanvas.REF_H * scale) / 2f;
|
||||
float vx = (cursor.x - ox2) / scale;
|
||||
float vy = (cursor.y - oy2) / scale;
|
||||
|
||||
for (int i = 0; i < displayOptions.size() && i < MAX_OPTIONS; i++) {
|
||||
float bx = optBounds[i][0], by = optBounds[i][1];
|
||||
float bw = optBounds[i][2], bh = optBounds[i][3];
|
||||
if (vx >= bx && vx <= bx + bw && vy >= by && vy <= by + bh) {
|
||||
selectedOpt = i;
|
||||
renderOptions();
|
||||
confirmOption(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void advanceText() {
|
||||
if (pageIdx + 1 < textPages.size()) {
|
||||
pageIdx++;
|
||||
renderCurrentTextPage(nameText.getText());
|
||||
} else if (afterText != null) {
|
||||
Runnable cb = afterText;
|
||||
afterText = null;
|
||||
cb.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void confirmOption(int idx) {
|
||||
if (idx < 0 || idx >= displayOptions.size()) return;
|
||||
DisplayOption selected = displayOptions.get(idx);
|
||||
|
||||
if (selected.option() == null) {
|
||||
// Exit
|
||||
closeDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
DialogOption opt = selected.option();
|
||||
|
||||
// Held-Text
|
||||
String heroText = opt.getTextHero() != null
|
||||
? TextResolver.get().resolve(opt.getTextHero()) : null;
|
||||
// NPC-Text
|
||||
String npcText = opt.getTextNpc() != null
|
||||
? TextResolver.get().resolve(opt.getTextNpc()) : null;
|
||||
|
||||
// Option-Effekte anwenden (Optionen aktualisieren, Quest, etc.)
|
||||
applyOption(opt);
|
||||
|
||||
List<DialogOption> nextOpts = resolveOptions(currentNpc, mainChar);
|
||||
|
||||
if (heroText != null && !heroText.isBlank()) {
|
||||
showText(Phase.TEXT_HERO, t("dialog.speaker.player"), heroText, () -> {
|
||||
if (npcText != null && !npcText.isBlank()) {
|
||||
showText(Phase.TEXT_NPC, resolveNpcName(currentNpc), npcText, () -> {
|
||||
if (nextOpts.isEmpty()) closeDialog(); else showOptions(nextOpts);
|
||||
});
|
||||
} else {
|
||||
if (nextOpts.isEmpty()) closeDialog(); else showOptions(nextOpts);
|
||||
}
|
||||
});
|
||||
} else if (npcText != null && !npcText.isBlank()) {
|
||||
showText(Phase.TEXT_NPC, resolveNpcName(currentNpc), npcText, () -> {
|
||||
if (nextOpts.isEmpty()) closeDialog(); else showOptions(nextOpts);
|
||||
});
|
||||
} else {
|
||||
if (nextOpts.isEmpty()) closeDialog(); else showOptions(nextOpts);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Optionen-Auflösung ────────────────────────────────────────────────────
|
||||
|
||||
private List<DialogOption> resolveOptions(NPC npc, MainCharacter mc) {
|
||||
if (npc.getCurrentOptions() == null || mc == null) return List.of();
|
||||
try {
|
||||
return npc.getAvailableOptions(mc);
|
||||
} catch (Exception e) {
|
||||
log.warn("[DialogHud] Optionen-Auflösung fehlgeschlagen: {}", e.getMessage());
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
/** Wendet die Dialog-Option an (Optionen-Listen aktualisieren, Quests etc.). */
|
||||
private void applyOption(DialogOption opt) {
|
||||
if (currentNpc.getCurrentOptions() == null) return;
|
||||
currentNpc.getCurrentOptions().remove(opt);
|
||||
if (opt.getDisablesOptions() != null)
|
||||
currentNpc.getCurrentOptions().removeAll(opt.getDisablesOptions());
|
||||
if (opt.getNextOptions() != null)
|
||||
currentNpc.getCurrentOptions().addAll(opt.getNextOptions());
|
||||
if (opt.isEnablesTrade()) currentNpc.setTrader(true);
|
||||
if (mainChar != null) mainChar.handleDialogOption(opt);
|
||||
}
|
||||
|
||||
// ── Dialog beenden ────────────────────────────────────────────────────────
|
||||
|
||||
private void closeDialog() {
|
||||
closePanel();
|
||||
if (onClose != null) { Runnable cb = onClose; onClose = null; cb.run(); }
|
||||
}
|
||||
|
||||
// ── UI-Aufbau / -Abbau ────────────────────────────────────────────────────
|
||||
|
||||
private void buildPanel() {
|
||||
canvasNode = MenuCanvas.createFixedCanvas(app.getCamera());
|
||||
guiNode.attachChild(canvasNode);
|
||||
|
||||
panel = new Node("dialog-panel");
|
||||
|
||||
// Hintergrundpanel
|
||||
panel.attachChild(NinePatch.panel(app.getAssetManager())
|
||||
.build(PNL_X, PNL_Y, PNL_W, PNL_H, -1f));
|
||||
|
||||
// NPC-Name
|
||||
nameText = makeTxt("", FONT_NAME, COL_NAME);
|
||||
nameText.setLocalTranslation(PNL_X + MARGIN_X, PNL_Y + PNL_H - 22f, 2f);
|
||||
nameText.setCullHint(Spatial.CullHint.Always);
|
||||
panel.attachChild(nameText);
|
||||
|
||||
// Trennlinie (dünnes Quad)
|
||||
panel.attachChild(makeSeparator(PNL_X + MARGIN_X, PNL_Y + PNL_H - 46f, PNL_W - MARGIN_X * 2));
|
||||
|
||||
// Dialog-Textzeilen
|
||||
float textStartY = PNL_Y + PNL_H - 72f;
|
||||
for (int i = 0; i < MAX_TEXT_LINES; i++) {
|
||||
lineTexts[i] = makeTxt("", FONT_TEXT, COL_TEXT);
|
||||
lineTexts[i].setLocalTranslation(PNL_X + MARGIN_X, textStartY - i * LINE_H_TXT, 2f);
|
||||
lineTexts[i].setCullHint(Spatial.CullHint.Always);
|
||||
panel.attachChild(lineTexts[i]);
|
||||
}
|
||||
|
||||
// Hint-Text (Rechtsklick-Weiter)
|
||||
hintText = makeTxt("", FONT_TEXT - 2f, COL_HINT);
|
||||
hintText.setLocalTranslation(PNL_X + PNL_W - MARGIN_X - 300f, PNL_Y + 28f, 2f);
|
||||
hintText.setCullHint(Spatial.CullHint.Always);
|
||||
panel.attachChild(hintText);
|
||||
|
||||
// Optionszeilen
|
||||
for (int i = 0; i < MAX_OPTIONS; i++) {
|
||||
optTexts[i] = makeTxt("", FONT_OPT, COL_OPT);
|
||||
optTexts[i].setCullHint(Spatial.CullHint.Always);
|
||||
panel.attachChild(optTexts[i]);
|
||||
}
|
||||
|
||||
canvasNode.attachChild(panel);
|
||||
}
|
||||
|
||||
private void closePanel() {
|
||||
phase = Phase.HIDDEN;
|
||||
unregisterInput();
|
||||
if (canvasNode != null) {
|
||||
guiNode.detachChild(canvasNode);
|
||||
canvasNode = null;
|
||||
panel = null;
|
||||
}
|
||||
textPages.clear();
|
||||
displayOptions.clear();
|
||||
pendingOption = null;
|
||||
afterText = null;
|
||||
currentNpc = null;
|
||||
mainChar = null;
|
||||
}
|
||||
|
||||
// ── Input-Registrierung ───────────────────────────────────────────────────
|
||||
|
||||
private void registerInput() {
|
||||
var im = app.getInputManager();
|
||||
im.addMapping(ACT_UP, new KeyTrigger(KeyInput.KEY_UP));
|
||||
im.addMapping(ACT_DOWN, new KeyTrigger(KeyInput.KEY_DOWN));
|
||||
im.addMapping(ACT_CONFIRM, new KeyTrigger(KeyInput.KEY_RETURN),
|
||||
new KeyTrigger(KeyInput.KEY_NUMPADENTER));
|
||||
im.addMapping(ACT_SKIP, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
||||
im.addMapping(ACT_CLICK, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||
im.addListener(inputListener, ACT_UP, ACT_DOWN, ACT_CONFIRM, ACT_SKIP, ACT_CLICK);
|
||||
im.setCursorVisible(true);
|
||||
}
|
||||
|
||||
private void unregisterInput() {
|
||||
var im = app.getInputManager();
|
||||
try { im.removeListener(inputListener); } catch (Exception ignored) {}
|
||||
for (String a : new String[]{ACT_UP, ACT_DOWN, ACT_CONFIRM, ACT_SKIP, ACT_CLICK}) {
|
||||
try { im.deleteMapping(a); } catch (Exception ignored) {}
|
||||
}
|
||||
im.setCursorVisible(false);
|
||||
}
|
||||
|
||||
private final ActionListener inputListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed) return;
|
||||
switch (name) {
|
||||
case ACT_UP -> onUp();
|
||||
case ACT_DOWN -> onDown();
|
||||
case ACT_CONFIRM -> onConfirm();
|
||||
case ACT_SKIP -> onSkip();
|
||||
case ACT_CLICK -> onMouseClick(app.getInputManager().getCursorPosition());
|
||||
}
|
||||
};
|
||||
|
||||
// ── Hilfsmethoden ────────────────────────────────────────────────────────
|
||||
|
||||
private BitmapText makeTxt(String s, float size, ColorRGBA color) {
|
||||
BitmapText t = new BitmapText(font);
|
||||
t.setSize(size);
|
||||
t.setColor(color);
|
||||
t.setText(s);
|
||||
return t;
|
||||
}
|
||||
|
||||
private Geometry makeSeparator(float x, float y, float w) {
|
||||
Geometry g = new Geometry("sep", new Quad(w, 1f));
|
||||
Material m = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
m.setColor("Color", new ColorRGBA(0.4f, 0.4f, 0.4f, 0.8f));
|
||||
m.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||
g.setMaterial(m);
|
||||
g.setQueueBucket(RenderQueue.Bucket.Transparent);
|
||||
g.setLocalTranslation(x, y, 1f);
|
||||
return g;
|
||||
}
|
||||
|
||||
private String resolveNpcName(NPC npc) {
|
||||
if (npc == null) return "?";
|
||||
String lk = npc.getLabelKey();
|
||||
if (!lk.isBlank()) {
|
||||
String resolved = TextResolver.get().resolveId(lk);
|
||||
if (!resolved.startsWith("[")) return resolved;
|
||||
}
|
||||
return npc.getCharacterId() != null ? npc.getCharacterId() : "NPC";
|
||||
}
|
||||
|
||||
private static String t(String id) { return TextResolver.get().resolveId(id); }
|
||||
|
||||
/** Bricht Text an Wortgrenzen auf. */
|
||||
private static List<String> wrapText(String text, int maxChars) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
if (text == null || text.isBlank()) return lines;
|
||||
// Zuerst explizite Zeilenumbrüche beachten
|
||||
for (String paragraph : text.split("\n")) {
|
||||
String[] words = paragraph.split("\\s+");
|
||||
StringBuilder cur = new StringBuilder();
|
||||
for (String w : words) {
|
||||
if (w.isBlank()) continue;
|
||||
if (cur.length() > 0 && cur.length() + 1 + w.length() > maxChars) {
|
||||
lines.add(cur.toString());
|
||||
cur = new StringBuilder(w);
|
||||
} else {
|
||||
if (cur.length() > 0) cur.append(' ');
|
||||
cur.append(w);
|
||||
}
|
||||
}
|
||||
if (cur.length() > 0) lines.add(cur.toString());
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
/** Gruppiert Zeilen in Seiten der Größe {@code linesPerPage}. */
|
||||
private static List<List<String>> paginate(List<String> lines, int linesPerPage) {
|
||||
List<List<String>> pages = new ArrayList<>();
|
||||
for (int i = 0; i < lines.size(); i += linesPerPage) {
|
||||
pages.add(lines.subList(i, Math.min(i + linesPerPage, lines.size())));
|
||||
}
|
||||
if (pages.isEmpty()) pages.add(List.of());
|
||||
return pages;
|
||||
}
|
||||
|
||||
// ── Hilfsrecord ──────────────────────────────────────────────────────────
|
||||
|
||||
private record DisplayOption(String label, DialogOption option) {}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import de.blight.lang.TextResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -26,6 +27,9 @@ public class InteractionHudState extends BaseAppState {
|
||||
private Camera cam;
|
||||
private Node guiNode;
|
||||
private WorldItemsState worldItems;
|
||||
private WorldInteractableState worldInteractables;
|
||||
private WorldNpcsState worldNpcs;
|
||||
private DialogHudState dialogHud;
|
||||
|
||||
private BitmapText labelText;
|
||||
|
||||
@@ -48,8 +52,13 @@ public class InteractionHudState extends BaseAppState {
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
worldItems = getStateManager().getState(WorldItemsState.class);
|
||||
worldInteractables = getStateManager().getState(WorldInteractableState.class);
|
||||
worldNpcs = getStateManager().getState(WorldNpcsState.class);
|
||||
dialogHud = getStateManager().getState(DialogHudState.class);
|
||||
if (worldItems == null)
|
||||
log.warn("[InteractionHud] WorldItemsState nicht gefunden.");
|
||||
if (worldInteractables == null)
|
||||
log.warn("[InteractionHud] WorldInteractableState nicht gefunden.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,40 +75,54 @@ public class InteractionHudState extends BaseAppState {
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
if (worldItems == null) {
|
||||
// Label ausblenden wenn Dialog aktiv
|
||||
if (dialogHud != null && dialogHud.isActive()) {
|
||||
labelText.setCullHint(Spatial.CullHint.Always);
|
||||
return;
|
||||
}
|
||||
|
||||
int idx = worldItems.getHoveredIdx();
|
||||
if (idx < 0) {
|
||||
String labelKey = null;
|
||||
Vector3f worldPos = null;
|
||||
|
||||
// NPC hat höchste Priorität, dann Interactable, dann Item
|
||||
if (worldNpcs != null) {
|
||||
String key = worldNpcs.getHoveredLabelKey();
|
||||
if (key != null && !key.isBlank()) {
|
||||
labelKey = key;
|
||||
worldPos = worldNpcs.getHoveredWorldPos();
|
||||
}
|
||||
}
|
||||
|
||||
// Interactable hat Vorrang vor Item
|
||||
if (labelKey == null && worldInteractables != null) {
|
||||
String key = worldInteractables.getHoveredLabelKey();
|
||||
if (key != null && !key.isBlank()) {
|
||||
labelKey = key;
|
||||
worldPos = worldInteractables.getHoveredWorldPos();
|
||||
}
|
||||
}
|
||||
|
||||
if (labelKey == null && worldItems != null && worldItems.getHoveredIdx() >= 0) {
|
||||
String key = worldItems.getHoveredLabelKey();
|
||||
if (key != null && !key.isBlank()) {
|
||||
labelKey = key;
|
||||
worldPos = worldItems.getHoveredWorldPos();
|
||||
}
|
||||
}
|
||||
|
||||
if (labelKey == null || worldPos == null) {
|
||||
labelText.setCullHint(Spatial.CullHint.Always);
|
||||
return;
|
||||
}
|
||||
|
||||
String name = worldItems.getHoveredItemName();
|
||||
if (name == null) {
|
||||
labelText.setCullHint(Spatial.CullHint.Always);
|
||||
return;
|
||||
}
|
||||
|
||||
// Weltposition des Items → Bildschirmkoordinate
|
||||
Node itemsRoot = worldItems.getItemsRoot();
|
||||
if (idx >= itemsRoot.getQuantity()) {
|
||||
labelText.setCullHint(Spatial.CullHint.Always);
|
||||
return;
|
||||
}
|
||||
Spatial target = itemsRoot.getChild(idx);
|
||||
Vector3f worldPos = target.getWorldTranslation().add(0f, Y_OFFSET, 0f);
|
||||
Vector3f screenV = cam.getScreenCoordinates(worldPos);
|
||||
|
||||
// Hinter der Kamera → nicht anzeigen
|
||||
Vector3f screenV = cam.getScreenCoordinates(worldPos.add(0f, Y_OFFSET, 0f));
|
||||
if (screenV.z >= 1f) {
|
||||
labelText.setCullHint(Spatial.CullHint.Always);
|
||||
return;
|
||||
}
|
||||
|
||||
labelText.setText(name);
|
||||
String text = TextResolver.get().resolveId(labelKey);
|
||||
labelText.setText(text);
|
||||
float textW = labelText.getLineWidth();
|
||||
labelText.setLocalTranslation(screenV.x - textW * 0.5f, screenV.y, 1f);
|
||||
labelText.setCullHint(Spatial.CullHint.Inherit);
|
||||
|
||||
@@ -20,9 +20,13 @@ import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.texture.Texture;
|
||||
import de.blight.common.model.*;
|
||||
import de.blight.game.config.KeyBindings;
|
||||
import de.blight.game.config.MenuCanvas;
|
||||
import de.blight.game.config.NinePatch;
|
||||
import de.blight.game.post.GaussianBlurFilter;
|
||||
import de.blight.game.scene.WorldScene;
|
||||
|
||||
import java.util.*;
|
||||
@@ -82,6 +86,9 @@ public class InventoryState extends BaseAppState {
|
||||
private Node guiNode;
|
||||
private Node panel;
|
||||
private Node gridNode;
|
||||
private Node bgLayer;
|
||||
private Node canvasNode;
|
||||
private GaussianBlurFilter blurFilter;
|
||||
|
||||
// ── Daten ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -137,7 +144,14 @@ public class InventoryState extends BaseAppState {
|
||||
app.getInputManager().addListener(scrollListener, MAP_SCROLL_UP, MAP_SCROLL_DN);
|
||||
app.getInputManager().addListener(clickListener, MAP_CLICK);
|
||||
WorldScene ws = app.getStateManager().getState(WorldScene.class);
|
||||
if (ws != null) ws.setPaused(true);
|
||||
if (ws != null) {
|
||||
ws.setPaused(true);
|
||||
FilterPostProcessor fpp = ws.getSharedFPP();
|
||||
if (fpp != null) {
|
||||
blurFilter = new GaussianBlurFilter(6f);
|
||||
fpp.addFilter(blurFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,7 +161,14 @@ public class InventoryState extends BaseAppState {
|
||||
app.getInputManager().removeListener(clickListener);
|
||||
app.getInputManager().setCursorVisible(false);
|
||||
WorldScene ws = app.getStateManager().getState(WorldScene.class);
|
||||
if (ws != null) ws.setPaused(false);
|
||||
if (ws != null) {
|
||||
ws.setPaused(false);
|
||||
if (blurFilter != null) {
|
||||
FilterPostProcessor fpp = ws.getSharedFPP();
|
||||
if (fpp != null) fpp.removeFilter(blurFilter);
|
||||
blurFilter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,10 +194,10 @@ public class InventoryState extends BaseAppState {
|
||||
|
||||
private final ActionListener clickListener = (name, pressed, tpf) -> {
|
||||
if (!pressed || panel == null || tabBounds == null) return;
|
||||
Vector2f c = app.getInputManager().getCursorPosition();
|
||||
float[] v = toVirtual(app.getInputManager().getCursorPosition());
|
||||
for (int i = 0; i < tabBounds.length; i++) {
|
||||
float[] b = tabBounds[i];
|
||||
if (c.x >= b[0] && c.x <= b[0] + b[2] && c.y >= b[1] && c.y <= b[1] + b[3]) {
|
||||
if (v[0] >= b[0] && v[0] <= b[0] + b[2] && v[1] >= b[1] && v[1] <= b[1] + b[3]) {
|
||||
switchTab(tabOrder[i]);
|
||||
return;
|
||||
}
|
||||
@@ -186,8 +207,13 @@ public class InventoryState extends BaseAppState {
|
||||
// ── Haupt-Panel aufbauen ──────────────────────────────────────────────────
|
||||
|
||||
private void buildPanel() {
|
||||
float sw = app.getCamera().getWidth();
|
||||
float sh = app.getCamera().getHeight();
|
||||
float sw = MenuCanvas.REF_W;
|
||||
float sh = MenuCanvas.REF_H;
|
||||
|
||||
bgLayer = MenuCanvas.createBgLayer(assetManager, app.getCamera());
|
||||
canvasNode = MenuCanvas.createCanvas(app.getCamera());
|
||||
guiNode.attachChild(bgLayer);
|
||||
guiNode.attachChild(canvasNode);
|
||||
|
||||
// Panelgröße: 5 Spalten + Ränder
|
||||
float pw = COLS * (CELL_W + CELL_GAP) + CELL_GAP + 2 * PAD;
|
||||
@@ -196,8 +222,7 @@ public class InventoryState extends BaseAppState {
|
||||
float py = (sh - ph) / 2f;
|
||||
|
||||
panel = new Node("inv-panel");
|
||||
quad(panel, 0, 0, sw, sh, COL_OVERLAY, -20); // Verdunkelung
|
||||
quad(panel, px, py, pw, ph, COL_PANEL, -19); // Hauptpanel
|
||||
panel.attachChild(NinePatch.panel(assetManager).build(px, py, pw, ph, -19));
|
||||
quad(panel, px, py + ph - HDR_H, pw, HDR_H, COL_HDR, -18); // Header-Balken
|
||||
|
||||
// Titel
|
||||
@@ -213,7 +238,7 @@ public class InventoryState extends BaseAppState {
|
||||
// Tabs aufbauen
|
||||
buildTabs(px, py, pw, ph);
|
||||
|
||||
guiNode.attachChild(panel);
|
||||
canvasNode.attachChild(panel);
|
||||
}
|
||||
|
||||
private void buildTabs(float px, float py, float pw, float ph) {
|
||||
@@ -229,7 +254,8 @@ public class InventoryState extends BaseAppState {
|
||||
for (int i = 0; i < tabOrder.length; i++) {
|
||||
boolean active = tabOrder[i] == activeTab;
|
||||
float tx = tabX0 + i * tabW;
|
||||
quad(panel, tx, tabY, tabW - 4, TAB_H, active ? COL_TAB_ON : COL_TAB_OFF, -18);
|
||||
NinePatch tabPatch = active ? NinePatch.tabActive(assetManager) : NinePatch.tabInactive(assetManager);
|
||||
panel.attachChild(tabPatch.build(tx, tabY, tabW - 4, TAB_H, -18));
|
||||
BitmapText lbl = txt(catLabel(tabOrder[i]), 13, active ? COL_WHITE : COL_MUTED);
|
||||
lbl.setLocalTranslation(tx + (tabW - 4 - lbl.getLineWidth()) / 2f, tabY + TAB_H - 8, -17);
|
||||
panel.attachChild(lbl);
|
||||
@@ -341,9 +367,7 @@ public class InventoryState extends BaseAppState {
|
||||
// ── Einzel-Zelle ──────────────────────────────────────────────────────────
|
||||
|
||||
private void buildCell(Node parent, Item item, int count, float x, float y) {
|
||||
// Zell-Hintergrund + Rand
|
||||
quad(parent, x, y, CELL_W, CELL_H, COL_CELL_FRAME, -18);
|
||||
quad(parent, x + 1, y + 1, CELL_W - 2, CELL_H - 2, COL_CELL, -17);
|
||||
parent.attachChild(NinePatch.itemCell(assetManager).build(x, y, CELL_W, CELL_H, -18));
|
||||
|
||||
// Thumbnail
|
||||
float thumbX = x + (CELL_W - THUMB_SZ) / 2f;
|
||||
@@ -415,8 +439,18 @@ public class InventoryState extends BaseAppState {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private float[] toVirtual(Vector2f screen) {
|
||||
float scale = Math.min(app.getCamera().getWidth() / MenuCanvas.REF_W,
|
||||
app.getCamera().getHeight() / MenuCanvas.REF_H);
|
||||
float ox = (app.getCamera().getWidth() - MenuCanvas.REF_W * scale) / 2f;
|
||||
float oy = (app.getCamera().getHeight() - MenuCanvas.REF_H * scale) / 2f;
|
||||
return new float[]{ (screen.x - ox) / scale, (screen.y - oy) / scale };
|
||||
}
|
||||
|
||||
private void destroyPanel() {
|
||||
if (panel != null) { guiNode.detachChild(panel); panel = null; gridNode = null; }
|
||||
if (bgLayer != null) { guiNode.detachChild(bgLayer); bgLayer = null; }
|
||||
if (canvasNode != null) { guiNode.detachChild(canvasNode); canvasNode = null; }
|
||||
panel = null; gridNode = null;
|
||||
}
|
||||
|
||||
private Geometry quad(Node parent, float x, float y, float w, float h, ColorRGBA col, float z) {
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package de.blight.game.state;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.BaseAppState;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.material.RenderState;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import de.blight.game.control.PlayerInputControl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Neues-Spiel-Intro: Schwarzer Bildschirm → Einblenden (Ton + Bild) → REVIVE-Animation → IDLE.
|
||||
*
|
||||
* Phasen:
|
||||
* BLACK (3 s) – voller schwarzer Schirm, keine Eingaben (IDLE läuft, nicht sichtbar)
|
||||
* FADING_IN (3 s) – Alpha und Listener-Lautstärke 0→1
|
||||
* REVIVE_PLAYING – schwarzer Schirm weg, Animation läuft durch
|
||||
* DONE – Eingaben freigegeben, State entfernt sich selbst
|
||||
*/
|
||||
public class NewGameIntroState extends BaseAppState {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NewGameIntroState.class);
|
||||
|
||||
private static final float BLACK_DURATION = 3f;
|
||||
private static final float FADE_DURATION = 3f;
|
||||
|
||||
private enum Phase { BLACK, FADING_IN, REVIVE_PLAYING, DONE }
|
||||
|
||||
private final PlayerInputControl playerInput;
|
||||
private final String reviveClip;
|
||||
private final float reviveLength;
|
||||
|
||||
private SimpleApplication app;
|
||||
private Geometry overlay;
|
||||
private Material overlayMat;
|
||||
|
||||
private Phase phase;
|
||||
private float timer;
|
||||
|
||||
public NewGameIntroState(PlayerInputControl playerInput, String reviveClip, float reviveLength) {
|
||||
this.playerInput = playerInput;
|
||||
this.reviveClip = reviveClip;
|
||||
this.reviveLength = reviveLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize(Application application) {
|
||||
app = (SimpleApplication) application;
|
||||
|
||||
float w = app.getCamera().getWidth();
|
||||
float h = app.getCamera().getHeight();
|
||||
Quad quad = new Quad(w, h);
|
||||
overlay = new Geometry("intro_overlay", quad);
|
||||
overlayMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
overlayMat.setColor("Color", new ColorRGBA(0f, 0f, 0f, 1f));
|
||||
overlayMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||
overlay.setMaterial(overlayMat);
|
||||
overlay.setQueueBucket(RenderQueue.Bucket.Gui);
|
||||
app.getGuiNode().attachChild(overlay);
|
||||
|
||||
app.getListener().setVolume(0f);
|
||||
|
||||
if (reviveClip != null) {
|
||||
playerInput.blockForIntro();
|
||||
phase = Phase.BLACK;
|
||||
timer = BLACK_DURATION;
|
||||
log.info("[NewGameIntro] Gestartet – REVIVE='{}' ({} s), Inputs blockiert", reviveClip, reviveLength);
|
||||
} else {
|
||||
log.warn("[NewGameIntro] Kein REVIVE-Clip – Intro übersprungen.");
|
||||
app.getGuiNode().detachChild(overlay);
|
||||
app.getListener().setVolume(1f);
|
||||
playerInput.unblockInputs();
|
||||
phase = Phase.DONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
switch (phase) {
|
||||
case BLACK -> {
|
||||
timer -= tpf;
|
||||
if (timer <= 0f) {
|
||||
// REVIVE unmittelbar vor dem Einblenden einfrieren
|
||||
playerInput.startFrozenRevive(reviveClip);
|
||||
phase = Phase.FADING_IN;
|
||||
timer = FADE_DURATION;
|
||||
log.info("[NewGameIntro] BLACK fertig – REVIVE eingefroren, starte FADING_IN ({} s)", FADE_DURATION);
|
||||
}
|
||||
}
|
||||
case FADING_IN -> {
|
||||
timer -= tpf;
|
||||
float alpha = Math.max(0f, timer / FADE_DURATION);
|
||||
overlayMat.setColor("Color", new ColorRGBA(0f, 0f, 0f, alpha));
|
||||
app.getListener().setVolume(1f - alpha);
|
||||
|
||||
if (timer <= 0f) {
|
||||
app.getGuiNode().detachChild(overlay);
|
||||
overlay = null;
|
||||
app.getListener().setVolume(1f);
|
||||
playerInput.unfreezeRevive();
|
||||
timer = reviveLength;
|
||||
phase = Phase.REVIVE_PLAYING;
|
||||
log.info("[NewGameIntro] Eingeblendet – REVIVE läuft ({} s)", reviveLength);
|
||||
}
|
||||
}
|
||||
case REVIVE_PLAYING -> {
|
||||
timer -= tpf;
|
||||
if (timer <= 0f) {
|
||||
playerInput.unblockInputs();
|
||||
phase = Phase.DONE;
|
||||
log.info("[NewGameIntro] REVIVE abgeschlossen – Eingaben freigegeben");
|
||||
}
|
||||
}
|
||||
case DONE -> getApplication().getStateManager().detach(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup(Application application) {
|
||||
if (overlay != null && overlay.getParent() != null) {
|
||||
app.getGuiNode().detachChild(overlay);
|
||||
}
|
||||
app.getListener().setVolume(1f);
|
||||
}
|
||||
|
||||
@Override protected void onEnable() {}
|
||||
@Override protected void onDisable() {}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package de.blight.game.state;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.BaseAppState;
|
||||
import com.jme3.audio.AudioData;
|
||||
import com.jme3.audio.AudioNode;
|
||||
import com.jme3.math.Vector3f;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Spielt Wellensounds positional ab. Die AudioNodes werden EINMALIG nach dem
|
||||
* ersten gültigen Scan positioniert (vermeidet den initialen Sprung von (0,0,0)
|
||||
* zur Ozean-Kante, der OpenAL-Knistern verursacht). Danach wird die Position
|
||||
* nur noch alle SCAN_INTERVAL Sekunden aktualisiert, wenn sich der Ozean
|
||||
* signifikant verschoben hat.
|
||||
*/
|
||||
public class OceanSoundState extends BaseAppState {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OceanSoundState.class);
|
||||
|
||||
private static final float MAX_DIST = 60f;
|
||||
private static final float REF_DIST = 8f;
|
||||
private static final float WIND_THRESHOLD = 20f;
|
||||
private static final float FADE_RATE = 1f / 3f;
|
||||
private static final float SCAN_INTERVAL = 0.25f;
|
||||
private static final float SCAN_STEP = 5f;
|
||||
/** Mindestverschiebung (m²) bevor die Node-Position aktualisiert wird. */
|
||||
private static final float POS_UPDATE_SQ = 4f * 4f; // 4 Meter
|
||||
|
||||
private static final float[] DIR_X = { 0f, 0.707f, 1f, 0.707f, 0f, -0.707f, -1f, -0.707f };
|
||||
private static final float[] DIR_Z = { 1f, 0.707f, 0f, -0.707f, -1f, -0.707f, 0f, 0.707f };
|
||||
|
||||
private final TerrainChunkState terrain;
|
||||
|
||||
private SimpleApplication app;
|
||||
private AudioNode nodeCalmSound;
|
||||
private AudioNode nodeStormySound;
|
||||
|
||||
private final Vector3f playerPos = new Vector3f();
|
||||
private final Vector3f targetPos = new Vector3f();
|
||||
private final Vector3f nodePos = new Vector3f(); // zuletzt gesetzte Node-Position
|
||||
|
||||
/** true bis der erste gültige Scan die Nodes positioniert und abgespielt hat. */
|
||||
private boolean firstScan = true;
|
||||
private boolean playing = false;
|
||||
|
||||
private float calmVol = 0f;
|
||||
private float stormyVol = 0f;
|
||||
private float scanTimer = 0f;
|
||||
private boolean oceanInRange = false;
|
||||
private float oceanDist = Float.MAX_VALUE;
|
||||
|
||||
public OceanSoundState(TerrainChunkState terrain) {
|
||||
this.terrain = terrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize(Application application) {
|
||||
app = (SimpleApplication) application;
|
||||
nodeCalmSound = loadLoop("audio/ambient/water/waves_calm.ogg", "waves_calm");
|
||||
nodeStormySound = loadLoop("audio/ambient/water/waves_stormy.ogg", "waves_stormy");
|
||||
// Noch NICHT abspielen – erst wenn wir eine gültige Position haben (firstScan).
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup(Application application) {
|
||||
stop(nodeCalmSound);
|
||||
stop(nodeStormySound);
|
||||
}
|
||||
|
||||
@Override protected void onEnable() {}
|
||||
@Override protected void onDisable() {}
|
||||
|
||||
public void setPlayerPosition(Vector3f pos) {
|
||||
playerPos.set(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
if (nodeCalmSound == null && nodeStormySound == null) return;
|
||||
|
||||
// Periodisch nächste Ozean-Position berechnen
|
||||
scanTimer -= tpf;
|
||||
if (scanTimer <= 0f) {
|
||||
scanTimer = SCAN_INTERVAL;
|
||||
scanOceanSource();
|
||||
}
|
||||
|
||||
// Lautstärke
|
||||
WeatherState weather = getApplication().getStateManager().getState(WeatherState.class);
|
||||
float wind = weather != null ? weather.getWindSpeed() : 4f;
|
||||
|
||||
AudioSettingsState audioSettings = getApplication().getStateManager().getState(AudioSettingsState.class);
|
||||
float scale = audioSettings != null ? audioSettings.effectiveAmbient() : 0.5f;
|
||||
|
||||
float distScale = oceanInRange
|
||||
? Math.max(0f, 1f - Math.max(0f, oceanDist - REF_DIST) / (MAX_DIST - REF_DIST))
|
||||
: 0f;
|
||||
|
||||
float calmTarget = (oceanInRange && wind < WIND_THRESHOLD) ? scale * distScale : 0f;
|
||||
float stormyTarget = (oceanInRange && wind >= WIND_THRESHOLD) ? scale * distScale : 0f;
|
||||
|
||||
calmVol = approach(calmVol, calmTarget, FADE_RATE * tpf);
|
||||
stormyVol = approach(stormyVol, stormyTarget, FADE_RATE * tpf);
|
||||
|
||||
if (nodeCalmSound != null) nodeCalmSound.setVolume(calmVol);
|
||||
if (nodeStormySound != null) nodeStormySound.setVolume(stormyVol);
|
||||
}
|
||||
|
||||
// ── Scan ────────────────────────────────────────────────────────────────
|
||||
|
||||
private void scanOceanSource() {
|
||||
float px = playerPos.x;
|
||||
float pz = playerPos.z;
|
||||
|
||||
if (terrain.getHeightAt(px, pz) < 0f) {
|
||||
oceanInRange = true;
|
||||
oceanDist = 0f;
|
||||
applyTarget(px, pz);
|
||||
return;
|
||||
}
|
||||
|
||||
float minDist = Float.MAX_VALUE;
|
||||
float bestX = px, bestZ = pz;
|
||||
|
||||
for (int d = 0; d < 8; d++) {
|
||||
float dx = DIR_X[d];
|
||||
float dz = DIR_Z[d];
|
||||
for (float r = SCAN_STEP; r <= MAX_DIST + SCAN_STEP; r += SCAN_STEP) {
|
||||
if (terrain.getHeightAt(px + dx * r, pz + dz * r) < 0f) {
|
||||
float dist = r - SCAN_STEP;
|
||||
if (dist < minDist) {
|
||||
minDist = dist;
|
||||
bestX = px + dx * r;
|
||||
bestZ = pz + dz * r;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minDist >= MAX_DIST) {
|
||||
oceanInRange = false;
|
||||
oceanDist = Float.MAX_VALUE;
|
||||
} else {
|
||||
oceanInRange = true;
|
||||
oceanDist = minDist;
|
||||
applyTarget(bestX, bestZ);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zielposition setzen. Beim ersten Scan: Nodes positionieren und Wiedergabe starten.
|
||||
* Danach: Node nur aktualisieren wenn Verschiebung > POS_UPDATE_SQ.
|
||||
*/
|
||||
private void applyTarget(float x, float z) {
|
||||
targetPos.set(x, 0f, z);
|
||||
|
||||
if (firstScan) {
|
||||
// Beim ersten gültigen Scan: Nodes korrekt platzieren, dann erst abspielen.
|
||||
firstScan = false;
|
||||
nodePos.set(targetPos);
|
||||
if (nodeCalmSound != null) {
|
||||
app.getRootNode().attachChild(nodeCalmSound);
|
||||
nodeCalmSound.setLocalTranslation(nodePos);
|
||||
nodeCalmSound.play();
|
||||
}
|
||||
if (nodeStormySound != null) {
|
||||
app.getRootNode().attachChild(nodeStormySound);
|
||||
nodeStormySound.setLocalTranslation(nodePos);
|
||||
nodeStormySound.play();
|
||||
}
|
||||
playing = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playing) return;
|
||||
|
||||
// Nur aktualisieren wenn sich die Zielposition signifikant geändert hat
|
||||
float dxSq = (targetPos.x - nodePos.x);
|
||||
float dzSq = (targetPos.z - nodePos.z);
|
||||
if (dxSq * dxSq + dzSq * dzSq < POS_UPDATE_SQ) return;
|
||||
|
||||
nodePos.set(targetPos);
|
||||
if (nodeCalmSound != null) nodeCalmSound.setLocalTranslation(nodePos);
|
||||
if (nodeStormySound != null) nodeStormySound.setLocalTranslation(nodePos);
|
||||
}
|
||||
|
||||
// ── Hilfsmethoden ───────────────────────────────────────────────────────
|
||||
|
||||
private AudioNode loadLoop(String path, String label) {
|
||||
try {
|
||||
AudioNode n = new AudioNode(app.getAssetManager(), path, AudioData.DataType.Stream);
|
||||
n.setLooping(true);
|
||||
n.setVolume(0f);
|
||||
n.setPositional(true);
|
||||
n.setRefDistance(REF_DIST);
|
||||
n.setMaxDistance(MAX_DIST);
|
||||
return n;
|
||||
} catch (Exception e) {
|
||||
log.warn("[OceanSound] {} nicht ladbar: {}", label, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void stop(AudioNode node) {
|
||||
if (node != null) {
|
||||
node.stop();
|
||||
if (node.getParent() != null) app.getRootNode().detachChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
private static float approach(float cur, float target, float maxStep) {
|
||||
float d = target - cur;
|
||||
return Math.abs(d) <= maxStep ? target : cur + Math.signum(d) * maxStep;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.Spatial;
|
||||
import de.blight.common.PlacedModel;
|
||||
import de.blight.common.PlacedModelIO;
|
||||
@@ -82,7 +83,8 @@ public class WorldInteractableState extends BaseAppState {
|
||||
private record InteractableEntry(
|
||||
float worldX, float worldY, float worldZ,
|
||||
InteractableType type,
|
||||
String interactableId
|
||||
String interactableId,
|
||||
String labelKey
|
||||
) {}
|
||||
|
||||
private final List<InteractableEntry> entries = new ArrayList<>();
|
||||
@@ -98,6 +100,9 @@ public class WorldInteractableState extends BaseAppState {
|
||||
WALKING_BACK
|
||||
}
|
||||
|
||||
private Camera cam;
|
||||
private int hoveredIdx = -1;
|
||||
|
||||
private Phase phase = Phase.IDLE;
|
||||
private int targetIdx = -1;
|
||||
private float walkTimer = 0f;
|
||||
@@ -122,13 +127,20 @@ public class WorldInteractableState extends BaseAppState {
|
||||
@Override
|
||||
protected void initialize(Application app) {
|
||||
this.inputManager = app.getInputManager();
|
||||
this.cam = app.getCamera();
|
||||
try {
|
||||
List<PlacedModel> models = PlacedModelIO.load();
|
||||
for (PlacedModel m : models) {
|
||||
if (m.interactableType() == null || m.interactableType().isBlank()) continue;
|
||||
InteractableType t = InteractableType.fromString(m.interactableType());
|
||||
if (t == InteractableType.BED || t == InteractableType.BENCH) {
|
||||
entries.add(new InteractableEntry(m.x(), m.y(), m.z(), t, m.interactableId()));
|
||||
if (t == InteractableType.BENCH) {
|
||||
Bench b = BenchIO.load(m.interactableId()).orElse(null);
|
||||
String lk = b != null ? b.getLabelKey() : "interactable.bench.name";
|
||||
entries.add(new InteractableEntry(m.x(), m.y(), m.z(), t, m.interactableId(), lk));
|
||||
} else if (t == InteractableType.BED) {
|
||||
Bed b = BedIO.load(m.interactableId()).orElse(null);
|
||||
String lk = b != null ? b.getLabelKey() : "interactable.bed.name";
|
||||
entries.add(new InteractableEntry(m.x(), m.y(), m.z(), t, m.interactableId(), lk));
|
||||
}
|
||||
}
|
||||
log.info("[WorldInteractable] {} Interactables geladen.", entries.size());
|
||||
@@ -158,6 +170,7 @@ public class WorldInteractableState extends BaseAppState {
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
updateHover();
|
||||
if (phase == Phase.WALKING_BACK) walkTimer += tpf;
|
||||
if (benchPendingId != null) {
|
||||
benchPendingTimer += tpf;
|
||||
@@ -183,6 +196,58 @@ public class WorldInteractableState extends BaseAppState {
|
||||
startGetUp();
|
||||
};
|
||||
|
||||
// ── Hover-Erkennung ───────────────────────────────────────────────────────
|
||||
|
||||
private void updateHover() {
|
||||
if (phase != Phase.IDLE || cam == null) {
|
||||
hoveredIdx = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3f charPos = physicsChar.getPhysicsLocation();
|
||||
float centerX = cam.getWidth() * 0.5f;
|
||||
float hMargin = cam.getWidth() * 0.10f;
|
||||
float screenH = cam.getHeight();
|
||||
|
||||
int bestIdx = -1;
|
||||
float bestDist = Float.MAX_VALUE;
|
||||
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
InteractableEntry e = entries.get(i);
|
||||
float dx = e.worldX() - charPos.x;
|
||||
float dz = e.worldZ() - charPos.z;
|
||||
float d = (float) Math.sqrt(dx * dx + dz * dz);
|
||||
float range = (e.type() == InteractableType.BENCH) ? BENCH_RANGE : BED_RANGE;
|
||||
if (d > range) continue;
|
||||
|
||||
Vector3f worldPos = new Vector3f(e.worldX(), e.worldY(), e.worldZ());
|
||||
Vector3f camToEntry = worldPos.subtract(cam.getLocation());
|
||||
if (camToEntry.dot(cam.getDirection()) <= 0f) continue;
|
||||
|
||||
Vector3f screen = cam.getScreenCoordinates(worldPos);
|
||||
if (Math.abs(screen.x - centerX) > hMargin) continue;
|
||||
if (screen.y < 0f || screen.y > screenH) continue;
|
||||
|
||||
if (d < bestDist) {
|
||||
bestDist = d;
|
||||
bestIdx = i;
|
||||
}
|
||||
}
|
||||
|
||||
hoveredIdx = bestIdx;
|
||||
}
|
||||
|
||||
public String getHoveredLabelKey() {
|
||||
if (hoveredIdx < 0 || hoveredIdx >= entries.size()) return null;
|
||||
return entries.get(hoveredIdx).labelKey();
|
||||
}
|
||||
|
||||
public Vector3f getHoveredWorldPos() {
|
||||
if (hoveredIdx < 0 || hoveredIdx >= entries.size()) return null;
|
||||
InteractableEntry e = entries.get(hoveredIdx);
|
||||
return new Vector3f(e.worldX(), e.worldY(), e.worldZ());
|
||||
}
|
||||
|
||||
// ── Suche nächstes Interactable ───────────────────────────────────────────
|
||||
|
||||
private int findNearestInRange() {
|
||||
|
||||
@@ -342,6 +342,19 @@ public class WorldItemsState extends BaseAppState {
|
||||
return def != null ? def.getDisplayText() : pi.itemId();
|
||||
}
|
||||
|
||||
public String getHoveredLabelKey() {
|
||||
if (hoveredIdx < 0 || hoveredIdx >= items.size()) return null;
|
||||
PlacedItem pi = items.get(hoveredIdx);
|
||||
Item def = itemDefs.get(pi.itemId());
|
||||
return def != null ? def.getLabelKey() : (pi.itemId() != null ? "item." + pi.itemId() + ".name" : "");
|
||||
}
|
||||
|
||||
public Vector3f getHoveredWorldPos() {
|
||||
if (hoveredIdx < 0 || hoveredIdx >= items.size()) return null;
|
||||
PlacedItem pi = items.get(hoveredIdx);
|
||||
return new Vector3f(pi.x(), pi.y() + 0.25f, pi.z());
|
||||
}
|
||||
|
||||
// ── Pickup-Sequenz ────────────────────────────────────────────────────────
|
||||
|
||||
private void updateWalking(float tpf) {
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
package de.blight.game.state;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.state.BaseAppState;
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.asset.plugins.FileLocator;
|
||||
import com.jme3.bullet.control.CharacterControl;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.*;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.*;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import de.blight.common.PlacedModel;
|
||||
import de.blight.common.PlacedModelIO;
|
||||
import de.blight.common.model.*;
|
||||
import de.blight.game.animation.AnimationLibrary;
|
||||
import de.blight.game.config.KeyBindings;
|
||||
import de.blight.game.control.PlayerInputControl;
|
||||
import de.blight.game.state.TerrainChunkState;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Platziert NPCs in der Spielwelt anhand ihrer Tagesablauf-Routinen.
|
||||
*
|
||||
* Jeder NPC hat eine aktive Routine mit zeitgebundenen Aktivitäten.
|
||||
* Der State ermittelt fortlaufend die Soll-Position jedes NPCs für die aktuelle
|
||||
* Spielstunde und lädt/entlädt den visuellen Repräsentanten je nach Spieler-Nähe.
|
||||
*/
|
||||
public class WorldNpcsState extends BaseAppState {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WorldNpcsState.class);
|
||||
|
||||
private static final float LOAD_RADIUS = 80f;
|
||||
private static final float UNLOAD_RADIUS = 100f;
|
||||
private static final float CHECK_INTERVAL = 2f;
|
||||
private static final float INTERACT_RANGE = 4f;
|
||||
private static final String INTERACT_ACTION = "InteractNpc";
|
||||
|
||||
// ── Abhängigkeiten ────────────────────────────────────────────────────────
|
||||
|
||||
private final KeyBindings keyBindings;
|
||||
private final CharacterControl physicsChar;
|
||||
private final PlayerInputControl playerInput;
|
||||
private final MainCharacter mainCharacter;
|
||||
|
||||
private SimpleApplication app;
|
||||
private AssetManager assets;
|
||||
private Camera cam;
|
||||
private Node rootNode;
|
||||
private Node npcsRoot;
|
||||
private DayNightState dayNight;
|
||||
private TerrainChunkState terrainChunks;
|
||||
|
||||
// ── NPC-Daten ─────────────────────────────────────────────────────────────
|
||||
|
||||
/** Alle NPCs die im Spiel existieren (geladen aus .character-Dateien). */
|
||||
private final List<NPC> allNpcs = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Position-Lookup für objekt-gebundene Aktivitäten (WORK, SLEEP, SIT@Interactable).
|
||||
* Schlüssel: interactableId des PlacedModel (= UUID der Bank/Bett/etc.).
|
||||
*/
|
||||
private final Map<String, Vector3f> interactablePositions = new HashMap<>();
|
||||
|
||||
/** Aktuell in der Welt gespawnte NPCs. */
|
||||
private final List<SpawnedNpc> spawned = new ArrayList<>();
|
||||
|
||||
private record SpawnedNpc(NPC npc, Spatial visual, float worldX, float worldZ) {}
|
||||
|
||||
// ── Periodischer Check ────────────────────────────────────────────────────
|
||||
|
||||
private float checkTimer = CHECK_INTERVAL; // sofortiger erster Check
|
||||
private int lastHour = -1;
|
||||
|
||||
// ── Hover + Dialog ────────────────────────────────────────────────────────
|
||||
|
||||
private int hoveredIdx = -1;
|
||||
private boolean dialogActive = false;
|
||||
|
||||
// ── Konstruktor ───────────────────────────────────────────────────────────
|
||||
|
||||
public WorldNpcsState(KeyBindings keyBindings, CharacterControl physicsChar,
|
||||
PlayerInputControl playerInput, MainCharacter mainCharacter) {
|
||||
this.keyBindings = keyBindings;
|
||||
this.physicsChar = physicsChar;
|
||||
this.playerInput = playerInput;
|
||||
this.mainCharacter = mainCharacter;
|
||||
}
|
||||
|
||||
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
||||
|
||||
@Override
|
||||
protected void initialize(Application app) {
|
||||
this.app = (SimpleApplication) app;
|
||||
this.assets = app.getAssetManager();
|
||||
this.cam = app.getCamera();
|
||||
this.rootNode = this.app.getRootNode();
|
||||
this.npcsRoot = new Node("npcsRoot");
|
||||
|
||||
try {
|
||||
assets.registerLocator(
|
||||
AnimationLibrary.findAssetRoot().toAbsolutePath().toString(),
|
||||
FileLocator.class);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
dayNight = getStateManager().getState(DayNightState.class);
|
||||
terrainChunks = getStateManager().getState(TerrainChunkState.class);
|
||||
|
||||
loadAllNpcs();
|
||||
buildInteractablePositions();
|
||||
|
||||
rootNode.attachChild(npcsRoot);
|
||||
|
||||
app.getInputManager().addMapping(INTERACT_ACTION, new KeyTrigger(keyBindings.interact));
|
||||
app.getInputManager().addListener(interactListener, INTERACT_ACTION);
|
||||
|
||||
checkTimer = CHECK_INTERVAL; // sofortiger erster Check im nächsten Frame
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
allNpcs.clear();
|
||||
interactablePositions.clear();
|
||||
spawned.clear();
|
||||
npcsRoot.detachAllChildren();
|
||||
npcsRoot.removeFromParent();
|
||||
hoveredIdx = -1;
|
||||
dialogActive = false;
|
||||
try { app.getInputManager().removeListener(interactListener); } catch (Exception ignored) {}
|
||||
try { app.getInputManager().deleteMapping(INTERACT_ACTION); } catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup(Application app) {}
|
||||
|
||||
// ── Update ────────────────────────────────────────────────────────────────
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
checkTimer += tpf;
|
||||
|
||||
int currentHour = dayNight != null ? dayNight.getDayTime().getHour() : 12;
|
||||
boolean hourChanged = currentHour != lastHour;
|
||||
|
||||
if (checkTimer >= CHECK_INTERVAL || hourChanged) {
|
||||
checkTimer = 0f;
|
||||
lastHour = currentHour;
|
||||
updateSpawnedNpcs(currentHour);
|
||||
}
|
||||
|
||||
if (!dialogActive) {
|
||||
updateHover();
|
||||
}
|
||||
}
|
||||
|
||||
// ── Spawn-Logik ───────────────────────────────────────────────────────────
|
||||
|
||||
private void updateSpawnedNpcs(int currentHour) {
|
||||
Vector3f playerPos = physicsChar.getPhysicsLocation();
|
||||
|
||||
// Bestehende NPCs prüfen: Position aktualisieren oder entladen
|
||||
List<SpawnedNpc> toRemove = new ArrayList<>();
|
||||
for (SpawnedNpc s : spawned) {
|
||||
Vector3f pos = resolveRoutinePosition(s.npc(), currentHour);
|
||||
float dist = pos != null ? dist2d(playerPos, pos) : Float.MAX_VALUE;
|
||||
|
||||
if (pos == null || dist > UNLOAD_RADIUS) {
|
||||
s.visual().removeFromParent();
|
||||
toRemove.add(s);
|
||||
} else {
|
||||
// Position aktualisieren wenn sich die Stunde geändert hat
|
||||
s.visual().setLocalTranslation(pos);
|
||||
}
|
||||
}
|
||||
spawned.removeAll(toRemove);
|
||||
|
||||
// IDs der bereits gespawnten NPCs für schnelle Prüfung
|
||||
Set<String> spawnedIds = new HashSet<>();
|
||||
for (SpawnedNpc s : spawned) {
|
||||
spawnedIds.add(s.npc().getCharacterId());
|
||||
}
|
||||
|
||||
// Neue NPCs einladen wenn in Reichweite
|
||||
for (NPC npc : allNpcs) {
|
||||
if (spawnedIds.contains(npc.getCharacterId())) continue;
|
||||
Vector3f pos = resolveRoutinePosition(npc, currentHour);
|
||||
if (pos == null) continue;
|
||||
if (dist2d(playerPos, pos) > LOAD_RADIUS) continue;
|
||||
|
||||
Spatial vis = buildVisual(npc);
|
||||
vis.setLocalTranslation(pos);
|
||||
npcsRoot.attachChild(vis);
|
||||
spawned.add(new SpawnedNpc(npc, vis, pos.x, pos.z));
|
||||
log.debug("[WorldNpcs] NPC '{}' gespawnt bei ({}, {})", npc.getCharacterId(), pos.x, pos.z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt die Weltposition eines NPCs für die angegebene Stunde
|
||||
* anhand seiner aktiven Routine.
|
||||
* Gibt null zurück wenn keine Position ermittelbar (keine Routine, keine Aktivität,
|
||||
* oder Aktivitäts-Objekt nicht gefunden).
|
||||
*/
|
||||
private Vector3f resolveRoutinePosition(NPC npc, int hour) {
|
||||
NpcRoutine routine = npc.getActiveRoutine();
|
||||
if (routine == null || routine.getBlocks() == null) return null;
|
||||
|
||||
RoutineBlock block = null;
|
||||
for (RoutineBlock b : routine.getBlocks()) {
|
||||
if (b.covers(hour)) { block = b; break; }
|
||||
}
|
||||
if (block == null || block.getActivity() == null) return null;
|
||||
|
||||
RoutineActivity act = block.getActivity();
|
||||
return switch (act.getType()) {
|
||||
case STAND, TALK -> worldPointToVec(act.getPosition());
|
||||
case SIT -> {
|
||||
if (act.getObjectUuid() != null && !act.getObjectUuid().isBlank()) {
|
||||
yield interactablePositions.get(act.getObjectUuid());
|
||||
}
|
||||
yield worldPointToVec(act.getPosition());
|
||||
}
|
||||
case PATROL -> {
|
||||
List<WorldPoint> wps = act.getWaypoints();
|
||||
if (wps == null || wps.isEmpty()) yield null;
|
||||
// Einfache Näherung: ersten Wegpunkt nehmen
|
||||
// TODO: NPC entlang der Wegpunkte animieren
|
||||
yield worldPointToVec(wps.get(0));
|
||||
}
|
||||
case WORK, SLEEP -> {
|
||||
if (act.getObjectUuid() == null || act.getObjectUuid().isBlank()) yield null;
|
||||
yield interactablePositions.get(act.getObjectUuid());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// ── Hover-Erkennung ───────────────────────────────────────────────────────
|
||||
|
||||
private void updateHover() {
|
||||
if (cam == null) { hoveredIdx = -1; return; }
|
||||
|
||||
Vector3f charPos = physicsChar.getPhysicsLocation();
|
||||
float centerX = cam.getWidth() * 0.5f;
|
||||
float hMargin = cam.getWidth() * 0.10f;
|
||||
float screenH = cam.getHeight();
|
||||
|
||||
int bestIdx = -1;
|
||||
float bestDist = Float.MAX_VALUE;
|
||||
|
||||
for (int i = 0; i < spawned.size(); i++) {
|
||||
SpawnedNpc s = spawned.get(i);
|
||||
Vector3f pos = s.visual().getLocalTranslation();
|
||||
|
||||
float dx = pos.x - charPos.x;
|
||||
float dz = pos.z - charPos.z;
|
||||
float d = (float) Math.sqrt(dx * dx + dz * dz);
|
||||
if (d > INTERACT_RANGE) continue;
|
||||
|
||||
Vector3f headPos = pos.add(0f, 1.5f, 0f);
|
||||
Vector3f camToHead = headPos.subtract(cam.getLocation());
|
||||
if (camToHead.dot(cam.getDirection()) <= 0f) continue;
|
||||
|
||||
Vector3f screen = cam.getScreenCoordinates(headPos);
|
||||
if (Math.abs(screen.x - centerX) > hMargin) continue;
|
||||
if (screen.y < 0f || screen.y > screenH) continue;
|
||||
|
||||
if (d < bestDist) { bestDist = d; bestIdx = i; }
|
||||
}
|
||||
|
||||
hoveredIdx = bestIdx;
|
||||
}
|
||||
|
||||
// ── Listener ─────────────────────────────────────────────────────────────
|
||||
|
||||
private final ActionListener interactListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed || dialogActive || hoveredIdx < 0) return;
|
||||
startDialog(hoveredIdx);
|
||||
};
|
||||
|
||||
private void startDialog(int idx) {
|
||||
SpawnedNpc entry = spawned.get(idx);
|
||||
DialogHudState dialog = getApplication().getStateManager().getState(DialogHudState.class);
|
||||
if (dialog == null) return;
|
||||
|
||||
dialogActive = true;
|
||||
playerInput.lockInPlace();
|
||||
|
||||
dialog.startDialog(entry.npc(), mainCharacter, () -> {
|
||||
dialogActive = false;
|
||||
playerInput.unlockFromPlace();
|
||||
});
|
||||
}
|
||||
|
||||
// ── Accessor für InteractionHudState ──────────────────────────────────────
|
||||
|
||||
public String getHoveredLabelKey() {
|
||||
if (hoveredIdx < 0 || hoveredIdx >= spawned.size()) return null;
|
||||
return spawned.get(hoveredIdx).npc().getLabelKey();
|
||||
}
|
||||
|
||||
public Vector3f getHoveredWorldPos() {
|
||||
if (hoveredIdx < 0 || hoveredIdx >= spawned.size()) return null;
|
||||
Vector3f pos = spawned.get(hoveredIdx).visual().getLocalTranslation();
|
||||
return pos.add(0f, 1.5f, 0f);
|
||||
}
|
||||
|
||||
// ── Hilfsmethoden ────────────────────────────────────────────────────────
|
||||
|
||||
private void loadAllNpcs() {
|
||||
allNpcs.clear();
|
||||
try {
|
||||
java.nio.file.Path charDir = AnimationLibrary.findAssetRoot().resolve("character");
|
||||
for (GameCharacter gc : CharacterIO.loadAll(charDir)) {
|
||||
if (gc instanceof NPC npc) {
|
||||
allNpcs.add(npc);
|
||||
}
|
||||
}
|
||||
log.info("[WorldNpcs] {} NPCs mit Routinen geladen.", allNpcs.size());
|
||||
} catch (Exception e) {
|
||||
log.warn("[WorldNpcs] Fehler beim Laden der NPCs: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void buildInteractablePositions() {
|
||||
interactablePositions.clear();
|
||||
try {
|
||||
List<PlacedModel> models = PlacedModelIO.load();
|
||||
for (PlacedModel m : models) {
|
||||
String id = m.interactableId();
|
||||
if (id != null && !id.isBlank()) {
|
||||
interactablePositions.put(id, new Vector3f(m.x(), m.y(), m.z()));
|
||||
}
|
||||
}
|
||||
log.debug("[WorldNpcs] {} Interactable-Positionen indexiert.", interactablePositions.size());
|
||||
} catch (Exception e) {
|
||||
log.warn("[WorldNpcs] Fehler beim Laden der Objekt-Positionen: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3f worldPointToVec(WorldPoint p) {
|
||||
if (p == null) return null;
|
||||
float y = p.y;
|
||||
// y == 0 bedeutet "Terrain-Höhe" → per TerrainChunkState auflösen
|
||||
if (y == 0f && terrainChunks != null) {
|
||||
y = terrainChunks.getHeightAt(p.x, p.z);
|
||||
}
|
||||
return new Vector3f(p.x, y, p.z);
|
||||
}
|
||||
|
||||
private static float dist2d(Vector3f a, Vector3f b) {
|
||||
float dx = a.x - b.x;
|
||||
float dz = a.z - b.z;
|
||||
return (float) Math.sqrt(dx * dx + dz * dz);
|
||||
}
|
||||
|
||||
private Spatial buildVisual(NPC npc) {
|
||||
String modelPath = npc.getModelPath();
|
||||
if (modelPath != null && !modelPath.isBlank()) {
|
||||
try {
|
||||
Spatial model = assets.loadModel(modelPath);
|
||||
model.setName("npc_" + npc.getCharacterId());
|
||||
return model;
|
||||
} catch (Exception e) {
|
||||
log.warn("[WorldNpcs] Modell '{}' nicht ladbar – Platzhalter.", modelPath);
|
||||
}
|
||||
}
|
||||
// Platzhalter: Körper + Kopf
|
||||
Node ph = new Node("npc_" + npc.getCharacterId());
|
||||
Material bodyMat = new Material(assets, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
bodyMat.setColor("Color", new ColorRGBA(0.5f, 0.7f, 1.0f, 1f));
|
||||
Geometry body = new Geometry("body", new Box(0.25f, 0.6f, 0.25f));
|
||||
body.setMaterial(bodyMat);
|
||||
body.setLocalTranslation(0f, 0.85f, 0f);
|
||||
Material headMat = new Material(assets, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
headMat.setColor("Color", new ColorRGBA(1.0f, 0.85f, 0.7f, 1f));
|
||||
Geometry head = new Geometry("head", new Box(0.2f, 0.2f, 0.2f));
|
||||
head.setMaterial(headMat);
|
||||
head.setLocalTranslation(0f, 1.7f, 0f);
|
||||
ph.attachChild(body);
|
||||
ph.attachChild(head);
|
||||
return ph;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
# ── Dialog ───────────────────────────────────────────────────────────────────
|
||||
dialog.exit=Gespräch beenden
|
||||
dialog.hint.advance=► Rechtsklick für nächste Seite
|
||||
dialog.hint.continue=► Rechtsklick zum Weiter
|
||||
dialog.speaker.player=Spieler
|
||||
|
||||
# ── Interactables ─────────────────────────────────────────────────────────────
|
||||
interactable.bench.name=Bank
|
||||
interactable.bed.name=Bett
|
||||
|
||||
# ── Items ────────────────────────────────────────────────────────────────────
|
||||
item.driftwood.name=Treibholz
|
||||
item.driftwood.description=Ein ans Ufer gespültes Stück Holz. Könnte nützlich sein.
|
||||
@@ -16,3 +26,56 @@ quest.intro.success=Du hast einen Unterschlupf gefunden. Ruh dich aus — morgen
|
||||
# ── Dialog ───────────────────────────────────────────────────────────────────
|
||||
dialog.fisherman.greet.hero=Hallo? Ist da jemand?
|
||||
dialog.fisherman.greet.npc=Hier drüben! Dem Himmel sei Dank, du lebst noch.
|
||||
|
||||
# ── Hauptmenü ────────────────────────────────────────────────────────────────
|
||||
menu.main.btn.new_game=Neues Spiel
|
||||
menu.main.btn.continue=Fortsetzen
|
||||
menu.main.btn.load=Spiel laden
|
||||
menu.main.btn.options=Optionen
|
||||
menu.main.btn.quit=Beenden
|
||||
|
||||
# ── Pausemenü ────────────────────────────────────────────────────────────────
|
||||
menu.pause.title=PAUSE
|
||||
menu.pause.btn.graphics=Grafik
|
||||
menu.pause.btn.audio=Audio
|
||||
menu.pause.btn.controls=Steuerung
|
||||
menu.pause.btn.save=Speichern
|
||||
menu.pause.btn.quit=Beenden
|
||||
|
||||
# ── Grafikeinstellungen ───────────────────────────────────────────────────────
|
||||
menu.graphics.title=GRAFIKEINSTELLUNGEN
|
||||
menu.graphics.row.resolution=Auflösung
|
||||
menu.graphics.row.fullscreen=Vollbild
|
||||
menu.graphics.row.vsync=VSync
|
||||
menu.graphics.row.aa=Kantenglättung
|
||||
menu.graphics.val.on=An
|
||||
menu.graphics.val.off=Aus
|
||||
menu.graphics.btn.apply=Übernehmen
|
||||
menu.graphics.btn.cancel=Abbrechen
|
||||
|
||||
# ── Audioeinstellungen ────────────────────────────────────────────────────────
|
||||
menu.audio.title=AUDIOEINSTELLUNGEN
|
||||
menu.audio.row.master=Gesamtlautstärke
|
||||
menu.audio.row.music=Musik
|
||||
menu.audio.row.speech=Sprache
|
||||
menu.audio.row.effects=Effekte
|
||||
menu.audio.row.ambient=Ambient
|
||||
menu.audio.btn.apply=Übernehmen
|
||||
menu.audio.btn.cancel=Abbrechen
|
||||
|
||||
# ── Tastenbelegung ────────────────────────────────────────────────────────────
|
||||
menu.controls.title=TASTENBELEGUNG
|
||||
menu.controls.hint=Klicke eine Taste um sie neu zu belegen
|
||||
menu.controls.btn.save=Speichern
|
||||
menu.controls.btn.cancel=Abbrechen
|
||||
|
||||
key.forward=Vorwärts
|
||||
key.backward=Rückwärts
|
||||
key.left=Links
|
||||
key.right=Rechts
|
||||
key.jump=Springen
|
||||
key.sprint=Rennen
|
||||
key.walk=Gehen
|
||||
key.interact=Interagieren
|
||||
key.inventory=Inventar
|
||||
key.quicksave=Schnellspeichern
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# ── Dialog ───────────────────────────────────────────────────────────────────
|
||||
dialog.exit=End conversation
|
||||
dialog.hint.advance=► Right-click for next page
|
||||
dialog.hint.continue=► Right-click to continue
|
||||
dialog.speaker.player=Player
|
||||
|
||||
# ── Interactables ─────────────────────────────────────────────────────────────
|
||||
interactable.bench.name=Bench
|
||||
interactable.bed.name=Bed
|
||||
|
||||
# ── Items ────────────────────────────────────────────────────────────────────
|
||||
item.driftwood.name=Driftwood
|
||||
item.driftwood.description=A piece of wood washed ashore. Could be useful.
|
||||
@@ -16,3 +26,56 @@ quest.intro.success=You have found shelter. Rest now — tomorrow brings new dan
|
||||
# ── Dialog ───────────────────────────────────────────────────────────────────
|
||||
dialog.fisherman.greet.hero=Hello? Is someone there?
|
||||
dialog.fisherman.greet.npc=Over here! Thank the gods you are alive.
|
||||
|
||||
# ── Main Menu ─────────────────────────────────────────────────────────────────
|
||||
menu.main.btn.new_game=New Game
|
||||
menu.main.btn.continue=Continue
|
||||
menu.main.btn.load=Load Game
|
||||
menu.main.btn.options=Options
|
||||
menu.main.btn.quit=Quit
|
||||
|
||||
# ── Pause Menu ────────────────────────────────────────────────────────────────
|
||||
menu.pause.title=PAUSE
|
||||
menu.pause.btn.graphics=Graphics
|
||||
menu.pause.btn.audio=Audio
|
||||
menu.pause.btn.controls=Controls
|
||||
menu.pause.btn.save=Save
|
||||
menu.pause.btn.quit=Quit
|
||||
|
||||
# ── Graphics Settings ─────────────────────────────────────────────────────────
|
||||
menu.graphics.title=GRAPHICS SETTINGS
|
||||
menu.graphics.row.resolution=Resolution
|
||||
menu.graphics.row.fullscreen=Fullscreen
|
||||
menu.graphics.row.vsync=VSync
|
||||
menu.graphics.row.aa=Anti-aliasing
|
||||
menu.graphics.val.on=On
|
||||
menu.graphics.val.off=Off
|
||||
menu.graphics.btn.apply=Apply
|
||||
menu.graphics.btn.cancel=Cancel
|
||||
|
||||
# ── Audio Settings ────────────────────────────────────────────────────────────
|
||||
menu.audio.title=AUDIO SETTINGS
|
||||
menu.audio.row.master=Master Volume
|
||||
menu.audio.row.music=Music
|
||||
menu.audio.row.speech=Speech
|
||||
menu.audio.row.effects=Effects
|
||||
menu.audio.row.ambient=Ambient
|
||||
menu.audio.btn.apply=Apply
|
||||
menu.audio.btn.cancel=Cancel
|
||||
|
||||
# ── Controls ─────────────────────────────────────────────────────────────────
|
||||
menu.controls.title=CONTROLS
|
||||
menu.controls.hint=Click a key to rebind it
|
||||
menu.controls.btn.save=Save
|
||||
menu.controls.btn.cancel=Cancel
|
||||
|
||||
key.forward=Forward
|
||||
key.backward=Backward
|
||||
key.left=Left
|
||||
key.right=Right
|
||||
key.jump=Jump
|
||||
key.sprint=Sprint
|
||||
key.walk=Walk
|
||||
key.interact=Interact
|
||||
key.inventory=Inventory
|
||||
key.quicksave=Quick Save
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
# x y z r g b intensity radius
|
||||
138.57341 1.10000 209.24336 0.80000 1.00000 0.80000 12.00000 50.00000
|
||||
131.40373 1.10000 196.12698 0.80000 1.00000 0.80000 12.00000 50.00000
|
||||
143.96100 1.10000 194.25346 0.80000 1.00000 0.80000 12.00000 50.00000
|
||||
|
||||
@@ -2,7 +2,4 @@
|
||||
Models/imported/wooden+cabin+3d+model.j3o 105.61634 4.85395 58.69108 0.00000 1.00000 0.00000 0.00000 false true true 30.00000 80.00000 120.00000
|
||||
Models/trees/pine/medium/pine_medium_20260615_221703.j3o 96.87341 6.11813 51.96483 0.00000 1.00000 0.00000 0.00000 false true true 30.00000 80.00000 120.00000
|
||||
Models/trees/pine/medium/pine_medium_20260615_221707.j3o 110.91007 4.33700 50.56980 0.00000 1.00000 0.00000 0.00000 false true true 30.00000 80.00000 120.00000
|
||||
Models/imported/Höhlenkristall1.j3o 138.57341 1.00000 209.24336 0.64251 1.00000 0.00000 0.00000 true true true 30.00000 80.00000 120.00000
|
||||
Models/imported/Höhlenkristall1.j3o 131.40373 1.00000 196.12698 3.95943 1.00000 0.00000 0.00000 true true true 30.00000 80.00000 120.00000
|
||||
Models/imported/Höhlenkristall1.j3o 143.96100 1.00000 194.25346 4.02822 1.00000 0.00000 0.00000 true true true 30.00000 80.00000 120.00000
|
||||
Models/imported/bank1.j3o 106.96240 2.89958 70.01086 0.00000 1.00000 0.00000 0.00000 false true true 30.00000 80.00000 120.00000 BENCH 5be97ffb-e413-42e5-9815-9d14d1e3b93f
|
||||
|
||||