-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathOpenRomScene.cs
More file actions
126 lines (94 loc) · 3.89 KB
/
OpenRomScene.cs
File metadata and controls
126 lines (94 loc) · 3.89 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using OpenTK.Input;
namespace SharpOcarina
{
public partial class OpenRomScene : Form
{
public List<Byte> Data;
public ushort sceneid;
Dictionary<byte, string> SceneNames;
public OpenRomScene(List<byte> _Data)
{
InitializeComponent();
Data = _Data;
string gameprefix = (!MainForm.settings.MajorasMask) ? "OOT/" : "MM/";
XmlNodeList nodes = XMLreader.getXMLNodes("SceneNames", "Scene");
SceneNames = new Dictionary<byte, string>();
foreach (XmlNode node in nodes)
{
XmlAttributeCollection nodeAtt = node.Attributes;
if (nodeAtt["Key"] != null)
{
SceneNames.Add(Convert.ToByte(nodeAtt["Key"].Value, 16), node.InnerText);
}
}
Init();
// UpdateWindow();
}
public void Init()
{
ROM rom = MainForm.CheckVersion(Data);
string scenename = "";
int offset = (int)rom.SceneTable;
int c = 0;
string notes = "";
while (offset < ((int)rom.SceneTableEnd) - 1)
{
// variable = Helpers.Read16(EntranceTable, offset + 2);
uint romstart = Helpers.Read32(Data, offset);
uint romend = Helpers.Read32(Data, offset + 4);
uint titlecardstart = Helpers.Read32(Data, offset + 8);
uint titlecardend = Helpers.Read32(Data, offset + 12);
if (romstart == 0 || romend == 0) scenename = "EMPTY";
else if (!SceneNames.TryGetValue((byte)c, out scenename)) scenename = "Unknown";
notes = "Offset: " + romstart.ToString("X8") + " - " + romend.ToString("X8") + Environment.NewLine +
"Title card : " + ((titlecardstart == 0) ? "Empty" : titlecardstart.ToString("X8") + " - " + titlecardend.ToString("X8")) + Environment.NewLine;
//Environment.NewLine
// notes = notes.Replace(Environment.NewLine, "\\par ");
// notes = @"{\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red0\green0\blue255;} \cf2" + @"\line" + @"\cf1 " + notes + "}";
SceneView.Nodes.Add(new SceneNode((ushort)c, (romstart != 0 && romend != 0), c.ToString("X2") + " - " + scenename, notes));
if (rom.Game == "OOT")
offset += 0x14;
else
offset += 0x10;
c++;
}
}
private void CancelButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void OpenSceneButton_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
public class SceneNode : TreeNode
{
public ushort Value { get; set; }
public bool Valid { get; set; }
public string Notes { get; set; }
public SceneNode(ushort _Value, bool _Valid, string text, string _Notes) : base(text)
{
Value = _Value;
Valid = _Valid;
Notes = _Notes;
}
}
private void SceneView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
OpenSceneButton.Enabled = ((SceneNode)e.Node).Valid;
NotesTextBox.Clear();
NotesTextBox.Text = ((SceneNode)e.Node).Notes;
sceneid = ((SceneNode)e.Node).Value;
}
}
}