Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot capitalize category names when category mode is enabled for the config GUI #69

Open
boubou19 opened this issue Sep 11, 2024 · 2 comments

Comments

@boubou19
Copy link
Member

boubou19 commented Sep 11, 2024

In GTNewHorizons/GT5-Unofficial@eb2b7d5 I wanted to have the config GUI to have a category per handler. So i enabled the categorized mode (here). It worked, however, i had the client category not capitalized. In order to do this, i tried 2 methods:

  • the usage of @Config.langKey annotation:
@Config(
    modid = Mods.Names.GREG_TECH,
    category = "client",
    configSubDirectory = "GregTech",
    filename = "Client")
@Config.LangKey("GT5U.gui.config.client")
public class Client {...}
The config
# Configuration file

client {

    ##########################################################################################################
    # colormodulation
    #--------------------------------------------------------------------------------------------------------#
    # Color Modulation section
    ##########################################################################################################

    colormodulation {
        # hex value for the cable insulation color modulation. [default: #404040]
        S:cableInsulation=#404040

        # hex value for the construction foam color modulation. [default: #404040]
        S:constructionFoam=#404040

        # hex value for the machine metal color modulation. [default: #D2DCFF]
        S:machineMetal=#D2DCFF
    }

    ##########################################################################################################
    # iface
    #--------------------------------------------------------------------------------------------------------#
    # Interface section
    ##########################################################################################################

    iface {
        # if true, puts the cover tabs display on the right of the UI instead of the left. [default: false]
        B:coverTabsFlipped=false

        # if true, makes cover tabs visible on GregTech machines. [default: true]
        B:coverTabsVisible=true

        # Which style to use for title tab on machine GUI? 0: text tab split-dark, 1: text tab unified, 2: item icon tab. [range: -2147483648 ~ 2147483647, default: 0]
        I:titleTabStyle=0

        # How verbose should tooltips be when LSHIFT is held? 0: disabled, 1: one-line, 2: normal, 3+: extended. [range: -2147483648 ~ 2147483647, default: 3]
        I:tooltipShiftVerbosity=3

        # How verbose should tooltips be? 0: disabled, 1: one-line, 2: normal, 3+: extended. [range: -2147483648 ~ 2147483647, default: 2]
        I:tooltipVerbosity=2
    }

    ##########################################################################################################
    # preference
    #--------------------------------------------------------------------------------------------------------#
    # Preference section
    ##########################################################################################################

    preference {
        # if true, input filter will initially be on when input buses are placed in the world. [default: false]
        B:inputBusInitialFilter=false

        # if true, allow multistacks on single blocks by default when they are first placed in the world. [default: false]
        B:singleBlockInitialAllowMultiStack=false

        # if true, input filter will initially be on when machines are placed in the world. [default: false]
        B:singleBlockInitialFilter=false
    }

    ##########################################################################################################
    # render
    #--------------------------------------------------------------------------------------------------------#
    # Render section
    ##########################################################################################################

    render {
        # if true, enables dirt particles when pollution reaches the threshold. [default: true]
        B:renderDirtParticles=true

        # if true, render flipped machine with flipped textures. [default: true]
        B:renderFlippedMachinesFlipped=true

        # if true, enables glowing of the machine controllers. [default: true]
        B:renderGlowTextures=true

        # if true, render indicators on hatches. [default: true]
        B:renderIndicatorsOnHatch=true

        # if true, enables the blue charge bar for an electric item's charge. [default: true]
        B:renderItemChargeBar=true

        # if true, enables the green -> red durability for an item's damage value. [default: true]
        B:renderItemDurabilityBar=true

        # if true, enables pollution fog when pollution reaches the threshold. [default: true]
        B:renderPollutionFog=true

        # if true, enables ambient-occlusion smooth lighting on tiles. [default: true]
        B:renderTileAmbientOcclusion=true

        # enables BaseMetaTileEntity block updates handled by BlockUpdateHandler. [default: false]
        B:useBlockUpdateHandler=false
    }

    ##########################################################################################################
    # waila
    #--------------------------------------------------------------------------------------------------------#
    # Waila section
    ##########################################################################################################

    waila {
        # if true, enables showing voltage tier of transformer for Waila, instead of raw voltage number. [default: false]
        B:wailaAverageNS=false

        # if true, enables showing voltage tier of transformer for Waila, instead of raw voltage number. [default: true]
        B:wailaTransformerVoltageTier=true
    }

}
As you can see below, it did not work (i ensured twice that the langkey exists):

image

  • The other method (currently implemented in the linked commit) is to capitalize the category name in the config annotation:
@Config(
    modid = Mods.Names.GREG_TECH,
    category = "Client",
    configSubDirectory = "GregTech",
    filename = "Client")
