@@ -99,6 +99,35 @@ class StrSetting extends Setting<string> {
99
99
}
100
100
}
101
101
102
+ class BuildPrefSetting extends Setting < string [ ] [ ] > {
103
+ public get value ( ) {
104
+ return super . value ;
105
+ }
106
+ public set value ( value : string [ ] [ ] ) {
107
+ if ( ! Array . isArray ( value ) ) {
108
+ super . value = super . default ;
109
+ return ;
110
+ }
111
+ if ( value . length <= 0 ) {
112
+ super . value = super . default ;
113
+ return ;
114
+ }
115
+ for ( const pref of value ) {
116
+ if ( ! Array . isArray ( pref ) || pref . length !== 2 ) {
117
+ super . value = super . default ;
118
+ return ;
119
+ }
120
+ for ( const i of pref ) {
121
+ if ( typeof i !== "string" ) {
122
+ super . value = super . default ;
123
+ return ;
124
+ }
125
+ }
126
+ }
127
+ super . value = value ;
128
+ }
129
+ }
130
+
102
131
/**
103
132
* This class encapsulates all device/project specific settings and
104
133
* provides common operations on them.
@@ -114,6 +143,7 @@ export class DeviceSettings {
114
143
public prebuild = new StrSetting ( ) ;
115
144
public postbuild = new StrSetting ( ) ;
116
145
public programmer = new StrSetting ( ) ;
146
+ public buildPreferences = new BuildPrefSetting ( ) ;
117
147
118
148
/**
119
149
* @returns true if any of the settings values has its modified flag
@@ -129,7 +159,8 @@ export class DeviceSettings {
129
159
this . configuration . modified ||
130
160
this . prebuild . modified ||
131
161
this . postbuild . modified ||
132
- this . programmer . modified ;
162
+ this . programmer . modified ||
163
+ this . buildPreferences . modified ;
133
164
}
134
165
/**
135
166
* Clear modified flags of all settings values.
@@ -145,6 +176,7 @@ export class DeviceSettings {
145
176
this . prebuild . commit ( ) ;
146
177
this . postbuild . commit ( ) ;
147
178
this . programmer . commit ( ) ;
179
+ this . buildPreferences . commit ( ) ;
148
180
}
149
181
/**
150
182
* Resets all settings values to their default values.
@@ -162,6 +194,7 @@ export class DeviceSettings {
162
194
this . prebuild . reset ( ) ;
163
195
this . postbuild . reset ( ) ;
164
196
this . programmer . reset ( ) ;
197
+ this . buildPreferences . reset ( ) ;
165
198
if ( commit ) {
166
199
this . commit ( ) ;
167
200
}
@@ -187,6 +220,7 @@ export class DeviceSettings {
187
220
this . prebuild . value = settings . prebuild ;
188
221
this . postbuild . value = settings . postbuild ;
189
222
this . programmer . value = settings . programmer ;
223
+ this . buildPreferences . value = settings . buildPreferences ;
190
224
if ( commit ) {
191
225
this . commit ( ) ;
192
226
}
0 commit comments