Exemplo n.º 1
0
/*************************************************************************************************************************/
        void Awake()
        {
            Log.Info("Awake");

            FMRS_core_awake();

            //stb_texture = new Texture2D(38, 38);
            //stb_texture.LoadImage(System.IO.File.ReadAllBytes(Path.Combine(KSPUtil.ApplicationRootPath, "GameData/FMRS/icons/tb_st_di.png")));

            //stb_texture = GameDatabase.Instance.GetTexture("FMRS/icons/tb_st_di", false);
            stockTexture  = "FMRS/icons/tb_st_di";
            blizzyTexture = "FMRS/icons/tb_blz_di";

            upArrow = new Texture2D(2, 2, TextureFormat.ARGB32, false);
            ToolbarControl.LoadImageFromFile(ref upArrow, "FMRS/Icons/up"); //   GameDatabase.Instance.GetTexture("FMRS/Icons/up", false);

            downArrow = new Texture2D(2, 2, TextureFormat.ARGB32, false);
            ToolbarControl.LoadImageFromFile(ref upArrow, "FMRS/Icons/down");
            //downArrow = GameDatabase.Instance.GetTexture("FMRS/Icons/down", false);

            upContent     = new GUIContent("", upArrow, "");
            downContent   = new GUIContent("", downArrow, "");
            buttonContent = downContent;

            add_toolbar_button();
            //if (ApplicationLauncher.Ready == true)
            //{
            //    add_toolbar_button();
            //}

#if DEBUG
            Log.Info("Version: " + mod_vers);
#endif
            _SAVE_SaveFolder = HighLogic.SaveFolder;
        }
Exemplo n.º 2
0
        public ScreenshotManager(SaveWatcher saveWatcher)
        {
            _loadedScreenshots = new Dictionary <string, Texture2D>();
            try
            {
                saveWatcher.OnSave += OnSave;
                // Migrate old full screenshots to thumbnails
                foreach (var file in Directory.GetFiles(Util.SaveDir, "*.*"))
                {
                    var fullPath = Path.Combine(Util.SaveDir, file);
                    if (IsFullScreenshot(fullPath))
                    {
                        EnqueueAction(() => ResizeScreenshot(fullPath));
                    }
                }

                //_placeholder = GameDatabase.Instance.GetTexture("BetterLoadSaveGame/placeholder", false);
                _placeholder = new Texture2D(2, 2);
                ToolbarControl.LoadImageFromFile(ref _placeholder, "GameData/BetterLoadSaveGame/PluginData/placeholder");
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Exemplo n.º 3
0
 void OnGUI2()
 {
     if (!Settings.hideUnlessChangesDetected || newPartsDetected)
     {
         // Log.Info("OnGUI2, Settings.hideUnlessChangesDetected: " + Settings.hideUnlessChangesDetected + ", newPartsDetected: " + newPartsDetected);
         if (btn == null)
         {
             btn             = new Texture2D(2, 2);
             guiContent      = new GUIContent();
             guiContent.text = "  KSP PartVolume Settings";
             if (!ToolbarControl.LoadImageFromFile(ref btn, "GameData/KSP_PartVolume/PluginData/PartVolume-38"))
             {
                 Log.Error("Unable to load image from file");
             }
             else
             {
                 guiContent.image = btn;
             }
         }
         GUI.skin = HighLogic.Skin;
         GUILayout.BeginArea(RectGUI);
         GUILayout.BeginVertical();
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         if (GUILayout.Button(guiContent, GUILayout.Width(200)))
         {
             ToggleWin();
         }
         GUILayout.FlexibleSpace();
         GUILayout.EndHorizontal();
         GUILayout.EndVertical();
         GUILayout.EndArea();
     }
 }
Exemplo n.º 4
0
        private static void ImageOrig(int width = 0, int height = 0)
        {
            _image = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref _image, _imagefile);

            //var _imagetex = UnityWebRequestTexture.GetTexture(_imagefile);
            //_image = ((DownloadHandlerTexture)_imagetex.downloadHandler).texture;
            //_imagetex.Dispose();

            if (width == 0)
            {
                width = Screen.width / 2;
            }
            if (height == 0)
            {
                height = Screen.height / 2;
            }

            if (_image.width > Screen.width / 2 || _image.height > Screen.height / 2)
            {
                float finalRatio = Mathf.Min((float)(Screen.width / 2) / (float)_image.width, (float)(Screen.height / 2) / (float)_image.height);

                float finalWidth  = (float)_image.width * finalRatio;
                float finalHeight = (float)_image.height * finalRatio;

                TextureScale.Bilinear(_image, (int)finalWidth, (int)finalHeight);
            }
            updateSize = true;
        }
Exemplo n.º 5
0
        void Start()
        {
            DontDestroyOnLoad(this);
            _windowId       = 21398734;
            _windowPosition = new Rect((Screen.width - WIDTH) / 2, (Screen.height - HEIGHT) / 2, WIDTH, HEIGHT);

            if (upArrow == null)
            {
                upArrow = new Texture2D(2, 2);
                if (ToolbarControl.LoadImageFromFile(ref upArrow, KSPUtil.ApplicationRootPath + "GameData/" + FOLDER + "/PluginData/Textures/up"))
                {
                    upContent = new GUIContent("", upArrow, "");
                }
                else
                {
                    upContent = new GUIContent("^", null, "");
                }
            }
            if (downArrow == null)
            {
                downArrow = new Texture2D(2, 2);
                if (ToolbarControl.LoadImageFromFile(ref downArrow, KSPUtil.ApplicationRootPath + "GameData/" + FOLDER + "/PluginData/Textures/down"))
                {
                    downContent = new GUIContent("", downArrow, "");
                }
                else
                {
                    downContent = new GUIContent("v", null, "");
                }
            }

            InvokeRepeating("CheckButtons", 0f, 1f);
            StartCoroutine(CheckButtons());
        }
        private Icon GetIcon(string iconName)
        {
#if false
            var normIcon     = new Texture2D(32, 32, TextureFormat.RGBA32, false);
            var normIconFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), iconName + "_off.png"); // icon to be present in same folder as dll
            WWW www          = new WWW(normIconFile);
            www.LoadImageIntoTexture(normIcon);
