Esempio n. 1
0
        /// <summary>
        /// Draws the content of the Presets section
        /// </summary>
        private void drawPresetsContent()
        {
            GUILayout.Label("A third-party mod can replace your current RemoteTech settings with its own settings (GameData/ExampleMod/RemoteTechSettings.cfg).\nAlso, you can revert to RemoteTech's default settings.\nHere you can see what presets are available:", this.mGuiRunningText);
            GUILayout.Space(15);

            List <String> presetList = this.mSettings.PreSets;

            if (this.mSettings.PreSets.Count <= 0)
            {
                GUILayout.Label("No presets are found", this.mGuiRunningText);
            }

            for (int i = presetList.Count - 1; i >= 0; --i)
            {
                GUILayout.BeginHorizontal("box", GUILayout.MaxHeight(15));
                {
                    string folderName = presetList[i];
                    int    index      = folderName.LastIndexOf("/RemoteTechSettings");
                    folderName = folderName.Substring(0, index) + folderName.Substring(index).Replace("/RemoteTechSettings", ".cfg").Trim();

                    GUILayout.Space(15);
                    GUILayout.Label("- " + folderName, this.mGuiListText, GUILayout.ExpandWidth(true));
                    if (GUILayout.Button("Overwrite", this.mGuiListButton, GUILayout.Width(70), GUILayout.Height(20)))
                    {
                        RTSettings.ReloadSettings(this.mSettings, presetList[i]);
                        ScreenMessages.PostScreenMessage(string.Format("Your RemoteTech settings are set to {0}", folderName), 15);
                        RTLog.Notify("Overwrote current settings with this cfg {0}", RTLogLevel.LVL3, presetList[i]);
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
Esempio n. 2
0
        private void btnUseTemplate_Click(object sender, EventArgs e)
        {
            string file = (string)lstTemplates.SelectedItem;

            if (string.IsNullOrEmpty(file))
            {
                MessageBox.Show("Please choose a template.");
                return;
            }
            XmlSerializer serializer = new XmlSerializer(typeof(RTEmail));
            RTEmail       email;

            using (TextReader textReader = new StreamReader(Path.Combine(RTSettings.GetTemplateDirectory(), file + RTSettings.TemplateFileType)))
            {
                using (XmlReader xmlReader = XmlReader.Create(textReader))
                {
                    email = (RTEmail)serializer.Deserialize(xmlReader);
                }
            }
            using (TicketForm frm = new TicketForm())
            {
                frm.LoadTicket(email);
                if (frm.CreatedTemplates)
                {
                    LoadTemplateList();
                }
            }
        }
Esempio n. 3
0
 public MainForm()
 {
     InitializeComponent();
     RTActiveDirectory.LoadInBackground();
     LoadTemplateList();
     lblTemplates.Text = "Select Template (from " + RTSettings.GetTemplateDirectory() + ")";
 }
Esempio n. 4
0
 private void LoadTemplateList()
 {
     lstTemplates.Items.Clear();
     if (!Directory.Exists(RTSettings.GetTemplateDirectory()))
     {
         Directory.CreateDirectory(RTSettings.GetTemplateDirectory());
     }
     else
     {
         foreach (string file in Directory.EnumerateFiles(RTSettings.GetTemplateDirectory(), "*" + RTSettings.TemplateFileType))
         {
             lstTemplates.Items.Add(Path.GetFileNameWithoutExtension(file));
         }
     }
 }
        /// <summary>
        /// Draws the content of the Presets section
        /// </summary>
        private void drawPresetsContent()
        {
            GUILayout.Label(Localizer.Format("#RT_OptionWindow_Presets_HelpText"), this.mGuiRunningText);//"You can revert your current settings to the starting settings, constructed from installed mods' MM patches. Also, you can reload your current settings with a third-party mod's own RemoteTech settings (the fallback in the event of no MM patch).\n\nHere you can see what presets are available:"
            GUILayout.Space(15);

            List <String> presetList = this.mSettings.PreSets;

            if (this.mSettings.PreSets.Count <= 0)
            {
                GUILayout.Label(Localizer.Format("#RT_OptionWindow_Presets_NotFound"), this.mGuiRunningText);//"No presets are found"
            }

            for (int i = presetList.Count - 1; i >= 0; --i)
            {
                GUILayout.BeginHorizontal("box", GUILayout.MaxHeight(15));
                {
                    string folderName = presetList[i];

                    //remove the node name
                    int index = folderName.LastIndexOf("/RemoteTechSettings");
                    folderName = folderName.Substring(0, index) + folderName.Substring(index).Replace("/RemoteTechSettings", "").Trim();

                    //change default name to better name for MM-patched settings
                    index = folderName.LastIndexOf("/Default_Settings");
                    if (index >= 0)
                    {
                        folderName = folderName.Substring(0, index) + " " + folderName.Substring(index).Replace("/Default_Settings", "starting settings");
                    }

                    GUILayout.Space(15);
                    GUILayout.Label(folderName, this.mGuiListText, GUILayout.ExpandWidth(true));
                    if (GUILayout.Button(Localizer.Format("#RT_OptionWindow_Presets_Reload"), this.mGuiListButton, GUILayout.Width(70), GUILayout.Height(20)))//"Reload"
                    {
                        RTSettings.ReloadSettings(this.mSettings, presetList[i]);
                        ScreenMessages.PostScreenMessage(Localizer.Format("#RT_OptionWindow_Presets_msg1", folderName), 10);//string.Format("Your RemoteTech settings are set to {0}", )
                        RTLog.Notify("Overwrote current settings with this cfg {0}", RTLogLevel.LVL3, presetList[i]);
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Draws the content of the Presets section
        /// </summary>
        private void drawPresetsContent()
        {
            GUILayout.Label("Other mods can deliver their own RemoteTech_Settings.cfg and override config values. Here you can see what presets we've loaded:", this.mGuiRunningText);
            GUILayout.Space(15);

            List <String> presetList = this.mSettings.PreSets;

            if (this.mSettings.PreSets.Count <= 0)
            {
                GUILayout.Label("- no presets found", this.mGuiRunningText);
            }

            for (int i = presetList.Count - 1; i >= 0; i--)
            {
                String FolderName = presetList[i].Replace("/RemoteTechSettings", ".cfg").Trim();
                GUILayout.BeginHorizontal("box", GUILayout.MaxHeight(15));
                {
                    GUILayout.Space(15);
                    GUILayout.Label("- " + FolderName, this.mGuiListText, GUILayout.ExpandWidth(true));
                    if (GUILayout.Button("Reload", this.mGuiListButton, GUILayout.Width(50), GUILayout.Height(20)))
                    {
                        RTLog.Notify("Reload cfg {0}", RTLogLevel.LVL3, presetList[i]);
                        this.mSettings.PreSets.RemoveAt(i);
                        RTSettings.ReloadSettings();
                    }
                }
                GUILayout.EndHorizontal();
            }

            // Reload all button
            if (presetList.Count >= 2)
            {
                if (GUILayout.Button("Reload All", this.mGuiListButton))
                {
                    this.mSettings.PreSets.Clear();
                    RTSettings.ReloadSettings();
                }
            }
        }
Esempio n. 7
0
 private void btnMakeTemplate_Click(object sender, EventArgs e)
 {
     using (AskTemplateNameForm frm = new AskTemplateNameForm())
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             string                  fullPath   = Path.Combine(RTSettings.GetTemplateDirectory(), frm.TemplateName + RTSettings.TemplateFileType);
             XmlSerializer           serializer = new XmlSerializer(typeof(RTEmail));
             StringBuilder           sb         = new StringBuilder();
             XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();
             ns.Add("", "");
             XmlWriterSettings xmlSettings = new XmlWriterSettings();
             xmlSettings.Indent             = true;
             xmlSettings.OmitXmlDeclaration = true;
             using (XmlWriter xmlWriter = XmlWriter.Create(fullPath, xmlSettings))
             {
                 serializer.Serialize(xmlWriter, grdValues.SelectedObject, ns);
             }
             MessageBox.Show("Saved as template.");
             CreatedTemplates = true;
         }
     }
 }
 private void btnOkay_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtName.Text))
     {
         MessageBox.Show("Enter a template name.");
         return;
     }
     if (txtName.Text.Contains("\\") || txtName.Text.Contains(".") || txtName.Text.Contains("?") || txtName.Text.Contains("*") || txtName.Text.Contains("/"))
     {
         MessageBox.Show("Name contains invalid character.");
         return;
     }
     if (System.IO.File.Exists(System.IO.Path.Combine(RTSettings.GetTemplateDirectory(), txtName.Text + RTSettings.TemplateFileType)))
     {
         DialogResult response = MessageBox.Show("There is already a template by that name. Do you want to replace it?", "Confirm", MessageBoxButtons.OKCancel);
         if (response != DialogResult.OK)
         {
             return;
         }
     }
     TemplateName      = txtName.Text;
     this.DialogResult = DialogResult.OK;
     this.Close();
 }