use of org.bleachhack.gui.clickgui.window.UIWindow in project BleachHack by BleachDrinker420.
the class BleachFileHelper method readUI.
public static void readUI() {
JsonObject jo = BleachJsonHelper.readJsonFile("ui.json");
if (jo == null)
return;
Map<String, UIWindow> uiWindows = UIClickGuiScreen.INSTANCE.getUIContainer().windows;
for (Entry<String, JsonElement> e : jo.entrySet()) {
if (!e.getValue().isJsonObject() || !uiWindows.containsKey(e.getKey()))
continue;
JsonObject jw = e.getValue().getAsJsonObject();
if (!jw.has("x") || !jw.has("y"))
continue;
Position pos = new Position(jw.get("x").getAsDouble(), jw.get("y").getAsDouble());
if (jw.has("attachments")) {
for (Entry<String, JsonElement> ja : jw.get("attachments").getAsJsonObject().entrySet()) {
if (uiWindows.containsKey(ja.getKey()) || ja.getKey().length() == 1) {
pos.addAttachment(ja.getKey(), ja.getValue().getAsInt());
}
}
}
uiWindows.get(e.getKey()).position = pos;
}
}
use of org.bleachhack.gui.clickgui.window.UIWindow in project BleachHack by BleachDrinker420.
the class BleachFileHelper method saveUI.
public static void saveUI() {
JsonObject jo = new JsonObject();
for (Entry<String, UIWindow> w : UIClickGuiScreen.INSTANCE.getUIContainer().windows.entrySet()) {
JsonObject jw = new JsonObject();
jw.addProperty("x", w.getValue().position.xPercent);
jw.addProperty("y", w.getValue().position.yPercent);
JsonObject ja = new JsonObject();
for (Object2IntMap.Entry<String> atm : w.getValue().position.getAttachments().object2IntEntrySet()) {
ja.add(atm.getKey(), new JsonPrimitive(atm.getIntValue()));
}
if (ja.size() > 0) {
jw.add("attachments", ja);
}
jo.add(w.getKey(), jw);
}
BleachJsonHelper.setJsonFile("ui.json", jo);
}
use of org.bleachhack.gui.clickgui.window.UIWindow in project BleachHack by BleachDrinker420.
the class UIClickGuiScreen method render.
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
BleachFileHelper.SCHEDULE_SAVE_UI.set(true);
uiContainer.updatePositions(width, height);
for (UIWindow w : uiContainer.windows.values()) {
boolean shouldClose = w.shouldClose();
if (shouldClose && !w.closed)
w.detachFromOthers(false);
w.closed = shouldClose;
}
super.render(matrices, mouseX, mouseY, delta);
}
Aggregations