Skip to content

Commit

Permalink
Added settings menu and import tags setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sbxte committed Mar 19, 2024
1 parent 101312c commit 31b5b38
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
6 changes: 5 additions & 1 deletion assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ schematicbrowser.fail.parse = Failed to parse {0} {1}
schematicbrowser.togglevisibility = Toggle visibility
schematicbrowser.cleartags = Clear tags
schematicbrowser.prunetags = Prune tags
schematicbrowser.tagged = {0}/{1} tagged
schematicbrowser.tagged = {0}/{1} tagged

# Settings
setting.schematicbrowserimporttags.name = Import schematic browser tag
setting.schematicbrowserimporttags.description = Whether to import tags when downloading schematic from schematic browser
19 changes: 19 additions & 0 deletions src/schembrowser/SchematicBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mindustry.gen.*;
import mindustry.input.*;
import mindustry.mod.*;
import mindustry.ui.dialogs.SettingsMenuDialog;
import schembrowser.ui.*;

import static mindustry.Vars.*;
Expand Down Expand Up @@ -44,5 +45,23 @@ public boolean keyDown(InputEvent event, KeyCode keycode) {
return super.keyDown(event, keycode);
}
});

// Settings Menu
ui.settings.getCategories().add(settingsCategory());
}

public static SettingsMenuDialog.SettingsCategory settingsCategory() {
return new SettingsMenuDialog.SettingsCategory(
Core.bundle.format("schematicbrowser"),
// new TextureRegionDrawable(Core.atlas.find("schematic-browser-logo")), // FINISHME: Use sprite logo
Icon.host,
SchematicBrowser::settingsMenuTable
);
}

public static void settingsMenuTable(SettingsMenuDialog.SettingsTable table) {
table.checkPref("schematicbrowserimporttags", true);
}
}


7 changes: 6 additions & 1 deletion src/schembrowser/ui/SchematicBrowserDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ void setupRepoUi(Table table, String searchString, String repo){
buttons.button(Icon.upload, style, () -> showExport(s)).tooltip("@editor.export");
buttons.button(Icon.download, style, () -> {
ui.showInfoFade("@schematic.saved");
schematics.add(s);
if (Core.settings.getBool("schematicbrowserimporttags")) schematics.add(s);
else {
Schematic cpy = new Schematic(s.tiles, s.tags, s.width, s.height);
cpy.labels.clear();
schematics.add(cpy);
}
Reflect.invoke(ui.schematics, "checkTags", new Object[]{s}, Schematic.class); // Vars.ui.schematics.checkTags(s)
}).tooltip("@schematicbrowser.download");
}).growX().height(50f);
Expand Down

0 comments on commit 31b5b38

Please sign in to comment.