Beispiel #1
0
        public void CopyFrom(MorphemeVersionSelector morphemeVersionSelector)
        {
            string versionSelected = morphemeVersionSelector.SelectedVersionKey;

            if (versionSelected == null || versionSelected.Length == 0)
            {
                // Choose the latest available (not counting 'custom').
                // There should be the custom version + at least another one. Take the one with the 'greatest' name.
                // This is not the most robust solution but it allows to test dev installers.
                versionSelected = "";
                if (morphemeVersionSelector.VersionDictionary.Count >= 2)
                {
                    foreach (var pair in morphemeVersionSelector.VersionDictionary)
                    {
                        if (pair.Key.CompareTo(versionSelected) > 0)
                        {
                            versionSelected = pair.Key;
                        }
                    }
                }
                else
                {
                    // Fall back on the custom one.
                    versionSelected = CustomStr;
                }
            }

            SelectedVersionKey = versionSelected;

            VersionDictionary[CustomStr] = morphemeVersionSelector.CustomVersionReference;
        }
Beispiel #2
0
        private void AddNetworksDialog()
        {
            // open a dialog and ask the user to add mcn networks

            DialogResult result = openFileDialogMCNs.ShowDialog();

            if (result == DialogResult.OK)
            {
                AddFiles(openFileDialogMCNs.FileNames, MorphemeVersionSelector.GetInstance().SelectedVersion.MajorVersion);
            }
        }
Beispiel #3
0
        public static MorphemeVersionSelector GetInstance()
        {
            if (Instance == null)
            {
                Instance = new MorphemeVersionSelector();
                if (Instance.VersionDictionary.Keys.Count != 0)
                {
                    Instance.SelectedVersionKey = Instance.VersionDictionary.Keys.First();
                }
            }

            return(Instance);
        }
Beispiel #4
0
        private void textBoxMorphemeConnect_TextChanged(object sender, EventArgs e)
        {
            TextBox textBox = sender as TextBox;

            textBox.BackColor = ValidateTextBoxIsFile(textBox);

            // special case for custom selection
            if (MorphemeVersionSelector.GetInstance().SelectedVersionKey.Equals(MorphemeVersionSelector.CustomStr))
            {
                // set the macro for the custom install path
                MorphemeVersionSelector.GetInstance().SetCustomValue(MacrosSystem.ReservedVersionMacroKeys.APP_INSTALL_FULL_PATH, textBox.Text);
            }
        }
