Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,36 @@ public class TestConfig_Test extends Config {
)
public static float[] range = {25f, 75f};

@RangeNumber(
title = "Range Number",
description = "Two inputs, no track, for spans too wide to drag.",
min = 0f,
max = 1000000f
)
public static int[] rangeNumber = {1200, 36000};

@RangeSliderList(
title = "Range Slider List",
description = "A two-handle slider per entry, stored flat as start, end pairs.",
category = "Lists",
subcategory = "Other Lists",
step = 5f,
addText = "Add range"
)
public static float[] rangeSliderList = {0f, 25f, 50f, 75f};

@RangeNumberList(
title = "Range Number List",
description = "A pair of inputs per entry.",
category = "Lists",
subcategory = "Other Lists",
min = 0f,
max = 72000f,
maxEntries = 4,
addText = "Add range"
)
public static int[] rangeNumberList = {0, 600, 1200, 9600};

// everything below is disabled rather than hidden while the master switch is off so that
// disabled options can be checked for being non-interactable
@Switch(
Expand Down
69 changes: 69 additions & 0 deletions modules/config-impl/api/config-impl.api
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,16 @@ public class org/polyfrost/oneconfig/api/config/v1/KtConfig : org/polyfrost/onec
protected final synthetic fun radiobutton ([Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
public static synthetic fun radiobutton$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;Ljava/lang/String;Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlin/properties/PropertyDelegateProvider;
public static synthetic fun radiobutton$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;[Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
protected final synthetic fun rangeNumber (Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
public static synthetic fun rangeNumber$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;ILjava/lang/Object;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
protected final synthetic fun rangeNumberList (Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZLjava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
public static synthetic fun rangeNumberList$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZLjava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;ILjava/lang/Object;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
protected final synthetic fun rangeSlider (Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFF)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
protected final synthetic fun rangeSlider (Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
public static synthetic fun rangeSlider$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFFILjava/lang/Object;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
public static synthetic fun rangeSlider$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;ILjava/lang/Object;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
protected final synthetic fun rangeSliderList (Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZLjava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
public static synthetic fun rangeSliderList$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;Ljava/lang/String;[FLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZLjava/lang/String;Ljava/lang/String;FFFLorg/polyfrost/oneconfig/api/config/v1/ValueFormatter;ILjava/lang/Object;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
protected final synthetic fun singleSelectDropdown (Ljava/lang/String;[Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
public static synthetic fun singleSelectDropdown$default (Lorg/polyfrost/oneconfig/api/config/v1/KtConfig;Ljava/lang/String;[Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;ILjava/lang/Object;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
protected final synthetic fun slider (FFFLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/polyfrost/oneconfig/api/config/v1/KtConfig$Provider;
Expand Down Expand Up @@ -368,6 +374,24 @@ public final class org/polyfrost/oneconfig/api/config/v1/Visualizer$RadioVisuali
public fun visualize (Lorg/polyfrost/oneconfig/api/config/v1/Property;Landroidx/compose/runtime/Composer;I)V
}

public final class org/polyfrost/oneconfig/api/config/v1/Visualizer$RangeNumberListVisualizer : org/polyfrost/oneconfig/api/config/v1/Visualizer {
public static final field $stable I
public fun <init> ()V
public fun visualize (Lorg/polyfrost/oneconfig/api/config/v1/Property;Landroidx/compose/runtime/Composer;I)V
}

public final class org/polyfrost/oneconfig/api/config/v1/Visualizer$RangeNumberVisualizer : org/polyfrost/oneconfig/api/config/v1/Visualizer {
public static final field $stable I
public fun <init> ()V
public fun visualize (Lorg/polyfrost/oneconfig/api/config/v1/Property;Landroidx/compose/runtime/Composer;I)V
}

public final class org/polyfrost/oneconfig/api/config/v1/Visualizer$RangeSliderListVisualizer : org/polyfrost/oneconfig/api/config/v1/Visualizer {
public static final field $stable I
public fun <init> ()V
public fun visualize (Lorg/polyfrost/oneconfig/api/config/v1/Property;Landroidx/compose/runtime/Composer;I)V
}

public final class org/polyfrost/oneconfig/api/config/v1/Visualizer$RangeSliderVisualizer : org/polyfrost/oneconfig/api/config/v1/Visualizer {
public static final field $stable I
public fun <init> ()V
Expand Down Expand Up @@ -721,6 +745,33 @@ public abstract interface annotation class org/polyfrost/oneconfig/api/config/v1
public abstract fun titleTranslation ()Z
}

public abstract interface annotation class org/polyfrost/oneconfig/api/config/v1/annotations/RangeNumber : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
public abstract fun description ()Ljava/lang/String;
public abstract fun formatter ()Ljava/lang/Class;
public abstract fun icon ()Ljava/lang/String;
public abstract fun max ()F
public abstract fun min ()F
public abstract fun step ()F
public abstract fun subcategory ()Ljava/lang/String;
public abstract fun title ()Ljava/lang/String;
}

public abstract interface annotation class org/polyfrost/oneconfig/api/config/v1/annotations/RangeNumberList : java/lang/annotation/Annotation {
public abstract fun addText ()Ljava/lang/String;
public abstract fun category ()Ljava/lang/String;
public abstract fun description ()Ljava/lang/String;
public abstract fun formatter ()Ljava/lang/Class;
public abstract fun icon ()Ljava/lang/String;
public abstract fun max ()F
public abstract fun maxEntries ()I
public abstract fun min ()F
public abstract fun reorderable ()Z
public abstract fun step ()F
public abstract fun subcategory ()Ljava/lang/String;
public abstract fun title ()Ljava/lang/String;
}

public abstract interface annotation class org/polyfrost/oneconfig/api/config/v1/annotations/RangeSlider : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
public abstract fun description ()Ljava/lang/String;
Expand All @@ -733,6 +784,21 @@ public abstract interface annotation class org/polyfrost/oneconfig/api/config/v1
public abstract fun title ()Ljava/lang/String;
}

public abstract interface annotation class org/polyfrost/oneconfig/api/config/v1/annotations/RangeSliderList : java/lang/annotation/Annotation {
public abstract fun addText ()Ljava/lang/String;
public abstract fun category ()Ljava/lang/String;
public abstract fun description ()Ljava/lang/String;
public abstract fun formatter ()Ljava/lang/Class;
public abstract fun icon ()Ljava/lang/String;
public abstract fun max ()F
public abstract fun maxEntries ()I
public abstract fun min ()F
public abstract fun reorderable ()Z
public abstract fun step ()F
public abstract fun subcategory ()Ljava/lang/String;
public abstract fun title ()Ljava/lang/String;
}

public abstract interface annotation class org/polyfrost/oneconfig/api/config/v1/annotations/Slider : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
public abstract fun categoryKey ()Ljava/lang/String;
Expand Down Expand Up @@ -906,7 +972,10 @@ public final class org/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL {
public final fun put (Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$Prop;Lorg/polyfrost/oneconfig/api/config/v1/Visualizer;)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$Prop;
public final fun radiobutton (I[Ljava/lang/String;)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$OptionsProp;
public final synthetic fun radiobutton (I[Ljava/lang/String;)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$Prop;
public final fun rangeNumber (FF)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$RangeProp;
public final fun rangeNumberList ([F)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$NumberListProp;
public final fun rangeSlider (FF)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$RangeProp;
public final fun rangeSliderList ([F)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$NumberListProp;
public final fun singleSelectDropdown (I[Ljava/lang/String;)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$OptionsProp;
public final fun slider (F)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$FloatProp;
public final fun slider (I)Lorg/polyfrost/oneconfig/api/config/v1/dsl/ConfigDSL$IntProp;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* This file is part of OneConfig.
* OneConfig - Next Generation Config Library for Minecraft: Java Edition
* Copyright (C) 2021~2024 Polyfrost.
* <https://polyfrost.org> <https://github.com/Polyfrost/>
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* OneConfig is licensed under the terms of version 3 of the GNU Lesser
* General Public License as published by the Free Software Foundation, AND
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost,
* either version 1.0 of the Additional Terms, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License. If not, see <https://www.gnu.org/licenses/>. You should
* have also received a copy of the Additional Terms Applicable
* to OneConfig, as published by Polyfrost. If not, see
* <https://polyfrost.org/legal/oneconfig/additional-terms>
*/

package org.polyfrost.oneconfig.api.config.v1.annotations;

import java.lang.annotation.*;
import org.polyfrost.oneconfig.api.config.v1.ValueFormatter;
import org.polyfrost.oneconfig.api.config.v1.Visualizer;

/**
* A start and end pair within {@link #min()} and {@link #max()} edited with two number inputs
* <br>
* This is {@link RangeSlider} without the track so it suits ranges too wide to drag across
* <br>
* The annotated field holds both ends together as a two-element numeric array or list
* such as {@code float[]} or {@code int[]} or {@code List<Integer>} where index 0 is the
* start and index 1 is the end
* <br>
* Values are written back in whatever container shape the field already holds so its type is preserved
*/
@Option(display = Visualizer.RangeNumberVisualizer.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface RangeNumber {
String title();

String description() default "";

String icon() default "";

String category() default "General";

String subcategory() default "General";

float min() default 0f;

float max() default 100f;

/** Amount the arrows on each input step by */
float step() default 1f;

Class<? extends ValueFormatter> formatter() default ValueFormatter.class;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* This file is part of OneConfig.
* OneConfig - Next Generation Config Library for Minecraft: Java Edition
* Copyright (C) 2021~2024 Polyfrost.
* <https://polyfrost.org> <https://github.com/Polyfrost/>
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* OneConfig is licensed under the terms of version 3 of the GNU Lesser
* General Public License as published by the Free Software Foundation, AND
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost,
* either version 1.0 of the Additional Terms, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License. If not, see <https://www.gnu.org/licenses/>. You should
* have also received a copy of the Additional Terms Applicable
* to OneConfig, as published by Polyfrost. If not, see
* <https://polyfrost.org/legal/oneconfig/additional-terms>
*/

package org.polyfrost.oneconfig.api.config.v1.annotations;

import java.lang.annotation.*;
import org.polyfrost.oneconfig.api.config.v1.ValueFormatter;
import org.polyfrost.oneconfig.api.config.v1.Visualizer;

/**
* Renders a user-editable list of ranges with each row being a pair of number inputs
* <p>
* The annotated field must be a flat numeric array such as {@code int[]} or {@code float[]} or a {@code List}
* of numbers holding each range's start then end so {@code {0, 10, 20, 30}} is the ranges 0-10 and 20-30
* <p>
* The field must hold an even number of values
* <p>
* See {@link RangeSliderList} for the slider variant
*/
@Option(display = Visualizer.RangeNumberListVisualizer.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface RangeNumberList {
String title();

String description() default "";

String icon() default "";

String category() default "General";

String subcategory() default "General";

float min() default 0f;

float max() default 100f;

/** Amount the arrows on each input step by */
float step() default 1f;

/** Maximum number of ranges the user may add and {@code 0} means unlimited */
int maxEntries() default 0;

/** Allow the user to drag ranges to reorder them */
boolean reorderable() default true;

/** Label of the button that appends a new range */
String addText() default "Add";

Class<? extends ValueFormatter> formatter() default ValueFormatter.class;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* This file is part of OneConfig.
* OneConfig - Next Generation Config Library for Minecraft: Java Edition
* Copyright (C) 2021~2024 Polyfrost.
* <https://polyfrost.org> <https://github.com/Polyfrost/>
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* OneConfig is licensed under the terms of version 3 of the GNU Lesser
* General Public License as published by the Free Software Foundation, AND
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost,
* either version 1.0 of the Additional Terms, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License. If not, see <https://www.gnu.org/licenses/>. You should
* have also received a copy of the Additional Terms Applicable
* to OneConfig, as published by Polyfrost. If not, see
* <https://polyfrost.org/legal/oneconfig/additional-terms>
*/

package org.polyfrost.oneconfig.api.config.v1.annotations;

import java.lang.annotation.*;
import org.polyfrost.oneconfig.api.config.v1.ValueFormatter;
import org.polyfrost.oneconfig.api.config.v1.Visualizer;

/**
* Renders a user-editable list of ranges with each row being a two-handle slider with a value field for each end
* <p>
* The annotated field must be a flat numeric array such as {@code int[]} or {@code float[]} or a {@code List}
* of numbers holding each range's start then end so {@code {0, 10, 20, 30}} is the ranges 0-10 and 20-30
* <p>
* The field must hold an even number of values
* <p>
* See {@link RangeNumberList} for the variant without the track
*/
@Option(display = Visualizer.RangeSliderListVisualizer.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface RangeSliderList {
String title();

String description() default "";

String icon() default "";

String category() default "General";

String subcategory() default "General";

float min() default 0f;

float max() default 100f;

/** Value the handles snap to multiples of and {@code 0} slides continuously */
float step() default 1f;

/** Maximum number of ranges the user may add and {@code 0} means unlimited */
int maxEntries() default 0;

/** Allow the user to drag ranges to reorder them */
boolean reorderable() default true;

/** Label of the button that appends a new range */
String addText() default "Add";

Class<? extends ValueFormatter> formatter() default ValueFormatter.class;

}
Loading
Loading