OptiGUI

OptiGUI

8M Downloads

text colours

DadoIrie opened this issue Β· 13 comments

commented

Functionality of changing text color with RGBA or/and HEX
As an example I'll use an dilemma I'm currently facing and really wanna add a background behind the container title - I'm working on 2 versions of a GUI (dark mode and vanilla) and changing the text color with core shaders which works pretty well in all containers - in this case shulker boxes - except black shulker boxes on vanilla GUI (hard to read the black text on black background) and white shulker boxes in dark mode (white text on white background)
vanilla-black
dark-white

now this is how the opposite shulker boxes look and how the text color actually should be - black shulker boxes in dark mode just goes perfectly as it is white-ish on black - same goes with white shulker boxes in vanilla GUI
dark-black
vanilla-white

having the possibility to change text color in selected containers would pretty much resolve this (I personally would prefer RGBA, because core shaders do use vec4 - which is RGBA / 255 and easier to make the transparency with just numbers - especially if using a config for the resourcepack with a slider from 0 to 100 * 255 (or 0 to 100 / 100 if its for vec4) for transparency)

commented

I'll fix this in OptiGUI 2.4.0 after releasing a stable 2.3.0. For real now. I need a couple of months for that. Thanks for your patience

commented

how about this? It's already done, I'll offer it to PR soon
image

Π‘an also use this option for JSON lovers.
image

commented

Something like this is planned in a future release. Until then, the way I changed the text color is overriding the key in the language JSON and use formatting codes (which changes the color for every texture, because it's rendered on top of it, and probably isn't helpful).
My idea is that a text format can be specified optionally for each texture (one option is to insert a format code in front, changing the entire text)

commented

somebody else on discord also suggested the language strings and formatting codes, and that changes every - in this case - shulker box which is not what I'm having the issue with. Also changing text color with vanilla core shaders is more practical and easier to maintain - no need to change every language file
Your idea for future release will work nicely too - I just wished to fine tune it more and that's why I suggested supporting RGBA text coloring for each texture independently as it allows for more flexibility

slightly related note in combination with #69 : this also could be used with the linked storage color code combinations - OptiGUI just gotta know which color combination is currently open and if it is a private or public chest

commented

I'm working on the next version of the OptiGUI JSON format, which will allow changing the style of any displayed text. Such JSON would look something like this:

{
  // Other properties
  "change_text_style": [
    {
      "@optigui:is_title": 1,
      // Other text properties when needed, such as @translate or @literal
      "#set_style": {
        "color": "#hex"
        // Other text style properties
      }
    }
    // Change the style of another text
  ]
}

The thing I dislike about this fornat is # is used for matching list items, and here it's used to set something, like the textures block in the JSON. Another special character prefix could also be used, but set_style would be the only thing using it. Another syntax I have in mind is this:

{
  // Other properties
  "change_text_style": [
    {
      "match": {
        "@optigui:is_title": 1,
        // Other text properties when needed, such as @translate or @literal
      },
      "set_style": {
        "color": "#hex"
        // Other text style properties
      }
    }
    // Change the style of another text
  ]
}

This makes the JSON cleaner and easier to understand, but also deeper.

style (verb) instead of set_style can also work. What unfortunately can't work, is the following syntax, because the text style codec won't recognize the prefix (! is just a placeholder prefix, could be almost any other special character):

{
  // Other properties
  "change_text_style": [
    {
      "@optigui:is_title": 1,
      // Other text properties when needed, such as @translate or @literal
      "!color": "#hex"
      // Other text style properties
    }
    // Change the style of another text
  ]
}

Text style wiki: https://minecraft.wiki/w/Text_component_format#Java_Edition, see Formatting.

Setting click_event and maybe also hover_event would be disabled by default or entirely for security reasons.

Let me know if you have any questions or suggestions.

commented

cleaner looks much better in terms of readability, but also structured with its match & style