diff --git a/GameEngine/src/main/java/gameEngine/GameEditor.java b/GameEngine/src/main/java/gameEngine/GameEditor.java index c51335d..6c4bb62 100644 --- a/GameEngine/src/main/java/gameEngine/GameEditor.java +++ b/GameEngine/src/main/java/gameEngine/GameEditor.java @@ -1,8 +1,7 @@ package gameEngine; +import gameEngine.entites.Entity; import gameEngine.entites.GameObject; -import gameEngine.entites.gameComponents.ColorController; -import gameEngine.entites.gameComponents.Mesh; import gameEngine.scenes.*; import javax.swing.*; @@ -11,9 +10,6 @@ import java.awt.event.ActionListener; import java.util.Map; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - public class GameEditor extends JFrame { private JList objectList; @@ -50,8 +46,8 @@ public Component getListCellRendererComponent(JList list, String value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = new JLabel(); int id = Integer.parseInt(value); // 内部でIDを使用 - GameObject gameObject = gameScene.gameObjects.get(id); - label.setText(gameObject.name); // リストには名前を表示する + Entity entity = gameScene.entities.get(id); + label.setText(entity.name); // リストには名前を表示する if (isSelected) { label.setBackground(list.getSelectionBackground()); label.setForeground(list.getSelectionForeground()); @@ -152,11 +148,11 @@ String selectedIdStr = objectList.getSelectedValue(); if (selectedIdStr != null) { int selectedId = Integer.parseInt(selectedIdStr); - GameObject selectedObject = gameScene.gameObjects.get(selectedId); - if (selectedObject != null) { - // コンポーネントを追加 (例: Mesh など) - gameScene.addComponent(selectedObject); - JOptionPane.showMessageDialog(this, "Component Added to " + selectedObject.name); + Entity selectedEntity = gameScene.entities.get(selectedId); + if (selectedEntity instanceof GameObject) { + GameObject gameObject = (GameObject) selectedEntity; + gameScene.addComponent(gameObject); + JOptionPane.showMessageDialog(this, "Component Added to " + selectedEntity.name); } } } @@ -164,29 +160,29 @@ // GameObjectのリストを更新 public void updateGameObjectList(Scene gameScene) { listModel.clear(); - for (Map.Entry entry : gameScene.gameObjects.entrySet()) { - GameObject gameObject = entry.getValue(); - listModel.addElement(String.valueOf(gameObject.getId())); // IDをリストに表示(内部) - } + for (Map.Entry entry : gameScene.entities.entrySet()) { + Entity entity = entry.getValue(); + listModel.addElement(String.valueOf(entity.getId())); // IDをリストに表示 + } } // 選択されたGameObjectのプロパティをロードする private void loadSelectedGameObject() { String selectedIdStr = objectList.getSelectedValue(); if (selectedIdStr != null) { - int selectedId = Integer.parseInt(selectedIdStr); // IDとして扱う - GameObject selectedObject = gameScene.gameObjects.get(selectedId); - if (selectedObject != null) { - nameField.setText(selectedObject.name); - posXField.setText(String.valueOf(selectedObject.transform.position.x)); - posYField.setText(String.valueOf(selectedObject.transform.position.y)); - posZField.setText(String.valueOf(selectedObject.transform.position.z)); - rotXField.setText(String.valueOf(selectedObject.transform.rotation.x)); - rotYField.setText(String.valueOf(selectedObject.transform.rotation.y)); - rotZField.setText(String.valueOf(selectedObject.transform.rotation.z)); - scaleXField.setText(String.valueOf(selectedObject.transform.scale.x)); - scaleYField.setText(String.valueOf(selectedObject.transform.scale.y)); - scaleZField.setText(String.valueOf(selectedObject.transform.scale.z)); + int selectedId = Integer.parseInt(selectedIdStr); + Entity selectedEntity = gameScene.entities.get(selectedId); + if (selectedEntity != null) { + nameField.setText(selectedEntity.name); + posXField.setText(String.valueOf(selectedEntity.transform.position.x)); + posYField.setText(String.valueOf(selectedEntity.transform.position.y)); + posZField.setText(String.valueOf(selectedEntity.transform.position.z)); + rotXField.setText(String.valueOf(selectedEntity.transform.rotation.x)); + rotYField.setText(String.valueOf(selectedEntity.transform.rotation.y)); + rotZField.setText(String.valueOf(selectedEntity.transform.rotation.z)); + scaleXField.setText(String.valueOf(selectedEntity.transform.scale.x)); + scaleYField.setText(String.valueOf(selectedEntity.transform.scale.y)); + scaleZField.setText(String.valueOf(selectedEntity.transform.scale.z)); } } } @@ -203,20 +199,20 @@ String selectedIdStr = objectList.getSelectedValue(); if (selectedIdStr != null) { int selectedId = Integer.parseInt(selectedIdStr); // IDとして扱う - GameObject selectedObject = gameScene.gameObjects.get(selectedId); - if (selectedObject != null) { - selectedObject.name = nameField.getText(); - selectedObject.transform.setPosition( + Entity selectedEntity = gameScene.entities.get(selectedId); + if (selectedEntity != null) { + selectedEntity.name = nameField.getText(); + selectedEntity.transform.setPosition( Float.parseFloat(posXField.getText()), Float.parseFloat(posYField.getText()), Float.parseFloat(posZField.getText()) ); - selectedObject.transform.setRotation( + selectedEntity.transform.setRotation( Float.parseFloat(rotXField.getText()), Float.parseFloat(rotYField.getText()), Float.parseFloat(rotZField.getText()) ); - selectedObject.transform.setScale( + selectedEntity.transform.setScale( Float.parseFloat(scaleXField.getText()), Float.parseFloat(scaleYField.getText()), Float.parseFloat(scaleZField.getText())