#endif
            Texture2D normIcon = new Texture2D(2, 2);

            if (!ToolbarControl.LoadImageFromFile(ref normIcon, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/../PluginData/" + iconName + "_off.png"))
            {
                Debug.Log("Error loading: " + iconName + "_off.png");
            }

            Texture2D selIcon = new Texture2D(2, 2);
            if (!ToolbarControl.LoadImageFromFile(ref selIcon, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/../PluginData/" + iconName + "_on.png"))
            {
                Debug.Log("Error loading: " + iconName + "_on.png");
            }

            Icon icon = new Icon(iconName + "Icon", normIcon, selIcon);

            return(icon);
        }
Exemplo n.º 7
0
        internal static void InitBuildPlans()
        {
            _buildPlansbutton         = new GUIStyle(HighLogic.Skin.button);
            _buildPlansbutton.margin  = new RectOffset(0, 0, 0, 0);
            _buildPlansbutton.padding = new RectOffset(0, 0, 0, 0);
            _buildPlansbutton.border  = new RectOffset(0, 0, 0, 0);
            _buildPlansbutton.normal  = _buildPlansbutton.hover;
            _buildPlansbutton.active  = _buildPlansbutton.hover;

            _background = new Texture2D(2, 2);
            Color[] color = new Color[4];
            color[0] = new Color(1, 1, 1, 0);
            color[1] = color[0];
            color[2] = color[0];
            color[3] = color[0];
            _background.SetPixels(color);

            _buildPlansbutton.normal.background   = _background;
            _buildPlansbutton.hover.background    = _background;
            _buildPlansbutton.onHover.background  = _background;
            _buildPlansbutton.active.background   = _background;
            _buildPlansbutton.onActive.background = _background;

            _up    = new Texture2D(2, 2);
            _hover = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref _up, KSPUtil.ApplicationRootPath + "GameData/LRTR/KCT/icons/KCT_add_normal");
            ToolbarControl.LoadImageFromFile(ref _hover, KSPUtil.ApplicationRootPath + "GameData/LRTR/KCT/icons/KCT_add_hover");
            //up = GameDatabase.Instance.GetTexture("LRTR/KCT/cons/KCT_add_normal", false);
            //hover = GameDatabase.Instance.GetTexture("LRTR/KCT/icons/KCT_add_hover", false);

            PositionAndSizeIcon();
        }
Exemplo n.º 8
0
        internal static void InitDevPartsToggle()
        {
            _devPartsToggle = new GUIStyle(HighLogic.Skin.button)
            {
                margin  = new RectOffset(0, 0, 0, 0),
                padding = new RectOffset(0, 0, 0, 0),
                border  = new RectOffset(0, 0, 0, 0)
            };
            _devPartsToggle.normal = _devPartsToggle.hover;
            _devPartsToggle.active = _devPartsToggle.hover;

            _devPartsBackground = new Texture2D(2, 2);
            Color[] color = new Color[4];
            color[0] = new Color(1, 1, 1, 0);
            color[1] = color[0];
            color[2] = color[0];
            color[3] = color[0];
            _devPartsBackground.SetPixels(color);

            _devPartsToggle.normal.background   = _devPartsBackground;
            _devPartsToggle.hover.background    = _devPartsBackground;
            _devPartsToggle.onHover.background  = _devPartsBackground;
            _devPartsToggle.active.background   = _devPartsBackground;
            _devPartsToggle.onActive.background = _devPartsBackground;

            _devPartsOnTex  = new Texture2D(2, 2);
            _devPartsOffTex = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref _devPartsOnTex, KSPUtil.ApplicationRootPath + "GameData/RP-0/PluginData/Icons/KCT_dev_parts_on");
            ToolbarControl.LoadImageFromFile(ref _devPartsOffTex, KSPUtil.ApplicationRootPath + "GameData/RP-0/PluginData/Icons/KCT_dev_parts_off");

            PositionAndSizeDevPartsIcon();
        }
Exemplo n.º 9
0
 static internal void LoadImage(ref Texture2D tex, string name)
 {
     if (!ToolbarControl.LoadImageFromFile(ref tex, Resources.DIR + name))
     {
         Log.Info("Unable to load image from file:  " + DIR + name);
     }
 }
Exemplo n.º 10
0
        public static Texture2D GetTexture(string name)
        {
            Texture2D tex = new Texture2D(2, 2);
            bool      b   = ToolbarControl.LoadImageFromFile(ref tex, "GameData/NASA_Countdown/Images/" + name);

            return(tex);
            //return GameDatabase.Instance.GetTexture($"NASA_Countdown/Images/{name}", false);
        }
Exemplo n.º 11
0
 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");
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Load image from file
 /// </summary>
 /// <param name="targ"></param>
 /// <param name="filename">File name in images directory. Path is hardcoded: HrmHaystack/images/</param>
 private static void LoadImage(ref Texture2D targ, string filename)
 {
     if (!ToolbarControl.LoadImageFromFile(ref targ, filename))
     {
         Debug.Log("Missing file: " + filename);
         return;
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Loads external config node data.
        /// </summary>
        void LoadConfiguration()
        {
            // Load all the celestial body configuration
            ConfigNode[] bodyConfig = GameDatabase.Instance.GetConfigNodes("WAYPOINT_MANAGER_BODIES");
            foreach (ConfigNode configNode in bodyConfig)
            {
                try
                {
                    string config = configNode.GetValue("name");

                    Log.Info("WaypointManager: Loading " + config + " icons.");
                    string url = configNode.GetValue("url");
                    if (url.Last() != '/')
                    {
                        url += '/';
                    }
                    if (Directory.Exists("GameData/" + url))
                    {
                        foreach (var str in Directory.GetFiles("GameData/" + url))
                        {
                            var icon = new Texture2D(2, 2);
                            ToolbarControl.LoadImageFromFile(ref icon, str);
                            //string name = icon.name.Substring(icon.name.LastIndexOf('/') + 1);
                            string name = Path.GetFileNameWithoutExtension(str);
                            bodyIcons[name] = icon;
                        }
                    }

#if false
                    foreach (GameDatabase.TextureInfo icon in GameDatabase.Instance.GetAllTexturesInFolder(url))
                    {
                        string name = icon.name.Substring(icon.name.LastIndexOf('/') + 1);
                        bodyIcons[name] = icon.texture;
                        Log.Info("WaypointManager: Loaded icon for " + name + ".");
                    }
#endif
                }
                catch (Exception e)
                {
                    Debug.LogError("WaypointManager: Exception when attempting to load Celestial Body configuration:");
                    Debug.LogException(e);
                }
            }

            // Extra stuff!
            GameDatabase.TextureInfo nyan = GameDatabase.Instance.databaseTexture.Where(t => t.name.Contains("WaypointManager/icons/Special/nyan")).FirstOrDefault();
            if (nyan != null && DateTime.Now.Month == 4 && DateTime.Now.Day == 1)
            {
                foreach (GameDatabase.TextureInfo texInfo in GameDatabase.Instance.databaseTexture.Where(t => t.name.StartsWith("Squad/Contracts/Icons/")))
                {
                    string name = texInfo.name.Replace("Squad/Contracts/Icons/", "");
                    if (!CustomWaypointGUI.forbiddenIcons.Contains(name))
                    {
                        texInfo.texture = nyan.texture;
                    }
                }
            }
        }
Exemplo n.º 14
0
        void Start()
        {
            Instance = this;
            Log.Info("KeoCacheDriver.Start");
            CreateButton();
            //if (activeKeoCacheCollection == null)
            //    activeKeoCacheCollection = new KeoCacheCollection();

            //
            // Dynamically generate the window IDs based off of the time
            //
            collectionWinID     = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond;
            KeocacheWinID       = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond + 1;
            menuWinID           = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond + 2;
            hintWinID           = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond + 3;
            travelbugWinID      = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond + 4;
            importWinID         = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond + 5;
            activeCollectionsID = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond + 6;
            kerbalXWinID        = (DateTime.Now.Hour * 3600 + DateTime.Now.Minute * 60 + DateTime.Now.Second) * 1000 + DateTime.Now.Millisecond + 7;

            GameEvents.onHideUI.Add(this.HideUI);
            GameEvents.onShowUI.Add(this.ShowUI);
            GameEvents.onGamePause.Add(this.HideUIWhenPaused);
            GameEvents.onGameUnpause.Add(this.ShowUIwhenPaused);
            GameEvents.OnVesselRollout.Add(OnVesselRollout);
            GameEvents.onLevelWasLoaded.Add(OnLevelLoaded);

            if (upArrow == null)
            {
                upArrow = new Texture2D(2, 2);
                if (ToolbarControl.LoadImageFromFile(ref upArrow, "GameData/KeoCaching/PluginData/Icons/up"))
                {
                    upContent = new GUIContent("", upArrow, "");
                }
                else
                {
                    Log.Error("Unable to load up arrow");
                }
            }
            if (downArrow == null)
            {
                downArrow = new Texture2D(2, 2);
                if (ToolbarControl.LoadImageFromFile(ref downArrow, "GameData/KeoCaching/PluginData/Icons/down"))
                {
                    downContent = new GUIContent("", downArrow, "");
                }
                else
                {
                    Log.Error("Unable to load down arrow");
                }
            }


            InitiatePlay();
            ReadAllCaches();
        }
Exemplo n.º 15
0
        public MainWindow(FuelBalanceController controller, Settings settings, /* SettingsWindow settingsWindow,*/ HelpWindow helpWindow)
            : base("TAC Fuel Balancer", 500, 500)
        {
            Debug.Log("MainWindow");
            this.controller = controller;
            this.settings   = settings;
#if false
            this.settingsWindow = settingsWindow;
#endif
            this.helpWindow = helpWindow;
            //SetVisible(true);

#if false
            //var settingstexture = TextureHelper.FromResource("Tac.icons.settings.png", 16, 16);
            Texture2D settingstexture = null;
            try
            {
                settingstexture = TextureHelper.FromResource("icons.settings.png", 16, 16);
            }
            catch { }
            settingsContent = (settingstexture != null) ? new GUIContent(settingstexture, "Settings window") : new GUIContent("S", "Settings window");
#endif
            //var helptexture = TextureHelper.FromResource("Tac.icons.help.png", 16, 16);
            Texture2D helptexture = null;
            try
            {
                helptexture = TextureHelper.FromResource("icons.help.png", 16, 16);
            }
            catch (Exception ex)
            {
                Debug.Log("exception loading helptexture from resource: " + ex.Message);
                helptexture = new Texture2D(16, 16);
                if (!ToolbarControl.LoadImageFromFile(ref helptexture, "GameData/TacFuelBalancer/Icons/help.png"))
                {
                    helptexture = null;
                }
            }
            helpContent = (helptexture != null) ? new GUIContent(helptexture, "Help window") : new GUIContent("?", "Help window");

            //var resettexture = TextureHelper.FromResource("Tac.icons.reset.png", 16, 16);
            Texture2D resettexture;
            try
            {
                resettexture = TextureHelper.FromResource("icons.reset.png", 16, 16);
            }
            catch (Exception ex)
            {
                Debug.Log("exception loading resettexture from resource: " + ex.Message);
                resettexture = new Texture2D(16, 16);
                if (!ToolbarControl.LoadImageFromFile(ref resettexture, "GameData/TacFuelBalancer/Icons/reset.png"))
                {
                    resettexture = null;
                }
            }
            resetContent = (resettexture != null) ? new GUIContent(resettexture, "Reset resource lists") : new GUIContent("?", "Reset resource lists");
        }
Exemplo n.º 16
0
        public static Texture2D GetTexture(string name)
        {
            Texture2D tex = new Texture2D(2, 2);
            bool      b   = ToolbarControl.LoadImageFromFile(ref tex, KSPUtil.ApplicationRootPath + "GameData/NASA_CountDown/Images/" + name);

            if (!b)
            {
                Log.Error("LoadImageFromFile failed:" + name);
            }
            return(tex);
            //return GameDatabase.Instance.GetTexture($"NASA_Countdown/Images/{name}", false);
        }
Exemplo n.º 17
0
        protected Window(string windowTitle, float defaultWidth, float defaultHeight)
        {
            this.windowTitle = windowTitle;
            this.windowId    = windowTitle.GetHashCode() + new System.Random().Next(65536);

            configNodeName = windowTitle.Replace(" ", "");

            windowPos = new Rect((Screen.width - defaultWidth) / 2, (Screen.height - defaultHeight) / 2, defaultWidth, defaultHeight);
            mouseDown = false;
            visible   = false;

            //var texture = TextureHelper.FromResource("Tac.icons.resize.png", 16, 16);
            Texture2D texture = null;

            try
            {
                texture = TextureHelper.FromResource("icons.resize.png", 16, 16);
            }
            catch (Exception ex)
            {
                Debug.Log("exception loading resize texture from resource: " + ex.Message);
                texture = new Texture2D(16, 16);
                if (!ToolbarControl.LoadImageFromFile(ref texture, "GameData/TacFuelBalancer/Icons/resize.png"))
                {
                    texture = null;
                }
            }
            resizeContent = (texture != null) ? new GUIContent(texture, "Drag to resize the window") : new GUIContent("R", "Drag to resize the window");

            //var closetexture = TextureHelper.FromResource("Tac.icons.close.png", 16, 16);
            Texture2D closetexture = null;

            try
            {
                closetexture = TextureHelper.FromResource("icons.close.png", 16, 16);
            }
            catch (Exception ex)
            {
                Debug.Log("exception loading closetexture from resource: " + ex.Message);
                closetexture = new Texture2D(16, 16);
                if (!ToolbarControl.LoadImageFromFile(ref closetexture, "GameData/TacFuelBalancer/Icons/close.png"))
                {
                    closetexture = null;
                }
            }
            closeContent = (closetexture != null) ? new GUIContent(closetexture, "Close window") : new GUIContent("X", "Close window");


            Resizable       = true;
            HideCloseButton = false;
            HideWhenPaused  = true;
        }
Exemplo n.º 18
0
        void LoadAndInitTexture()
        {
            colorPicker = new Texture2D(2, 2);
            bool rc = ToolbarControl.LoadImageFromFile(ref colorPicker, texturePath);

            curTextureNum = null;
            for (int i = 0; i < pickerTextures.Length; i++)
            {
                if (texturePath == TEXTURES + pickerTextures[i])
                {
                    curTextureNum = i;
                    break;
                }
            }
            if (settings != null && curTextureNum != null)
            {
                settings.Save((int)curTextureNum);
            }
            if (!rc)
            {
                Log.Error("Unable to load ColorPicker image");
                CloseAndDestroy();
            }
            colorPicker.Apply();
            displayPicker = colorPicker;
#if false
            if (!useDefinedSize)
            {
                textureWidth  = Math.Min(400, colorPicker.width);
                textureHeight = Math.Min(400, colorPicker.height);
            }
#endif
            if (!useDefinedPosition)
            {
                positionLeft = (Screen.width / 2) - (textureWidth / 2);
                positionTop  = (Screen.height / 2) - (textureHeight / 2);
            }
            saturationTexture = new Texture2D(20, textureHeight);
            SetSaturationTexture(Color.black);

            saturationTextureStyle = new GUIStyle();
            saturationTextureStyle.stretchHeight = true;
            saturationTextureStyle.stretchWidth  = true;

            selectedColor = lastSetColor;
            // small color picker box texture
            styleTexture = new Texture2D(1, 1);
            styleTexture.SetPixel(0, 0, selectedColor);
            _windowPos = new Rect(positionLeft, positionTop, textureWidth + 70, textureHeight + 70 + TITLE_HEIGHT);

            styleTextureStyle = new GUIStyle();
        }
        private Texture LoadTextureResource(string resourceName)
        {
            string path = BuildPath(resourceName);

            Log.Debug("Loading texture: " + path);

            Texture2D texture = new Texture2D(2, 2);

            if (!ToolbarControl.LoadImageFromFile(ref texture, path))
            {
                Log.Error("Failed to load texture " + resourceName);
            }
            return(texture);
        }
Exemplo n.º 20
0
        public static Texture2D LoadImage(string textureName, bool relativeToGameData = true)
        {
            if (relativeToGameData)
            {
                textureName = "GameData/ScienceAlert/PluginData/Textures/" + textureName;
            }
            var texture2D = new Texture2D(2, 2);

            if (!ToolbarControl.LoadImageFromFile(ref texture2D, textureName))
            {
                Log.Debug("[ScienceAlert]:Failed to find texture '{0}'", textureName);
            }
            return(texture2D);
        }
Exemplo n.º 21
0
        public void LoadConfig()
        {
            if (!File.Exists(PLUGINDATA + "config.cfg"))
            {
                return;
            }
            ConfigNode fileNode = ConfigNode.Load(PLUGINDATA + "config.cfg");

            if (fileNode == null)
            {
                return;
            }
            ConfigNode node = null;

            if (fileNode.TryGetNode(NODE, ref node))
            {
                TextureUrl = node.SafeLoad("TextureUrl", string.Empty);
                if (TextureUrl != "")
                {
                    _mainTextureRef = new Texture2D(2, 2);
                    ToolbarControl.LoadImageFromFile(ref _mainTextureRef, TextureUrl);
                }
                IVATextureUrl = node.SafeLoad("IVATextureUrl", string.Empty);
                if (IVATextureUrl != "")
                {
                    _ivaTextureRef = new Texture2D(2, 2);
                    ToolbarControl.LoadImageFromFile(ref _ivaTextureRef, IVATextureUrl);
                }
                EmissiveUrl = node.SafeLoad("EmissiveUrl", string.Empty);
                if (EmissiveUrl != "")
                {
                    _emissiveTextureRef = new Texture2D(2, 2);
                    ToolbarControl.LoadImageFromFile(ref _emissiveTextureRef, EmissiveUrl);
                }
                EmissiveColor = node.SafeLoad("EmissiveColor", new Color(0.376f, 0.376f, 0.376f, 1f));

                if (!NavBallChanger.IVAactive)
                {
                    _flightMaterial.Value.SetTexture("_MainTexture", _mainTextureRef);
                    SetFlightTexture();
                }
                else
                {
                    _flightMaterial.Value.SetTexture("_MainTexture", _ivaTextureRef);
                    SetIvaTextures();
                }
            }
        }
Exemplo n.º 22
0
        private void LoadTextures()
        {
            Config.toolbarIcon = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref Config.toolbarIcon, "GameData/WaypointManager/PluginData/icons/toolbar");

            Config.addWaypointIcon = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref Config.addWaypointIcon, "GameData/WaypointManager/PluginData/icons/addWaypoint");
            Config.editWaypointIcon = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref Config.editWaypointIcon, "GameData/WaypointManager/PluginData/icons/editWaypoint");
            Config.deleteWaypointIcon = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref Config.deleteWaypointIcon, "GameData/WaypointManager/PluginData/icons/deleteWaypoint");
            Config.settingsIcon = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref Config.settingsIcon, "GameData/WaypointManager/PluginData/icons/settings");
            Config.closeIcon = new Texture2D(2, 2);
            ToolbarControl.LoadImageFromFile(ref Config.closeIcon, "GameData/WaypointManager/PluginData/icons/close");
        }
