Skip to content

Commit 5eae4d8

Browse files
committed
Sets the background source by default in the animation dialog.
1 parent 96d16f3 commit 5eae4d8

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ public EditAnimationDialog(Skin skin, SpriteActor p, AnimationDesc e) {
103103
Param.Type.BOOLEAN, true, "true");
104104
dispose = InputPanelFactory.createInputPanel(skin, "Dispose When Played", "Dispose de animation after playing",
105105
Param.Type.BOOLEAN, true, "false");
106-
107-
106+
108107
((SelectBox<String>) repeat.getField()).addListener(new ChangeListener() {
109108

110109
@Override
@@ -146,14 +145,14 @@ public void changed(ChangeEvent event, Actor actor) {
146145
});
147146

148147
setInfoWidget(spriteWidget);
149-
148+
150149
init(p, e, new InputPanel[] { source, localizable, atlas, id, repeat, speed, count, in, out, sound, preload,
151150
dispose });
152-
151+
153152
addSources();
154-
153+
155154
// call modelToInputs again to set the correct source
156-
if( e != null )
155+
if (e != null)
157156
modelToInputs();
158157

159158
setVisible(count, false);
@@ -172,13 +171,15 @@ public void changed(ChangeEvent event, Actor actor) {
172171
source.setText(e.source);
173172
} else {
174173
// If the actor has some animation, set the same source.
175-
HashMap<String, AnimationDesc> animations = ((AnimationRenderer)p.getRenderer()).getAnimations();
176-
if(animations.size() > 0) {
174+
HashMap<String, AnimationDesc> animations = ((AnimationRenderer) p.getRenderer()).getAnimations();
175+
if (animations.size() > 0) {
177176
source.setText(animations.values().iterator().next().source);
177+
} else {
178+
// set the background source it atlas type
179+
if (p.getRenderer() instanceof AtlasRenderer && p.getScene().getBackgroundAtlas() != null)
180+
source.setText(p.getScene().getBackgroundAtlas());
178181
}
179182
}
180-
181-
182183

183184
if (source.getText() != null && !source.getText().isEmpty()) {
184185
setSource();
@@ -397,7 +398,7 @@ protected void ok() {
397398
protected void inputsToModel(boolean create) {
398399

399400
String sourceStr = source.getText();
400-
AnimationRenderer renderer = (AnimationRenderer)parent.getRenderer();
401+
AnimationRenderer renderer = (AnimationRenderer) parent.getRenderer();
401402

402403
if (create) {
403404

@@ -423,8 +424,8 @@ protected void inputsToModel(boolean create) {
423424
} else {
424425
HashMap<String, AnimationDesc> animations = renderer.getAnimations();
425426
animations.remove(e.id);
426-
427-
if(e.id.equals(renderer.getInitAnimation()))
427+
428+
if (e.id.equals(renderer.getInitAnimation()))
428429
renderer.setInitAnimation(null);
429430
}
430431

@@ -439,14 +440,14 @@ protected void inputsToModel(boolean create) {
439440
e.outD = Param.parseVector2(out.getText());
440441
e.duration = Float.parseFloat(speed.getText());
441442

442-
((AnimationRenderer)parent.getRenderer()).addAnimation(e);
443+
((AnimationRenderer) parent.getRenderer()).addAnimation(e);
443444

444445
if (renderer instanceof ImageRenderer && Boolean.parseBoolean(localizable.getText()) && e.source != null
445446
&& e.source.length() > 0) {
446447
e.source = I18N.PREFIX + e.source;
447448
}
448-
449-
if(renderer.getInitAnimation() == null)
449+
450+
if (renderer.getInitAnimation() == null)
450451
renderer.setInitAnimation(e.id);
451452

452453
// TODO UNDO OP

0 commit comments

Comments
 (0)