File tree Expand file tree Collapse file tree 3 files changed +53
-10
lines changed
common/src/main/kotlin/com/lambda/newgui Expand file tree Collapse file tree 3 files changed +53
-10
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ class TitleBar(
2424 textHAlignment = HAlign .CENTER
2525
2626 onUpdate {
27+ offsetX = NewCGui .fontOffset
2728 scale = NewCGui .fontScale
2829 }
2930 }
Original file line number Diff line number Diff line change 1+ package com.lambda.newgui.impl.clickgui
2+
3+ import com.lambda.config.AbstractSetting
4+ import com.lambda.module.modules.client.NewCGui
5+ import com.lambda.newgui.component.HAlign
6+ import com.lambda.newgui.component.layout.Layout
7+ import com.lambda.newgui.component.window.Window
8+ import com.lambda.util.math.Vec2d
9+
10+ /* *
11+ * A base class for setting layouts.
12+ */
13+ abstract class SettingLayout <V : Any , T : AbstractSetting <V >> (
14+ owner : Layout ,
15+ setting : T ,
16+ expandable : Boolean = false
17+ ) : Window( // going to use window to easily implement expandable settings (such as color picker)
18+ owner,
19+ setting.name,
20+ Vec2d .ZERO , Vec2d .ZERO ,
21+ false , false ,
22+ if (expandable) Minimizing .Relative else Minimizing .Disabled ,
23+ false ,
24+ AutoResize .ForceEnabled ,
25+ true
26+ ) {
27+ init {
28+ overrideSize(owner::renderWidth, NewCGui ::settingsHeight)
29+ minimized = true
30+
31+ with (titleBar.textField) {
32+ text = setting.name
33+ bold = false
34+ textHAlignment = HAlign .LEFT
35+
36+ onUpdate {
37+ scale = NewCGui .fontScale * 0.92
38+ }
39+ }
40+
41+ children.removeAll(listOf (titleBarRect, contentRect, outlineRect))
42+ if (! expandable) children.remove(content)
43+ }
44+ }
Original file line number Diff line number Diff line change 11package com.lambda.newgui.impl.clickgui.settings
22
33import com.lambda.config.settings.comparable.BooleanSetting
4- import com.lambda.module.modules.client.NewCGui
5- import com.lambda.newgui.component.core.TextField.Companion.textField
64import com.lambda.newgui.component.core.UIBuilder
75import com.lambda.newgui.component.layout.Layout
6+ import com.lambda.newgui.impl.clickgui.SettingLayout
7+ import com.lambda.util.Mouse
88
99class BooleanButton (
1010 owner : Layout ,
11- val setting : BooleanSetting
12- ) : Layout (owner, true , true ) {
11+ setting : BooleanSetting
12+ ) : SettingLayout<Boolean, BooleanSetting> (owner, setting ) {
1313 init {
14- overrideSize(owner::renderWidth, NewCGui ::settingsHeight)
15-
16- textField {
17- text = setting.name
18- scale = NewCGui .fontScale * 0.95
19- offsetX = NewCGui .fontOffset
14+ titleBar.onMouseClick { button, action ->
15+ if (button == Mouse .Button .Left && action == Mouse .Action .Click ) {
16+ setting.value = ! setting.value
17+ }
2018 }
2119 }
2220
You can’t perform that action at this time.
0 commit comments