示例#1
0
        internal void BuildIcon()
        {
            _toolbarManagerLoaded = null;

            if (_toolbarManagerLoaded.HasValue == false)
            {
                _toolbarManagerLoaded = ToolbarDLL.Loaded;
            }

            if (_toolbarManagerLoaded.Value)
            {
                if ((_toolbarButton == null))
                {
                    try
                    {
                        _toolbarButton             = new ToolbarButtonWrapper("EnhancedNavball", "btnEnhancedNavballToolbarIcon");
                        _toolbarButton.TexturePath = "EnhancedNavBall/Resources/navball24";
                        _toolbarButton.ToolTip     = "Enhanced Navball";
                        _toolbarButton.AddButtonClickHandler(e => ToggleButton());
                    }
                    catch (Exception)
                    {
                        DestroyToolbarButton();
                    }
                }
            }
            else
            {
                if (_iconTexture == null)
                {
                    _iconTexture = GameDatabase.Instance.GetTexture("EnhancedNavBall/Resources/navball32", false);
                }
            }
        }
示例#2
0
        public override void OnStart(StartState state)
        {
            if (!useStockToolBar) // blizzy
            {
                try
                {
                    //print("@@@Toolbar init");
                    toolbarButton = new ToolbarButtonWrapper("Proximity", "toolbarButton");
                    RefreshBlizzyButton();
                    toolbarButton.ToolTip = "Proximity settings";
                    toolbarButton.Visible = true;
                    toolbarButton.AddButtonClickHandler((e) =>
                    {
                        //print("@@@ prox toolbar button clicked");
                        toolbarShowSettings = !toolbarShowSettings;
                        sizechange          = true;
                        RefreshBlizzyButton();
                        //windowPos.yMax = windowPos.yMin + 20;
                    });
                }
                catch (Exception ex)
                {
                    //print("@@@Exception on blizzy toolbar init, msg = " + ex.Message);
                }
                UseToolbar = true;
            }
            else // stock
            {
                UseToolbar = true;
            }

            if (state != StartState.Editor)
            {
                //print("@@@OnStart");
                RenderingManager.AddToPostDrawQueue(0, OnDraw);

                sampleRate = AudioSettings.outputSampleRate;
                obj        = new GameObject();
                obj.AddComponent("AudioSource");
                MakeBeep();
                obj.audio.ignoreListenerVolume = true;
                obj.audio.volume = volume;

                timeSinceLanding = FlightGlobals.ActiveVessel.missionTime;

                if (Sines == null)
                {
                    Sines = new float[10000];
                    for (int i = 0; i < 10000; i++)
                    {
                        Sines[i] = Mathf.Sin((float)i);
                    }
                }

                sizechange = true;
            }
        }
示例#3
0
        public override void OnStart(StartState state)
        {
            //print("###Biomatic OnStart");
            if (!useStockToolBar) // blizzy
            {
                try
                {
                    //print("###Toolbar init");
                    toolbarButton = new ToolbarButtonWrapper("Biomatic", "toolbarButton");
                    RefreshBlizzyButton();
                    toolbarButton.ToolTip = "Biomatic settings";
                    toolbarButton.Visible = true;
                    toolbarButton.AddButtonClickHandler((e) =>
                    {
                        //print("### prox toolbar button clicked");
                        toolbarShowSettings = !toolbarShowSettings;
                        RefreshBlizzyButton();
                        sizechange = true;
                    });
                }
                catch (Exception ex)
                {
                    //print("###Exception on blizzy toolbar init, msg = " + ex.Message);
                }
                UseToolbar = true;
            }
            else // stock
            {
                UseToolbar = true;
            }

            if (state != StartState.Editor)
            {
                RenderingManager.AddToPostDrawQueue(0, OnDraw);

                if (listIgnore == null)
                {
                    listIgnore = new List <string>();
                }

                historyArray = new BiomeSituation[5];
                sizechange   = true;
            }
        }
