Skip to content

Commit 257ee42

Browse files
committed
Small bug fixes.
1 parent 4913e8e commit 257ee42

File tree

8 files changed

+83
-73
lines changed

8 files changed

+83
-73
lines changed

adventure-editor/src/main/java/com/bladecoder/engineeditor/ui/EditSceneDialog.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.bladecoder.engineeditor.Ctx;
3838
import com.bladecoder.engineeditor.common.EditorLogger;
3939
import com.bladecoder.engineeditor.common.ElementUtils;
40-
import com.bladecoder.engineeditor.common.Message;
4140
import com.bladecoder.engineeditor.model.Project;
4241
import com.bladecoder.engineeditor.ui.panels.EditModelDialog;
4342
import com.bladecoder.engineeditor.ui.panels.FilteredSelectBox;
@@ -74,25 +73,25 @@ public EditSceneDialog(Skin skin, World parent, Scene e) {
7473

7574
super(skin);
7675

77-
id = InputPanelFactory.createInputPanel(skin, "Scene ID",
78-
"The ID is mandatory for scenes.", true);
76+
id = InputPanelFactory.createInputPanel(skin, "Scene ID", "The ID is mandatory for scenes.", true);
7977
backgroundAtlas = InputPanelFactory.createInputPanel(skin, "Background Atlas",
8078
"The atlas where the background for the scene is located", Type.ATLAS_ASSET, false);
8179
backgroundRegion = InputPanelFactory.createInputPanel(skin, "Background Region Id",
8280
"The region id for the background.", new String[0], false);
8381
// depthVector = InputPanelFactory.createInputPanel(skin, "Depth Vector",
8482
// "X: the actor 'y' position for a 0.0 scale, Y: the actor 'y' position for a 1.0 scale.",
8583
// Param.Type.VECTOR2, false);
86-
87-
depthVector = InputPanelFactory.createInputPanel(skin, "Fake depth", "Change actor scale based in the 'y' axis position.", Param.Type.BOOLEAN, true,
88-
"false");
89-
84+
85+
depthVector = InputPanelFactory.createInputPanel(skin, "Fake depth",
86+
"Change actor scale based in the 'y' axis position.", Param.Type.BOOLEAN, true, "false");
87+
9088
state = InputPanelFactory.createInputPanel(skin, "State", "The initial state for the scene.", false);
91-
music = InputPanelFactory.createInputPanel(skin, "Music Filename", "The music for the scene", Type.MUSIC_ASSET, false);
89+
music = InputPanelFactory.createInputPanel(skin, "Music Filename", "The music for the scene", Type.MUSIC_ASSET,
90+
false);
9291
loopMusic = InputPanelFactory.createInputPanel(skin, "Loop Music", "If the music is playing in looping",
9392
Param.Type.BOOLEAN, true, "true");
94-
volumeMusic = InputPanelFactory.createInputPanel(skin, "Music Volume", "The volume of the music. Value is between 0 and 1.",
95-
Param.Type.FLOAT, true, "1");
93+
volumeMusic = InputPanelFactory.createInputPanel(skin, "Music Volume",
94+
"The volume of the music. Value is between 0 and 1.", Param.Type.FLOAT, true, "1");
9695
initialMusicDelay = InputPanelFactory.createInputPanel(skin, "Initial music delay",
9796
"The time to wait before playing", Param.Type.FLOAT, true, "0");
9897
repeatMusicDelay = InputPanelFactory.createInputPanel(skin, "Repeat music delay",
@@ -103,8 +102,9 @@ public EditSceneDialog(Skin skin, World parent, Scene e) {
103102
sceneSize = InputPanelFactory.createInputPanel(skin, "Scene Dimension",
104103
"Sets the size of the scene. If empty, the background image size is used as the scene dimension.",
105104
Param.Type.DIMENSION, false);
106-
107-
walkzone = InputPanelFactory.createInputPanel(skin, "Walkzone", "The initial walkzone.", Type.WALKZONE_ACTOR, false);
105+
106+
walkzone = InputPanelFactory.createInputPanel(skin, "Walkzone", "The initial walkzone.", Type.WALKZONE_ACTOR,
107+
false);
108108

109109
bgImage = new Image();
110110
bgImage.setScaling(Scaling.fit);
@@ -118,7 +118,8 @@ public void changed(ChangeEvent event, Actor actor) {
118118
try {
119119
fillBGRegions(backgroundAtlas, backgroundRegion);
120120
} catch (Exception e) {
121-
Message.showMsg(getStage(), "Error loading regions from selected atlas", 4);
121+
EditorLogger.error("Error loading regions from selected atlas: " + backgroundAtlas.getText() + "."
122+
+ backgroundRegion.getText());
122123
}
123124
}
124125
});
@@ -133,7 +134,8 @@ public void changed(ChangeEvent event, Actor actor) {
133134
try {
134135
fillBGRegions(backgroundAtlas, backgroundRegion);
135136
} catch (Exception e2) {
136-
EditorLogger.error("Error loading regions from selected atlas");
137+
EditorLogger.error("Error loading regions from selected atlas: " + backgroundAtlas.getText() + "."
138+
+ backgroundRegion.getText());
137139
}
138140

139141
init(parent, e, new InputPanel[] { id, backgroundAtlas, backgroundRegion, depthVector, state, sceneSize, music,
@@ -214,19 +216,20 @@ protected void inputsToModel(boolean create) {
214216
parent.getScenes().remove(e.getId());
215217
}
216218

217-
e.setId(ElementUtils.getCheckedId(id.getText(), Ctx.project.getWorld().getScenes().keySet().toArray(new String[0])));
219+
e.setId(ElementUtils.getCheckedId(id.getText(),
220+
Ctx.project.getWorld().getScenes().keySet().toArray(new String[0])));
218221

219222
e.setBackgroundAtlas(backgroundAtlas.getText());
220223
e.setBackgroundRegionId(backgroundRegion.getText());
221-
224+
222225
boolean dv = Boolean.parseBoolean(depthVector.getText());
223-
224-
if(dv == true && e.getDepthVector() == null) { // create depth vector
226+
227+
if (dv == true && e.getDepthVector() == null) { // create depth vector
225228
e.setDepthVector(new Vector2(Ctx.project.getWorld().getHeight(), 0));
226-
} else if(dv == false && e.getDepthVector() != null) { // Remove depth vector
229+
} else if (dv == false && e.getDepthVector() != null) { // Remove depth vector
227230
e.setDepthVector(null);
228231
}
229-
232+
230233
e.setState(state.getText());
231234

232235
MusicDesc md = null;
@@ -245,7 +248,7 @@ protected void inputsToModel(boolean create) {
245248
e.setMusicDesc(md);
246249

247250
e.setSceneSize(Param.parseVector2(sceneSize.getText()));
248-
251+
249252
e.setWalkZone(walkzone.getText());
250253

251254
parent.addScene(e);
@@ -269,12 +272,12 @@ protected void modelToInputs() {
269272
id.setText(e.getId());
270273
backgroundAtlas.setText(e.getBackgroundAtlas());
271274
backgroundRegion.setText(e.getBackgroundRegionId());
272-
275+
273276
if (e.getDepthVector() != null)
274277
depthVector.setText("true");
275278
else
276279
depthVector.setText("false");
277-
280+
278281
state.setText(e.getState());
279282

280283
MusicDesc md = e.getMusicDesc();
@@ -290,7 +293,7 @@ protected void modelToInputs() {
290293

291294
if (e.getSceneSize() != null)
292295
sceneSize.setText(Param.toStringParam(e.getSceneSize()));
293-
296+
294297
walkzone.setText(e.getWalkZone());
295298
}
296299

blade-engine/src/com/bladecoder/engine/actions/ScaleAction.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.bladecoder.engine.model.World;
2424
import com.bladecoder.engine.util.InterpolationMode;
2525

26-
@ActionDescription(name = "ScaleAnim", value= "Proportional Scale animation for sprite actors")
26+
@ActionDescription(name = "ScaleAnim", value = "Proportional Scale animation for sprite actors")
2727
public class ScaleAction implements Action {
2828
@ActionPropertyDescription("The target actor")
2929
@ActionProperty(type = Type.SPRITE_ACTOR)
@@ -39,37 +39,36 @@ public class ScaleAction implements Action {
3939

4040
@ActionProperty
4141
@ActionPropertyDescription("The The times to repeat")
42-
private int count = 1;
42+
private int count = -1;
4343

4444
@ActionProperty(required = true)
4545
@ActionPropertyDescription("If this param is 'false' the transition is showed and the action continues inmediatly")
4646
private boolean wait = true;
4747

48-
@ActionProperty(required = true, defaultValue = "REPEAT")
48+
@ActionProperty(required = true, defaultValue = "NO_REPEAT")
4949
@ActionPropertyDescription("The repeat mode")
50-
private Tween.Type repeat = Tween.Type.REPEAT;
50+
private Tween.Type repeat = Tween.Type.NO_REPEAT;
5151

5252
@ActionProperty
5353
@ActionPropertyDescription("The interpolation mode")
5454
private InterpolationMode interpolation;
55-
55+
5656
private World w;
57-
57+
5858
@Override
5959
public void init(World w) {
6060
this.w = w;
6161
}
6262

6363
@Override
64-
public boolean run(VerbRunner cb) {
64+
public boolean run(VerbRunner cb) {
6565
SpriteActor a = (SpriteActor) w.getCurrentScene().getActor(actor, false);
66-
66+
6767
SpriteScaleTween t = new SpriteScaleTween();
68-
t.start(a, repeat, count, scale, scale, speed, interpolation,
69-
wait ? cb : null);
70-
68+
t.start(a, repeat, count, scale, scale, speed, interpolation, wait ? cb : null);
69+
7170
a.addTween(t);
72-
71+
7372
return wait;
7473
}
7574

blade-engine/src/com/bladecoder/engine/actions/SetActorAttrAction.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class SetActorAttrAction implements Action {
6060
@ActionProperty
6161
@ActionPropertyDescription("Sets the actor scale proportionally")
6262
private Float scale;
63-
63+
6464
@ActionProperty
6565
@ActionPropertyDescription("Sets the actor scale non proportionally")
6666
private Vector2 scaleXY;
@@ -91,13 +91,13 @@ public class SetActorAttrAction implements Action {
9191
@ActionProperty
9292
@ActionPropertyDescription("Sets the actor speed for walking. Only supported for character actors.")
9393
private Float walkingSpeed;
94-
94+
9595
@ActionProperty
9696
@ActionPropertyDescription("Sets the position of the text when talking. Relative to the character position.")
9797
private Vector2 talkingTextPos;
98-
98+
9999
private World w;
100-
100+
101101
@Override
102102
public void init(World w) {
103103
this.w = w;
@@ -163,7 +163,7 @@ public boolean run(VerbRunner cb) {
163163
else
164164
EngineLogger.error("'scale' property not supported for actor:" + a.getId());
165165
}
166-
166+
167167
if (scaleXY != null) {
168168
if (a instanceof SpriteActor)
169169
((SpriteActor) a).setScale(scaleXY.x, scaleXY.y);
@@ -180,7 +180,7 @@ public boolean run(VerbRunner cb) {
180180

181181
if (tint != null) {
182182
if (a instanceof SpriteActor)
183-
((SpriteActor) a).setTint(tint);
183+
((SpriteActor) a).setTint(tint.cpy());
184184
else
185185
EngineLogger.error("'tint' property not supported for actor:" + a.getId());
186186
}
@@ -229,7 +229,7 @@ public boolean run(VerbRunner cb) {
229229
} else
230230
EngineLogger.error("'uiActor' property not supported for actor:" + a.getId());
231231
}
232-
232+
233233
if (talkingTextPos != null) {
234234
if (a instanceof CharacterActor)
235235
((CharacterActor) a).setTalkingTextPos(talkingTextPos);
@@ -244,8 +244,7 @@ private void setUIActor(Scene scn, InteractiveActor actor) {
244244

245245
scn.removeActor(actor);
246246

247-
if (scn != w.getCurrentScene() && w.getCachedScene(scn.getId()) == null
248-
&& actor instanceof AssetConsumer) {
247+
if (scn != w.getCurrentScene() && w.getCachedScene(scn.getId()) == null && actor instanceof AssetConsumer) {
249248
((AssetConsumer) actor).loadAssets();
250249
EngineAssetManager.getInstance().finishLoading();
251250
((AssetConsumer) actor).retrieveAssets();

blade-engine/src/com/bladecoder/engine/anim/SpriteAlphaTween.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,28 @@
2626
* Tween for SpriteActor alpha animation
2727
*/
2828
public class SpriteAlphaTween extends Tween<SpriteActor> {
29-
29+
3030
private float startAlpha;
3131
private float targetAlpha;
32-
32+
3333
public SpriteAlphaTween() {
3434
}
3535

36-
public void start(SpriteActor target, Type repeatType, int count, float tAlpha, float duration, InterpolationMode interpolation, ActionCallback cb) {
37-
36+
public void start(SpriteActor target, Type repeatType, int count, float tAlpha, float duration,
37+
InterpolationMode interpolation, ActionCallback cb) {
38+
3839
setTarget(target);
39-
40-
if(target.getTint() == null)
40+
41+
if (target.getTint() == null) {
4142
target.setTint(Color.WHITE.cpy());
42-
43+
} else {
44+
// to set the flag dirty
45+
target.setTint(target.getTint());
46+
}
47+
4348
startAlpha = target.getTint().a;
4449
targetAlpha = tAlpha;
45-
50+
4651
setDuration(duration);
4752
setType(repeatType);
4853
setCount(count);
@@ -51,15 +56,15 @@ public void start(SpriteActor target, Type repeatType, int count, float tAlpha,
5156
if (cb != null) {
5257
setCb(cb);
5358
}
54-
59+
5560
restart();
5661
}
5762

5863
@Override
5964
public void updateTarget() {
6065
target.getTint().a = startAlpha + getPercent() * (targetAlpha - startAlpha);
6166
}
62-
67+
6368
@Override
6469
public void write(Json json) {
6570
super.write(json);
@@ -70,8 +75,8 @@ public void write(Json json) {
7075

7176
@Override
7277
public void read(Json json, JsonValue jsonData) {
73-
super.read(json, jsonData);
74-
78+
super.read(json, jsonData);
79+
7580
startAlpha = json.readValue("startAlpha", float.class, 1.0f, jsonData);
7681
targetAlpha = json.readValue("targetAlpha", float.class, 1.0f, jsonData);
7782
}

blade-engine/src/com/bladecoder/engine/anim/SpriteTintTween.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,28 @@
2626
* Tween for SpriteActor tint animation
2727
*/
2828
public class SpriteTintTween extends Tween<SpriteActor> {
29-
29+
3030
private Color startColor;
3131
private Color targetColor;
32-
32+
3333
public SpriteTintTween() {
3434
}
3535

36-
public void start(SpriteActor target, Type repeatType, int count, Color tColor, float duration, InterpolationMode interpolation, ActionCallback cb) {
37-
36+
public void start(SpriteActor target, Type repeatType, int count, Color tColor, float duration,
37+
InterpolationMode interpolation, ActionCallback cb) {
38+
3839
setTarget(target);
39-
40-
if(target.getTint() == null)
40+
41+
if (target.getTint() == null) {
4142
target.setTint(Color.WHITE.cpy());
42-
43+
} else {
44+
// to set the flag dirty
45+
target.setTint(target.getTint());
46+
}
47+
4348
startColor = target.getTint().cpy();
4449
targetColor = tColor.cpy();
45-
50+
4651
setDuration(duration);
4752
setType(repeatType);
4853
setCount(count);
@@ -51,19 +56,19 @@ public void start(SpriteActor target, Type repeatType, int count, Color tColor,
5156
if (cb != null) {
5257
setCb(cb);
5358
}
54-
59+
5560
restart();
5661
}
5762

5863
@Override
5964
public void updateTarget() {
60-
65+
6166
target.getTint().a = startColor.a + getPercent() * (targetColor.a - startColor.a);
6267
target.getTint().r = startColor.r + getPercent() * (targetColor.r - startColor.r);
6368
target.getTint().g = startColor.g + getPercent() * (targetColor.g - startColor.g);
6469
target.getTint().b = startColor.b + getPercent() * (targetColor.b - startColor.b);
6570
}
66-
71+
6772
@Override
6873
public void write(Json json) {
6974
super.write(json);
@@ -74,8 +79,8 @@ public void write(Json json) {
7479

7580
@Override
7681
public void read(Json json, JsonValue jsonData) {
77-
super.read(json, jsonData);
78-
82+
super.read(json, jsonData);
83+
7984
startColor = json.readValue("startColor", Color.class, Color.WHITE, jsonData);
8085
targetColor = json.readValue("targetColor", Color.class, Color.WHITE, jsonData);
8186
}

0 commit comments

Comments
 (0)