-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from XTerPL/Functions
Functions
- Loading branch information
Showing
68 changed files
with
2,709 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/io/github/techstreet/dfscript/screen/CReloadableScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.techstreet.dfscript.screen; | ||
|
||
import io.github.techstreet.dfscript.DFScript; | ||
import io.github.techstreet.dfscript.screen.widget.CWidget; | ||
import io.github.techstreet.dfscript.util.RenderUtil; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.text.Text; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class CReloadableScreen extends CScreen { | ||
|
||
public abstract void reload(); | ||
|
||
protected CReloadableScreen(int width, int height) { | ||
super(width, height); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ain/java/io/github/techstreet/dfscript/screen/script/ScriptAddFunctionArgValueScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.github.techstreet.dfscript.screen.script; | ||
|
||
import io.github.techstreet.dfscript.DFScript; | ||
import io.github.techstreet.dfscript.screen.CScreen; | ||
import io.github.techstreet.dfscript.screen.widget.CItem; | ||
import io.github.techstreet.dfscript.screen.widget.CScrollPanel; | ||
import io.github.techstreet.dfscript.script.Script; | ||
import io.github.techstreet.dfscript.script.ScriptParametrizedPart; | ||
import io.github.techstreet.dfscript.script.action.ScriptActionArgument; | ||
import io.github.techstreet.dfscript.script.argument.ScriptConfigArgument; | ||
import io.github.techstreet.dfscript.script.argument.ScriptFunctionArgument; | ||
import io.github.techstreet.dfscript.script.event.ScriptFunction; | ||
import io.github.techstreet.dfscript.script.event.ScriptHeader; | ||
|
||
public class ScriptAddFunctionArgValueScreen extends CScreen { | ||
private final Script script; | ||
|
||
private final ScriptHeader header; | ||
private final ScriptParametrizedPart action; | ||
private final int insertIndex; | ||
|
||
private static int WIDTH = 200; | ||
private static int HEIGHT = 94; | ||
|
||
public ScriptAddFunctionArgValueScreen(ScriptParametrizedPart action, Script script, int insertIndex, ScriptHeader header, String overwrite) { | ||
super(WIDTH, HEIGHT); | ||
this.script = script; | ||
this.action = action; | ||
this.header = header; | ||
this.insertIndex = insertIndex; | ||
|
||
CScrollPanel panel = new CScrollPanel(0, 0, WIDTH, HEIGHT); | ||
|
||
if(header instanceof ScriptFunction f) | ||
{ | ||
int x = 5; | ||
int y = 5; | ||
for (ScriptActionArgument arg : f.argList()) { | ||
CItem item = new CItem(x, y, arg.getIcon()); | ||
item.setClickListener((btn) -> { | ||
if(overwrite != null) action.getArguments().remove(insertIndex); | ||
this.action.getArguments().add(insertIndex, new ScriptFunctionArgument(arg.name(), header)); | ||
DFScript.MC.setScreen(new ScriptEditPartScreen(this.action, this.script, this.header)); | ||
}); | ||
panel.add(item); | ||
x += 10; | ||
if (x > WIDTH-10) { | ||
x = 5; | ||
y += 10; | ||
} | ||
} | ||
|
||
widgets.add(panel); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() { | ||
DFScript.MC.setScreen(new ScriptAddArgumentScreen(script, action, insertIndex, header)); | ||
} | ||
} |
Oops, something went wrong.