Alshain Posted May 26, 2017 Share Posted May 26, 2017 I'm having a bit of difficulty here and I need some more eyes. My ElectricLights mod extends ModuleAnimateGeneric and ModuleColorChanger to consume electricity for the cockpits and command pods respectively. I have a set of code which I have been localizing using the stock dictionary. public override string GetInfo() { StringBuilder info = new StringBuilder(); info.AppendLine("<color=#FF8C00><b><<1>></b></color>").Replace("<<1>>", Localizer.GetStringByTag("#autoLOC_244332")); info.Append(Localizer.GetStringByTag("#autoLOC_244201")); info.Replace("<<1>>", Localizer.GetStringByTag("#autoLOC_501004")); info.Replace("<<2>>", (resourceRate * 60 * resourceAmount).ToString()); return info.ToString(); } public string GetModuleTitle() { return "#autoLOC_6003003"; } This code is exactly the same in both my extension modules. The module that inherits ModuleAnimateGeneric produces the following: So that is beautiful, it appears to be translating tags correctly and all is well. Then I look at the extension of ModuleColorChanger: Now, why does that say "Color Changer" instead of "Light"? I went back to my previous version DLL (with no localization, just static text) and it turns out it's broken there too. This was working in 1.2 with static text, but now in 1.3 it doesn't seem to want to return the title from my implementation regardless. Before you answer, no there is nothing to override in either module. Link to comment Share on other sites More sharing options...
Alshain Posted May 26, 2017 Author Share Posted May 26, 2017 (edited) Ok, so finally after hours of searching it would appear that Squad added a redundant method in PartModule and some modules are using one and some modules are using the other. Why would you do this Squad? public string GetModuleTitle() { return "#autoLOC_6003003"; } public override string GetModuleDisplayName() { return GetModuleTitle(); } That was the solution. Edited May 26, 2017 by Alshain Link to comment Share on other sites More sharing options...
linuxgurugamer Posted May 26, 2017 Share Posted May 26, 2017 Can you add this to my thread: Link to comment Share on other sites More sharing options...
Alshain Posted May 26, 2017 Author Share Posted May 26, 2017 Done Link to comment Share on other sites More sharing options...
TriggerAu Posted May 27, 2017 Share Posted May 27, 2017 My recollection of how this works is GetModuleTitle is the English title which is the "name" for a bunch of stuff in the code (like filters) - it fills the moduleInfo.Name value and is always in english - we didnt change that one as its the old name (I say name, but its called title for some reason ) GetModuleDisplayName is the localized string thats printed in the UI IModuleInfo is not changed If the displayname is empty then it plugs in the "title" as the displayname In the case of the ColorChanger the default displayName is "Color Changer" as your seeing there, A better way to do that code might be public string GetModuleTitle() { return "Light"; } public override string GetModuleDisplayName() { return Localizer.Format("#autoLOC_6003003"); } Link to comment Share on other sites More sharing options...
Alshain Posted May 27, 2017 Author Share Posted May 27, 2017 (edited) @TriggerAu If that is how it is, I have to say, that is kinda dumb. IModuleInfo provides other display information (as seen in the first code snipit, GetInfo is in IModuleInfo) There is also a callback in IModuleInfo to let you know when the info panel is drawn on screen. So what you are saying is IModuleInfo contains and inconsistent combination of unique identifier and display information while you have to go to PartModule to find the rest of the display information. On top of that, not all modules need display information, but they would need an identifier, so why would you put that identifier in an interface that may not be implemented and display information in the base class? Sorry Trigger, but your explanation makes no sense. Either that or someone over there at Squad is horrifically bad at organizing their classes. EDIT: Also, why would you filter by an English name in a localized game? Wouldn't you localize the filter? Edited May 27, 2017 by Alshain Link to comment Share on other sites More sharing options...
TriggerAu Posted May 27, 2017 Share Posted May 27, 2017 Sorry I cant explain it sufficiently, but I can't share the code with you as to why its done this way which would probably clarify it. The way its done is the least impactful method we had available with the existing codebase. If the game was built with Localization from the ground up then some of this would be different I can guarantee it, but in places where code uses names we stuck with English and have a display version for the UI - same as for actual filtering - its done by the name and displays a localized version. I think thats the best I can do on the explanation, but hopefully the code example and the updated info in the modders notes means you can use it Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now