|
1 | 1 | /*******************************************************************************
|
2 | 2 | * Copyright 2014 Rafael Garcia Moreno.
|
3 |
| - * |
| 3 | + * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
6 | 6 | * You may obtain a copy of the License at
|
7 |
| - * |
| 7 | + * |
8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 |
| - * |
| 9 | + * |
10 | 10 | * Unless required by applicable law or agreed to in writing, software
|
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25 | 25 | import com.bladecoder.engineeditor.ui.panels.InputPanelFactory;
|
26 | 26 |
|
27 | 27 | public class EditLayerDialog extends EditModelDialog<Scene, SceneLayer> {
|
28 |
| - |
29 |
| - private InputPanel name; |
30 |
| - private InputPanel visible; |
31 |
| - private InputPanel dynamic; |
32 |
| - private InputPanel parallax; |
33 |
| - |
34 |
| - public EditLayerDialog(Skin skin, Scene parent, SceneLayer e) { |
35 |
| - super(skin); |
36 |
| - |
37 |
| - name = InputPanelFactory.createInputPanel(skin, "Layer Name", "The name of the layer", true); |
38 |
| - visible = InputPanelFactory.createInputPanel(skin, "Visible", "Layer Visibility", Param.Type.BOOLEAN, true, "true"); |
39 |
| - dynamic = InputPanelFactory.createInputPanel(skin, "Dynamic", "True for actor reordering based in y position", Param.Type.BOOLEAN, true,"false"); |
40 |
| - parallax = InputPanelFactory.createInputPanel(skin, "Parallax Factor", "The multiplier factor for parallax effect", Param.Type.FLOAT, true,"1.0"); |
41 | 28 |
|
42 |
| - setInfo("Scenes can have a list of layers. Actors are added to a specific layer to control the draw order"); |
| 29 | + private InputPanel name; |
| 30 | + private InputPanel visible; |
| 31 | + private InputPanel dynamic; |
| 32 | + private InputPanel parallax; |
43 | 33 |
|
44 |
| - init(parent, e, new InputPanel[] { name, visible, dynamic, parallax }); |
45 |
| - } |
46 |
| - |
47 |
| - @Override |
48 |
| - protected void inputsToModel(boolean create) { |
49 |
| - |
50 |
| - if(create) { |
51 |
| - e = new SceneLayer(); |
52 |
| - } |
53 |
| - |
54 |
| - // TODO if the name is changed. Change all actor layer name. |
55 |
| - e.setName(name.getText()); |
56 |
| - e.setVisible(Boolean.parseBoolean(visible.getText())); |
57 |
| - e.setDynamic(Boolean.parseBoolean(dynamic.getText())); |
58 |
| - e.setParallaxMultiplier(Float.parseFloat(parallax.getText())); |
59 |
| - |
60 |
| - if(create) { |
61 |
| - parent.getLayers().add(e); |
62 |
| - } |
| 34 | + public EditLayerDialog(Skin skin, Scene parent, SceneLayer e) { |
| 35 | + super(skin); |
63 | 36 |
|
64 |
| - // TODO UNDO OP |
| 37 | + name = InputPanelFactory.createInputPanel(skin, "Layer Name", "The name of the layer", true); |
| 38 | + visible = InputPanelFactory.createInputPanel(skin, "Visible", "Layer Visibility", Param.Type.BOOLEAN, true, "true"); |
| 39 | + dynamic = InputPanelFactory.createInputPanel(skin, "Dynamic", "True for actor reordering based in y position", Param.Type.BOOLEAN, true, "false"); |
| 40 | + parallax = InputPanelFactory.createInputPanel(skin, "Parallax Factor", "The multiplier factor for parallax effect", Param.Type.FLOAT, true, "1.0"); |
| 41 | + |
| 42 | + setInfo("Scenes can have a list of layers. Actors are added to a specific layer to control the draw order"); |
| 43 | + |
| 44 | + init(parent, e, new InputPanel[]{name, visible, dynamic, parallax}); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + protected void inputsToModel(boolean create) { |
| 49 | + |
| 50 | + if (create) { |
| 51 | + e = new SceneLayer(); |
| 52 | + } |
| 53 | + |
| 54 | + // if the name is changed. Change all actor layer name. |
| 55 | + if (!create && !e.getName().equals(name.getText())) { |
| 56 | + for (SceneLayer l : parent.getLayers()) { |
| 57 | + for (int i = 0; i < l.getActors().size(); i++) { |
| 58 | + if (l.getActors().get(i).getLayer().equals(e.getName())) { |
| 59 | + l.getActors().get(i).setLayer(name.getText()); |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + e.setName(name.getText()); |
| 66 | + e.setVisible(Boolean.parseBoolean(visible.getText())); |
| 67 | + e.setDynamic(Boolean.parseBoolean(dynamic.getText())); |
| 68 | + e.setParallaxMultiplier(Float.parseFloat(parallax.getText())); |
| 69 | + |
| 70 | + if (create) { |
| 71 | + parent.getLayers().add(e); |
| 72 | + } |
| 73 | + |
| 74 | + // TODO UNDO OP |
65 | 75 | // UndoOp undoOp = new UndoAddElement(doc, e);
|
66 | 76 | // Ctx.project.getUndoStack().add(undoOp);
|
67 |
| - |
68 |
| - Ctx.project.setModified(); |
69 |
| - } |
70 | 77 |
|
71 |
| - @Override |
72 |
| - protected void modelToInputs() { |
73 |
| - name.setText(e.getName()); |
74 |
| - visible.setText(Boolean.toString(e.isVisible())); |
75 |
| - dynamic.setText(Boolean.toString(e.isDynamic())); |
76 |
| - parallax.setText(Float.toString(e.getParallaxMultiplier())); |
77 |
| - } |
| 78 | + Ctx.project.setModified(); |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + protected void modelToInputs() { |
| 83 | + name.setText(e.getName()); |
| 84 | + visible.setText(Boolean.toString(e.isVisible())); |
| 85 | + dynamic.setText(Boolean.toString(e.isDynamic())); |
| 86 | + parallax.setText(Float.toString(e.getParallaxMultiplier())); |
| 87 | + } |
78 | 88 | }
|
0 commit comments