mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
asdfasdf
This commit is contained in:
@@ -76,6 +76,9 @@ setting.shar-title = Informatis Settings
|
||||
setting.shar-ui = Overlay UI Settings
|
||||
setting.shar-draw = Overdrawing Settings
|
||||
|
||||
#UI
|
||||
mode.custom.name = Custom
|
||||
|
||||
#Hud
|
||||
hud.schematic-list = Schematic List
|
||||
|
||||
|
||||
@@ -96,6 +96,9 @@ setting.shar-opacity = 투명도 설정
|
||||
setting.shar-draw = 덧그리기 설정
|
||||
setting.shar-etc = 기타
|
||||
|
||||
#UI
|
||||
mode.custom.name = ??
|
||||
|
||||
#Hud
|
||||
hud.unit = 유닛 정보
|
||||
hud.wave = 단계 정보
|
||||
|
||||
@@ -3,6 +3,7 @@ package informatis.core;
|
||||
import arc.input.KeyCode;
|
||||
import informatis.ui.*;
|
||||
import informatis.ui.draws.OverDraws;
|
||||
import informatis.ui.fragments.FragmentManager;
|
||||
import informatis.ui.window.*;
|
||||
import arc.*;
|
||||
import mindustry.*;
|
||||
@@ -50,7 +51,7 @@ public class Main extends Mod {
|
||||
|
||||
SettingS.init();
|
||||
WindowManager.init();
|
||||
DisplayManager.init();
|
||||
FragmentManager.init();
|
||||
OverDraws.init();
|
||||
OverDrawer.init();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package informatis.ui.display;
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Lines;
|
||||
@@ -13,13 +13,13 @@ import mindustry.graphics.Pal;
|
||||
import static arc.Core.scene;
|
||||
import static arc.Core.settings;
|
||||
|
||||
public class ElementDisplay extends Element {
|
||||
public class ElementViewFragment extends Element {
|
||||
Group root;
|
||||
|
||||
public ElementDisplay() {
|
||||
public ElementViewFragment() {
|
||||
this(scene.root);
|
||||
}
|
||||
public ElementDisplay(Group root) {
|
||||
public ElementViewFragment(Group root) {
|
||||
this.root = root;
|
||||
fillParent = true;
|
||||
touchable = Touchable.disabled;
|
||||
@@ -1,15 +1,12 @@
|
||||
package informatis.ui;
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.struct.Seq;
|
||||
import informatis.ui.display.ElementDisplay;
|
||||
import informatis.ui.display.SchemDisplay;
|
||||
import informatis.ui.display.WaveInfoDisplay;
|
||||
|
||||
import static arc.Core.scene;
|
||||
import static mindustry.Vars.ui;
|
||||
|
||||
public class DisplayManager {
|
||||
public class FragmentManager {
|
||||
public static void init() {
|
||||
//layout debug
|
||||
Seq.with(scene.root,
|
||||
@@ -17,12 +14,12 @@ public class DisplayManager {
|
||||
ui.load, ui.custom, ui.language, ui.database, ui.settings, ui.host,
|
||||
ui.paused, ui.about, ui.bans, ui.admins, ui.traces, ui.maps, ui.content,
|
||||
ui.planet, ui.research, ui.mods, ui.schematics, ui.logic
|
||||
).each(dialog-> dialog.addChild(new ElementDisplay(dialog)));
|
||||
).each(dialog-> dialog.addChild(new ElementViewFragment(dialog)));
|
||||
|
||||
//schem quick-slot
|
||||
Table table = ((Table) scene.find("minimap/position")).row();
|
||||
table.add(new SchemDisplay());
|
||||
new WaveInfoDisplay().addWaveInfoTable();
|
||||
|
||||
table.add(new QuickSchemFragment());
|
||||
new WaveInfoFragment().addWaveInfoTable();
|
||||
new ServerSearchFragment();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package informatis.ui.display;
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import informatis.SUtils;
|
||||
import arc.Core;
|
||||
@@ -26,7 +26,7 @@ import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.Vars.ui;
|
||||
|
||||
public class SchemDisplay extends Table implements Updatable {
|
||||
public class QuickSchemFragment extends Table implements Updatable {
|
||||
static float schemScrollPos, tagScrollPos;
|
||||
static boolean schemShown;
|
||||
static Schematic firstSchematic;
|
||||
@@ -34,7 +34,7 @@ public class SchemDisplay extends Table implements Updatable {
|
||||
static Runnable rebuildList = () -> {};
|
||||
float heat;
|
||||
|
||||
public SchemDisplay() {
|
||||
public QuickSchemFragment() {
|
||||
setSchemTable();
|
||||
}
|
||||
|
||||
164
src/informatis/ui/fragments/ServerSearchFragment.java
Normal file
164
src/informatis/ui/fragments/ServerSearchFragment.java
Normal file
@@ -0,0 +1,164 @@
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import arc.Core;
|
||||
import arc.Events;
|
||||
import arc.func.Cons;
|
||||
import arc.func.Prov;
|
||||
import arc.scene.actions.DelayAction;
|
||||
import arc.scene.actions.RepeatAction;
|
||||
import arc.scene.ui.Label;
|
||||
import arc.scene.ui.TextButton;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.Vars;
|
||||
import mindustry.game.EventType;
|
||||
import mindustry.game.Gamemode;
|
||||
import mindustry.gen.Tex;
|
||||
import mindustry.net.ServerGroup;
|
||||
import mindustry.ui.Styles;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Objects;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class ServerSearchFragment extends Table {
|
||||
String mode;
|
||||
Seq<ServerGroup> tempGroup = new Seq<>();
|
||||
ObjectMap<ServerGroup, String[]> addresses = new ObjectMap<>();
|
||||
boolean loading = false;
|
||||
Label loadingLabel = new Label("loading");
|
||||
public ServerSearchFragment() {
|
||||
super();
|
||||
|
||||
Core.app.post(() -> {
|
||||
tempGroup.set(Vars.defaultServers.copy());
|
||||
tempGroup.each(group -> addresses.put(group, group.addresses));
|
||||
Log.info("[Informatis] Fetched @ community servers.", tempGroup.size);
|
||||
});
|
||||
|
||||
final int[] i = {0};
|
||||
final int[] count = {0};
|
||||
Events.run(EventType.Trigger.update, () -> {
|
||||
if(!loading) {
|
||||
loadingLabel.setText("");
|
||||
return;
|
||||
};
|
||||
i[0] += Time.delta;
|
||||
if(i[0] >= 5) {
|
||||
i[0] = 0;
|
||||
count[0]++;
|
||||
loadingLabel.setText("loading" + (count[0] % 4 == 0 ? "" : count[0] % 4 == 1 ? "." : count[0] % 4 == 2 ? ".." : count[0] % 4 == 3 ? "..." : ""));
|
||||
}
|
||||
});
|
||||
setBackground(Tex.button);
|
||||
addButton("survival");
|
||||
addButton("pvp");
|
||||
addButton("attack");
|
||||
addButton("sandbox");
|
||||
addButton("custom");
|
||||
Vars.ui.join.shown(this::addFragment);
|
||||
}
|
||||
|
||||
void refreshAll() {
|
||||
Method refreshAll;
|
||||
try {
|
||||
refreshAll = Vars.ui.join.getClass().getDeclaredMethod("refreshAll");
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
refreshAll.setAccessible(true);
|
||||
try {
|
||||
refreshAll.invoke(Vars.ui.join);
|
||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
void refresh(boolean toggle) throws NoSuchMethodException {
|
||||
if(!toggle) {
|
||||
Log.info("trying backdown");
|
||||
Vars.defaultServers.set(tempGroup);
|
||||
defaultServers.each(group -> group.addresses = addresses.get(group));
|
||||
refreshAll();
|
||||
return;
|
||||
}
|
||||
loading = true;
|
||||
getChildren().each(elem -> ((TextButton)elem).setDisabled(true));
|
||||
Time.run(15 * 60, () -> {
|
||||
loading = false;
|
||||
mode = "";
|
||||
getChildren().each(elem -> ((TextButton)elem).setDisabled(false));
|
||||
refreshAll();
|
||||
});
|
||||
final int[] iStack = {0};
|
||||
for(int i = 0; i < tempGroup.size; i ++){
|
||||
int j = i;
|
||||
ServerGroup group = tempGroup.get((i + tempGroup.size/2) % tempGroup.size);
|
||||
Seq<String> tmp = Seq.with(group.addresses);
|
||||
|
||||
final int[] iiStack = {0};
|
||||
int addressesLength = group.addresses.length;
|
||||
for(int ii = 0; ii < addressesLength; ii++){
|
||||
String address = tmp.get(ii);
|
||||
String resaddress = address.contains(":") ? address.split(":")[0] : address;
|
||||
int resport = address.contains(":") ? Strings.parseInt(address.split(":")[1]) : Vars.port;
|
||||
Vars.net.pingHost(resaddress, resport, res -> {
|
||||
if(!loading || (tmp.contains(address) && res.mode == null
|
||||
? Objects.equals(res.modeName, mode)
|
||||
: !Objects.equals(mode, "custom") && res.mode.equals(Gamemode.valueOf(mode))
|
||||
)) {
|
||||
tmp.remove(address);
|
||||
group.addresses = tmp.toArray();
|
||||
Log.info(address + " has been removed");
|
||||
Vars.defaultServers.set((j + Vars.defaultServers.size/2) % Vars.defaultServers.size, group);
|
||||
}
|
||||
if(++iiStack[0] < addressesLength) return;
|
||||
if(++iStack[0] < tempGroup.size) return;
|
||||
loading = false;
|
||||
mode = "";
|
||||
getChildren().each(elem -> ((TextButton)elem).setDisabled(false));
|
||||
refreshAll();
|
||||
}, e -> {
|
||||
if(!loading) return;
|
||||
if(++iiStack[0] < addressesLength) return;
|
||||
if(++iStack[0] < tempGroup.size) return;
|
||||
loading = false;
|
||||
mode = "";
|
||||
getChildren().each(elem -> ((TextButton)elem).setDisabled(false));
|
||||
refreshAll();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addFragment() {
|
||||
Table serverTable = (Table) Vars.ui.join.getChildren().get(1);
|
||||
var saved = serverTable.getChildren().copy();
|
||||
|
||||
serverTable.clear();
|
||||
serverTable.add(saved.get(0)).row();
|
||||
serverTable.add(this).row();
|
||||
serverTable.add(loadingLabel).pad(5).row();
|
||||
serverTable.add(saved.get(1)).row();
|
||||
serverTable.add(saved.get(2));
|
||||
}
|
||||
|
||||
void addButton(String string) {
|
||||
TextButton button = new TextButton("@mode." + string + ".name", Styles.flatTogglet);
|
||||
button.getLabel().setWrap(false);
|
||||
button.clicked(()-> {
|
||||
getChildren().each(elem -> {
|
||||
if(!elem.equals(button)) ((TextButton)elem).setChecked(false);
|
||||
});
|
||||
mode = string;
|
||||
try {
|
||||
Log.info(button.isChecked());
|
||||
refresh(button.isChecked());
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
add(button).minWidth(100).height(50);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package informatis.ui.display;
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
@@ -14,7 +14,7 @@ import static informatis.SVars.*;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class WaveInfoDisplay {
|
||||
public class WaveInfoFragment {
|
||||
private boolean waveShown;
|
||||
|
||||
public void addWaveInfoTable() {
|
||||
Reference in New Issue
Block a user