Exemplo n.º 23
0
        /// <summary>
        /// Load image from file
        /// </summary>
        /// <param name="targ"></param>
        /// <param name="filename">File name in images directory. Path is hardcoded: HrmHaystack/images/</param>
        private static void LoadImage(ref Texture2D targ, string filename)
        {
#if false
            Debug.Log("LoadImage: " + filename);
            if (!File.Exists(filename))
            {
                Debug.Log("Missing file: " + filename);
                return;
            }
            targ.LoadImage(File.ReadAllBytes(filename));
#endif
            if (!ToolbarControl.LoadImageFromFile(ref targ, filename))
            {
                Debug.Log("Missing file: " + filename);
                return;
            }
        }
Exemplo n.º 24
0
 public void Start()
 {
     /* DesiredTime = UT; */
     if (HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.FLIGHT)
     {
         CreateButtonIcon();
     }
     if (ShipIcon == null)
     {
         ShipIcon = GameDatabase.Instance.GetTexture("Squad/PartList/SimpleIcons/RDicon_commandmodules", false);
     }
     if (BodyIcon == null)
     {
         BodyIcon = new Texture2D(2, 2, TextureFormat.ARGB32, false);
         ToolbarControl.LoadImageFromFile(ref BodyIcon, KSPUtil.ApplicationRootPath + "GameData/" + "SlingShotter/PluginData/Textures/body");
     }
 }
