diff --git a/blight-editor/src/main/java/de/blight/editor/EditorApp.java b/blight-editor/src/main/java/de/blight/editor/EditorApp.java index 391f275..934f301 100644 --- a/blight-editor/src/main/java/de/blight/editor/EditorApp.java +++ b/blight-editor/src/main/java/de/blight/editor/EditorApp.java @@ -5409,6 +5409,9 @@ public class EditorApp extends Application { || input.activeLayer == SharedInput.LAYER_WATERFALL || input.activeLayer == SharedInput.LAYER_VOXEL_CLIFF)) input.cancelZoneDrawing = true; + else if (pressed && input.activeLayer == SharedInput.LAYER_OBJECTS + && "objecteditor".equals(registry.activeToolId())) + Platform.runLater(objectController::cancelPlacement); } case DELETE -> { if (pressed) { diff --git a/blight-editor/src/main/java/de/blight/editor/toolset/object/ObjectController.java b/blight-editor/src/main/java/de/blight/editor/toolset/object/ObjectController.java index 46b0d4b..aeac1e3 100644 --- a/blight-editor/src/main/java/de/blight/editor/toolset/object/ObjectController.java +++ b/blight-editor/src/main/java/de/blight/editor/toolset/object/ObjectController.java @@ -6,7 +6,6 @@ import de.blight.editor.ToolContext; import de.blight.editor.ToolController; import de.blight.editor.ui.TextureChooser; import javafx.geometry.Insets; -import javafx.geometry.Orientation; import javafx.geometry.Pos; import javafx.scene.control.*; import javafx.scene.layout.*; @@ -40,8 +39,6 @@ public class ObjectController implements ToolController { private Button objMergeBtn; private Button objSaveBtn; private Button objDeleteBtn; - private ToggleButton objPlaceBtn; - private ToggleButton objEditBtn; private ToggleButton selModeObjectBtn; private ToggleGroup meshToggleGroup; private Label randomTreeStatusLabel; @@ -61,7 +58,6 @@ public class ObjectController implements ToolController { @Override public void activate() { ctx.setCenterView().accept(ctx.viewportSupplier().get()); - ctx.setMainToolbar().accept(buildObjectEditorToolBar(pendingPlaceMode)); if (pendingPlaceMode) { ctx.input().activeLayer = SharedInput.LAYER_OBJECTS; ctx.setRightPanel().accept(buildObjectPlacePanel()); @@ -108,7 +104,10 @@ public class ObjectController implements ToolController { // ── Öffentliche API ───────────────────────────────────────────────────── public void activatePlaceMode() { - pendingPlaceMode = true; + // Place mode only when something is actually selected; otherwise fall back to edit mode + boolean hasSelection = (ctx.input().pendingModelPath != null && !ctx.input().pendingModelPath.isEmpty()) + || (ctx.input().treeFolderPath != null && !ctx.input().treeFolderPath.isEmpty()); + pendingPlaceMode = hasSelection; if (ctx.registry().getActive() == this) { activate(); } else { @@ -129,48 +128,26 @@ public class ObjectController implements ToolController { if (multiPlaceCB != null) multiPlaceCB.setSelected(true); } - /** Zeigt das Platzieren-Panel (ohne Toolbar-Wechsel – für Aufrufe aus dem Welt-Editor). */ + /** Zeigt das Platzieren-Panel. */ public void showPlacePanel() { + pendingPlaceMode = true; ctx.input().activeLayer = SharedInput.LAYER_OBJECTS; ctx.setRightPanel().accept(buildObjectPlacePanel()); - if (objPlaceBtn != null) objPlaceBtn.setSelected(true); } - /** Zeigt das Bearbeiten-Panel (ohne Toolbar-Wechsel). */ + /** Zeigt das Bearbeiten-Panel. */ public void showEditPanel() { + pendingPlaceMode = false; ctx.input().activeLayer = SharedInput.LAYER_OBJECTS_EDIT; ctx.input().pendingModelPath = null; ctx.setRightPanel().accept(buildObjectEditPanel()); - if (objEditBtn != null) objEditBtn.setSelected(true); } - // ── Toolbar ────────────────────────────────────────────────────────────── - - private ToolBar buildObjectEditorToolBar(boolean placeMode) { - Button backBtn = new Button("← Welteneditor"); - backBtn.setOnAction(e -> ctx.switchToWorld().run()); - - objPlaceBtn = new ToggleButton("+ Platzieren"); - objEditBtn = new ToggleButton("# Bearbeiten"); - objPlaceBtn.setStyle("-fx-font-weight: bold;"); - objEditBtn.setStyle("-fx-font-weight: bold;"); - - ToggleGroup objGroup = new ToggleGroup(); - objPlaceBtn.setToggleGroup(objGroup); - objEditBtn.setToggleGroup(objGroup); - if (placeMode) objPlaceBtn.setSelected(true); - else objEditBtn.setSelected(true); - - objPlaceBtn.setOnAction(e -> showPlacePanel()); - objEditBtn.setOnAction(e -> showEditPanel()); - - Label label = new Label("Objekt Editor"); - label.setStyle("-fx-font-weight: bold; -fx-font-size: 13;"); - ToolBar tb = new ToolBar(); - tb.getItems().addAll(backBtn, new Separator(Orientation.VERTICAL), - objPlaceBtn, objEditBtn, - new Separator(Orientation.VERTICAL), label); - return tb; + /** Hebt die Platzierungs-Auswahl auf und wechselt zum Selektier-Modus. */ + public void cancelPlacement() { + ctx.input().pendingModelPath = null; + ctx.input().treeFolderPath = null; + showEditPanel(); } // ── Platzieren-Panel ───────────────────────────────────────────────────── @@ -179,6 +156,12 @@ public class ObjectController implements ToolController { VBox inner = new VBox(8); inner.setPadding(new Insets(10)); + Button cancelBtn = new Button("✕ Auswahl aufheben [Esc]"); + cancelBtn.setMaxWidth(Double.MAX_VALUE); + cancelBtn.setStyle("-fx-background-color: #e8e8e8;"); + cancelBtn.setOnAction(e -> cancelPlacement()); + inner.getChildren().add(cancelBtn); + inner.getChildren().addAll(sectionTitle("Baum aus Ordner"), new Separator()); treeFolderCB = new ComboBox<>(); diff --git a/blight-game/src/main/java/de/blight/game/scene/WorldScene.java b/blight-game/src/main/java/de/blight/game/scene/WorldScene.java index 45e9233..39008d2 100644 --- a/blight-game/src/main/java/de/blight/game/scene/WorldScene.java +++ b/blight-game/src/main/java/de/blight/game/scene/WorldScene.java @@ -104,6 +104,7 @@ public class WorldScene extends BaseAppState { private de.blight.game.state.RiverSoundState riverSound; private de.blight.game.state.AmbientSoundSystem ambientSounds; private de.blight.game.state.MusicSystem musicSystem; + private de.blight.game.state.EmitterSystem emitterSystem; private de.blight.game.audio.FootstepSystem footstepSystem; private de.blight.game.state.DrownState drownState; private WaterInteractionState waterInteractionState; @@ -277,6 +278,8 @@ public class WorldScene extends BaseAppState { BlightGame.status("Lade Welt-Objekte..."); app.getStateManager().attach(new RiverState()); app.getStateManager().attach(new de.blight.game.state.WaterfallState()); + emitterSystem = new de.blight.game.state.EmitterSystem(); + app.getStateManager().attach(emitterSystem); WorldObjectsState worldObjects = new WorldObjectsState(); worldObjects.setLodFactor((float) graphicsSettings.viewDistance.lod0Range); app.getStateManager().attach(worldObjects); @@ -467,6 +470,7 @@ public class WorldScene extends BaseAppState { if (riverSound != null) riverSound.setPlayerPosition(pos); if (ambientSounds != null) ambientSounds.setPlayerPosition(pos); if (musicSystem != null) musicSystem.setPlayerPosition(pos); + if (emitterSystem != null) emitterSystem.setPlayerPosition(pos); } if (musicSystem != null && dayNight != null)