示例#4
0
        /// <summary>
        /// initialises a Toolbar Button for this mod
        /// </summary>
        /// <returns>The ToolbarButtonWrapper that was created</returns>
        internal ToolbarButtonWrapper InitToolbarButton()
        {
            ToolbarButtonWrapper btnReturn = null;

            try
            {
                KACWorker.DebugLogFormatted("Initialising the Toolbar Icon");
                btnReturn             = new ToolbarButtonWrapper("KerbalAlarmClock", "btnToolbarIcon");
                btnReturn.TexturePath = "TriggerTech/ToolbarIcons/KACIcon-Norm";
                btnReturn.ToolTip     = "Kerbal Alarm Clock";
                btnReturn.AddButtonClickHandler((e) =>
                {
                    WorkerObjectInstance.WindowVisibleByActiveScene = !WorkerObjectInstance.WindowVisibleByActiveScene;
                    Settings.Save();
                });
            }
            catch (Exception ex)
            {
                DestroyToolbarButton(btnReturn);
                KACWorker.DebugLogFormatted("Error Initialising Toolbar Button: {0}", ex.Message);
            }
            return(btnReturn);
        }
        internal void BuildIcon()
        {
            _toolbarManagerLoaded = null;

            if (_toolbarManagerLoaded.HasValue == false)
                _toolbarManagerLoaded = ToolbarDLL.Loaded;

            if (_toolbarManagerLoaded.Value)
            {
                if ((_toolbarButton == null))
                {
                    try
                    {
                        _toolbarButton = new ToolbarButtonWrapper("EnhancedNavball", "btnEnhancedNavballToolbarIcon");
                        _toolbarButton.TexturePath = "EnhancedNavBall/Resources/navball24";
                        _toolbarButton.ToolTip = "Enhanced Navball";
                        _toolbarButton.AddButtonClickHandler(e => ToggleButton());
                    }
                    catch (Exception)
                    {
                        DestroyToolbarButton();
                    }
                }
            }
            else
            {
                if (_iconTexture == null)
                    _iconTexture = GameDatabase.Instance.GetTexture("EnhancedNavBall/Resources/navball32", false);
            }
        }