Exemplo n.º 25
0
        public static Texture2D LoadTexture(string path)
        {
            Texture2D tex = new Texture2D(25, 25);

            ToolbarControl.LoadImageFromFile(ref tex, "GameData/" + path);
            return(tex);

#if false
            var texture = GameDatabase.Instance.GetTexture(path, false);
            if (texture == null)
            {
                LogError($"Filter - Unable to load texture file {path}");
                return(new Texture2D(25, 25));
            }
            return(texture);
#endif
        }
Exemplo n.º 26
0
        void UpdateImageCache()
        {
            for (int i = imgCacheList.Count; i < kaptainsLogList.Count; i++)
            {
                var le1 = kaptainsLogList[i];

                var        fileName = le1.jpgThumbnailName;
                GUIContent content  = new GUIContent();
                if (System.IO.File.Exists(fileName))
                {
                    Texture2D imagetex = new Texture2D(2, 2);
                    ToolbarControl.LoadImageFromFile(ref imagetex, fileName);
                    content.image = imagetex;
                }
                imgCacheList.Add(content);
            }
            KLScenario.imgCacheFilled = true;
        }
        void Start()
        {
            Instance = this;
            Debug.Log("[ResonantOrbitCalculator]: Starting!");

            graphWindow = new GraphWindow();
            // should be called once, so let's deserialize graph here too
            graphWindow.Start();
            graphWindow.load_settings();
            graphWindow.init_textures();

            KACWrapper.InitKACWrapper();

            GameEvents.onHideUI.Add(this.HideUI);
            GameEvents.onShowUI.Add(this.ShowUI);
            GameEvents.onGamePause.Add(this.HideUIWhenPaused);
            GameEvents.onGameUnpause.Add(this.ShowUIwhenUnpaused);
            onAppLauncherLoad();

            if (upArrow == null)
            {
                upArrow = new Texture2D(2, 2);
                if (ToolbarControl.LoadImageFromFile(ref upArrow, KSPUtil.ApplicationRootPath + "GameData/ResonantOrbitCalculator/PluginData/Images/up"))
                {
                    upContent = new GUIContent("", upArrow, "");
                }
                else
                {
                    upContent = new GUIContent("^", null, "");
                }
            }
            if (downArrow == null)
            {
                downArrow = new Texture2D(2, 2);
                if (ToolbarControl.LoadImageFromFile(ref downArrow, KSPUtil.ApplicationRootPath + "GameData/ResonantOrbitCalculator/PluginData/Images/down"))
                {
                    downContent = new GUIContent("", downArrow, "");
                }
                else
                {
                    downContent = new GUIContent("v", null, "");
                }
            }
        }
