use of net.wurstclient.features.Category in project Wurst-MC-1.12 by Wurst-Imperium.
the class ClickGui method init.
public void init() {
LinkedHashMap<Category, Window> windowMap = new LinkedHashMap<>();
for (Category category : Category.values()) windowMap.put(category, new Window(category.getName()));
ArrayList<Feature> features = new ArrayList<>();
features.addAll(WurstClient.INSTANCE.mods.getAllMods());
features.addAll(WurstClient.INSTANCE.commands.getAllCommands());
features.addAll(WurstClient.INSTANCE.special.getAllFeatures());
for (Feature f : features) if (f.getCategory() != null)
windowMap.get(f.getCategory()).add(new FeatureButton(f));
windows.addAll(windowMap.values());
int x = 5;
int y = 5;
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
for (Window window : windows) {
window.pack();
window.setMinimized(true);
if (x + window.getWidth() + 5 > sr.getScaledWidth()) {
x = 5;
y += 18;
}
window.setX(x);
window.setY(y);
x += window.getWidth() + 5;
}
JsonObject json;
try (BufferedReader reader = Files.newBufferedReader(windowsFile)) {
json = JsonUtils.jsonParser.parse(reader).getAsJsonObject();
} catch (NoSuchFileException e) {
saveWindows();
return;
} catch (Exception e) {
System.out.println("Failed to load " + windowsFile.getFileName());
e.printStackTrace();
saveWindows();
return;
}
for (Window window : windows) {
JsonElement jsonWindow = json.get(window.getTitle());
if (jsonWindow == null || !jsonWindow.isJsonObject())
continue;
JsonElement jsonX = jsonWindow.getAsJsonObject().get("x");
if (jsonX.isJsonPrimitive() && jsonX.getAsJsonPrimitive().isNumber())
window.setX(jsonX.getAsInt());
JsonElement jsonY = jsonWindow.getAsJsonObject().get("y");
if (jsonY.isJsonPrimitive() && jsonY.getAsJsonPrimitive().isNumber())
window.setY(jsonY.getAsInt());
JsonElement jsonMinimized = jsonWindow.getAsJsonObject().get("minimized");
if (jsonMinimized.isJsonPrimitive() && jsonMinimized.getAsJsonPrimitive().isBoolean())
window.setMinimized(jsonMinimized.getAsBoolean());
JsonElement jsonPinned = jsonWindow.getAsJsonObject().get("pinned");
if (jsonPinned.isJsonPrimitive() && jsonPinned.getAsJsonPrimitive().isBoolean())
window.setPinned(jsonPinned.getAsBoolean());
}
saveWindows();
}
Aggregations