Skip to content

Commit 990ce83

Browse files
committed
Added some CategoryCSGO options
1 parent c5f27d5 commit 990ce83

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

example-mod12/src/main/java/com/lukflug/examplemod12/ExampleMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class ExampleMod {
2424
public static final String MODID="example-mod12";
2525
public static final String NAME="PanelStudio-MC12 Example Mod";
26-
public static final String VERSION="0.2.0";
26+
public static final String VERSION="0.2.1";
2727
public static Logger logger;
2828
private static ClickGUI gui;
2929

example-mod8-forge/src/main/java/com/lukflug/examplemod8forge/ExampleMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class ExampleMod {
2424
public static final String MODID="example-mod8-forge";
2525
public static final String NAME="PanelStudio-MC8-Forge Example Mod";
26-
public static final String VERSION="0.2.0";
26+
public static final String VERSION="0.2.1";
2727
public static Logger logger;
2828
private static ClickGUI gui;
2929

panelstudio/src/main/java/com/lukflug/panelstudio/layout/CSGOLayout.java

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public class CSGOLayout implements ILayout,IScrollSize {
6262
* Whether settings are in a separate column.
6363
*/
6464
protected boolean moduleColumn;
65+
/**
66+
* The width of the category column.
67+
*/
68+
protected int columnWidth;
6569
/**
6670
* The weight of the settings column.
6771
*/
@@ -90,13 +94,33 @@ public class CSGOLayout implements ILayout,IScrollSize {
9094
* @param popupType child util instance
9195
*/
9296
public CSGOLayout (ILabeled label, Point position, int width, int popupWidth, Supplier<Animation> animation, String enabledButton, boolean horizontal, boolean moduleColumn, int weight, ChildMode colorType, PopupTuple popupType) {
97+
this(label,position,width,popupWidth,animation,enabledButton,horizontal,moduleColumn,-1,weight,colorType,popupType);
98+
}
99+
100+
/**
101+
* Constructor.
102+
* @param label panel label
103+
* @param position panel position
104+
* @param width panel width
105+
* @param popupWidth pop-up width
106+
* @param animation animation supplier
107+
* @param enabledButton title for module toggles
108+
* @param horizontal whether tab list is horizontal
109+
* @param moduleColumn whether settings are in a separate column
110+
* @param columnWidth the width of the category column
111+
* @param weight weight of the module column
112+
* @param colorType child mode to use for setting components that are containers (e.g. color components)
113+
* @param popupType child util instance
114+
*/
115+
public CSGOLayout (ILabeled label, Point position, int width, int popupWidth, Supplier<Animation> animation, String enabledButton, boolean horizontal, boolean moduleColumn, int columnWidth, int weight, ChildMode colorType, PopupTuple popupType) {
93116
this.label=label;
94117
this.position=position;
95118
this.width=width;
96119
this.animation=animation;
97120
this.enabledButton=enabledButton;
98121
this.horizontal=horizontal;
99122
this.moduleColumn=moduleColumn;
123+
this.columnWidth=columnWidth;
100124
this.weight=weight;
101125
this.colorType=colorType;
102126
util=new ChildUtil(popupWidth,animation,popupType);
@@ -113,15 +137,15 @@ public void populateGUI (IComponentAdder gui, IComponentGenerator components, IC
113137
container.addComponent(window);
114138
gui.addComponent(title,container,new ThemeTuple(theme,0,0),position,width,animation);
115139
} else {
116-
catSelect=addContainer(label,client.getCategories().map(cat->cat),window,new ThemeTuple(theme,0,1),false,button->wrapColumn(button,new ThemeTuple(theme,0,1),1),()->true);
140+
catSelect=addContainer(label,client.getCategories().map(cat->cat),window,new ThemeTuple(theme,0,1),false,button->wrapColumn(button,new ThemeTuple(theme,0,1),columnWidth>0?columnWidth:0,columnWidth>0?0:1),()->true);
117141
gui.addComponent(title,window,new ThemeTuple(theme,0,0),position,width,animation);
118142
}
119143
client.getCategories().forEach(category->{
120144
if (moduleColumn) {
121-
IEnumSetting modSelect=addContainer(category,category.getModules().map(mod->mod),window,new ThemeTuple(theme,1,1),false,button->wrapColumn(button,new ThemeTuple(theme,0,1),1),()->catSelect.getValueName()==category.getDisplayName());
145+
IEnumSetting modSelect=addContainer(category,category.getModules().map(mod->mod),window,new ThemeTuple(theme,1,1),false,button->wrapColumn(button,new ThemeTuple(theme,0,1),0,1),()->catSelect.getValueName()==category.getDisplayName());
122146
category.getModules().forEach(module->{
123147
VerticalContainer container=new VerticalContainer(module,theme.getContainerRenderer(1,1,false));
124-
window.addComponent(wrapColumn(container,new ThemeTuple(theme,1,1),weight),()->catSelect.getValueName()==category.getDisplayName()&&modSelect.getValueName()==module.getDisplayName());
148+
window.addComponent(wrapColumn(container,new ThemeTuple(theme,1,1),0,weight),()->catSelect.getValueName()==category.getDisplayName()&&modSelect.getValueName()==module.getDisplayName());
125149
if (module.isEnabled()!=null) container.addComponent(components.getComponent(new IBooleanSetting() {
126150
@Override
127151
public String getDisplayName() {
@@ -142,7 +166,7 @@ public boolean isOn() {
142166
});
143167
} else {
144168
VerticalContainer categoryContent=new VerticalContainer(category,theme.getContainerRenderer(0,1,false));
145-
window.addComponent(wrapColumn(categoryContent,new ThemeTuple(theme,0,1),1),()->catSelect.getValueName()==category.getDisplayName());
169+
window.addComponent(wrapColumn(categoryContent,new ThemeTuple(theme,0,1),0,weight),()->catSelect.getValueName()==category.getDisplayName());
146170
category.getModules().forEach(module->{
147171
int graphicalLevel=1;
148172
FocusableComponent moduleTitle;
@@ -268,10 +292,11 @@ protected boolean isDownKey (int key) {
268292
* Wrap content in a scrollable horizontal component to be added as a column.
269293
* @param button the content container
270294
* @param theme the theme to be used
295+
* @param width the horizontal width
271296
* @param weight the horizontal weight
272297
* @return a horizontal component
273298
*/
274-
protected HorizontalComponent<ScrollBarComponent<Void,IComponent>> wrapColumn (IComponent button, ThemeTuple theme, int weight) {
299+
protected HorizontalComponent<ScrollBarComponent<Void,IComponent>> wrapColumn (IComponent button, ThemeTuple theme, int width, int weight) {
275300
return new HorizontalComponent<ScrollBarComponent<Void,IComponent>>(new ScrollBarComponent<Void,IComponent>(button,theme.getScrollBarRenderer(Void.class),theme.getEmptySpaceRenderer(Void.class,false),theme.getEmptySpaceRenderer(Void.class,true)) {
276301
@Override
277302
public int getScrollHeight (Context context, int componentHeight) {
@@ -282,7 +307,7 @@ public int getScrollHeight (Context context, int componentHeight) {
282307
protected Void getState() {
283308
return null;
284309
}
285-
},0,weight);
310+
},width,weight);
286311
}
287312

288313
/**

panelstudio/src/main/java/com/lukflug/panelstudio/layout/ChildUtil.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ public ChildUtil (int width, Supplier<Animation> animation, PopupTuple popupType
6363
* @param theme the theme to be used
6464
* @param mode the child mode to be used
6565
*/
66-
protected <T> void addContainer (ILabeled label, IComponent title, IComponent container, Supplier<T> state, Class<T> stateClass, VerticalContainer parent, IComponentAdder gui, ThemeTuple theme, ChildMode mode) {
66+
public <T> void addContainer (ILabeled label, IComponent title, IComponent container, Supplier<T> state, Class<T> stateClass, VerticalContainer parent, IComponentAdder gui, ThemeTuple theme, ChildMode mode) {
6767
IFixedComponent popup;
6868
IToggleable toggle;
6969
boolean drawTitle=mode==ChildMode.DRAG_POPUP;
7070
switch (mode) {
7171
case DOWN:
72-
parent.addComponent(new ClosableComponent<>(title,container,state,new AnimatedToggleable(new SimpleToggleable(false),animation.get()),theme.getPanelRenderer(stateClass),false));
72+
parent.addComponent(new ClosableComponent<>(title,container,state,getAnimatedToggleable(animation.get()),theme.getPanelRenderer(stateClass),false));
7373
break;
7474
case POPUP:
7575
case DRAG_POPUP:
@@ -92,6 +92,16 @@ public void handleButton (Context context, int button) {
9292
}
9393
}
9494

95+
/**
96+
* Get animated toggleable.
97+
* @param animation the animation to be used
98+
* @return the animated toggleable to be used
99+
*/
100+
protected AnimatedToggleable getAnimatedToggleable (Animation animation) {
101+
return new AnimatedToggleable(new SimpleToggleable(false),animation);
102+
}
103+
104+
95105
/**
96106
* Enum listing the ways a child component can be added.
97107
* @author lukflug

0 commit comments

Comments
 (0)