mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-28 07:22:21 -08:00
Implements Anuken/Mindustry-Suggestions/issues/4665
This commit is contained in:
parent
8c93fb5f10
commit
73e9ed4919
2 changed files with 48 additions and 7 deletions
|
|
@ -681,7 +681,6 @@ resources.max = Max
|
|||
bannedblocks = Banned Blocks
|
||||
objectives = Objectives
|
||||
bannedunits = Banned Units
|
||||
rules.hidebannedblocks = Hide Banned Blocks
|
||||
bannedunits.whitelist = Banned Units As Whitelist
|
||||
bannedblocks.whitelist = Banned Blocks As Whitelist
|
||||
addall = Add All
|
||||
|
|
@ -1223,6 +1222,8 @@ mode.attack.name = Attack
|
|||
mode.attack.description = Destroy the enemy's base. \n[gray]Requires a red core in the map to play.
|
||||
mode.custom = Custom Rules
|
||||
|
||||
rules.invaliddata = Invalid clipboard data.
|
||||
rules.hidebannedblocks = Hide Banned Blocks
|
||||
rules.infiniteresources = Infinite Resources
|
||||
rules.onlydepositcore = Only Allow Core Depositing
|
||||
rules.reactorexplosions = Reactor Explosions
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import mindustry.game.*;
|
|||
import mindustry.game.Rules.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.type.Weather.*;
|
||||
import mindustry.ui.*;
|
||||
|
|
@ -38,6 +39,51 @@ public class CustomRulesDialog extends BaseDialog{
|
|||
setFillParent(true);
|
||||
shown(this::setup);
|
||||
addCloseButton();
|
||||
|
||||
buttons.button("@edit", Icon.pencil, () -> {
|
||||
BaseDialog dialog = new BaseDialog("@waves.edit");
|
||||
dialog.addCloseButton();
|
||||
dialog.setFillParent(false);
|
||||
|
||||
dialog.cont.table(Tex.button, t -> {
|
||||
var style = Styles.cleart;
|
||||
t.defaults().size(280f, 64f).pad(2f);
|
||||
|
||||
t.button("@waves.copy", Icon.copy, style, () -> {
|
||||
ui.showInfoFade("@waves.copied");
|
||||
Core.app.setClipboardText(JsonIO.write(rules));
|
||||
dialog.hide();
|
||||
}).marginLeft(12f).row();
|
||||
|
||||
t.button("@waves.load", Icon.download, style, () -> {
|
||||
try{
|
||||
Rules newRules = JsonIO.read(Rules.class, Core.app.getClipboardText());
|
||||
//objectives and spawns are considered to be map-specific; don't use them
|
||||
newRules.spawns = rules.spawns;
|
||||
newRules.objectives = rules.objectives;
|
||||
rules = newRules;
|
||||
refresh();
|
||||
}catch(Throwable e){
|
||||
Log.err(e);
|
||||
ui.showErrorMessage("@rules.invaliddata");
|
||||
}
|
||||
dialog.hide();
|
||||
}).disabled(Core.app.getClipboardText() == null || !Core.app.getClipboardText().startsWith("{")).marginLeft(12f).row();
|
||||
|
||||
t.button("@settings.reset", Icon.refresh, style, () -> {
|
||||
rules = resetter.get();
|
||||
refresh();
|
||||
}).marginLeft(12f);
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
});
|
||||
}
|
||||
|
||||
void refresh(){
|
||||
setup();
|
||||
requestKeyboard();
|
||||
requestScroll();
|
||||
}
|
||||
|
||||
private <T extends UnlockableContent> void showBanned(String title, ContentType type, ObjectSet<T> set, Boolf<T> pred){
|
||||
|
|
@ -128,12 +174,6 @@ public class CustomRulesDialog extends BaseDialog{
|
|||
cont.clear();
|
||||
cont.pane(m -> main = m).scrollX(false);
|
||||
main.margin(10f);
|
||||
main.button("@settings.reset", () -> {
|
||||
rules = resetter.get();
|
||||
setup();
|
||||
requestKeyboard();
|
||||
requestScroll();
|
||||
}).size(300f, 50f);
|
||||
main.left().defaults().fillX().left().pad(5);
|
||||
main.row();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue