Exemple #1
0
        /// <summary>
        /// Called when the user wishes to create the map.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Click_CreateMap(object sender, RoutedEventArgs e)
        {
            // Save the selected template
            string template = ctrlTemplates.SelectedItem as string;

            if (!string.IsNullOrEmpty(template))
            {
                UserData.SelectedMapTemplate = template;
            }

            // Save the data
            UserData.Instance.Save();

            // Get the map name
            string mapName = ctrlMapName.Text;

            if (!Utility.IsValid(mapName))
            {
                AppDialogMessage.Show(string.Format("The given map name of '{0}' is not valid.", mapName),
                                      "Invalid map name", MessageButtons.OK, MessageIcon.Warning);
            }
            else
            {
                SelectedMap = mapName;
                ComTemplate.Install(TemplateType.Maps, template, mapName);
                DialogResult = true;
            }
        }
        public static MessageResult Show(string message, string title, MessageButtons buttons, MessageIcon icon)
        {
            AppDialogMessage dialog = new AppDialogMessage(message, title, buttons, icon);

            dialog.ShowDialog();
            return(dialog.Result);
        }
Exemple #3
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            // Suspend to prevent the data from being saved during load
            Preferences.Instance.Load();
            UserData.Instance.Load();

            // For now
            tabResourceViewer.Visibility = Visibility.Hidden;

            // Validates and loads
            if (Validate_CompilerInstallation())
            {
                Load_PreferencesData();

                if (!Validate_Preferences())
                {
                    Compiler_SetInteraction(false);
                }

                HasLoaded = true;
            }
            else
            {
                AppDialogMessage.Show("Compiler installation has been detected to be corrupted. Please reinstall the tools." +
                                      " Additional information has been copied to the clipboard.",
                                      "Corrupted installation", MessageButtons.OK, MessageIcon.Error);
                Click_CopyConsole(null, null);
                Close();
            }
        }
Exemple #4
0
        /// <summary>
        /// Called when any of the buttons in the Browsing tab has been clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Common_ClickBrowse(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            Debug.Assert(button != null);

            string browse = null;

            if (button == ctrlBrowseLocalized || button == ctrlMapBrowseLocalized)
            {
                browse = string.Format("raw/{0}/localizedstrings", Preferences.Language.ToLower());
            }
            else if (button == ctrlBrowseImagesMain)
            {
                browse = "main/images";

                // Extract the images if the directory does not exist
                string imagesMain = string.Format("{0}{1}main{1}images", Preferences.InstallPath, System.IO.Path.DirectorySeparatorChar);
                if (!Directory.Exists(imagesMain))
                {
                    MessageResult result = AppDialogMessage.Show("main/images could not be located. Do you wish the compiler to extract the .iwi files for you?",
                                                                 "Create main/images directory?", MessageButtons.YesNo, MessageIcon.Question);
                    if (result == MessageResult.Yes)
                    {
                        // NOTE: We do not need to handle the result
                        AppDialogExtract dialog = new AppDialogExtract();
                        dialog.ShowDialog();
                    }
                }
            }
            else
            {
                browse = button.Tag as string;
                Debug.Assert(browse != null);
            }

            // Replace all the seperators for the system's path seperator
            browse = browse.Replace('/', System.IO.Path.DirectorySeparatorChar);

            // Create the destination path and try to open it
            string path = string.Format("{0}{1}{2}", Preferences.InstallPath, System.IO.Path.DirectorySeparatorChar, browse);

            if (!Directory.Exists(path))
            {
                AppDialogMessage.Show(string.Format("Could not locate directory at '{0}'.", path),
                                      "Missing directory", MessageButtons.OK, MessageIcon.Warning);
            }
            else
            {
                SPiApp2.Components.Application.Browse(path);
            }
        }
Exemple #5
0
        private void Click_RunConverter(object sender, RoutedEventArgs e)
        {
            MessageResult result = AppDialogMessage.Show(
                "The converter overwrites exisiting files in the raw directory." +
                " This may hinder your ability to create mods and maps." +
                " Are you sure you want to run the converter?", "Are you sure?",
                MessageButtons.YesNo, MessageIcon.Question);

            if (result == MessageResult.Yes)
            {
                SPiApp2.Components.Application.Launch("converter.exe",
                                                      string.Format("{0}{1}bin", Preferences.InstallPath, System.IO.Path.DirectorySeparatorChar));
            }
        }
Exemple #6
0
        /// <summary>
        /// Called when the user wishes to save the advanced preferences values.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Click_PreferencesAdvancedSave(object sender, RoutedEventArgs e)
        {
            Preferences.Instance.Save();

            if (Validate_PreferencesAdvanced())
            {
                Compiler_SetInteraction(true);
            }
            else
            {
                Compiler_SetInteraction(false);
                AppDialogMessage.Show("One or more settings were found to be invalid. Check the console for more information",
                                      "Invalid settings", MessageButtons.OK, MessageIcon.Information);
            }
        }
