KerbulatorOptions LoadConfig()
        {
            PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <Kerbulator>(null);

            config.load();

            options = new KerbulatorOptions();

            try {
                options.mainWindowPos.x        = config.GetValue <int>("mainWindowX", 0);
                options.mainWindowPos.y        = config.GetValue <int>("mainWindowY", 60);
                options.mainWindowPos.width    = config.GetValue <int>("mainWindowWidth", 280);
                options.mainWindowPos.height   = config.GetValue <int>("mainWindowHeight", 400);
                options.editWindowPos.x        = config.GetValue <int>("editWindowX", 280);
                options.editWindowPos.y        = config.GetValue <int>("editWindowY", 60);
                options.editWindowPos.width    = config.GetValue <int>("editWindowWidth", 500);
                options.editWindowPos.height   = config.GetValue <int>("editWindowHeight", 400);
                options.runWindowPos.x         = config.GetValue <int>("runWindowX", 0);
                options.runWindowPos.y         = config.GetValue <int>("runWindowY", 470);
                options.runWindowPos.width     = config.GetValue <int>("runWindowWidth", 200);
                options.runWindowPos.height    = config.GetValue <int>("runWindowHeight", 200);
                options.repeatWindowPos.x      = config.GetValue <int>("repeatWindowX", 200);
                options.repeatWindowPos.y      = config.GetValue <int>("repeatWindowY", 470);
                options.repeatWindowPos.width  = config.GetValue <int>("repeatWindowWidth", 200);
                options.repeatWindowPos.height = config.GetValue <int>("repeatWindowHeight", 100);
            } catch (ArgumentException) {
            }

            return(options);
        }
        public KerbulatorGUI(IGlue glue, bool inEditor, bool drawMainButton, KerbulatorOptions options)
        {
            this.glue           = glue;
            this.inEditor       = inEditor;
            this.drawMainButton = drawMainButton;
            this.options        = options;
            ChangeState(false);

            // Use the game base directory + PluginData as base folder for plugin data
            functionDir = glue.GetFunctionDir();
            functionDir = functionDir.Replace("\\", "/");

            Debug.Log("Kerbulator function dir: " + functionDir);

            editFunctionContent = maneuverTemplate;

            if (!Directory.Exists(functionDir))
            {
                Directory.CreateDirectory(functionDir);
            }

            // Load icons
            kerbulatorIcon = glue.GetTexture("kerbulator");
            editIcon       = glue.GetTexture("edit");
            runIcon        = glue.GetTexture("run");
            repeatIcon     = glue.GetTexture("repeat");
            nodeIcon       = glue.GetTexture("node");
            alarmIcon      = glue.GetTexture("alarm");
            saveIcon       = glue.GetTexture("save");
            deleteIcon     = glue.GetTexture("delete");

            kalc = new Kerbulator(functionDir);
        }
        /// <summary>Called by Unity when the Plugin is loaded</summary>
        void Awake()
        {
            Debug.Log("[Kerbulator] Start");
            options = LoadConfig();
            gui     = new KerbulatorGUI(this, false, false, options);

            if (!ToolbarManager.ToolbarAvailable)
            {
                GameEvents.onGUIApplicationLauncherReady.Add(InitToolbarButton);
                GameEvents.onGUIApplicationLauncherUnreadifying.Add(OnGuiApplicationLauncherUnreadifying);
            }

            Debug.Log("[Kerbulator] Start done");
        }
Exemple #4
0
 /// <summary>Called by Unity when the Plugin is started</summary>
 void Awake()
 {
     options = new KerbulatorOptions();
     gui     = new KerbulatorGUI(this, true, true, options);
 }