Beispiel #5
0
        void Form1_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];

                if (dataGridViewMCNList.Enabled)
                {
                    AddFiles(files, MorphemeVersionSelector.GetInstance().SelectedVersion.MajorVersion);
                }
                else
                {
                    Program.Logger.Log(LogSeverity.Error, "Cannot add files. Please create a new list");
                }
            }
            catch (System.Exception ex)
            {
                Program.Logger.Log(LogSeverity.Error, ex.ToString());
            }
        }
        private void ParseConnectlogFile()
        {
            string logFile = MorphemeVersionSelector.GetInstance().GetCurrentValue(MacrosSystem.ReservedVersionMacroKeys.APP_LOCAL_SETTINGS_PATH);

            logFile = Path.Combine(logFile, morphemeConnectLog);

            if (!File.Exists(logFile))
            {
                Log.Add(new LogItem(LogSeverity.Warning, "cannot find log file " + logFile));
            }
            else
            {
                // write the connect log file to the local log
                StreamReader sr = null;
                try
                {
                    sr = new StreamReader(logFile);
                    String line;
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] parts = line.Split('|');

                        if (parts.Length > 0)
                        {
                            LogSeverity logType = LogSeverity.Info;

                            switch (parts[0].Trim().ToLower())
                            {
                            case "info":
                                logType = LogSeverity.Info;
                                break;

                            case "warning":
                                logType = LogSeverity.Warning;
                                break;

                            case "error":
                                logType = LogSeverity.Error;
                                break;

                            default:
                                break;
                            }

                            // connect 2.3.3 will report "RUN error" as info
                            if (parts[0].Contains("RUN error"))
                            {
                                logType = LogSeverity.Error;
                            }

                            Log.Add(new LogItem(logType, "morphemeConnect.exe > " + line));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Add(new LogItem(LogSeverity.Warning, ex.Message));
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Dispose();
                    }
                }
            }
        }
        public void BuildDictionary()
        {
            MacroStringDictionary.Clear();
            MacroStringSystemList.Clear();

            foreach (ReservedVersionMacroKeys versionKey in Enum.GetValues(typeof(ReservedVersionMacroKeys)))
            {
                string key   = Enum.GetName(typeof(ReservedVersionMacroKeys), versionKey);
                string value = MorphemeVersionSelector.GetInstance().GetCurrentValue(versionKey);

                if (string.IsNullOrEmpty(key) ||
                    string.IsNullOrEmpty(value))
                {
                    continue;
                }

                if (MacroStringDictionary.ContainsKey(Prefix + key + Suffix))
                {
                    OutputLog.Log(LogSeverity.Warning, "skipping duplicate macro key: " + key);
                    continue;
                }

                MacroStringDictionary.Add(Prefix + key + Suffix, value);
                MacroStringSystemList.Add(new Macro(key, value));
            }

            foreach (Environment.SpecialFolder specialFolder in Enum.GetValues(typeof(Environment.SpecialFolder)))
            {
                // only add certain SpecialFolders
                if (specialFolder != Environment.SpecialFolder.ApplicationData &&
                    specialFolder != Environment.SpecialFolder.CommonApplicationData &&
                    specialFolder != Environment.SpecialFolder.CommonProgramFiles &&
                    specialFolder != Environment.SpecialFolder.Desktop &&
                    specialFolder != Environment.SpecialFolder.LocalApplicationData &&
                    specialFolder != Environment.SpecialFolder.MyComputer &&
                    specialFolder != Environment.SpecialFolder.MyDocuments &&
                    specialFolder != Environment.SpecialFolder.ProgramFiles &&
                    specialFolder != Environment.SpecialFolder.ProgramFilesX86 &&
                    specialFolder != Environment.SpecialFolder.Programs &&
                    specialFolder != Environment.SpecialFolder.System)
                {
                    continue;
                }

                string key = Enum.GetName(typeof(Environment.SpecialFolder), specialFolder);

                var duplicates = from pair in MacroStringSystemList.ToList() // (binding list needs to be converted to list)
                                 where (pair.Key != null && pair.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase))
                                 select pair;

                if (duplicates.Count() > 0)
                {
                    // only supports one value per key (a 1-1 mapping)
                    continue;
                }

                string folderPath = Environment.GetFolderPath(specialFolder);

                if (string.IsNullOrEmpty(folderPath))
                {
                    continue;
                }

                MacroStringDictionary.Add(Prefix + key + Suffix, folderPath);
                MacroStringSystemList.Add(new Macro(key, folderPath));
            }

            // lastly add the custom macros and do not allow duplicates of system macros added above

            foreach (Macro pair in MacroStringCustomList)
            {
                if (string.IsNullOrEmpty(pair.Key) ||
                    string.IsNullOrEmpty(pair.Value))
                {
                    continue;
                }

                if (pair.Key.Equals(pair.Value, StringComparison.CurrentCultureIgnoreCase))
                {
                    // avoid infinite recursion
                    OutputLog.Log(LogSeverity.Warning, "skipping macro with equal key and value");
                    continue;
                }

                if (MacroStringDictionary.ContainsKey(Prefix + pair.Key + Suffix))
                {
                    OutputLog.Log(LogSeverity.Warning, "skipping duplicate macro key: " + pair.Key);
                    continue;
                }

                MacroStringDictionary.Add(Prefix + pair.Key + Suffix, pair.Value);
            }

            SortDictionary();
        }
Beispiel #8
0
 public Config()
 {
     settings = Settings.GetInstance();
     macro    = MacrosSystem.GetInstance();
     morphemeVersionSelector = MorphemeVersionSelector.GetInstance();
 }
