-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSuperRepliesForm.cs
More file actions
214 lines (193 loc) · 8.19 KB
/
Copy pathSuperRepliesForm.cs
File metadata and controls
214 lines (193 loc) · 8.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace CustomStreamMaker
{
public partial class SuperRepliesForm : Form
{
StreamEditor streamEditor;
ChatSays chatComment;
internal List<KAngelSays> kAngelSaysDupe = new();
string _currentAnim = "";
public SuperRepliesForm(StreamEditor streamEditor, ChatSays chat)
{
chatComment = chat;
this.streamEditor = streamEditor;
InitializeComponent();
}
private void SuperRepliesForm_Load(object sender, EventArgs e)
{
KAnimReply_List.Items.AddRange(ThatOneLongListOfAnimationsOriginallyInTheGame.list);
SuperChatComment.Text = chatComment.Comment;
SetBackgroundPreview(streamEditor.settings.StartingBackground);
LoadInReplies();
SetNewSpritePreview(_currentAnim);
SuperRepliesListView.ClearSelection();
SuperRepliesListView.CurrentCell = null;
if (SuperRepliesListView.SelectedRows.Count > 0)
{
AddEditSuperReply_Button.Text = "Save Reply";
}
CheckIfAtReplyLimit();
}
private void LoadInReplies()
{
if (chatComment.Replies.Count <= 1)
{
_currentAnim = chatComment.Replies[0].AnimName;
return;
}
for (int i = 1; i < chatComment.Replies.Count; i++)
{
AddToReplyListView(chatComment.Replies[i]);
}
_currentAnim = chatComment.Replies[1].AnimName;
KAnimReply_List.Text = _currentAnim;
KAngelReply_Text.Text = chatComment.Replies[1].Dialogue;
}
private void AddToReplyListView(KAngelSays kChat)
{
CustomAsset customAsset = null;
if (CustomAssetExtractor.customAssets.Count > 0 && CustomAssetExtractor.customAssets.Exists(a => a.fileName == kChat.AnimName && a.customAssetType == CustomAssetType.Sprite))
{
customAsset = CustomAssetExtractor.customAssets.Find(a => a.fileName == kChat.AnimName && a.customAssetType == CustomAssetType.Sprite);
}
SuperRepliesListView.Rows.Add($"{kChat.Dialogue}\n({kChat.AnimName})");
kAngelSaysDupe.Add(new(kChat.AnimName, kChat.Dialogue, customAsset));
}
private void EditToReplyListView(int index)
{
var newReply = new KAngelSays(_currentAnim, KAngelReply_Text.Text);
if (CustomAssetExtractor.customAssets.Count > 0 && CustomAssetExtractor.customAssets.Exists(a => a.fileName == newReply.AnimName && a.customAssetType == CustomAssetType.Sprite))
{
var customAsset = CustomAssetExtractor.customAssets.Find(a => a.fileName == newReply.AnimName && a.customAssetType == CustomAssetType.Sprite);
newReply.SetCustomAnim(customAsset);
}
DeleteFromReplyView(index);
kAngelSaysDupe.Insert(index, newReply);
SuperRepliesListView.Rows.Insert(index, $"{newReply.Dialogue}\n({newReply.AnimName})");
}
private void DeleteFromReplyView(int index)
{
kAngelSaysDupe.RemoveAt(index);
SuperRepliesListView.Rows.RemoveAt(index);
streamEditor.ChangeFileLabelIfUnsaved();
}
private void SetNewSpritePreview(string imgName)
{
SpritePreview.Image?.Dispose();
SpritePreview.Image = AssetExtractor.GetCachedSprite(imgName);
}
private void SetBackgroundPreview(StreamBackground streamBg)
{
SpritePreview.BackgroundImage?.Dispose();
if (streamBg == StreamBackground.Black)
{
SpritePreview.BackgroundImage = null;
SpritePreview.BackColor = Color.Black;
}
else if (streamBg == StreamBackground.Void)
{
SpritePreview.BackgroundImage = null;
SpritePreview.BackColor = Color.White;
}
else
{
SpritePreview.BackColor = Color.FromKnownColor(KnownColor.Control);
SpritePreview.BackgroundImage = streamEditor.currentBackground;
}
}
private void SuperRepliesForm_Click(object sender, EventArgs e)
{
ActiveControl = null;
SuperRepliesListView.ClearSelection();
}
private void KAnimReply_List_SelectedIndexChanged(object sender, EventArgs e)
{
_currentAnim = (string)KAnimReply_List.SelectedItem;
SetNewSpritePreview(_currentAnim);
}
private void KAnimReply_List_Leave(object sender, EventArgs e)
{
KAnimReply_List.Text.ToLower();
streamEditor.ValidateAnimationValue(ref KAnimReply_List, ref _currentAnim);
_currentAnim = KAnimReply_List.Text;
SetNewSpritePreview(_currentAnim);
}
private void SuperChatComment_Click(object sender, EventArgs e)
{
ActiveControl = null;
SuperRepliesListView.ClearSelection();
}
private void AddEditSuperReply_Button_Click(object sender, EventArgs e)
{
streamEditor.ValidateAnimationValue(ref KAnimReply_List, ref _currentAnim);
if (SuperRepliesListView.SelectedRows.Count > 0)
{
EditToReplyListView(SuperRepliesListView.SelectedRows[0].Index);
CheckIfAtReplyLimit();
return;
}
AddToReplyListView(new KAngelSays(_currentAnim, KAngelReply_Text.Text));
SuperRepliesListView.ClearSelection();
CheckIfAtReplyLimit();
}
private void SuperChatComment_MouseClick(object sender, MouseEventArgs e)
{
ActiveControl = null;
SuperRepliesListView.ClearSelection();
}
private void SuperRepliesListView_SelectionChanged(object sender, EventArgs e)
{
if (SuperRepliesListView.SelectedRows.Count > 0 && kAngelSaysDupe.Count > 0)
{
AddEditSuperReply_Button.Enabled = true;
var index = SuperRepliesListView.SelectedRows[0].Index;
KAnimReply_List.SelectedItem = kAngelSaysDupe[index].AnimName;
KAngelReply_Text.Text = kAngelSaysDupe[index].Dialogue;
AddEditSuperReply_Button.Text = "Save Reply";
return;
}
AddEditSuperReply_Button.Text = "Add Reply";
CheckIfAtReplyLimit();
}
private void SuperRepliesForm_FormClosing(object sender, FormClosingEventArgs e)
{
var firstReply = new KAngelSays(streamEditor._currentSuperReplies[0].AnimName, streamEditor._currentSuperReplies[0].Dialogue, streamEditor._currentSuperReplies[0].customAnim);
streamEditor._currentSuperReplies = new List<KAngelSays>() { firstReply };
streamEditor._currentSuperReplies.AddRange(kAngelSaysDupe);
streamEditor.ChangeFileLabelIfUnsaved();
Dispose();
}
private void SuperRepliesListView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && SuperRepliesListView.SelectedRows.Count > 0)
{
DeleteFromReplyView(SuperRepliesListView.SelectedRows[0].Index);
SuperRepliesListView.ClearSelection();
CheckIfAtReplyLimit();
}
}
private void CheckIfAtReplyLimit()
{
if (kAngelSaysDupe.Count >= 3 && SuperRepliesListView.SelectedRows.Count == 0)
AddEditSuperReply_Button.Enabled = false;
else AddEditSuperReply_Button.Enabled = true;
}
private void KAnimReply_List_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
ActiveControl = null;
}
}
private void KAngelReply_Text_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
ActiveControl = null;
}
}
}
}