@@ -8,18 +8,17 @@ import { BuildingUpgradeSettingsUi } from "./BuildingUpgradeSettingsUi.js";
8
8
import { Delimiter } from "./components/Delimiter.js" ;
9
9
import { Dialog } from "./components/Dialog.js" ;
10
10
import { HeaderListItem } from "./components/HeaderListItem.js" ;
11
- import { SettingListItem , type SettingListItemOptions } from "./components/SettingListItem.js" ;
11
+ import { SettingListItem } from "./components/SettingListItem.js" ;
12
12
import { SettingTriggerListItem } from "./components/SettingTriggerListItem.js" ;
13
13
import { SettingsList } from "./components/SettingsList.js" ;
14
- import { SettingsPanel , type SettingsPanelOptions } from "./components/SettingsPanel.js" ;
14
+ import { SettingsPanel } from "./components/SettingsPanel.js" ;
15
15
import type { UiComponent } from "./components/UiComponent.js" ;
16
16
17
17
export class BonfireSettingsUi extends SettingsPanel < BonfireSettings , SettingTriggerListItem > {
18
18
constructor (
19
19
parent : UiComponent ,
20
20
settings : BonfireSettings ,
21
21
locale : SettingOptions < SupportedLocale > ,
22
- options ?: SettingsPanelOptions < SettingTriggerListItem > & SettingListItemOptions ,
23
22
) {
24
23
const label = parent . host . engine . i18n ( "ui.build" ) ;
25
24
super (
@@ -28,18 +27,13 @@ export class BonfireSettingsUi extends SettingsPanel<BonfireSettings, SettingTri
28
27
new SettingTriggerListItem ( parent , settings , locale , label , {
29
28
onCheck : ( isBatchProcess ?: boolean ) => {
30
29
parent . host . engine . imessage ( "status.auto.enable" , [ label ] ) ;
31
- this . refreshUi ( ) ;
32
- options ?. onCheck ?.( isBatchProcess ) ;
33
30
} ,
34
31
onUnCheck : ( isBatchProcess ?: boolean ) => {
35
32
parent . host . engine . imessage ( "status.auto.disable" , [ label ] ) ;
36
- this . refreshUi ( ) ;
37
- options ?. onUnCheck ?.( isBatchProcess ) ;
38
33
} ,
39
34
onRefresh : ( ) => {
40
- const element = this . settingItem ;
41
- element . triggerButton . inactive = ! settings . enabled || settings . trigger < 0 ;
42
- element . triggerButton . ineffective =
35
+ this . settingItem . triggerButton . inactive = ! settings . enabled || settings . trigger < 0 ;
36
+ this . settingItem . triggerButton . ineffective =
43
37
settings . enabled &&
44
38
settings . trigger < 0 &&
45
39
! Object . values ( settings . buildings ) . some ( _ => _ . enabled && 0 < _ . max && 0 <= _ . trigger ) ;
@@ -56,12 +50,14 @@ export class BonfireSettingsUi extends SettingsPanel<BonfireSettings, SettingTri
56
50
! settings . upgradeBuildings . enabled ;
57
51
} ,
58
52
onRefreshTrigger : ( ) => {
59
- const element = this . settingItem ;
60
- element . triggerButton . element [ 0 ] . title = parent . host . engine . i18n ( "ui.trigger.section" , [
61
- settings . trigger < 0
62
- ? parent . host . engine . i18n ( "ui.trigger.section.inactive" )
63
- : parent . host . renderPercentage ( settings . trigger , locale . selected , true ) ,
64
- ] ) ;
53
+ this . settingItem . triggerButton . element [ 0 ] . title = parent . host . engine . i18n (
54
+ "ui.trigger.section" ,
55
+ [
56
+ settings . trigger < 0
57
+ ? parent . host . engine . i18n ( "ui.trigger.section.inactive" )
58
+ : parent . host . renderPercentage ( settings . trigger , locale . selected , true ) ,
59
+ ] ,
60
+ ) ;
65
61
} ,
66
62
onSetTrigger : async ( ) => {
67
63
const value = await Dialog . prompt (
@@ -95,100 +91,95 @@ export class BonfireSettingsUi extends SettingsPanel<BonfireSettings, SettingTri
95
91
// We want the ability to use `this` in our callbacks, to construct more complex
96
92
// usage scenarios where we need access to the entire UI section.
97
93
this . addChildren ( [
98
- new SettingsList ( parent , {
99
- children : coalesceArray (
100
- parent . host . game . bld . buildingGroups . flatMap ( buildingGroup => [
101
- new HeaderListItem ( parent , buildingGroup . title ) ,
94
+ new SettingsList ( this , {
95
+ onReset : ( ) => {
96
+ this . setting . load ( { buildings : new BonfireSettings ( ) . buildings } ) ;
97
+ this . refreshUi ( ) ;
98
+ } ,
99
+ } ) . addChildren (
100
+ coalesceArray (
101
+ this . host . game . bld . buildingGroups . flatMap ( buildingGroup => [
102
+ new HeaderListItem ( this , buildingGroup . title ) ,
102
103
...buildingGroup . buildings . flatMap ( building =>
103
- this . _getBuildOptions ( parent , settings , locale , label , building ) ,
104
+ this . _getBuildOptions ( this , settings , locale , label , building ) ,
104
105
) ,
105
106
buildingGroup !==
106
- parent . host . game . bld . buildingGroups [ parent . host . game . bld . buildingGroups . length - 1 ]
107
- ? new Delimiter ( parent )
107
+ this . host . game . bld . buildingGroups [ this . host . game . bld . buildingGroups . length - 1 ]
108
+ ? new Delimiter ( this )
108
109
: undefined ,
109
110
] ) ,
110
111
) ,
111
- onReset : ( ) => {
112
- this . setting . load ( { buildings : new BonfireSettings ( ) . buildings } ) ;
113
- this . refreshUi ( ) ;
114
- } ,
115
- } ) ,
116
- new SettingsList ( parent , {
117
- children : [
118
- new HeaderListItem ( parent , parent . host . engine . i18n ( "ui.additional" ) ) ,
119
- new SettingListItem (
120
- parent ,
121
- settings . gatherCatnip ,
122
- parent . host . engine . i18n ( "option.catnip" ) ,
123
- {
124
- onCheck : ( ) => {
125
- parent . host . engine . imessage ( "status.sub.enable" , [
126
- parent . host . engine . i18n ( "option.catnip" ) ,
127
- ] ) ;
128
- } ,
129
- onUnCheck : ( ) => {
130
- parent . host . engine . imessage ( "status.sub.disable" , [
131
- parent . host . engine . i18n ( "option.catnip" ) ,
132
- ] ) ;
133
- } ,
112
+ ) ,
113
+ new SettingsList ( this , {
114
+ hasDisableAll : false ,
115
+ hasEnableAll : false ,
116
+ } ) . addChildren ( [
117
+ new HeaderListItem ( this , this . host . engine . i18n ( "ui.additional" ) ) ,
118
+ new SettingListItem ( this , settings . gatherCatnip , this . host . engine . i18n ( "option.catnip" ) , {
119
+ onCheck : ( ) => {
120
+ this . host . engine . imessage ( "status.sub.enable" , [
121
+ this . host . engine . i18n ( "option.catnip" ) ,
122
+ ] ) ;
123
+ } ,
124
+ onUnCheck : ( ) => {
125
+ this . host . engine . imessage ( "status.sub.disable" , [
126
+ this . host . engine . i18n ( "option.catnip" ) ,
127
+ ] ) ;
128
+ } ,
129
+ } ) ,
130
+ new SettingListItem (
131
+ this ,
132
+ settings . turnOnSteamworks ,
133
+ this . host . engine . i18n ( "option.steamworks" ) ,
134
+ {
135
+ onCheck : ( ) => {
136
+ this . host . engine . imessage ( "status.sub.enable" , [
137
+ this . host . engine . i18n ( "option.steamworks" ) ,
138
+ ] ) ;
134
139
} ,
135
- ) ,
136
- new SettingListItem (
137
- parent ,
138
- settings . turnOnSteamworks ,
139
- parent . host . engine . i18n ( "option.steamworks" ) ,
140
- {
141
- onCheck : ( ) => {
142
- parent . host . engine . imessage ( "status.sub.enable" , [
143
- parent . host . engine . i18n ( "option.steamworks" ) ,
144
- ] ) ;
145
- } ,
146
- onUnCheck : ( ) => {
147
- parent . host . engine . imessage ( "status.sub.disable" , [
148
- parent . host . engine . i18n ( "option.steamworks" ) ,
149
- ] ) ;
150
- } ,
140
+ onUnCheck : ( ) => {
141
+ this . host . engine . imessage ( "status.sub.disable" , [
142
+ this . host . engine . i18n ( "option.steamworks" ) ,
143
+ ] ) ;
151
144
} ,
152
- ) ,
153
- new SettingListItem (
154
- parent ,
155
- settings . turnOnMagnetos ,
156
- parent . host . engine . i18n ( "option.magnetos" ) ,
157
- {
158
- onCheck : ( ) => {
159
- parent . host . engine . imessage ( "status.sub.enable" , [
160
- parent . host . engine . i18n ( "option.magnetos" ) ,
161
- ] ) ;
162
- } ,
163
- onUnCheck : ( ) => {
164
- parent . host . engine . imessage ( "status.sub.disable" , [
165
- parent . host . engine . i18n ( "option.magnetos" ) ,
166
- ] ) ;
167
- } ,
145
+ } ,
146
+ ) ,
147
+ new SettingListItem (
148
+ this ,
149
+ settings . turnOnMagnetos ,
150
+ this . host . engine . i18n ( "option.magnetos" ) ,
151
+ {
152
+ onCheck : ( ) => {
153
+ this . host . engine . imessage ( "status.sub.enable" , [
154
+ this . host . engine . i18n ( "option.magnetos" ) ,
155
+ ] ) ;
168
156
} ,
169
- ) ,
170
- new SettingListItem (
171
- parent ,
172
- settings . turnOnReactors ,
173
- parent . host . engine . i18n ( "option.reactors" ) ,
174
- {
175
- onCheck : ( ) => {
176
- parent . host . engine . imessage ( "status.sub.enable" , [
177
- parent . host . engine . i18n ( "option.reactors" ) ,
178
- ] ) ;
179
- } ,
180
- onUnCheck : ( ) => {
181
- parent . host . engine . imessage ( "status.sub.disable" , [
182
- parent . host . engine . i18n ( "option.reactors" ) ,
183
- ] ) ;
184
- } ,
157
+ onUnCheck : ( ) => {
158
+ this . host . engine . imessage ( "status.sub.disable" , [
159
+ this . host . engine . i18n ( "option.magnetos" ) ,
160
+ ] ) ;
185
161
} ,
186
- ) ,
187
- new BuildingUpgradeSettingsUi ( parent , settings . upgradeBuildings , locale , settings ) ,
188
- ] ,
189
- hasDisableAll : false ,
190
- hasEnableAll : false ,
191
- } ) ,
162
+ } ,
163
+ ) ,
164
+ new SettingListItem (
165
+ this ,
166
+ settings . turnOnReactors ,
167
+ this . host . engine . i18n ( "option.reactors" ) ,
168
+ {
169
+ onCheck : ( ) => {
170
+ this . host . engine . imessage ( "status.sub.enable" , [
171
+ this . host . engine . i18n ( "option.reactors" ) ,
172
+ ] ) ;
173
+ } ,
174
+ onUnCheck : ( ) => {
175
+ this . host . engine . imessage ( "status.sub.disable" , [
176
+ this . host . engine . i18n ( "option.reactors" ) ,
177
+ ] ) ;
178
+ } ,
179
+ } ,
180
+ ) ,
181
+ new BuildingUpgradeSettingsUi ( this , settings . upgradeBuildings , locale , settings ) ,
182
+ ] ) ,
192
183
] ) ;
193
184
}
194
185
@@ -215,14 +206,6 @@ export class BonfireSettingsUi extends SettingsPanel<BonfireSettings, SettingTri
215
206
settings ,
216
207
meta . stages [ 0 ] . label ,
217
208
sectionLabel ,
218
- {
219
- onCheck : ( ) => {
220
- this . refreshUi ( ) ;
221
- } ,
222
- onUnCheck : ( ) => {
223
- this . refreshUi ( ) ;
224
- } ,
225
- } ,
226
209
) ,
227
210
BuildSectionTools . getBuildOption (
228
211
parent ,
@@ -233,12 +216,6 @@ export class BonfireSettingsUi extends SettingsPanel<BonfireSettings, SettingTri
233
216
sectionLabel ,
234
217
{
235
218
upgradeIndicator : true ,
236
- onCheck : ( ) => {
237
- this . refreshUi ( ) ;
238
- } ,
239
- onUnCheck : ( ) => {
240
- this . refreshUi ( ) ;
241
- } ,
242
219
} ,
243
220
) ,
244
221
] ;
@@ -252,14 +229,6 @@ export class BonfireSettingsUi extends SettingsPanel<BonfireSettings, SettingTri
252
229
settings ,
253
230
meta . label ,
254
231
sectionLabel ,
255
- {
256
- onCheck : ( ) => {
257
- this . refreshUi ( ) ;
258
- } ,
259
- onUnCheck : ( ) => {
260
- this . refreshUi ( ) ;
261
- } ,
262
- } ,
263
232
) ,
264
233
] ;
265
234
}
0 commit comments