Exemple #7
0
        private void LoadData()
        {
            if (!File.Exists(ZoneFile))
            {
                AppDialogMessage.Show(string.Format("Could not locate the mod's zone_source file at '{0}'", ZoneFile),
                                      "Missing zone file", MessageButtons.OK, MessageIcon.Warning);
                DialogResult = true;
            }
            else
            {
                textZone.Text = File.ReadAllText(ZoneFile, Encoding.ASCII);

                if (File.Exists(MissingMods))
                {
                    textMods.Text = File.ReadAllText(MissingMods, Encoding.ASCII);
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Called when the user wishes to create the mod.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Click_CreateMod(object sender, RoutedEventArgs e)
        {
            // Save the selected template
            string template = ctrlTemplates.SelectedItem as string;

            if (!string.IsNullOrEmpty(template))
            {
                UserData.SelectedModTemplate = template;
            }

            // Save the selected type
            ComboBoxItem item = ctrlTypes.SelectedItem as ComboBoxItem;

            Debug.Assert(item != null);
            string type = item.Content as string;

            Debug.Assert(type != null);
            UserData.SelectedModType = type;

            // Save the data
            UserData.Instance.Save();

            // Get the mod name
            string modName = ctrlModName.Text;

            if (!Utility.IsValid(modName))
            {
                AppDialogMessage.Show(string.Format("The given mod name of '{0}' is not valid.", modName),
                                      "Invalid mod name", MessageButtons.OK, MessageIcon.Warning);
            }
            else
            {
                SelectedMod = modName;
                ComTemplate.Install(TemplateType.Mods, template, modName);
                SaveModType(modName, type);
                DialogResult = true;
            }
        }
Exemple #9
0
        /// <summary>
        /// Called when the user changes the theme of the compiler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Select_CompilerThemeChanged(object sender, SelectionChangedEventArgs e)
        {
            MessageResult result = AppDialogMessage.Show(
                "Changing the theme requires a restart of the application. Do you still want to change the theme?",
                "Change theme?", MessageButtons.YesNo, MessageIcon.Question);

            // Always remove the theme event handler before changing
            ctrlThemes.SelectionChanged -= Select_CompilerThemeChanged;

            if (result == MessageResult.Yes)
            {
                Themes.ChangeTheme(e.AddedItems[0] as string);
            }
            else
            {
                ComboBox obj = sender as ComboBox;
                Debug.Assert(obj != null);
                obj.SelectedItem = e.RemovedItems[0];
            }

            // When done rebind the event handler
            ctrlThemes.SelectionChanged += Select_CompilerThemeChanged;
        }
Exemple #10
0
        /// <summary>
        /// Called when the user wants to save the settings in the Required Preferences tab.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Click_PreferencesSaveRequired(object sender, RoutedEventArgs e)
        {
            ComboBoxItem item = ctrlLanguage.SelectedItem as ComboBoxItem;

            Debug.Assert(item != null);

            string language = item.Content as string;

            Debug.Assert(language != null);

            Preferences.Instance.Save();

            // Check the new settings
            if (Validate_PreferencesRequired())
            {
                Compiler_SetInteraction(true);
            }
            else
            {
                Compiler_SetInteraction(false);
                AppDialogMessage.Show("One or more settings were found to be invalid. Check the console for more information",
                                      "Invalid settings", MessageButtons.OK, MessageIcon.Information);
            }
        }
Exemple #11
0
        private void Compiler_ExecuteCustomCommand(string value)
        {
            try
            {
                // Only execute the command when there is data
                if (value.Length > 0)
                {
                    // First replace all the keywords
                    value = SPiApp2.Components.Common.Template.ReplaceAllKeywords(value);

                    // Split the data and take the path
                    string[] data = Utility.Split(value);
                    string   path = data[0];

                    if (File.Exists(path))
                    {
                        string directory = Path.GetDirectoryName(path);
                        string filename  = Path.GetFileName(path);

                        if (Utility.IsTextFile(filename))
                        {
                            SPiApp2.Components.Application.OpenTextFile(directory, filename);
                        }
                        else if (Utility.IsExecutableFile(filename))
                        {
                            // NOTE: Safe as 0 is the program executable!
                            string[] arguments = new string[data.Length - 1];
                            for (int i = 1; i < data.Length; i++)
                            {
                                arguments[i - 1] = data[i];
                            }

                            SPiApp2.Components.Application.Launch(filename, directory, arguments);
                        }
                        else
                        {
                            SPiApp2.Components.Application.Browse(directory, filename);
                        }
                    }
                    else if (Directory.Exists(path))
                    {
                        SPiApp2.Components.Application.Browse(path);
                    }
                    else
                    {
                        AppDialogMessage.Show(string.Format("Target at {0} isn't a directory or a file.", path),
                                              "Missing target", MessageButtons.OK, MessageIcon.Warning);
                    }
                }
            }
            catch (Exception)
            {
                AppDialogMessage.Show("An unknown error occured while processing your custom commands.",
                                      "Corrupted commands", MessageButtons.OK, MessageIcon.Error);
            }

#if OLD_VERSION
            if (!string.IsNullOrEmpty(data[1]))
            {
                LaunchApplication(filename, directory, data[1]);
            }
            else
            {
                LaunchApplication(filename, directory);
            }
#endif
        }