-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditor.cs
More file actions
251 lines (202 loc) · 9.57 KB
/
Copy pathEditor.cs
File metadata and controls
251 lines (202 loc) · 9.57 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace yh9uoip
{
public partial class Editor : Form
{
public static string loadedFileS;
public static byte[] loadedFileB;
public int loadedDataPosition;
public static string loadedFileLoc;
private DecryptUtil decryptUtil = new DecryptUtil();
public Editor()
{
InitializeComponent();
/* Get info from the MainWindow */
loadedFileS = MainWindow.tmpOpenFileS;
loadedFileB = MainWindow.tmpOpenFileB;
loadedFileLoc = MainWindow.tmpFileLoc;
loadedDataPosition = MainWindow.tmpDataPos;
this.Text = MainWindow.tmpFileName + " - PTR2SDE";
/* Load the file */
decryptUtil.startLoad();
/* GUI */
GenerateGui();
Console.WriteLine("Populated GUI");
DebugShowLoadedSubtitles();
Console.WriteLine("Generated Debug tab");
SizeLastColumns();
}
/* GUI */
private void GenerateGui()
{
string useless = "~";
/* Cutscene */
int a = 0;
int lastTmgId = -1;
foreach (Subtitle curSub in decryptUtil.subtitleList)
{
a++;
if (!curSub.IsHidden)
{
ListViewItem tmpItem = cutsceneView.Items.Add(a.ToString());
tmpItem.SubItems.Add(curSub.SubtitleId.ToString());
/* Start/End subtitle, lets make prettier */
if (curSub.TimingId != lastTmgId)
{
lastTmgId = curSub.TimingId;
tmpItem.SubItems.Add(decryptUtil.timingList[curSub.TimingId].TimingAppear.ToString());
tmpItem.SubItems.Add(decryptUtil.timingList[curSub.TimingId].TimingDisappear.ToString());
}
else
{
tmpItem.SubItems.Add(useless).BackColor = Color.Gray;
tmpItem.SubItems.Add(useless).BackColor = Color.Gray;
}
tmpItem.SubItems.Add(curSub.SubtitleText);
}
}
/* In-gameplay */
int b = 0;
foreach (GSubtitle curSub in decryptUtil.gameplaySubtitleList)
{
b++;
if (!curSub.IsHidden)
{
ListViewItem tmpItem = gameplayView.Items.Add(b.ToString());
tmpItem.SubItems.Add(curSub.SubtitleText);
}
}
}
/* GUI Debug Gen */
private void DebugShowLoadedSubtitles()
{
var debugText = new StringBuilder();
/* Cutscene */
for (int id = 0; id < decryptUtil.datalistAmmount; id++)
{
debugText.Append(Environment.NewLine + "# CUTSCENE " + id + " #" + Environment.NewLine);
foreach (Subtitle curSubtitle in decryptUtil.subtitleList)
{
if (curSubtitle.SubtitleId == id)
{
debugText.Append(Environment.NewLine + Environment.NewLine + "[SUBTITLE]"
+ Environment.NewLine + "Text: " + curSubtitle.SubtitleText
+ Environment.NewLine + "HEX Position: " + curSubtitle.DataPosition
+ Environment.NewLine + "Is second data: " + curSubtitle.IsSecondData.ToString()
+ Environment.NewLine + "Timing ID: " + curSubtitle.TimingId
+ Environment.NewLine + "Time Start: " + Convert.ToInt32(decryptUtil.timingList[curSubtitle.TimingId].TimingAppear)
+ Environment.NewLine + "Time End: " + Convert.ToInt32(decryptUtil.timingList[curSubtitle.TimingId].TimingDisappear));
}
}
}
/* In-gameplay */
debugText.Append(Environment.NewLine + Environment.NewLine + "# IN-GAMEPLAY #" + Environment.NewLine);
foreach (GSubtitle curSubtitle in decryptUtil.gameplaySubtitleList)
{
debugText.Append(Environment.NewLine + Environment.NewLine + "[SUBTITLE]"
+ Environment.NewLine + "Text: " + curSubtitle.SubtitleText
+ Environment.NewLine + "HEX Position: " + curSubtitle.DataPosition
+ Environment.NewLine + "STR Position: " + curSubtitle.SubtitlePosition);
}
debuggingText.Text = debugText.ToString();
}
/* "Notepad" bar */
private void ToBeMade(object sender, EventArgs e)
{
MessageBox.Show("This function is still being made, if you aren't sure if this is supposed to happen contact the developers", "PTR2SDE", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void aboutBut_Click(object sender, EventArgs e)
{
MessageBox.Show("PTR2SDE - Made by Vortex64 & DHTSinho" + "\n" + "Version : " + MainWindow.toolVersion);
}
private void exitBut_Click(object sender, EventArgs e)
{
this.Close();
}
/* ListView Select */
private int cCurItem = -1;
private void cutsceneView_MouseDoubleClick(object sender, MouseEventArgs e)
{
ListViewItem tmp = cutsceneView.GetItemAt(e.X, e.Y);
if (cutsceneView.SelectedItems.Count != 0)
{
cCurItem = Int32.Parse(tmp.SubItems[0].Text);
ctimingStartText.Text = tmp.SubItems[2].Text;
ctimingEndText.Text = tmp.SubItems[3].Text;
cutsceneEditText.Text = tmp.SubItems[4].Text;
}
}
private int gCurItem = -1;
private void gameplayView_MouseDoubleClick(object sender, MouseEventArgs e)
{
ListViewItem tmp = gameplayView.GetItemAt(e.X, e.Y);
if (gameplayView.SelectedItems.Count != 0)
{
gCurItem = Int32.Parse(tmp.SubItems[0].Text);
gameplayEditText.Text = tmp.SubItems[1].Text;
}
}
/* Edit */
private void editBut_Click(object sender, EventArgs e)
{
if (cCurItem == -1) return;
Subtitle curSub = decryptUtil.subtitleList[cCurItem - 1];
int tmpDiff = cutsceneEditText.Text.Length - cutsceneView.FindItemWithText(cCurItem.ToString()).SubItems[4].Text.Length;
int tmpPos = curSub.SubtitlePosition;
decryptUtil.fixList.Add(new ModPoint(tmpPos, tmpDiff, cCurItem - 1, false));
decryptUtil.FixStrings(tmpPos, tmpDiff);
Console.WriteLine("Correction added. Subtitle position: " + tmpPos + ", diff: " + tmpDiff);
ListViewItem tmp = cutsceneView.FindItemWithText(cCurItem.ToString());
tmp.SubItems[2].Text = ctimingStartText.Text;
tmp.SubItems[3].Text = ctimingEndText.Text;
tmp.SubItems[4].Text = cutsceneEditText.Text;
decryptUtil.timingList[curSub.TimingId].TimingAppear = Convert.ToInt32(ctimingStartText.Text);
decryptUtil.timingList[curSub.TimingId].TimingDisappear = Convert.ToInt32(ctimingEndText.Text);
curSub.SubtitleText = cutsceneEditText.Text;
}
private void geditButton_Click(object sender, EventArgs e)
{
if (gCurItem == -1) return;
GSubtitle curSub = decryptUtil.gameplaySubtitleList[gCurItem - 1];
int tmpDiff = gameplayEditText.Text.Length - gameplayView.FindItemWithText(gCurItem.ToString()).SubItems[1].Text.Length;
int tmpPos = curSub.SubtitlePosition;
decryptUtil.fixList.Add(new ModPoint(tmpPos, tmpDiff, gCurItem - 1, true));
decryptUtil.FixStrings(tmpPos, tmpDiff);
ListViewItem tmp = gameplayView.FindItemWithText(gCurItem.ToString());
tmp.SubItems[1].Text = gameplayEditText.Text;
decryptUtil.gameplaySubtitleList[gCurItem - 1].SubtitleText = gameplayEditText.Text;
}
/* Save */
private void save_Click(object sender, EventArgs e)
{
decryptUtil.SaveFile(loadedFileLoc);
MessageBox.Show("File saved successfully.", "PTR2SDE", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void saveAs_Click(object sender, EventArgs e)
{
if (saveOLM.ShowDialog() == DialogResult.OK)
{
decryptUtil.SaveFile(saveOLM.FileName);
MessageBox.Show("File saved successfully.", "PTR2SDE", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
/* Tools/Fixes */
private void cutsceneView_Resize(object sender, EventArgs e)
{
SizeLastColumns();
}
private void gameplayView_Resize(object sender, EventArgs e)
{
SizeLastColumns();
}
private void SizeLastColumns()
{
cutsceneView.Columns[cutsceneView.Columns.Count - 1].Width = -2;
gameplayView.Columns[gameplayView.Columns.Count - 1].Width = -2;
}
/* Tools (Program) */
}
}