gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src/gdxstudio/panel/EventPanel.java
| a9b2a64 | 1 | package gdxstudio.panel; |
| a9b2a64 | 2 | import gdxstudio.SceneEditor; |
| a9b2a64 | 3 | |
| a62d533 | 4 | import javax.swing.DefaultCellEditor; |
| a62d533 | 5 | import javax.swing.JComboBox; |
| a62d533 | 6 | |
| a9b2a64 | 7 | import scene2d.EventType; |
| a9b2a64 | 8 | import scene2d.ImageJson; |
| a9b2a64 | 9 | import scene2d.Scene; |
| a9b2a64 | 10 | |
| a62d533 | 11 | public class EventPanel extends BaseTable {
|
| a62d533 | 12 | private static final long serialVersionUID = 1L; |
| a62d533 | 13 | |
| a62d533 | 14 | JComboBox<String> eventComboBox = createComboBox(); |
| a62d533 | 15 | JComboBox<String> onEventComboBox = createComboBox(); |
| a62d533 | 16 | JComboBox<String> sceneComboBox = createComboBox(); |
| a62d533 | 17 | |
| a62d533 | 18 | public EventPanel(){
|
| a62d533 | 19 | super("Events");
|
| a62d533 | 20 | editors.add(new DefaultCellEditor(eventComboBox)); |
| a62d533 | 21 | editors.add(new DefaultCellEditor(onEventComboBox)); |
| a62d533 | 22 | editors.add(new DefaultCellEditor(sceneComboBox)); |
| a62d533 | 23 | for(EventType event: EventType.values()) |
| a62d533 | 24 | eventComboBox.addItem(event.toString()); |
| a9b2a64 | 25 | for(Scene.OnEventType onEvent: Scene.OnEventType.values()) |
| a62d533 | 26 | onEventComboBox.addItem(onEvent.toString()); |
| a62d533 | 27 | for(String scene: Scene.scenesMap.keys()) |
| a62d533 | 28 | sceneComboBox.addItem(scene); |
| a62d533 | 29 | } |
| a62d533 | 30 | |
| a62d533 | 31 | @Override |
| a62d533 | 32 | public void clear(String... names){
|
| a62d533 | 33 | super.clear("Event", "onEvent", "Scene");
|
| a62d533 | 34 | } |
| a62d533 | 35 | |
| a62d533 | 36 | @Override |
| a62d533 | 37 | public void update(String... propertyNames){
|
| a62d533 | 38 | if(SceneEditor.selectedActor instanceof ImageJson){
|
| a62d533 | 39 | ImageJson img = (ImageJson) SceneEditor.selectedActor; |
| a62d533 | 40 | super.update("Event", img.evtType.toString(), "onEvent", ""+img.onEvtType.toString(),
|
| a62d533 | 41 | "Scene", ""+img.eventScene); |
| a62d533 | 42 | sceneComboBox.removeAllItems(); |
| a62d533 | 43 | for(String scene: Scene.scenesMap.keys()) |
| a62d533 | 44 | sceneComboBox.addItem(scene); |
| a62d533 | 45 | } |
| a62d533 | 46 | else{
|
| a62d533 | 47 | clear(); |
| a62d533 | 48 | } |
| a62d533 | 49 | } |
| a62d533 | 50 | |
| a62d533 | 51 | @Override |
| a62d533 | 52 | public void setProperty(String key, String value){
|
| a62d533 | 53 | if(key.isEmpty() || value.isEmpty()) |
| a62d533 | 54 | return ; |
| a62d533 | 55 | if(SceneEditor.selectedActor instanceof ImageJson){
|
| a62d533 | 56 | ImageJson img = (ImageJson)SceneEditor.selectedActor; |
| a62d533 | 57 | switch(key){
|
| a62d533 | 58 | case "Event": |
| a62d533 | 59 | img.evtType = EventType.valueOf(value); |
| a62d533 | 60 | if(img.evtType == EventType.None){
|
| a62d533 | 61 | onEventComboBox.setEnabled(false); |
| a62d533 | 62 | } |
| a62d533 | 63 | else if(img.evtType == EventType.SceneCreated){
|
| a9b2a64 | 64 | onEventComboBox.setSelectedItem(Scene.OnEventType.DoEffect.toString()); |
| a62d533 | 65 | onEventComboBox.setEnabled(false); |
| a62d533 | 66 | } |
| a62d533 | 67 | else{
|
| a62d533 | 68 | onEventComboBox.setEnabled(true); |
| a62d533 | 69 | } |
| a62d533 | 70 | |
| a62d533 | 71 | break; |
| a62d533 | 72 | case "onEvent": |
| a9b2a64 | 73 | img.onEvtType = Scene.OnEventType.valueOf(value); |
| a9b2a64 | 74 | if(img.onEvtType == Scene.OnEventType.DoEffect){
|
| a62d533 | 75 | sceneComboBox.setEnabled(false); |
| a62d533 | 76 | } |
| a62d533 | 77 | else{
|
| a62d533 | 78 | sceneComboBox.setEnabled(true); |
| a62d533 | 79 | } |
| a62d533 | 80 | break; |
| a62d533 | 81 | case "Scene": img.eventScene = value;break; |
| a62d533 | 82 | } |
| a9b2a64 | 83 | Scene.isDirty = true; |
| a62d533 | 84 | } |
| a62d533 | 85 | } |
| a62d533 | 86 | } |