Hello,
I am trying to work out the MCMs in CCL, and I am wondering if there is a way to include dropdown selection menus in it. I've been trying to mess around with it but my c# experience is pretty limited so setting up UI stuff is really confusing to me. What I am thinking of is something like:
http://puu.sh/qxnSA/f88f9c4a3c.png
where there are several settings, each with 6~ possible values in a dropdown menu, and also an additional pair of dropdowns at the bottom, one containing a list of a ton of specific settings and one with the possible values (the same possibilities for all of them). Selecting an item in the dropdown list would set the value of that setting to whatever was selected. I have been looking through a lot of the example code and other mods I could find which use the MCM, but I couldn't find any using dropdown menus. Failing that, a button which opens a FloatMenu, like in the main game config menu for temperature settings for example, would work just as well for the most part, but I also haven't seen one of those. If anyone has any idea and can help, I would appreciate it!
Thanks!
There are no drop-down widges (although, they would be super handy), everything in he game spawns a float menu from a button for those types of things.
Yeah, I figured as much. A button with float menu is fine then, but I can't figure out how to make it draw. For some reason ButtonText returns a bool? and every implementation of it seems to use if (Widgets.ButtonText(...)) but when I do that it doesn't seem to actually spawn a button. I can get labels to appear but not buttons. How would I go about creating one?
That's correct, the button widgets return a bool to indicate that the user has pressed the button.
If it's not showing then your rect is probably too small or it's position is such that it's been clipped.
I see. Then my question is, I tried to just copy the Minimap MCM code and then adjust it, but the listing_standard.set_ColumnWidth doesn't compile. It does not recognize set_ColumnWidth as valid. Why wouldn't that work?
Are you perhaps using an A13 version?
A14 made ColumnWidth a public field so it no longer needs reflection.
Quote from: 1000101 on August 11, 2016, 09:07:35 PM
Are you perhaps using an A13 version?
I don't think so, I never had downloaded it before A14, and it says AssemblyVersion("0.14.0.0") in the dll. Though trying it without reflection does seem to compile. The code in MCM_MiniMap is
Listing_Standard listing_Standard = new Listing_Standard(rect);
listing_Standard.set_ColumnWidth(rect.width - 4f);
string text = Translator.Translate("MiniMap.MCMToggleMain");
listing_Standard.CheckboxLabeled(text, ref MiniMapController.visible, null);
listing_Standard.Gap(12f);
and it uses .get_ColumnWidth and .get_CurHeight several times. Perhaps I do somehow have an outdated version though.
Edit: it seems you are on v14.2 now, the version in the github repository does not use reflection, so that must have been my problem. Thanks
As far as CCL goes, I'm not sure why people decompile it. The source is on github and will provide far more and better information than the decompiled sources.
All you need to do is use:
listing.ColumnWidth = x;
y = listing.ColumnWidth;
The "get_" and "set_" prefixes you may see in the decompiled code are the compiler referencing the property getter and setters.