Skip to content

Commit

Permalink
feat: add extension field to search target file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharlottes committed Nov 7, 2023
1 parent 2a53e58 commit c746823
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/mlogwatcher/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import arc.scene.Group;
import arc.scene.ui.Dialog;
import arc.scene.ui.Label;
import arc.scene.ui.TextField;
import arc.scene.ui.layout.*;

import mindustry.Vars;
Expand All @@ -12,20 +13,31 @@

public class Setting {
public static void init(){
Label label = new Label(Core.settings.getString("mlogwatcher-mlog-path", "[lightgray]none[]"));
label.setFontScale(0.75f);

TextField field = new TextField();
field.setText("mlog");
field.setFilter((f, c) -> c != ' ' && c != '.');
field.setMessageText("no ext");

Dialog dialog = new BaseDialog("MlogWatcher Setting");
dialog.addCloseButton();
dialog.cont.center();
dialog.cont.add("current .mlog target path").row();
Label label = dialog.cont.add(Core.settings.getString("mlogwatcher-mlog-path", "[lightgray]none[]")).fontScale(0.75f).get();
dialog.row();
dialog.cont.add("current mlog target path").row();
dialog.cont.add(label).row();
dialog.cont.button("Change watcher target", () -> {
Vars.platform.showFileChooser(true, "open target file to watch", "mlog", fi -> {
Vars.platform.showFileChooser(true, "open target file to watch", field.getText(), fi -> {
label.setText(fi.absolutePath());
Core.settings.put("mlogwatcher-mlog-path", fi.absolutePath());
FileWatcher.stopWatcherThread();
FileWatcher.startWatcherThread();
});
}).width(280f).height(60f).pad(16f);
}).width(280f).height(60f).pad(16f).row();
dialog.cont.table(fieldTable -> {
fieldTable.add("file extension to search: ");
fieldTable.add(field);
});

Vars.ui.settings.shown(() -> {
Table settingUi = (Table)((Group)((Group)(Vars.ui.settings.getChildren().get(1))).getChildren().get(0)).getChildren().get(0); //This looks so stupid lol
Expand Down

0 comments on commit c746823

Please sign in to comment.