@@ -35,221 +35,6 @@ public ScriptEditScreen(Script script) {
3535 this .script = script ;
3636
3737 reload ();
38- /*panel = new CScrollPanel(0, 3, 120, 94);
39-
40- //CTextField description = new CTextField(script.getDescription(), 3, 3, 115, 20, true);
41- //description.setChangedListener(() -> script.setDescription(description.getText()));
42- //panel.add(description);
43-
44- widgets.add(panel);
45-
46- int y = 0;
47- int index = 0;
48- int indent = 0;
49-
50- CText name = new CText(5,y+2,Text.literal(script.getName()),0,1,false,false);
51- panel.add(name);
52-
53- CButton settings = new CTexturedButton(120-8, y, 8, 8, DFScript.MOD_ID + ":settings.png", () -> {
54- DFScript.MC.setScreen(new ScriptSettingsScreen(this.script, true));
55- }, 0, 0, 1, 0.5f, 0, 0.5f);
56-
57- panel.add(settings);
58-
59- y += 10;
60-
61- for (ScriptPart part : script.getParts()) {
62- if (part instanceof ScriptEvent se) {
63- panel.add(new CItem(5, y, se.getType().getIcon()));
64- panel.add(new CText(15, y + 2, Text.literal(se.getType().getName())));
65- indent = 5;
66-
67- int currentIndex = index;
68- panel.add(new CButton(5, y-1, 115, 10, "",() -> {}) {
69- @Override
70- public void render(MatrixStack stack, int mouseX, int mouseY, float tickDelta) {
71- Rectangle b = getBounds();
72-
73- if (b.contains(mouseX, mouseY)) {
74- int color = 0x33000000;
75-
76- DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, color);
77- }
78- }
79-
80- @Override
81- public boolean mouseClicked(double x, double y, int button) {
82- if (getBounds().contains(x, y)) {
83- DFScript.MC.getSoundManager().play(PositionedSoundInstance.ambient(SoundEvents.UI_BUTTON_CLICK, 1f,1f));
84-
85- if (button != 0) {
86- CButton insertBefore = new CButton((int) x, (int) y, 40, 8, "Insert Before", () -> {
87- DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex));
88- });
89- CButton insertAfter = new CButton((int) x, (int) y+8, 40, 8, "Insert After", () -> {
90- DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex + 1));
91- });
92- CButton delete = new CButton((int) x, (int) y+16, 40, 8, "Delete", () -> {
93- script.getParts().remove(currentIndex);
94- scroll = panel.getScroll();
95- DFScript.MC.setScreen(new ScriptEditScreen(script));
96- });
97- DFScript.MC.send(() -> {
98- panel.add(insertBefore);
99- panel.add(insertAfter);
100- panel.add(delete);
101- contextMenu.add(insertBefore);
102- contextMenu.add(insertAfter);
103- contextMenu.add(delete);
104- });
105- }
106- return true;
107- }
108- return false;
109- }
110- });
111- } else if (part instanceof ScriptAction sa) {
112- if (sa.getType() == ScriptActionType.CLOSE_BRACKET) {
113- indent -= 5;
114- }
115-
116- panel.add(new CItem(5 + indent, y, sa.getType().getIcon()));
117- panel.add(new CText(15 + indent, y + 2, Text.literal(sa.getType().getName())));
118-
119- createIndent(indent, y);
120-
121- int currentIndex = index;
122- panel.add(new CButton(5, y - 1, 115, 10, "", () -> {
123- }) {
124- @Override
125- public void render(MatrixStack stack, int mouseX, int mouseY, float tickDelta) {
126- Rectangle b = getBounds();
127- if (b.contains(mouseX, mouseY)) {
128- int color = 0x33000000;
129-
130- if (sa.getType().isDeprecated()) {
131- color = 0x80FF0000;
132- }
133-
134- DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, color);
135- } else {
136- if (sa.getType().isDeprecated()) {
137- DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, 0x33FF0000);
138- }
139- }
140- }
141-
142- @Override
143- public boolean mouseClicked(double x, double y, int button) {
144- if (getBounds().contains(x, y)) {
145- DFScript.MC.getSoundManager().play(PositionedSoundInstance.ambient(SoundEvents.UI_BUTTON_CLICK, 1f, 1f));
146-
147- if (button == 0) {
148- if (sa.getType() != ScriptActionType.CLOSE_BRACKET) {
149- scroll = panel.getScroll();
150- DFScript.MC.setScreen(new ScriptEditActionScreen(sa, script));
151- }
152- } else {
153- CButton insertBefore = new CButton((int) x, (int) y, 40, 8, "Insert Before", () -> {
154- DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex));
155- });
156- CButton insertAfter = new CButton((int) x, (int) y + 8, 40, 8, "Insert After", () -> {
157- DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex + 1));
158- });
159- CButton delete = new CButton((int) x, (int) y + 16, 40, 8, "Delete", () -> {
160- script.getParts().remove(currentIndex);
161- scroll = panel.getScroll();
162- DFScript.MC.setScreen(new ScriptEditScreen(script));
163- });
164- DFScript.MC.send(() -> {
165- panel.add(insertBefore);
166- panel.add(insertAfter);
167- panel.add(delete);
168- contextMenu.add(insertBefore);
169- contextMenu.add(insertAfter);
170- contextMenu.add(delete);
171- });
172- }
173- return true;
174- }
175- return false;
176- }
177- });
178-
179- if (sa.getType().hasChildren()) {
180- indent += 5;
181- }
182- } else if (part instanceof ScriptComment sc) {
183- panel.add(new CItem(5 + indent, y, new ItemStack(Items.MAP).setCustomName(Text.literal("Comment").setStyle(Style.EMPTY.withItalic(false)))));
184-
185- CTextField cTextField = new CTextField(sc.getComment(),15+indent, y-1, width-(15+indent)-5, 10, true);
186-
187- cTextField.setChangedListener(() -> sc.setComment(cTextField.getText()));
188-
189- panel.add(cTextField);
190-
191- int currentIndex = index;
192-
193- panel.add(new CButton(5, y-1, 115, 10, "",() -> {}) {
194- @Override
195- public void render(MatrixStack stack, int mouseX, int mouseY, float tickDelta) {
196- Rectangle b = getBounds();
197-
198- if (b.contains(mouseX, mouseY)) {
199- int color = 0x33000000;
200-
201- DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, color);
202- }
203- }
204-
205- @Override
206- public boolean mouseClicked(double x, double y, int button) {
207- if (getBounds().contains(x, y)) {
208- DFScript.MC.getSoundManager().play(PositionedSoundInstance.ambient(SoundEvents.UI_BUTTON_CLICK, 1f,1f));
209-
210- if (button != 0) {
211- CButton insertBefore = new CButton((int) x, (int) y, 40, 8, "Insert Before", () -> {
212- DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex));
213- });
214- CButton insertAfter = new CButton((int) x, (int) y+8, 40, 8, "Insert After", () -> {
215- DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex + 1));
216- });
217- CButton delete = new CButton((int) x, (int) y+16, 40, 8, "Delete", () -> {
218- script.getParts().remove(currentIndex);
219- scroll = panel.getScroll();
220- DFScript.MC.setScreen(new ScriptEditScreen(script));
221- });
222- DFScript.MC.send(() -> {
223- panel.add(insertBefore);
224- panel.add(insertAfter);
225- panel.add(delete);
226- contextMenu.add(insertBefore);
227- contextMenu.add(insertAfter);
228- contextMenu.add(delete);
229- });
230-
231- return true;
232- }
233- }
234- return false;
235- }
236- });
237-
238- createIndent(indent, y);
239- } else {
240- throw new IllegalArgumentException("Unknown script part type");
241- }
242-
243- y += 10;
244- index++;
245- }
246-
247- CButton add = new CButton(37, y, 46, 8, "Add", () -> {
248- DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, script.getParts().size()));
249- });
250-
251- panel.add(add);
252- panel.setScroll(scroll);*/
25338 }
25439
25540 public void reload ()
0 commit comments