This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptEditForm.cs
80 lines (64 loc) · 2.13 KB
/
ScriptEditForm.cs
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
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace LEdit
{
public partial class ScriptEditForm : Form
{
L2BattleScript initial_script;
L2BattleScript script;
public ScriptEditForm(L2BattleScript open_script, string title)
{
InitializeComponent();
Text = "Skript-Editor: " + title;
initial_script = open_script;
script = open_script;
ShowStuff();
}
private void ShowStuff()
{
txtScript.Text = script.Disassemble();
txtScript.SelectionStart = 0;
txtScript.SelectionLength = 0;
txtCode.Text = "";
for (int i = 0; i < script.Bytes.Count; i++ )
{
txtCode.Text += script.Bytes[i].ToString("X2");
if (i + 1 < script.Bytes.Count)
txtCode.Text += " ";
}
}
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void ScriptEditForm_Load(object sender, EventArgs e)
{
}
private void codeKompilierenToolStripMenuItem_Click(object sender, EventArgs e)
{
Collection<byte> x = new Collection<byte>();
string code = txtCode.Text.Replace(" ", "");
code = code.Replace("\r\n", "");
if(code.Length % 2 == 0)
{
for (int i = 0; i < code.Length; i += 2)
{
byte b = 0;
if (byte.TryParse(code.Substring(i, 2), System.Globalization.NumberStyles.HexNumber, null, out b))
x.Add(b);
}
}
script = new L2BattleScript(x, initial_script.Offset);
ShowStuff();
}
private void speichernToolStripMenuItem_Click(object sender, EventArgs e)
{
if(initial_script != script)
initial_script.Bytes = script.Bytes;
}
}
}