|
17 | 17 |
|
18 | 18 | package com.lambda.config |
19 | 19 |
|
20 | | -import com.lambda.Lambda.typeFactory |
21 | 20 | import com.lambda.config.ConfigLoader.configs |
22 | 21 | import com.lambda.config.entries.ConfigEntryDsl |
23 | 22 | import com.lambda.config.entries.Property |
24 | 23 | import com.lambda.config.entries.PropertyEntryLayer |
25 | 24 | import com.lambda.config.entries.Setting |
26 | 25 | import com.lambda.config.entries.SettingEntryLayer |
27 | | -import com.lambda.config.settings.CharSetting |
28 | | -import com.lambda.config.settings.FunctionSetting |
29 | | -import com.lambda.config.settings.StringSetting |
30 | | -import com.lambda.config.settings.collections.BlockCollectionSetting |
31 | | -import com.lambda.config.settings.collections.ClassCollectionSetting |
32 | | -import com.lambda.config.settings.collections.CollectionSetting |
33 | | -import com.lambda.config.settings.collections.FluidCollectionSetting |
34 | | -import com.lambda.config.settings.collections.ItemCollectionSetting |
35 | | -import com.lambda.config.settings.collections.MapSetting |
36 | | -import com.lambda.config.settings.comparable.BooleanSetting |
37 | | -import com.lambda.config.settings.comparable.EnumSetting |
38 | | -import com.lambda.config.settings.complex.Bind |
39 | | -import com.lambda.config.settings.complex.BlockPosSetting |
40 | | -import com.lambda.config.settings.complex.BlockSetting |
41 | | -import com.lambda.config.settings.complex.ColorSetting |
42 | | -import com.lambda.config.settings.complex.KeybindSetting |
43 | | -import com.lambda.config.settings.complex.Vec3dSetting |
44 | | -import com.lambda.config.settings.numeric.DoubleSetting |
45 | | -import com.lambda.config.settings.numeric.FloatSetting |
46 | | -import com.lambda.config.settings.numeric.IntegerSetting |
47 | | -import com.lambda.config.settings.numeric.LongSetting |
48 | | -import com.lambda.event.Muteable |
49 | | -import com.lambda.imgui.flag.ImGuiInputTextFlags |
50 | | -import com.lambda.util.KeyCode |
51 | 26 | import com.lambda.util.Nameable |
52 | | -import net.minecraft.block.Block |
53 | | -import net.minecraft.fluid.Fluid |
54 | | -import net.minecraft.item.Item |
55 | | -import net.minecraft.registry.Registries |
56 | | -import net.minecraft.util.math.BlockPos |
57 | | -import net.minecraft.util.math.Vec3d |
58 | | -import java.awt.Color |
59 | 27 | import kotlin.reflect.KClass |
60 | 28 | import kotlin.reflect.KProperty |
61 | 29 | import kotlin.reflect.full.declaredMemberProperties |
@@ -188,210 +156,6 @@ abstract class Config( |
188 | 156 | } |
189 | 157 | } |
190 | 158 |
|
191 | | - @ConfigEntryDsl |
192 | | - fun setting( |
193 | | - name: String, |
194 | | - defaultValue: Boolean, |
195 | | - description: String = "", |
196 | | - visibility: () -> Boolean = { true } |
197 | | - ) = setting(name) { layer -> BooleanSetting(name, description, this, layer, visibility, defaultValue) } |
198 | | - |
199 | | - @ConfigEntryDsl |
200 | | - fun <T : Enum<T>> setting( |
201 | | - name: String, |
202 | | - defaultValue: T, |
203 | | - description: String = "", |
204 | | - visibility: () -> Boolean = { true } |
205 | | - ) = setting(name) { layer -> EnumSetting(name, description, this, layer, visibility, defaultValue) } |
206 | | - |
207 | | - @ConfigEntryDsl |
208 | | - fun setting( |
209 | | - name: String, |
210 | | - defaultValue: Char, |
211 | | - description: String = "", |
212 | | - visibility: () -> Boolean = { true } |
213 | | - ) = setting(name) { layer -> CharSetting(name, description, this, layer, defaultValue, visibility) } |
214 | | - |
215 | | - @ConfigEntryDsl |
216 | | - fun setting( |
217 | | - name: String, |
218 | | - defaultValue: String, |
219 | | - multiline: Boolean = false, |
220 | | - flags: Int = ImGuiInputTextFlags.None, |
221 | | - description: String = "", |
222 | | - visibility: () -> Boolean = { true } |
223 | | - ) = setting(name) { layer -> StringSetting(name, description, this, layer, defaultValue, visibility, multiline, flags) } |
224 | | - |
225 | | - @ConfigEntryDsl |
226 | | - @JvmName("collectionSetting1") |
227 | | - fun setting( |
228 | | - name: String, |
229 | | - defaultValue: Collection<Block>, |
230 | | - immutableCollection: Collection<Block> = Registries.BLOCK.toList(), |
231 | | - description: String = "", |
232 | | - visibility: () -> Boolean = { true } |
233 | | - ) = setting(name) { layer -> BlockCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } |
234 | | - |
235 | | - @ConfigEntryDsl |
236 | | - @JvmName("collectionSetting2") |
237 | | - fun setting( |
238 | | - name: String, |
239 | | - defaultValue: Collection<Item>, |
240 | | - immutableCollection: Collection<Item> = Registries.ITEM.toList(), |
241 | | - description: String = "", |
242 | | - visibility: () -> Boolean = { true } |
243 | | - ) = setting(name) { layer -> ItemCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } |
244 | | - |
245 | | - @ConfigEntryDsl |
246 | | - @JvmName("collectionSetting3") |
247 | | - fun setting( |
248 | | - name: String, |
249 | | - defaultValue: Collection<Fluid>, |
250 | | - immutableCollection: Collection<Fluid> = Registries.FLUID.toList(), |
251 | | - description: String = "", |
252 | | - visibility: () -> Boolean = { true } |
253 | | - ) = setting(name) { layer -> FluidCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } |
254 | | - |
255 | | - @ConfigEntryDsl |
256 | | - @JvmName("collectionSetting4") |
257 | | - inline fun <reified T : Any> setting( |
258 | | - name: String, |
259 | | - defaultValue: Collection<T>, |
260 | | - immutableList: Collection<T> = defaultValue, |
261 | | - description: String = "", |
262 | | - displayClassName: Boolean = false, |
263 | | - serialize: Boolean = false, |
264 | | - noinline visibility: () -> Boolean = { true } |
265 | | - ) = setting(name) { layer -> |
266 | | - if (displayClassName) ClassCollectionSetting(name, description, this, layer, visibility, immutableList, defaultValue.toMutableList()) |
267 | | - else CollectionSetting(name, description, this, layer, visibility, defaultValue.toMutableList(), immutableList, typeFactory.constructCollectionType(Collection::class.java, T::class.java), serialize) |
268 | | - } |
269 | | - |
270 | | - @ConfigEntryDsl |
271 | | - inline fun <reified K : Any, reified V : Any> setting( |
272 | | - name: String, |
273 | | - defaultValue: Map<K, V>, |
274 | | - description: String = "", |
275 | | - noinline visibility: () -> Boolean = { true } |
276 | | - ) = setting(name) { layer -> |
277 | | - MapSetting( |
278 | | - name, description, this, layer, visibility, defaultValue.toMutableMap(), |
279 | | - typeFactory.constructMapType(MutableMap::class.java, K::class.java, V::class.java) |
280 | | - ) |
281 | | - } |
282 | | - |
283 | | - @ConfigEntryDsl |
284 | | - fun setting( |
285 | | - name: String, |
286 | | - defaultValue: Double, |
287 | | - range: ClosedRange<Double>, |
288 | | - step: Double = 1.0, |
289 | | - description: String = "", |
290 | | - unit: String = "", |
291 | | - visibility: () -> Boolean = { true } |
292 | | - ) = setting(name) { layer -> DoubleSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } |
293 | | - |
294 | | - @ConfigEntryDsl |
295 | | - fun setting( |
296 | | - name: String, |
297 | | - defaultValue: Float, |
298 | | - range: ClosedRange<Float>, |
299 | | - step: Float = 1f, |
300 | | - description: String = "", |
301 | | - unit: String = "", |
302 | | - visibility: () -> Boolean = { true } |
303 | | - ) = setting(name) { layer -> FloatSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } |
304 | | - |
305 | | - @ConfigEntryDsl |
306 | | - fun setting( |
307 | | - name: String, |
308 | | - defaultValue: Int, |
309 | | - range: ClosedRange<Int>, |
310 | | - step: Int = 1, |
311 | | - description: String = "", |
312 | | - unit: String = "", |
313 | | - visibility: () -> Boolean = { true } |
314 | | - ) = setting(name) { layer -> IntegerSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } |
315 | | - |
316 | | - @ConfigEntryDsl |
317 | | - fun setting( |
318 | | - name: String, |
319 | | - defaultValue: Long, |
320 | | - range: ClosedRange<Long>, |
321 | | - step: Long = 1, |
322 | | - description: String = "", |
323 | | - unit: String = "", |
324 | | - visibility: () -> Boolean = { true } |
325 | | - ) = setting(name) { layer -> LongSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } |
326 | | - |
327 | | - @ConfigEntryDsl |
328 | | - fun setting( |
329 | | - name: String, |
330 | | - defaultValue: Bind, |
331 | | - description: String = "", |
332 | | - alwaysListening: Boolean = false, |
333 | | - screenCheck: Boolean = true, |
334 | | - visibility: () -> Boolean = { true } |
335 | | - ) = setting(name) { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } |
336 | | - |
337 | | - @ConfigEntryDsl |
338 | | - fun setting( |
339 | | - name: String, |
340 | | - defaultValue: KeyCode, |
341 | | - description: String = "", |
342 | | - alwaysListening: Boolean = false, |
343 | | - screenCheck: Boolean = true, |
344 | | - visibility: () -> Boolean = { true } |
345 | | - ) = setting(name) { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } |
346 | | - |
347 | | - @ConfigEntryDsl |
348 | | - fun setting( |
349 | | - name: String, |
350 | | - defaultValue: Color, |
351 | | - description: String = "", |
352 | | - visibility: () -> Boolean = { true } |
353 | | - ) = setting(name) { layer -> ColorSetting(name, description, this, layer, visibility, defaultValue) } |
354 | | - |
355 | | - @ConfigEntryDsl |
356 | | - fun setting( |
357 | | - name: String, |
358 | | - defaultValue: Vec3d, |
359 | | - description: String = "", |
360 | | - visibility: () -> Boolean = { true } |
361 | | - ) = setting(name) { layer -> Vec3dSetting(name, description, this, layer, visibility, defaultValue) } |
362 | | - |
363 | | - @ConfigEntryDsl |
364 | | - fun setting( |
365 | | - name: String, |
366 | | - defaultValue: BlockPos.Mutable, |
367 | | - description: String = "", |
368 | | - visibility: () -> Boolean = { true } |
369 | | - ) = setting(name) { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } |
370 | | - |
371 | | - @ConfigEntryDsl |
372 | | - fun setting( |
373 | | - name: String, |
374 | | - defaultValue: BlockPos, |
375 | | - description: String = "", |
376 | | - visibility: () -> Boolean = { true } |
377 | | - ) = setting(name) { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } |
378 | | - |
379 | | - @ConfigEntryDsl |
380 | | - fun setting( |
381 | | - name: String, |
382 | | - defaultValue: Block, |
383 | | - description: String = "", |
384 | | - visibility: () -> Boolean = { true } |
385 | | - ) = setting(name) { layer -> BlockSetting(name, description, this, layer, visibility, defaultValue) } |
386 | | - |
387 | | - @ConfigEntryDsl |
388 | | - fun <T : () -> R, R> setting( |
389 | | - name: String, |
390 | | - defaultValue: T, |
391 | | - description: String = "", |
392 | | - visibility: () -> Boolean = { true } |
393 | | - ) = setting(name) { layer -> FunctionSetting(name, description, defaultValue, this, layer, visibility) } |
394 | | - |
395 | 159 | @ConfigEntryDsl |
396 | 160 | fun <T : ConfigBlock> configBlock( |
397 | 161 | configBlock: T |
@@ -486,8 +250,7 @@ abstract class Config( |
486 | 250 | valueSupplier: () -> T = { defaultValue } |
487 | 251 | ) = property(defaultValue, valueSupplier(), setter, equals) |
488 | 252 |
|
489 | | - @PublishedApi |
490 | | - internal fun <T : Setting<R>, R> setting(name: String, settingSupplier: (single: SettingEntryLayer<T, R>) -> T): T { |
| 253 | + fun <T : Setting<R>, R> setting(name: String, settingSupplier: (single: SettingEntryLayer<T, R>) -> T): T { |
491 | 254 | val spec = try { |
492 | 255 | registrationQueue.removeFirst() |
493 | 256 | } catch (_: NoSuchElementException) { |
|
0 commit comments