示例#6
0
        //This runs upon entering the flight scene.
        public void Awake()
        {
            //only run once
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            Debug.Log("(CB) Starting Custom Biomes v" + _versionString);
            //Check compatability first
            if (!CompatibilityChecker.IsCompatible())
            {
                Debug.Log("(CB) Custom Biomes may be incompatible with the installed version of KSP.  Please visit the KSP forums for more information.");
                string        buf   = "Version " + VersionString + " of Custom Biomes is not designed for with KSP version" + _compatibleMajorVersion + "." + _compatibleMinorVersion;
                ScreenMessage click = new ScreenMessage(buf, 10, ScreenMessageStyle.UPPER_CENTER);
                ScreenMessages.PostScreenMessage(click);
                //_disabled = true;
                //return;
            }
            //_disabled = false;
            //Load persistant configuration data
            if (_debug)
            {
                Debug.Log("(CB) Loading configuration data...");
            }
            LoadMe();
            if (_debug)
            {
                Debug.Log("(CB) Loading complete.");
            }
            //Get the save files in this installation
            char dsc = Path.DirectorySeparatorChar;
            char asc = Path.AltDirectorySeparatorChar;
            //Debug.Log("DSC: " + dsc + " ASC: " + asc);
            //Debug.Log("KSPUtil: "+KSPUtil.ApplicationRootPath);
            String currentsave = Application.dataPath;

            if (_debug)
            {
                Debug.Log("(CB) DataPath: " + currentsave);
            }
            currentsave = currentsave.Remove(currentsave.LastIndexOf(asc));
            if (_debug)
            {
                Debug.Log("(CB) Trimmed: " + currentsave);
            }
            if (currentsave.Substring(currentsave.LastIndexOf(asc)).Contains("KSP.app"))
            {
                currentsave = currentsave.Remove(currentsave.LastIndexOf(asc));
                //Debug.Log("Trimmed2: " + currentsave);
            }
            //currentsave = currentsave.Remove(currentsave.LastIndexOf(asc));
            currentsave = currentsave + asc + "saves";
            if (_debug)
            {
                Debug.Log("(CB) Saves: " + currentsave);
            }
            _saveFiles = Directory.GetDirectories(currentsave);
            //Strip the first part of the directory off the save names
            for (int i = 0; i < _saveFiles.Length; i++)
            {
                _saveFiles[i] = _saveFiles[i].Substring(_saveFiles[i].LastIndexOf(dsc) + 1);
            }
            //List the biome sets in this installation
            currentsave = Application.dataPath;
            currentsave = currentsave.Remove(currentsave.LastIndexOf(asc));
            if (currentsave.Substring(currentsave.LastIndexOf(asc)).Contains("KSP.app"))
            {
                currentsave = currentsave.Remove(currentsave.LastIndexOf(asc));
            }
            currentsave = currentsave + asc + "GameData" + asc + "CustomBiomes" + asc + "PluginData" + asc + "CustomBiomes";
            if (_debug)
            {
                Debug.Log("(CB) Full Path: " + currentsave);
            }
            //currentsave = Directory.GetCurrentDirectory() + dsc+"GameData"+dsc+"CustomBiomes"+dsc+"PluginData"+dsc+"CustomBiomes";
            _setFolders = Directory.GetDirectories(currentsave);
            currentsave = HighLogic.SaveFolder;
            //Strip the leading directory info off the set names
            for (int i = 0; i < _setFolders.Length; i++)
            {
                _setFolders[i] = _setFolders[i].Substring(_setFolders[i].LastIndexOf(dsc) + 1);
            }
            //Set up the defaults list
            String[] ds = null;
            if (!_defaultSets.Equals(""))
            {
                ds = _defaultSets.Split(';');
            }
            //_saveDefaults = new string[_saveFiles.Length, 2];
            _saveDictionary = new Dictionary <string, string>();
            _resultList     = new List <sciresult>();
            string s, d;

            //Look at each save file in this install
            for (int i = 0; i < _saveFiles.Length; i++)
            {
                //_saveDefaults[i, 0] = _saveFiles[i];
                //look through the default sets string to see if we can find a match
                if (ds != null)
                {
                    bool found = false;
                    for (int j = 0; j < ds.Length; j++)
                    {
                        //Split the "save|biome set" combination into 2 strings
                        split(ds[j], out s, out d);
                        if (s.Equals(_saveFiles[i]))
                        {
                            if (_debug)
                            {
                                Debug.Log("(CB) " + d + " is the default set for " + s);
                            }
                            found = true;
                            //_saveDefaults[i, 1] = d;
                            _saveDictionary.Add(_saveFiles[i], d);
                            break;
                        }
                    }
                    if (!found) //Set basic to default if this save doesn't have a default ie, new save detected
                    {
                        if (_debug)
                        {
                            Debug.Log("(CB) Default set not found for" + _saveFiles[i]);
                        }
                        //_saveDefaults[i, 1] = "Basic";
                        _saveDictionary.Add(_saveFiles[i], "Basic");
                    }
                }
                else   //If no defaults were set, use the Basic pack as the default
                {
                    if (_debug)
                    {
                        Debug.Log("(CB) No defaults found, setting all saves to 'Basic' set.");
                    }
                    _saveDictionary.Add(_saveFiles[i], "Basic");
                }
                //If this is the active save, load the default biome set
                if (_saveFiles[i].Equals(currentsave) && !_replaced)
                {
                    string def;
                    if (_saveDictionary.TryGetValue(_saveFiles[i], out def))
                    {
                        ReplaceBiomes(def);
                    }
                    else
                    {
                        ReplaceBiomes("Basic");
                    }
                }
            }
            _defaultSets = buildDefaultsString();
            SaveMe();
            bool loaded = ToolbarDLL.Loaded;

            if ((_useLauncher || !loaded) && _enableGUI)
            {
                //Stock toolbar a.k.a App Launcher
                _appButton = ApplicationLauncher.Instance.AddModApplication(
                    () => {
                    if (_debug)
                    {
                        Debug.Log("(CB) CustomBiomes menu toggled.");
                    }
                    _isMinimized = !_isMinimized;
                    SaveMe();
                },
                    () => {
                    if (_debug)
                    {
                        Debug.Log("(CB) CustomBiomes menu toggled.");
                    }
                    _isMinimized = !_isMinimized;
                    SaveMe();
                },
                    null,
                    null,
                    null,
                    null,
                    ApplicationLauncher.AppScenes.FLIGHT,
                    GameDatabase.Instance.GetTexture("CustomBiomes/BiomeIcon", false)
                    );
            }
            else if (_enableGUI)
            {
                //Blizzy's toolbar buton setup, using wrapper
                if (_debug)
                {
                    Debug.Log("(CB) Setting up Custom Biomes toolbar button...");
                }
                _biomeButton             = new ToolbarButtonWrapper("CustomBiomes", "Biomes1");
                _biomeButton.TexturePath = "CustomBiomes/biome";
                _biomeButton.ToolTip     = "CustomBiomes Menu";
                _biomeButton.SetButtonVisibility(GameScenes.FLIGHT);
                _biomeButton.AddButtonClickHandler((e) =>
                {
                    if (_debug)
                    {
                        Debug.Log("(CB) CustomBiomes menu toggled.");
                    }
                    _isMinimized = !_isMinimized;
                    SaveMe();
                });
            }
            //This needs to get drawn from here on out
            if (_debug)
            {
                Debug.Log("(CB) Adding to post draw queue...");
            }
            RenderingManager.AddToPostDrawQueue(3, OnDraw);
            _mainWindow.height = 300;    //Reset height since we don't save which biome was active
            _mainWindow.width  = 350;
            _mapWindow.height  = 10;
            _mapWindow.width   = 50;

            if (_debug)
            {
                Debug.Log("(CB) Initializing GUI styles...");
            }
            //Initialize styles, if not already done
            if (!_hasInitStyles)
            {
                initStyles();
            }

            if (_debug)
            {
                Debug.Log("(CB) Determining current biome...");
            }
            //Now load the names of all the biomes into an array
            String _lastMainBody = Planetarium.fetch.CurrentMainBody.name;

            for (int i = 0; i < _biomes.Length; i++)
            {
                if (_biomes[i].Equals(_lastMainBody))
                {
                    _currentBiome = i;
                    break;
                }
            }
            _lastTab = -1;
            Debug.Log("(CB) Biome replacement complete. Custom Biomes initialization complete.");
        }
