diff --git a/GameEngine/src/main/java/gameEngine/GameEditor.java b/GameEngine/src/main/java/gameEngine/GameEditor.java index f3baceb..a3fbdeb 100644 --- a/GameEngine/src/main/java/gameEngine/GameEditor.java +++ b/GameEngine/src/main/java/gameEngine/GameEditor.java @@ -3,7 +3,7 @@ import gameEngine.entites.Entity; import gameEngine.entites.GameObject; import gameEngine.entites.gameComponents.GameComponent; -import gameEngine.entites.gameComponents.MoveImage; +import gameEngine.entites.gameComponents.*; import gameEngine.scenes.*; import org.joml.Vector3f; @@ -27,6 +27,7 @@ private JTextField nameField; private Scene gameScene; private Timer updateTimer; + private JComboBox componentDropdown; private String lastLoadedName; private Vector3f lastLoadedPos, lastLoadedRot, lastLoadedScale; @@ -70,6 +71,7 @@ scaleXField = new JTextField(5); scaleYField = new JTextField(5); scaleZField = new JTextField(5); + componentDropdown = new JComboBox<>(new String[]{"ColorController", "CopyEntity", "MoveImage"}); addChangeListener(posXField, posYField, posZField, rotXField, rotYField, rotZField, scaleXField, scaleYField, scaleZField, nameField); @@ -105,6 +107,7 @@ setComponentBounds(newGameObjectButton, 200, 170, 110, 20); setComponentBounds(addComponentButton, 200, 260, 130, 20); setComponentBounds(removeComponentButton, 200, 290, 130, 20); + setComponentBounds(componentDropdown, 200, 225, 130, 20); // ドロップダウンの位置とサイズを設定 objectList.addListSelectionListener(e -> { if (!e.getValueIsAdjusting()) { // ユーザーが調整中でない場合のみ @@ -196,8 +199,22 @@ Entity selectedEntity = gameScene.getEntity(selectedObject); if (selectedEntity instanceof GameObject) { GameObject gameObject = (GameObject) selectedEntity; - System.out.println("仮でMeshコンポーネントを付与します"); - gameScene.addComponentToGameObject(gameObject, new MoveImage(gameObject)); + + String component = (String) componentDropdown.getSelectedItem(); + switch (component) { + case "ColorController": + gameScene.addComponentToGameObject(gameObject, new ColorController()); + break; + case "CopyEntity": + gameScene.addComponentToGameObject(gameObject, new CopyEntity(gameObject)); + break; + case "MoveImage": + gameScene.addComponentToGameObject(gameObject, new MoveImage(gameObject)); + break; + default: + JOptionPane.showMessageDialog(this, "Unknown Component Selected"); + break; + } // リストの更新 updateComponentList(gameObject);