DMagic

Members
  • Content count

    3337
  • Joined

  • Last visited

Community Reputation

2496 Excellent

About DMagic

Recent Profile Visitors

6784 profile views
  1. That's good to know. Though I think, assuming stock ids don't change, that it might be a good idea to keep the #autoLOC_ prefix, since it would make any localized text field instantly recognizable as such. All of the strings are loaded into a dictionary in the Localization class. You can directly access the dictionary, but it's probably best not to. Hopefully not much will need updating here. But I intend for this thread to be as much about helping with translations as it is about actually supporting localization. For mods that support localization, but are in need of translations it would help (after 1.3 is released) if authors could provide links to the text assets (presumably a config file with all of the localization fields or a folder with several such files) and an idea of what needs translating. For instance, SCANsat has 107 lines of UI text, 4 part descriptions and about 60 science results in need of translation. Contracts Window + will have about 30 lines of UI text, and another 10 or so lines for associated mods. @Luis topete This probably isn't the right place to get information about that. Presumably KSP 1.3, along with all of the localization support, will come to consoles at some point.
  2. The Air Force blowing up your crappy broken rocket part of the infrastructure.
  3. @Calvin_Maclure SCANsat hasn't really changed since KSP 1.1; nothing major has been changed or added for KSP 1.2 (it works fine in 1.2.2, even if the AVC popup complains). And it has nothing to do with Orbital Survey Plus, though there are some possible conflicts when displaying the map view planet overlays. @Loren Pechtel Yes, it will make a difference; the performance impact manifests as a little hiccup once per second, it's generally only noticeable at the highest one or two time warp levels and can be moderated by changing the scanning resolution. Handling of scanners that have finished a planet is something that I need improve. You can turn off the scanners manually or just go to the settings menu and turn off scanning for any completed planets.
  4. SpaceFlight Now still has SpaceX listed for March 29, and no date listed for the Atlas V. So maybe they just lost their spot in line. Also: Apparently it's a robot for securing a landed booster.
  5. It's creating a new texture every time it's called. Even with small textures this adds up quickly over time. If the textures are always the same size then just create a texture once and reuse it. Is the code in the first post meant to test if the texture is readable? Because the try block is just reading the texture's pixels then setting them again. If you want to test if it's readable you can just try a single GetPixel, since Get, Set and Apply are all somewhat expensive calls to be made so often. Do you mean like mods that replace the stock icons, Alternate Resource Panel, or Contracts Window + (which doesn't actually change the icon)? Those are the only two that I know of. If so maybe you can just wait for a scene change to do anything with those. It's not exactly common for a user to be toggling them on and off, and if it's the only thing preventing you from using the Object listener method (which is almost certainly a far more efficient and more reliable method) I would reconsider.
  6. @CRV-WKD Try again: And this is most likely not the correct thread if you are downloading from CKAN. As the first post says, this is the still-in-development version. Try here:
  7. @Drew Kerman You can check the code here and here. Everything is handled while the map is being drawn; it basically just draws a line across the map and checks if the current pixel's latitude is above or below that line. @OHara The background scanning tab should be fixed in the next version. I just forgot to implement that, so they were always initializing with the toggles set to true. As for CommNet, I've spent a lot of time thinking about how to handle it and I think that some of the core components of SCANsat just aren't compatible with the kind of integration that makes sense to me. Any kind of real-time connection-status check simply doesn't work at moderate time warp levels. You would end up with some segments of the planet scanned when the satellite should be out of connection, and vice versa, since the scanning mechanism relies on orbital math, not the actual vessel position. Something like what you suggest would probably work, but I'm not sure I want to deal with the data management headache and the bloating of the save file that would follow. And in any event I really don't like the idea of disrupting the way that maps instantly update. Despite seeing it happen probably thousands of times I still really like watching a map being built from three or four different satellites at the same time. I think the basic idea, scanning satellite having some kind of local storage that needs to be synced with the master record somehow, would work fine. But the end-result would, in most cases, probably be basically the same as how things are now, or would require something that breaks up the map building process, like going through to each vessel and transmitting data.
  8. No, I'm saying the font set used by the GUILayout system is very different from the fonts used by TextMeshPro, and they aren't compatible. So it's possible that certain character sets won't render correctly when using OnGUI. Standard Unity UI Text objects might also not render correctly, or they might require that modders find usable fonts. I try to use TMP objects whenever possible, but that complicates making a UI quite a bit, so it would be nice if someone could find out if there are acceptable Unity fonts that we could use. Separate files should also be fine, I'm just saying that they can probably all be downloaded and loaded by KSP at the same time.
  9. @Diazo Yes, except that you should be beaten over the head for suggesting its use for OnGUI. There might actually be problems using OnGUI, since I'm not sure how the fonts would work. The UISkinManager lists NotoSans-Regular SDF as the TextMeshPro Font being used for the English version. Different fonts may be used for different translations, and the TMP Font is probably not compatible with OnGUI fonts, or with standard Unity fonts. Another thing to note, since the Config Nodes use the language selection for the node with all of the text fields, I think you can include multiple translations in a single file. You would just use the same text ids for each translation and put them under different nodes, each with their respective language id. Localization { en-us { #autoLOC_7001100 = Loading... #autoLOC_7001101 = Adding K to Every Word... #autoLOC_7001102 = Adding More Boosters... } //I don't know the actual available language codes es { #autoLOC_7001100 = ... } cn { #autoLOC_7001100 = ... } }
  10. For SCANsat, I have an existing framework in place to handle localization. It works in broadly the same manner as stock localization, but there are some differences. Text fields are read from config files on disk, each with an identifier, this time using simple names, rather than the #autoLOC ids. Some processing is required to convert the files from disk into text that works in code. Then the text fields are applied to wherever they are needed based on their identifier. The first difference is that the text identifier is usually applied to Text objects in Unity, rather than in code. So each text field that supports localization has a simple tag that tells SCANsat which string to apply to it. The other difference is in how the text is processed. It is loaded from Config Nodes in basically the same way as anything else, but it uses some Regex to match string formatters and new line breaks. /// <summary> /// Convert string fields from the Config Node on disk to a format readable in code. /// /// The first two Regex fields match the opening and closing arrows and are used to replace them with curly braces, /// the Regex is created to very specifically only match arrows found for use in string.format. /// /// The third Regex is used to create line breaks. The Config Node loader apparently strips \n characters from values /// so I'm using something simple in its place. /// /// Reflection is used to apply the Regex matches to all string fields in the object. /// </summary> public override void OnDecodeFromConfigNode() { Regex openBracket = new Regex(@"\<\<(?=\d+:?\w?\d?\>\>)"); Regex closeBraket = new Regex(@"(?<=\{\d+:?\w?\d?)\>\>"); Regex newLines = new Regex("NEWLINE"); var stringFields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public).Where(a => a.FieldType == typeof(string)).ToList(); for (int i = stringFields.Count - 1; i >= 0; i--) { FieldInfo f = stringFields[i]; f.SetValue(this, openBracket.Replace((string)f.GetValue(this), "{")); f.SetValue(this, closeBraket.Replace((string)f.GetValue(this), "}")); f.SetValue(this, newLines.Replace((string)f.GetValue(this), Environment.NewLine)); } } Then, when the UI is being loaded and processed the text for the appropriate translation is applied to all of the tagged Unity Text objects. /// <summary> /// This method is used to match a string id with string in this class. /// /// It is not particularly efficient and is only used once, during UI processing. /// </summary> /// <param name="title"></param> /// <returns></returns> public string GetStringWithName(string title) { var stringField = this.GetType() .GetFields(BindingFlags.Instance | BindingFlags.Public) .Where(a => a.FieldType == typeof(string)) .FirstOrDefault(f => f.Name == title); if (stringField != null) return (string)stringField.GetValue(this); return ""; } Strings that aren’t applied directly to Text objects can easily be used by storing a static reference to the active language file. Any text that uses string formatting can be used directly in a string.format. All of this code uses lots of Linq and Reflection and so probably shouldn't be used in any manner that requires it to be repeatedly called during use. For SCANsat everything is applied during UI processing in the main menu, strings that need to be accessed later are then used by referring to the active language pack. The most up-to-date version (which is still out-of-date ) of all this code can be found in the dev branch of the SCANsat GitHub repo.
  11. I have some general notes about how stock localization works that I can put here. All of the text files are kept in the KSP/GameData/Squad/Localization folder. Each config file uses the standard KSP config node structure: Localization { en-us { #autoLOC_7001100 = Loading... #autoLOC_7001101 = Adding K to Every Word... #autoLOC_7001102 = Adding More Boosters... } } Each text entry uses an identifier: #autoLOC_ followed by in id. I believe that anything can be used for an id, alphanumerics, periods, etc., but maybe not an underscore, and definitely no curly braces. There is nothing special about the file location, you can move the files out into another folder in GameData and they will load fine. I assume they are replaced when a different language selection is made in Steam or the KSP Store (Steam refuses to let me switch languages, so I can’t be sure). For actual usage there are two different methods. One is for use in other config files, part descriptions, science results, etc.; for these you just replace the text in the existing config file with the text id. manufacturer = #autoLOC_501627 description = #autoLOC_500605 or KerbinSrfLandedLaunchpad = #autoLOC_501259 To use the text in code, everything can be found in the KSP.Localization.Localization class. In place of hard-coded strings you can use Localization.Format and the string id. using KSP.Localization; String text = Localization.Format(“#autoLOC_500605”); The text fields also use something similar to the placeholders in string.format strings. Because config nodes use {} to open and close segments, they can’t be used in the text fields. Instead format positions are denoted with double arrows: <<1>>, also note these start with 1, instead of the 0-based index that string.format uses. I’m not sure, but I think standard string content formatting works, so you can use <<1:P1>> to convert 0.1257 to 12.6%, or <<2:N3>> to convert 12.245436356 to 12.245. It seems that Lingoona has many different string format converters and they don't follow the same style as the standard c# string formats. String text = Localization.Format(“autoLOC_600605”, new string[] { 0.1256.ToString(“P1”), CelestialBody.displayName }); Or String text = Localization.Format(“autoLOC_600605”, new object[] { 0.1256, CelestialBody.displayName }); Some of this will need confirming to make sure that’s how it all works, but I think for the most part this is all correct. Another thing to note about the stock translations is that there are a lot of them. Depending on what your mod does you may find that the required translations already exist in the included files. The files are long, but if you know what you are searching for it can be easy to find.
  12. Now that KSP natively supports localization we might as well try to get mods to support it wherever possible, too. This topic will serve as a database of mods that support localization, a place where people who can provide translation help can connect with mods that need said help, and as place to discuss how to implement localization in your mod and how to work with stock localization. I figure we can have three lists for mods, one for mods that support localization and have at least one non-english translation available, preferably in one of the languages KSP supports, another for mods that support localization, but that need translating, and a third for mods that plan to add localization support. Keep in mind that some mods may be able to provide localization support using only KSP’s existing translations. Localization supported; translations available: KSP Language Patches Localization supported; translations needed - Links point to the primary assets in need of translating: SCANsat Planned localization support: Contracts Window + Science Relay We can also keep links to responses and other resources that can provide tips and examples of how to add localization support. I would ask that people try to limit responses to notifying me of mods that should be added to one of the lists, or to providing some manner of localization support.
  13. I've been planning on making a mod-localization thread at some point, with a list of mods and help on how to support translations. Sometime soon. Simplified Chinese is left-to-right (both when using characters and pinyin) as far as I know. I think traditional chinese is sometimes written top-to-bottom, but I imagine it isn't uncommon to be written left-to-right given how impractical vertical text could be in many situations. Yes. You can easily use any of the stock text by finding the right text field in the localization files and using Localization.Format("#autoloc-1010101") to get the text in-game. Though I'm not sure on how well adding in text for mods would work (what would happen if mods use duplicate ids?).
  14. I might could rework the anomaly icon to work like the waypoint icon. The point of that icon falls at the actual location of the waypoint, whereas every other icon is just centered over the location. The anomaly icon could be changed so the dot is directly over the waypoint, maybe with the dot being changed to a circle.
  15. @DStaal Thanks for that, now I just need Module Manager. Do you mean the colors or the question mark icon itself, or both? The colors are just those used by all icons and overlays. I like the question mark, and I wanted something similar to what you see in KerbNet. I really hated the anomaly marker selection thing the old settings menu, so I just made it a fixed thing.