Beispiel #9
0
        private void comboBoxMorphemeVersion_SelectedIndexChanged(object sender, EventArgs e)
        {
            // the Product combo box has changed

            try
            {
                ComboBox cb = sender as ComboBox;

                string newValue = cb.Text;

                // Leave the euphoria asset compiler in place
                if (!newValue.Equals(MorphemeVersionSelector.CustomStr))
                {
                    if (newValue.Contains("Euphoria") && !MCN.SKUSupportedAssetCompilers.Contains(MCN.AssetCompilerType.Euphoria))
                    {
                        MCN.SKUSupportedAssetCompilers.Add(MCN.AssetCompilerType.Euphoria);
                    }

                    if (!newValue.Contains("Euphoria") && MCN.SKUSupportedAssetCompilers.Contains(MCN.AssetCompilerType.Euphoria))
                    {
                        MCN.SKUSupportedAssetCompilers.Remove(MCN.AssetCompilerType.Euphoria);
                    }
                }

                // if the new value is the custom selection then allow browsing for connect
                if (newValue == MorphemeVersionSelector.CustomStr)
                {
                    textBoxMorphemeConnect.Enabled    = true;
                    buttonBrowseConnect.Enabled       = true;
                    checkBoxUseDynamicPlugins.Enabled = true;
                }
                else
                {
                    textBoxMorphemeConnect.Enabled    = false;
                    buttonBrowseConnect.Enabled       = false;
                    checkBoxUseDynamicPlugins.Enabled = false;

                    // version 3.6 introduced dynamic plugins
                    MorphemeVersionSelector.MorphemeVersion version = MorphemeVersionSelector.GetInstance().SelectedVersion;
                    checkBoxUseDynamicPlugins.Checked = !(version.MajorVersion < 3 || (version.MajorVersion == 3 && version.MinorVersion < 6));
                }

                int numModified = 0;
                foreach (MCN mcn in MCNCollection.GetInstance())
                {
                    if (mcn.AssetCompiler == MCN.AssetCompilerType.Euphoria &&
                        !MCN.SKUSupportedAssetCompilers.Contains(MCN.AssetCompilerType.Euphoria))
                    {
                        ++numModified;
                        mcn.AssetCompiler = MCN.AssetCompilerType.NoPhysics;
                    }
                }

                if (numModified > 0)
                {
                    dataGridViewMCNList.Refresh();
                }
            }
            catch (System.Exception ex)
            {
                Program.Logger.Log(LogSeverity.Error, ex.ToString());
            }
        }