public class Client {...}

It did work:

image

However, the sub categories are empty:
image

This can be explained when we look at the config file:

The config
# Configuration file

Client {

    ##########################################################################################################
    # colormodulation
    #--------------------------------------------------------------------------------------------------------#
    # Color Modulation section
    ##########################################################################################################

    colormodulation {
    }

    ##########################################################################################################
    # iface
    #--------------------------------------------------------------------------------------------------------#
    # Interface section
    ##########################################################################################################

    iface {
    }

    ##########################################################################################################
    # preference
    #--------------------------------------------------------------------------------------------------------#
    # Preference section
    ##########################################################################################################

    preference {
    }

    ##########################################################################################################
    # render
    #--------------------------------------------------------------------------------------------------------#
    # Render section
    ##########################################################################################################

    render {
    }

    ##########################################################################################################
    # waila
    #--------------------------------------------------------------------------------------------------------#
    # Waila section
    ##########################################################################################################

    waila {
    }

}


client {

    colormodulation {
        # hex value for the cable insulation color modulation. [default: #404040]
        S:cableInsulation=#404040

        # hex value for the construction foam color modulation. [default: #404040]
        S:constructionFoam=#404040

        # hex value for the machine metal color modulation. [default: #D2DCFF]
        S:machineMetal=#D2DCFF
    }

    iface {
        # if true, puts the cover tabs display on the right of the UI instead of the left. [default: false]
        B:coverTabsFlipped=false

        # if true, makes cover tabs visible on GregTech machines. [default: true]
        B:coverTabsVisible=true

        # Which style to use for title tab on machine GUI? 0: text tab split-dark, 1: text tab unified, 2: item icon tab. [range: -2147483648 ~ 2147483647, default: 0]
        I:titleTabStyle=0

        # How verbose should tooltips be when LSHIFT is held? 0: disabled, 1: one-line, 2: normal, 3+: extended. [range: -2147483648 ~ 2147483647, default: 3]
        I:tooltipShiftVerbosity=3

        # How verbose should tooltips be? 0: disabled, 1: one-line, 2: normal, 3+: extended. [range: -2147483648 ~ 2147483647, default: 2]
        I:tooltipVerbosity=2
    }

    preference {
        # if true, input filter will initially be on when input buses are placed in the world. [default: false]
        B:inputBusInitialFilter=false

        # if true, allow multistacks on single blocks by default when they are first placed in the world. [default: false]
        B:singleBlockInitialAllowMultiStack=false

        # if true, input filter will initially be on when machines are placed in the world. [default: false]
        B:singleBlockInitialFilter=false
    }

    render {
        # if true, enables dirt particles when pollution reaches the threshold. [default: true]
        B:renderDirtParticles=true

        # if true, render flipped machine with flipped textures. [default: true]
        B:renderFlippedMachinesFlipped=true

        # if true, enables glowing of the machine controllers. [default: true]
        B:renderGlowTextures=true

        # if true, render indicators on hatches. [default: true]
        B:renderIndicatorsOnHatch=true

        # if true, enables the blue charge bar for an electric item's charge. [default: true]
        B:renderItemChargeBar=true

        # if true, enables the green -> red durability for an item's damage value. [default: true]
        B:renderItemDurabilityBar=true

        # if true, enables pollution fog when pollution reaches the threshold. [default: true]
        B:renderPollutionFog=true

        # if true, enables ambient-occlusion smooth lighting on tiles. [default: true]
        B:renderTileAmbientOcclusion=true

        # enables BaseMetaTileEntity block updates handled by BlockUpdateHandler. [default: false]
        B:useBlockUpdateHandler=false
    }

    waila {
        # if true, enables showing voltage tier of transformer for Waila, instead of raw voltage number. [default: false]
        B:wailaAverageNS=false

        # if true, enables showing voltage tier of transformer for Waila, instead of raw voltage number. [default: true]
        B:wailaTransformerVoltageTier=true
    }

}

Imo, there are a few issues here:

  • Config.LangKey annotation does ignore classes, so it's impossible to change the displayed string for main config classes in game when categorization mode is enabled.
  • The category field of the Config annotation is not sanitized, because forge never expects non lowercase configs.
  • The parsing of the sub classes does not use the same parent category, as sub categories use sanitized parent category names while main categories use the raw name.

i'm running GTNHLib 0.5.5

@Lyfts
Copy link
Member

Lyfts commented Sep 11, 2024

The problem with @Config.Langkey not working when applied to classes is addressed in #68, I can cherry pick it out if need be.

@boubou19
Copy link
Member Author

in this case, i'll just merge #68 this will give me the occasion to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants