Advertisement
xMissCorielx

NPC Creator - Dialogue Boutique

Jan 10th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using Newtonsoft.Json;
  12.  
  13. namespace NPC_Creator
  14. {
  15.     public partial class dialogueBoutique : Form
  16.     {
  17.         string systemName;
  18.         public Dictionary<string, string> content = new Dictionary<string, string>();
  19.         public Dictionary<string, string> marriage = new Dictionary<string, string>();
  20.         public Dictionary<string, string> savedata;
  21.         public string editData;
  22.  
  23.         public void updateList(string commitChange)
  24.         {
  25.             listDialogue.Items.Add(commitChange);
  26.         }
  27.  
  28.         public dialogueBoutique()
  29.         {
  30.             InitializeComponent();
  31.             Load += dialogueBoutique_Load;
  32.         }
  33.         private void dialogueBoutique_Load(object sender, EventArgs e)
  34.         {
  35.             systemName = Form1.exportSystem;
  36.         }
  37.         private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  38.         {
  39.             System.Diagnostics.Process.Start("https://stardewvalleywiki.com/Modding:Dialogue");
  40.         }
  41.  
  42.         private void Label6_Click(object sender, EventArgs e)
  43.         {
  44.  
  45.         }
  46.  
  47.         private void AddToKey_Click(object sender, EventArgs e)
  48.         {
  49.             keyList.Items.Add(customKey.Text);
  50.         }
  51.  
  52.         private void SpouseDialog_Click(object sender, EventArgs e)
  53.         {
  54.             keyList.Items.Add($"patio_{systemName}");
  55.             keyList.Items.Add($"Rainy_Day_{systemName}");
  56.             keyList.Items.Add($"Rainy_Night_{systemName}");
  57.             keyList.Items.Add($"Indoor_Day_{systemName}");
  58.             keyList.Items.Add($"Indoor_Night_{systemName}");
  59.             keyList.Items.Add($"Outdoor_{systemName}");
  60.             keyList.Items.Add($"funLeave_{systemName}");
  61.             keyList.Items.Add($"funReturn_{systemName}");
  62.             keyList.Items.Add($"jobLeave_{systemName}");
  63.             keyList.Items.Add($"jobReturn_{systemName}");
  64.             MessageBox.Show($"Special Marriage Dialogue has been added for {systemName}!  Check bottom of the list.", "Dialogue Added!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  65.         }
  66.  
  67.         private void AddDialogList_Click(object sender, EventArgs e)
  68.         {
  69.             listDialogue.Items.Add(keyList.SelectedItem + ": " + dialogBody.Text);
  70.             dialogBody.Text = String.Empty;
  71.         }
  72.  
  73.         private void SubmitQuestion_Click(object sender, EventArgs e)
  74.         {
  75.             listDialogue.Items.Add(keyList.SelectedItem + ": " + preQuestion.Text + "#$b#$q " + positiveID.Value + "/" + negativeID.Value + " " + fallBackID.Text + "#" + question.Text + "#$r " + positiveID.Value + " " + positivePoints.Value + " " + positiveResponse.Text + "#" + positiveAnswer.Text + "#$r " + negativeID.Value + " " + negativePoints.Value + " " + negativeResponse.Text + "#" + negativeAnswer.Text);
  76.             keyList.Items.Add(fallBackID.Text);
  77.             keyList.Items.Add(positiveResponse.Text);
  78.             keyList.Items.Add(negativeResponse.Text);
  79.             MessageBox.Show($"{fallBackID.Text}, {positiveResponse.Text}, and {negativeResponse.Text} were added to the Key List.  Do NOT Forget to add them to the dialogue!", "REMINDER!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  80.             preQuestion.Text = String.Empty;
  81.             fallBackID.Text = String.Empty;
  82.             question.Text = String.Empty;
  83.             positiveResponse.Text = String.Empty;
  84.             positiveAnswer.Text = String.Empty;
  85.             negativeResponse.Text = String.Empty;
  86.             negativeAnswer.Text = String.Empty;
  87.  
  88.         }
  89.  
  90.         private void RemoveDialogue_Click(object sender, EventArgs e)
  91.         {
  92.             listDialogue.Items.Remove(listDialogue.SelectedItem);
  93.         }
  94.  
  95.         private void CreateDialogFile_Click(object sender, EventArgs e)
  96.         {
  97.             foreach (var item in listDialogue.Items)
  98.             {
  99.                 string entry = item.ToString();
  100.                 string key = entry.Substring(0, entry.IndexOf(':'));
  101.                 string value = entry.Substring(entry.IndexOf(':') + 2); // +1 to get past :, and +1 to get past the space
  102.                 content.Add(key, value);
  103.             }
  104.             string path = Path.Combine($"Export/[CP]{systemName}/assets/dialogue", "Dialogue.json");
  105.             File.WriteAllText(path, JsonConvert.SerializeObject(content, Formatting.Indented));
  106.             string save = Path.Combine($"Export/[CP]{systemName}/assets/dialogue", "Dialogue-backup.json");
  107.             File.WriteAllText(save, JsonConvert.SerializeObject(content, Formatting.Indented));
  108.             MessageBox.Show("Dialogue.Json Created!  Remember not all Keys are for the Main Dialogue", "Dialogue Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
  109.  
  110.         }
  111.  
  112.         private void CreateMarriageFile_Click(object sender, EventArgs e)
  113.         {
  114.             foreach (var item in listDialogue.Items)
  115.             {
  116.                 string entry = item.ToString();
  117.                 string key = entry.Substring(0, entry.IndexOf(':'));
  118.                 string value = entry.Substring(entry.IndexOf(':') + 2); // +1 to get past :, and +1 to get past the space
  119.                 marriage.Add(key, value);
  120.             }
  121.            
  122.             string path = Path.Combine($"Export/[CP]{systemName}/assets/dialogue", "MarriageDialogue.json");
  123.             File.WriteAllText(path, JsonConvert.SerializeObject(marriage, Formatting.Indented));
  124.             string save = Path.Combine($"Export/[CP]{systemName}/assets/dialogue", "BackupMarriageDialogue.json");
  125.             File.WriteAllText(save, JsonConvert.SerializeObject(marriage, Formatting.Indented));
  126.             MessageBox.Show("MarriageDialogue.Json Created!  Remember not all Keys are for the MarriageDialogue", "Dialogue Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
  127.  
  128.         }
  129.  
  130.         private void Button1_Click(object sender, EventArgs e)
  131.         {
  132.             listDialogue.Items.Clear();
  133.             string save = Path.Combine($"Export/[CP]{systemName}/assets/dialogue", "Dialogue-backup.json");
  134.             string json = File.ReadAllText(save);
  135.             var recentLoad = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
  136.             foreach (KeyValuePair<string, string> pair in recentLoad)
  137.             {
  138.                 listDialogue.Items.Add($"{pair.Key}: {pair.Value}");
  139.             }
  140.         }
  141.  
  142.         private void LoadMarriage_Click(object sender, EventArgs e)
  143.         {
  144.             listDialogue.Items.Clear();
  145.             string save = Path.Combine($"Export/[CP]{systemName}/assets/dialogue", "BackupMarriageDialogue.json");
  146.             string json = File.ReadAllText(save);
  147.             var recentLoad = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
  148.             foreach (KeyValuePair<string, string> pair in recentLoad)
  149.             {
  150.                 listDialogue.Items.Add($"{pair.Key}: {pair.Value}");
  151.             }
  152.  
  153.         }
  154.  
  155.         private void Button2_Click(object sender, EventArgs e)
  156.         {
  157.             editData = $"{listDialogue.SelectedItem}";
  158.             listDialogue.Items.Remove(listDialogue.SelectedItem);
  159.             EditDialogue frRem = new EditDialogue(editData);
  160.             frRem.ShowDialog();
  161.  
  162.         }
  163.     }
  164. }
  165.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement