forked from DFScripting/DFScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1) moved all the control actions into a new category called Control
2) rewrote a lot of the code to be easier to add on 3) you can now invert conditions 4) we gotta test this code lol
- Loading branch information
Showing
56 changed files
with
2,986 additions
and
1,034 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/main/java/io/github/techstreet/dfscript/screen/ContextMenuButton.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,41 @@ | ||
package io.github.techstreet.dfscript.screen; | ||
|
||
import io.github.techstreet.dfscript.DFScript; | ||
import io.github.techstreet.dfscript.screen.script.ScriptEditScreen; | ||
|
||
public class ContextMenuButton { | ||
String name; | ||
Runnable onClick; | ||
|
||
boolean reloadOnClick; | ||
|
||
public ContextMenuButton(String name, Runnable onClick) { | ||
this.name = name; | ||
this.onClick = onClick; | ||
this.reloadOnClick = true; | ||
} | ||
|
||
public ContextMenuButton(String name, Runnable onClick, boolean reloadOnClick) { | ||
this.name = name; | ||
this.onClick = onClick; | ||
this.reloadOnClick = reloadOnClick; | ||
} | ||
|
||
public Runnable getOnClick() { | ||
if(reloadOnClick) { | ||
return () -> { | ||
onClick.run(); | ||
if(DFScript.MC.currentScreen instanceof ScriptEditScreen editScreen) | ||
{ | ||
editScreen.reload(); | ||
} | ||
}; | ||
} | ||
|
||
return onClick; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
105 changes: 0 additions & 105 deletions
105
src/main/java/io/github/techstreet/dfscript/screen/script/ScriptAddActionScreen.java
This file was deleted.
Oops, something went wrong.
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
64 changes: 64 additions & 0 deletions
64
src/main/java/io/github/techstreet/dfscript/screen/script/ScriptAddHeaderScreen.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,64 @@ | ||
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.script.Script; | ||
import io.github.techstreet.dfscript.script.action.ScriptAction; | ||
import io.github.techstreet.dfscript.script.action.ScriptActionCategory; | ||
import io.github.techstreet.dfscript.script.action.ScriptActionCategoryExtra; | ||
import io.github.techstreet.dfscript.script.action.ScriptActionType; | ||
import io.github.techstreet.dfscript.script.event.ScriptEvent; | ||
import io.github.techstreet.dfscript.script.event.ScriptEventType; | ||
import io.github.techstreet.dfscript.script.event.ScriptHeaderCategory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ScriptAddHeaderScreen extends CScreen { | ||
|
||
private final Script script; | ||
private final int insertIndex; | ||
|
||
public ScriptAddHeaderScreen(Script script, int insertIndex, ScriptHeaderCategory category) { | ||
super(size(category), size(category)); | ||
int size = size(category); | ||
this.script = script; | ||
this.insertIndex = insertIndex; | ||
|
||
int x = 3; | ||
int y = 3; | ||
|
||
for (ScriptEventType type : ScriptEventType.values()) { | ||
//if (type.getCategory() != category) continue; | ||
|
||
CItem item = new CItem(x, y, type.getIcon()); | ||
item.setClickListener((btn) -> { | ||
ScriptEvent event = new ScriptEvent(type); | ||
script.getHeaders().add(insertIndex, event); | ||
DFScript.MC.setScreen(new ScriptEditScreen(script)); | ||
}); | ||
widgets.add(item); | ||
x += 10; | ||
if (x >= size-10) { | ||
x = 3; | ||
y += 10; | ||
} | ||
} | ||
} | ||
|
||
private static int size(ScriptHeaderCategory category) { | ||
int amount = 0; | ||
for (ScriptEventType type : ScriptEventType.values()) { | ||
//if (type.getCategory() != category) continue; | ||
|
||
amount++; | ||
} | ||
return (int) (Math.ceil(Math.sqrt(amount))*10)+4; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
DFScript.MC.setScreen(new ScriptHeaderCategoryScreen(script, insertIndex)); | ||
} | ||
} |
Oops, something went wrong.