/// <summary>
        /// Load images into corresponding textures
        /// </summary>
        public static void LoadTextures()
        {
            try
            {
                // LoadImage(ref appLauncherIcon, appLauncherIconPath);

                LoadImage(ref btnGo, btnGoFilePath);
                LoadImage(ref btnGoHover, btnGoHoverFilePath);
                LoadImage(ref btnTarg, btnGoTargFilePath);
                LoadImage(ref btnTargHover, btnGoTargHoverFilePth);
                //LoadImage(ref btnTargHover, "button_targ_hover.png"); // TODO: Create hover image, it is missing
                LoadImage(ref btnFold, btnFoldFilePath);
                LoadImage(ref btnFoldHover, btnFoldHoverFilePath);
                LoadImage(ref btnBodies, btnBodiesFilePath); // handled separate from vessels

                LoadImage(ref btnDownArrow, btnDownArrowFilePath);
                LoadImage(ref btnUpArrow, btnUpArrowFilePath);
                LoadImage(ref btnOrbitIcon, btnOrbitIconFilePath);
                LoadImage(ref btnHiddenIcon, btnHiddenIconFilePath);
                LoadImage(ref btnTargetAlpha, btnTargetAlphaFilePath);
                LoadImage(ref btnAscendingIcon, btnAscendingFilePath);
                LoadImage(ref btnDescendingIcon, btnDescendingFilePath);

                LoadImage(ref btnExtendedHoverBackground, btnExtendedHoverFilePath);
                LoadImage(ref btnExtendedPressedBackground, btnExtendedPressedFilePath);
                LoadImage(ref btnExtendedIconClose, btnExtendedIconCloseFilePath);
                LoadImage(ref btnExtendedIconOpen, btnExtendedIconOpenFilePath);

                LoadImage(ref btnFlatNormalBackground, btnFlatNormalFilePath);
                LoadImage(ref btnFlatHoverBackground, btnFlatHoverFilePath);
                LoadImage(ref btnFlatPressedBackground, btnFlatPressedFilePath);

                LoadImage(ref imgLine, imgLineFilePath);
                LoadImage(ref imgOutline, imgOutlineFilePath);
                LoadImage(ref imgVesselInfoHover, imgVesselInfoHoverFilePath);
                LoadImage(ref imgVesselInfoNormal, imgVesselInfoNormalFilePath);
                LoadImage(ref imgVesselInfoPressed, imgVesselInfoPressedFilePath);
                LoadImage(ref imgVesselInfoSelected, imgVesselInfoSelectedFilePath);

                LoadImage(ref imgVesselListButtonPressed, imgDockingPortButtonPressedFilePath);

                LoadImage(ref btnTerminateHoverBackground, btnTerminateFlatFilePath);
                LoadImage(ref btnTerminateNormalBackground, btnTerminateHoverFilePath);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                HSUtils.Log("Exception caught, probably failed to load file");
            }
        }
Esempio n. 2
0
        public void Save(ConfigNode node)
        {
            var ns = new NodeSeralizer {
                hiddenVessels = this.hiddenVessels
            };

            try
            {
                var        saveNode = new ConfigNode(this.GetType().Name);
                ConfigNode nsNode   = ConfigNode.CreateConfigFromObject(ns);

                saveNode.AddNode(nsNode);
                node.AddNode(saveNode);
            }
            catch (Exception e)
            {
                HSUtils.Log("HiddenVessles#Save: exception: " + e.Message);
            }
        }
        static DockingPortListView()
        {
            try
            {
                Type result = null;
                AssemblyLoader.loadedAssemblies.TypeOperation(t =>
                {
                    if (t.FullName == "NavyFish.ModuleDockingNodeNamed")
                    {
                        result = t;
                    }
                });

                moduleDockingNodeNamedType = result;

                modulePortName = moduleDockingNodeNamedType.GetField("portName",
                                                                     BindingFlags.Instance | BindingFlags.Public);
            }
            catch (Exception e)
            {
                moduleDockingNodeNamedType = null;
                modulePortName             = null;
                HSUtils.DebugLog("exception getting docking port alignment indicator type");
                HSUtils.DebugLog("{0}", e.Message);
            }

            if (moduleDockingNodeNamedType != null && modulePortName != null)
            {
                namedDockingPortSupport = true;

                HSUtils.Log("Docking Port Alignment Indicator mod detected: using named docking node support.");
                HSUtils.DebugLog("{0} {1}", moduleDockingNodeNamedType.FullName,
                                 moduleDockingNodeNamedType.AssemblyQualifiedName);
            }
            else
            {
                HSUtils.DebugLog("Docking Port Alignment Indicator mod was not detected");
            }
        }
Esempio n. 4
0
        private void convertToNewDirectory()
        {
            var oldSettingsFile = Resources.PathPlugin + "/settings.cfg";

            var oldSettingsExists = File.Exists(oldSettingsFile);
            var newSettingsExists = File.Exists(SettingsFile);

            System.IO.Directory.CreateDirectory(NewPluginDataDir);


            if (oldSettingsExists && !newSettingsExists)
            {
                HSUtils.Log("Moving settings file to new location.");

                File.Move(oldSettingsFile, SettingsFile);
            }
            else if (oldSettingsExists)
            {
                HSUtils.Log("Deleting old settings file.");

                File.Delete(oldSettingsFile);
            }
        }
Esempio n. 5
0
        private void Load()
        {
            HSUtils.Log("loading settings");
            HSUtils.DebugLog("Settings#Load: start");

            var load = ConfigNode.Load(SettingsFile) ?? new ConfigNode();

            if (!load.HasNode(NODE_SETTINGS))
            {
                HSUtils.DebugLog("Settings#Load: no settings node");
                return;
            }

            var config = load.GetNode(NODE_SETTINGS);

            var nodeWindowPositions = config.GetNode(NODE_WINDOW_POSITIONS) ?? new ConfigNode();

            var nodeWindowVisibility = config.GetNode(NODE_WINDOW_VISIBILITIES) ?? new ConfigNode();

            var bottomButtons = config.GetNode(BOTTOM_BUTTONS) ?? new ConfigNode();

            var defaultPos = new Rect(0, 0, 0, 0);

            foreach (var i in nodeWindowPositions.nodes)
            {
                var node     = (ConfigNode)i;
                var name     = node.name;
                var position = node.FromNode(WINDOW_POSITION, defaultPos);

                HSUtils.DebugLog("Settings#load name: {0} position: {1}", name, position);

                this.windowPositions[name] = position;
            }

            foreach (var n in nodeWindowVisibility.nodes)
            {
                var node    = (ConfigNode)n;
                var name    = node.name;
                var visible = node.FromNode(WINDOW_VISIBLE, false);

                HSUtils.DebugLog("Settings#Load name: {0} visible: {1}", name, visible);

                this.windowVisibilities[name] = visible;
            }

            foreach (var n in bottomButtons.nodes)
            {
                var node  = (ConfigNode)n;
                var name  = node.name;
                var value = node.FromNode(BUTTON_STATE, false);

                HSUtils.DebugLog("Settings#Load name: {0} value: {1}", name, value);

                this.bottomButtons[name] = value;
            }

            var nodeTypeVisibility = config.GetNode(NODE_VESSEL_TYPE_VISIBILITY) ?? new ConfigNode();

            foreach (var i in Resources.vesselTypesList)
            {
                i.visible = nodeTypeVisibility.GetBuiltinValue(i.name, true);
            }
        }