Esempio n. 1
0
        private void LoadWrd(string path)
        {
            loadedWrd = new WrdFile();
            loadedWrd.Load(path);
            loadedWrdLocation = path;

            statusText.Text = $"Loaded WRD file: {new FileInfo(path).Name}";

            // Clear the StackPanel of old entries
            wrdCommandTextBox.Text = string.Empty;

            // Generate a string for every command in the WRD
            StringBuilder sb = new StringBuilder();

            foreach (var tuple in loadedWrd.Commands)
            {
                sb.Append(tuple.Item1);
                sb.Append('|');
                sb.AppendJoin(", ", tuple.Item2);
                sb.Append('\n');
            }
            wrdCommandTextBox.Text = sb.ToString();
        }
Esempio n. 2
0
        private void OpenScriptMenuItem_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "WRD script files (*.wrd)|*.wrd|All files (*.*)|*.*";
            if (!(openFileDialog.ShowDialog() ?? false))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(openFileDialog.FileName))
            {
                MessageBox.Show("ERROR: Specified file name is empty or null.");
                return;
            }

            loadedWrd = new WrdFile();
            loadedWrd.Load(openFileDialog.FileName);
            loadedWrdLocation = openFileDialog.FileName;

            statusText.Text = $"Loaded WRD file: {new FileInfo(openFileDialog.FileName).Name}";

            // Clear the StackPanel of old entries
            wrdCommandTextBox.Text = string.Empty;

            // Generate a string for every command in the WRD
            StringBuilder sb = new StringBuilder();

            foreach (WrdCommand command in loadedWrd.Commands)
            {
                sb.Append(command.Opcode);
                sb.Append('|');
                sb.AppendJoin(", ", command.Arguments);
                sb.Append('\n');
            }
            wrdCommandTextBox.Text = sb.ToString();

            // Check if we need to prompt the user to open an external STX file for strings
            wrdStringsTextBox.Text = string.Empty;
            if (loadedWrd.UsesExternalStrings)
            {
                if (MessageBox.Show("The WRD file references external string data, load an STX file?", "Load external strings", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    OpenFileDialog openStxDialog = new OpenFileDialog();
                    openStxDialog.Filter = "STX text files (*.stx)|*.stx|All files (*.*)|*.*";

                    if (!(openStxDialog.ShowDialog() ?? false))
                    {
                        return;
                    }

                    if (string.IsNullOrWhiteSpace(openStxDialog.FileName))
                    {
                        MessageBox.Show("ERROR: Specified file name is empty or null.");
                        return;
                    }

                    StxFile stx = new StxFile();
                    stx.Load(openStxDialog.FileName);
                    loadedStxLocation = openStxDialog.FileName;

                    foreach (string str in stx.StringTables.First().Strings)
                    {
                        wrdStringsTextBox.Text += str.Replace("\n", "\\n").Replace("\r", "\\r") + '\n';
                    }
                }
            }
            else
            {
                foreach (string str in loadedWrd.InternalStrings)
                {
                    wrdStringsTextBox.Text += str.Replace("\n", "\\n").Replace("\r", "\\r") + '\n';
                }
            }
        }
Esempio n. 3
0
 public void LoadFile(string path)
 {
     wrd = new WrdFile();
     wrd.Load(path);
     wrdPath = path;
 }