Beispiel #10
0
        void InitCustomComponents()
        {
            // create columns in the DataGridViews
            // data bind, etc

            // MCN list
            {
                // bind to the mcns
                dataGridViewMCNList.DataSource = MCNCollection.GetInstance();

                // Set up the Combo box column data source
                DataGridViewComboBoxColumn assetCompilerCol = (DataGridViewComboBoxColumn)dataGridViewMCNList.Columns[2];
                assetCompilerCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                assetCompilerCol.DataSource   = MCN.SKUSupportedAssetCompilers;
            }

            // settings
            {
                // dataGridViewPlatforms
                {
                    dataGridViewPlatforms.AutoGenerateColumns = false;

                    dataGridViewPlatforms.DataSource = Settings.GetInstance().Platforms;

                    dataGridViewPlatforms.RowHeadersVisible = false;

                    DataGridViewCheckBoxColumn checkBox = new DataGridViewCheckBoxColumn();
                    checkBox.DataPropertyName = "UseDuringExport";
                    checkBox.Name             = DataGridViewPlatformNames.Use;

                    dataGridViewPlatforms.Columns.Add(checkBox);

#if DEV_ENV_SUPPORT
                    DataGridViewTextBoxColumn nameBox = new DataGridViewTextBoxColumn();
                    nameBox.DataPropertyName = "Name";
                    nameBox.Name             = DataGridViewPlatformNames.Name;
                    dataGridViewPlatforms.Columns.Add(nameBox);
#endif
                    DataGridViewTextBoxColumn processPathBox = new DataGridViewTextBoxColumn();
                    processPathBox.DataPropertyName = "ProcessPathSubDirectory";
                    processPathBox.Name             = DataGridViewPlatformNames.ProcessPath;
                    processPathBox.ToolTipText      = "Sub-folder of the export root where to store the processed networks";
                    dataGridViewPlatforms.Columns.Add(processPathBox);

#if DEV_ENV_SUPPORT
                    DataGridViewTextBoxColumn slnFileBox = new DataGridViewTextBoxColumn();
                    slnFileBox.DataPropertyName = "SlnPlatform";
                    slnFileBox.Name             = DataGridViewPlatformNames.AssetCompilerSLNFile;
                    dataGridViewPlatforms.Columns.Add(slnFileBox);

                    DataGridViewTextBoxColumn configFileBox = new DataGridViewTextBoxColumn();
                    configFileBox.DataPropertyName = "ConfigFileBox";
                    configFileBox.Name             = DataGridViewPlatformNames.Config;
                    dataGridViewPlatforms.Columns.Add(configFileBox);

                    DataGridViewColumn col = dataGridViewPlatforms.Columns["build config"];

                    Array values = Enum.GetValues(typeof(MCN.AssetCompilerType));

                    foreach (MCN.AssetCompilerType val in values)
                    {
                        DataGridViewButtonColumn buttonBox = new DataGridViewButtonColumn();
                        buttonBox.Name = Enum.GetName(typeof(MCN.AssetCompilerType), val);

                        dataGridViewPlatforms.Columns.Add(buttonBox);
                    }
#endif

                    DataGridViewTextBoxColumn exeName = new DataGridViewTextBoxColumn();
                    exeName.DataPropertyName = "AssetCompilerCustomEXE";
                    exeName.Name             = DataGridViewPlatformNames.AssetCompilerCustomEXEName;
                    dataGridViewPlatforms.Columns.Add(exeName);

                    DataGridViewCheckBoxColumn kinectCheckBox = new DataGridViewCheckBoxColumn();
                    kinectCheckBox.DataPropertyName = "UseKinect";
                    kinectCheckBox.Name             = DataGridViewPlatformNames.KinectOption;

                    dataGridViewPlatforms.Columns.Add(kinectCheckBox);


                    DataGridViewCheckBoxColumn moveCheckBox = new DataGridViewCheckBoxColumn();
                    moveCheckBox.DataPropertyName = "UseMove";
                    moveCheckBox.Name             = DataGridViewPlatformNames.MoveOption;

                    dataGridViewPlatforms.Columns.Add(moveCheckBox);

                    foreach (DataGridViewColumn col in dataGridViewPlatforms.Columns)
                    {
                        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    }
                }

                // bind the text boxes
                textBoxMorphemeConnect.DataBindings.Add("Text", Settings.GetInstance(), "MorphemeConnectPath");
                textBoxMorphemeSDKRoot.DataBindings.Add("Text", Settings.GetInstance(), "RuntimeSDKRoot");
                textBoxExportPath.DataBindings.Add("Text", Settings.GetInstance(), "ExportRootPath");
                textBoxAssetCompilerCommandLine.DataBindings.Add("Text", Settings.GetInstance(), "AssetCompilerCommandLine");
            }

            // bind the log output
            logItemBindingSource.DataSource = Program.Logger.VisibleList;

            {
                MCN.SKUSupportedAssetCompilers.Clear();
                foreach (MCN.AssetCompilerType acType in Enum.GetValues(typeof(MCN.AssetCompilerType)))
                {
                    MCN.SKUSupportedAssetCompilers.Add(acType);
                }
            }

            // bind the product combo box
            {
                comboBoxMorphemeVersion.DisplayMember = "Key";
                comboBoxMorphemeVersion.ValueMember   = "Key";

                BindingSource binding = new BindingSource();
                binding.DataSource = MorphemeVersionSelector.GetInstance().VersionDictionary;
                comboBoxMorphemeVersion.DataSource = binding;

                comboBoxMorphemeVersion.DataBindings.Add("SelectedValue", MorphemeVersionSelector.GetInstance(), "SelectedVersionKey", true,
                                                         DataSourceUpdateMode.OnPropertyChanged);
            }
            {
                BindingSource binding = new BindingSource();
                binding.DataSource = Settings.GetInstance().UseDynamicAssetCompilerPlugins;

                checkBoxUseDynamicPlugins.DataBindings.Add("Checked", Settings.GetInstance(), "UseDynamicAssetCompilerPlugins");
            }
        }