Exemplo n.º 28
0
        //private UnityWebRequest _imagetex;

        public Texture2D GetImage(String path, int width, int height)
        {
            Log.Info("GetImage, path: " + path);
            // Due to the image dimensions, they aren't loaded in to the KSP database properly,
            // the code below now does that directly

            //Texture2D img = new Texture2D(width, height, TextureFormat.ARGB32, false);
            //img = GameDatabase.Instance.GetTexture(path, false);


            Log.Info("Loading image manually");
            //_imagetex = UnityWebRequest.Get(KSPUtil.ApplicationRootPath.Replace("\\", "/") +  "/GameData/" + path + ".png");
            //Texture2D img = ((DownloadHandlerTexture)_imagetex.downloadHandler).texture;
            Texture2D img = new  Texture2D(2, 2);

            ToolbarControl.LoadImageFromFile(ref img, KSPUtil.ApplicationRootPath.Replace("\\", "/") + "/GameData/" + path + ".png");
            //_imagetex.Dispose();

            return(img);
        }
Exemplo n.º 29
0
        protected Window(string windowTitle, float defaultWidth, float defaultHeight)
        {
            this.windowTitle = windowTitle;
            this.windowId    = windowTitle.GetHashCode() + new System.Random().Next(65536);

            configNodeName = windowTitle.Replace(" ", "");

            windowPos = new Rect((Screen.width - defaultWidth) / 2, (Screen.height - defaultHeight) / 2, defaultWidth, defaultHeight);
            mouseDown = false;
            visible   = false;

            Texture2D texture = new Texture2D(2, 2);

            ToolbarControl.LoadImageFromFile(ref texture, "PAPIPlugin/PluginData/resize.png");
            resizeContent = (texture != null) ? new GUIContent(texture, "Drag to resize the window.") : new GUIContent("R", "Drag to resize the window.");

            Resizable       = true;
            HideCloseButton = false;
            HideWhenPaused  = true;
        }
Exemplo n.º 30
0
        public void Start()
        {
            try
            {
                fetch        = this;
                _saveWatcher = new SaveWatcher();

                _screenshotManager  = new ScreenshotManager(_saveWatcher);
                _saveGameCollection = new SaveGameCollection(_saveWatcher);

                _loadGameDialog = new LoadGameDialog(_saveWatcher, _saveGameCollection, _screenshotManager, GetInstanceID());
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            if (!ToolbarControl.LoadImageFromFile(ref clearBtn, "GameData/" + InstallChecker.FOLDERNAME + "/PluginData/clear-30"))
            {
                Log.Error("Error loading clear-30 image");
            }
        }