Getting a custom input for color in a config
I have this but it doesn't work I need it to choose the colour for the vehicle
Transform_Veh_Colour = config.GetValue<Color>("Options", "Transform_Veh_Colour", Color.Red);
config.SetValue<Color>("Options", "Transform_Veh_Colour", Color.Red);
to see how the function writes to your ini file, maybe the text in your ini isn't being parsed because it isn't in the correct "format".
Of you can try something like:
Transform_Veh_Colour = Color.FromName(config.GetValue<string>("Options", "Transform_Veh_Colour", "Red"));
Transform_Veh_Colour = config.GetValue<Color>("Options", "Transform_Veh_Colour", Color.FromName("Red"));
And in your ini it should look like:
Transform_Veh_Colour = Red
@stillhere Yes, but the only problem I am changing the color of a vehicle. I am using System.Drawing.Color which is not string it's Color.Red, Color.Blue, Color.Lime, etc......
@NotCrunchyTaco Color.FromName should be able to convert the color name from string to Color
@stillhere I will try that thank you! Hopefully it works!
@stillhere Sadly I couldn't get it too work:
@NotCrunchyTaco ClearCustomPrimaryColor() does not work like that I'm afraid. Should be tCar.ClearCustomPrimaryColor();
If you are setting a primary color, I think it should be tCar.CustomPrimaryColor = Transform_Veh_Color;
@stillhere I'M STUPID!!!! I DID CLEAR. NOT SET!!!!!!!!! I AM BLIND!!!!!!!!!! UGH!!!!!!!!!!!!!!!!!
@stillhere Sadly, I did it right and it still didn't work
@NotCrunchyTaco ah really? If you change:
Transform_Veh_Colour = config.GetValue<Color>...etc.
Transform_Veh_Colour = Color.Red;
does the color change work at least? Sadly I can't test right now.
@stillhere Yes just by typing that. No strings, doubles, floats, bools, ints, etc.....
@NotCrunchyTaco Okay so I got it to work using this:
Transform_Veh_Colour = Color.FromName(config.GetValue<string>("Options", "TransformVehColour", "Red"));
and inside my ini I have this:
TransformVehColour = White
so for some reason GetValue<string> isn't getting the name if there are underscores in it (Transform_Veh_Colour). So I changed Transform_Veh_Colour to TransformVehColour and it seems to work. Downside is some colors don't seem to match the name on the vehicle I tested. Ex: using Orange gives a more yellow color. You might be better off converting RGB values from the ini to Color instead.
@NotCrunchyTaco It's may not be any of my business but, That's rightly said by @stillhere, converting RGB values from INI file is better option.
Even I did create a mod (on request or something I don't remember) and thought this could help.
So instead of getting your native return type as <String>, simply get it as <int> and then in INI define RGB with range of 0-255.
The only downside, user may not know the combinations they will have to give to get a desired color. So either redirect them to any RGB converting site.
Also, in your initial post, you have mentioned "Transform_Veh_Colour" as field in your INI,
To take a note, INI file may not refer or read the underscores, special charactors, and or spaces in the field which you are passing to your mod. So be careful there. No extra and or white spaces.
@stillhere Thank you!
@ashishcw Okay, thank you! It's fine any help is great!
@stillhere Worked Thank you I will be crediting you in the mod! The update is coming soon!
@NotCrunchyTaco Welcome! Looking forward to your upcoming mods bro
@stillhere Thank you! Also this mod has helped me learn about the config a lot better