diff options
author | xander <xander@isxander.dev> | 2022-09-05 07:56:47 +0100 |
---|---|---|
committer | xander <xander@isxander.dev> | 2022-09-05 07:56:47 +0100 |
commit | 3d75debaf50c39576a0a5a198e0a15c62db606a9 (patch) | |
tree | 7768b4698b7349079d2c690fce6db1beaaeeb3af /src/main/java/dev/isxander/yacl/gui/controllers | |
parent | 833189bb4d8f524c572b6dcc86a7e146cdcf979f (diff) | |
download | YetAnotherConfigLib-3d75debaf50c39576a0a5a198e0a15c62db606a9.tar.gz YetAnotherConfigLib-3d75debaf50c39576a0a5a198e0a15c62db606a9.tar.bz2 YetAnotherConfigLib-3d75debaf50c39576a0a5a198e0a15c62db606a9.zip |
modrinth and cursefoge ids
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/controllers')
-rw-r--r-- | src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java b/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java index 4d1dfc3..11e33d0 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java @@ -63,10 +63,10 @@ public class ColorController implements IStringController<Color> { @Override public Text formatValue() { MutableText text = Text.literal("#"); - if (allowAlpha()) text.append(toHex(option().pendingValue().getAlpha())); text.append(Text.literal(toHex(option().pendingValue().getRed())).formatted(Formatting.RED)); text.append(Text.literal(toHex(option().pendingValue().getGreen())).formatted(Formatting.GREEN)); text.append(Text.literal(toHex(option().pendingValue().getBlue())).formatted(Formatting.BLUE)); + if (allowAlpha()) text.append(toHex(option().pendingValue().getAlpha())); return text; } @@ -82,12 +82,16 @@ public class ColorController implements IStringController<Color> { if (value.startsWith("#")) value = value.substring(1); - int alpha = Integer.parseInt(value.substring(0, 2), 16); - int red = Integer.parseInt(allowAlpha() ? value.substring(2, 4) : value.substring(0, 2), 16); - int green = Integer.parseInt(allowAlpha() ? value.substring(4, 6) : value.substring(2, 4), 16); - int blue = Integer.parseInt(allowAlpha() ? value.substring(6, 8) : value.substring(4, 6), 16); + int red = Integer.parseInt(value.substring(0, 2), 16); + int green = Integer.parseInt(value.substring(2, 4), 16); + int blue = Integer.parseInt(value.substring(4, 6), 16); - option().requestSet(allowAlpha() ? new Color(red, green, blue, alpha) : new Color(red, green, blue)); + if (allowAlpha()) { + int alpha = Integer.parseInt(value.substring(6, 8), 16); + option().requestSet(new Color(red, green, blue, alpha)); + } else { + option().requestSet(new Color(red, green, blue)); + } } @Override |