gdx-studio

#libgdx#java#desktop

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/EffectPanel.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.Effect;
a9b2a64 8
import scene2d.EffectType;
a9b2a64 9
import scene2d.ImageJson;
a9b2a64 10
import scene2d.InterpolationType;
a9b2a64 11
import scene2d.Scene;
7c84877 12
import web.laf.lite.utils.UIUtils;
7c84877 13
a62d533 14
a62d533 15
public class EffectPanel extends BaseTable {
a62d533 16
	private static final long serialVersionUID = 1L;
a62d533 17
	
a62d533 18
	static String[] durations = 
a62d533 19
	{
a62d533 20
		"0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9",
a62d533 21
		"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9",
a62d533 22
		"2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9",
a62d533 23
		"3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9",
a62d533 24
		"4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9",
a62d533 25
		"5.0"
a62d533 26
	};
a62d533 27
	
a62d533 28
	JComboBox<String> effectComboBox = createComboBox();
a62d533 29
	JComboBox<String> durationComboBox = createComboBox(durations);
a62d533 30
	JComboBox<String> interpolationComboBox = createComboBox();
a62d533 31
	
a62d533 32
	public EffectPanel(){
a62d533 33
		super("Effects");
7c84877 34
		UIUtils.setUndecorated(this, true);
a62d533 35
		editors.add(new DefaultCellEditor(effectComboBox));
a62d533 36
		editors.add(createNumberField());
a62d533 37
		editors.add(new DefaultCellEditor(durationComboBox));
a62d533 38
		editors.add(new DefaultCellEditor(interpolationComboBox));
a62d533 39
		for(EffectType effect: EffectType.values())
a62d533 40
			effectComboBox.addItem(effect.toString());
a62d533 41
		for(InterpolationType interpolation: InterpolationType.values())
a62d533 42
			interpolationComboBox.addItem(interpolation.toString());
a62d533 43
	}
a62d533 44
	
a62d533 45
	@Override
a62d533 46
	public void clear(String... names){
a62d533 47
		super.clear("Effect", "Value", "Duration", "Interpolation", "addEffectDelay", "addActorDelay");
a62d533 48
	}
a62d533 49
	
a62d533 50
	@Override
a62d533 51
	public void update(String... propertyNames){
a62d533 52
		if(SceneEditor.selectedActor instanceof ImageJson){
a62d533 53
			ImageJson img = (ImageJson) SceneEditor.selectedActor;
a62d533 54
			super.update("Effect", img.effectType.toString(), "Value", ""+img.effectValue, 
a62d533 55
					"Duration", ""+img.effectDuration,"Interpolation", img.interpolationType.toString(),
a62d533 56
					"addEffectDelay", ""+img.addEffectDelay,
a62d533 57
					"addActorDelay", ""+img.addActorDelay);
a62d533 58
		}
a62d533 59
		else{
a62d533 60
			clear();
a62d533 61
		}
a62d533 62
	}
a62d533 63
	
a62d533 64
	@Override
a62d533 65
	public void setProperty(String key, String value){
a62d533 66
		if(key.isEmpty() || value.isEmpty())
a62d533 67
			return ;
a62d533 68
		if(SceneEditor.selectedActor instanceof ImageJson){
a62d533 69
			ImageJson img = (ImageJson) SceneEditor.selectedActor;
a62d533 70
			img.clearActions();
a62d533 71
			switch(key){
a62d533 72
				case "Effect": img.effectType = EffectType.valueOf(value);break;
a62d533 73
				case "Value": img.effectValue = Float.parseFloat(value);break;
a62d533 74
				case "Duration": img.effectDuration = Float.parseFloat(value);break;
a62d533 75
				case "Interpolation":img.interpolationType = InterpolationType.valueOf(value);break;
a62d533 76
			}
a62d533 77
			Effect.createEffect(img);
a9b2a64 78
			Scene.isDirty = true;
a62d533 79
		}
a62d533 80
	}
a62d533 81
}