void FillModIfNeeded(ModDescriptor to, ModDescriptor from) { if (to.modIcon != null) { return; } Debug.Log("[Adjustable Mod Panel] Encountered a known mod: module " + to.module + ", method " + to.method + (to.textureHashNeeded? (", hash " + to.textureHash.ToString()) : "")); to.modIcon = from.modIcon; to.requiredScenes = from.requiredScenes; to.defaultScenes = from.defaultScenes; }
public void TestModDescriptor() { Assert.IsTrue(File.Exists(ApplicationPaths.DescriptorFile), "The mod descriptor file is missing"); ModDescriptor descriptor = ModDescriptor.FromFile(ApplicationPaths.DescriptorFile); if (descriptor.HasPicture) { string picturePath = Path.Combine(ApplicationPaths.ModDirectory, descriptor.Picture); Assert.IsTrue(File.Exists(picturePath), $"The mod picture ({descriptor.Picture}) is missing"); } Assert.AreEqual($"mod/{Path.GetFileName(ApplicationPaths.ModDirectory)}", descriptor.Path, "The mod name defined in the descriptor, and the mod directory name do not match"); }
private void LoadConfig() { Debug.Log("[Adjustable Mod Panel] Loading settings."); KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <AdjustableModPanel> (null); config.load(); try { int count = config.GetValue <int> ("count"); for (int i = 1; i <= count; i++) { string key = config.GetValue <string> ("mod" + i.ToString(), ""); ModDescriptor desc = null; if (key != "") { var vals = key.Split('+'); desc = new ModDescriptor() { module = vals[0], method = vals[1], textureHash = 0, textureHashNeeded = false, unmanageable = false, modIcon = null, defaultScenes = ApplicationLauncher.AppScenes.NEVER, requiredScenes = ApplicationLauncher.AppScenes.NEVER }; } else { desc = new ModDescriptor() { module = config.GetValue <string> ("module" + i.ToString()), method = config.GetValue <string> ("method" + i.ToString()), textureHashNeeded = config.GetValue <bool> ("hashNeeded" + i.ToString()), textureHash = (uint)config.GetValue <long> ("hash" + i.ToString(), 0u), unmanageable = false, modIcon = null, defaultScenes = ApplicationLauncher.AppScenes.NEVER, requiredScenes = ApplicationLauncher.AppScenes.NEVER }; } ApplicationLauncher.AppScenes value = (ApplicationLauncher.AppScenes)config.GetValue <int> ("scenes" + i.ToString()); descriptors.Add(desc); currentScenes[desc] = value; pinnedMods[desc] = config.GetValue <bool> ("pinned" + i.ToString(), false); } } catch (System.Exception e) { Debug.Log("[Adjustable Mod Panel] There was an error reading config: " + e); } }