示例#7
0
        public override void OnStart(StartState state)
        {
            try
            {
                //print("@@@Toolbar init");
                toolbarButton = new ToolbarButtonWrapper("Proximity", "toolbarButton");
                SetButtonTexture();
                toolbarButton.ToolTip = "Proximity settings";
                toolbarButton.Visible = true;
                toolbarButton.AddButtonClickHandler((e) =>
                {
                    //print("@@@ prox toolbar button clicked");
                    ToolbarShowSettings = !ToolbarShowSettings;
                    SetButtonTexture();
                    windowPos.yMax = windowPos.yMin + 20;
                });
                UseToolbar = true;
            }
            catch (Exception ex)
            {
                //print("@@@Exception on toolbar init, msg = " + ex.Message);
            }

            if (state != StartState.Editor)
            {
                //print("@@@OnStart");
                RenderingManager.AddToPostDrawQueue(0, OnDraw);

                sampleRate = AudioSettings.outputSampleRate;
                obj        = new GameObject();
                obj.AddComponent("AudioSource");
                MakeBeep();
                obj.audio.ignoreListenerVolume = true;
                obj.audio.volume = volume;
                //DontDestroyOnLoad(obj);

                timeSinceLanding = vessel.missionTime;

                if (Sines == null)
                {
                    Sines = new float[10000];
                    for (int i = 0; i < 10000; i++)
                    {
                        Sines[i] = Mathf.Sin((float)i);
                    }
                }

/*
 *              if (PingPongs == null)
 *              {
 *                  PingPongs = new float[10000];
 *                  for (int i = 0; i < 10000; i++)
 *                  {
 *                      PingPongs[i] = Mathf.PingPong((float)i, 0.5f);
 *                  }
 *              }
 *
 *              string s = "@@@";
 *              for (int i = 0; i < 10000; i += 100)
 *              {
 *                  s += PingPongs[i].ToString() + ", ";
 *              }
 *              print(s);
 */
            }
        }