public void LoadTextures() { AchieveButton = new Texture2D(2, 2); if (!ToolbarControl.LoadImageFromFile(ref AchieveButton, "GameData/Achievements/PluginData/Textures/AchievmentTrophyButton")) { Log.Error("Unable to load AchievmentTrophyButton from file"); } }
// Needed for KRASH support void TerminateSim() { simTermination = true; try { APIManager.ApiInstance.simAPI.TerminateSimNoDialog(); } catch { Log.Error("KRASH needs updating"); ScreenMessages.PostScreenMessage("KRASH needs to be updated for this to work ", 30.0f, ScreenMessageStyle.UPPER_CENTER); } }
internal void Awake() { try { //if (HighLogic.LoadedScene != GameScenes.SPACECENTER && !HighLogic.LoadedSceneIsFlight) // return; Settings.LoadSettings(); // Handle toolbars CreateToolbar(); settingsID = WindowHelper.NextWindowId("SkylabSettings"); windowSkylabID = WindowHelper.NextWindowId("WinSkylab"); } catch (Exception ex) { Log.Error($"Addon.Awake. Error: {ex}"); } }
void OnGUI() { Log.Info("Main.OnGUI"); if (skinInitialized) { return; } //if (HighLogic.CurrentGame == null) // return; //if (!HighLogic.CurrentGame.Parameters.CustomParams<RM_2>().altSkin) //{ // GUI.skin = HighLogic.Skin; //} InitStyles(); modDir = KSPUtil.ApplicationRootPath + "GameData/"; dataDir = modDir + MODNAME + "/PluginData/"; dataFile = dataDir + "Defaults.cfg"; LoadDefaults(); string[] iconList = null; string[] altIconList = null; Texture2D loadedIcon; icons = new Dictionary <string, Texture2D>(); if (Directory.Exists(modDir + ARP_ICONS)) { iconList = Directory.GetFiles(modDir + ARP_ICONS); foreach (var iconpath in iconList) { loadedIcon = new Texture2D(2, 2, TextureFormat.ARGB32, false); //var icon = ToolbarControl.LoadImageFromFile(ref loadedIcon, s); if (!ToolbarControl.LoadImageFromFile(ref loadedIcon, iconpath)) { Log.Error("Error loading icon from file: " + iconpath); } else { var s1 = System.IO.Path.GetFileName(iconpath); icons.Add(System.IO.Path.GetFileName(iconpath).Substring(0, s1.Length - 4), loadedIcon); } } if (Directory.Exists(modDir + ALT_ARP_ICONS)) { altIconList = Directory.GetFiles(modDir + ALT_ARP_ICONS); foreach (var iconpath in altIconList) { loadedIcon = new Texture2D(2, 2); if (!ToolbarControl.LoadImageFromFile(ref loadedIcon, iconpath)) { Log.Error("Error loading icon from file: " + iconpath); } else { var s1 = System.IO.Path.GetFileName(iconpath); s1 = s1.Substring(0, s1.Length - 4); if (icons.ContainsKey(s1)) { icons.Remove(s1); } icons.Add(s1, loadedIcon); } } } } foreach (var i in icons.Keys) { Log.Info("icon.key: " + i); } if (icons != null) { Log.Info("Number of icons found: " + icons.Count()); } skinInitialized = true; Destroy(this); }