1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package io.polyfrost.oneconfig.gui.pages;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.config.data.Mod;
import io.polyfrost.oneconfig.config.data.OptionPage;
import io.polyfrost.oneconfig.config.interfaces.BasicOption;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
public class ModConfigPage extends Page {
private final OptionPage page;
public ModConfigPage(OptionPage page) {
super("Mod: " + page.mod.name);
this.page = page;
}
@Override
public void draw(long vg, int x, int y) {
if (page.categories.size() == 0) return;
String selectedCategory = page.categories.keySet().stream().findFirst().get();
int optionX = x + 16;
int optionY = y + (page.categories.size() == 1 ? 32 : 72);
for (String subCategory : page.categories.get(selectedCategory).keySet()) {
RenderManager.drawString(vg, subCategory, x + 18, optionY, OneConfigConfig.WHITE, 24f, Fonts.INTER_MEDIUM);
optionY += 20;
int backgroundSize = 32;
for (int i = 0; i < page.categories.get(selectedCategory).get(subCategory).size(); i++) {
BasicOption option = page.categories.get(selectedCategory).get(subCategory).get(i);
if (i + 1 < page.categories.get(selectedCategory).get(subCategory).size()) {
BasicOption nextOption = page.categories.get(selectedCategory).get(subCategory).get(i + 1);
if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
backgroundSize += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
i++;
continue;
}
}
backgroundSize += option.getHeight();
}
RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20);
optionY += 16;
for (int i = 0; i < page.categories.get(selectedCategory).get(subCategory).size(); i++) {
BasicOption option = page.categories.get(selectedCategory).get(subCategory).get(i);
option.draw(vg, optionX, optionY);
if (i + 1 < page.categories.get(selectedCategory).get(subCategory).size()) {
BasicOption nextOption = page.categories.get(selectedCategory).get(subCategory).get(i + 1);
if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
nextOption.draw(vg, optionX + 464, optionY);
optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
i++;
continue;
}
}
optionY += option.getHeight() + 16;
}
}
}
@Override
public void finishUpAndClose() {
page.mod.config.save(); // TODO
}
}
|