-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPickCustomActorID.cs
More file actions
164 lines (146 loc) · 5.65 KB
/
PickCustomActorID.cs
File metadata and controls
164 lines (146 loc) · 5.65 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
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;
namespace SharpOcarina
{
public partial class PickCustomActorID : Form
{
public ushort ActorID;
public ushort ObjectID;
public bool AutoFind;
public bool HasCustomObject;
public bool AllowCustomObject;
public List<CustomActorz64rom> z64romactors;
public List<CustomObjectz64rom> z64romobjects;
public string name;
public PickCustomActorID(ushort _ActorID , ushort _ObjectID, bool _AutoFind, bool _HasCustomObject, bool _AllowCustomObject, string _Name, List<CustomActorz64rom> _z64romactors, List<CustomObjectz64rom> _z64romobjects)
{
ActorID = _ActorID;
ObjectID = _ObjectID;
AutoFind = _AutoFind;
HasCustomObject = _HasCustomObject;
AllowCustomObject = _AllowCustomObject;
z64romactors = _z64romactors;
z64romobjects = _z64romobjects;
InitializeComponent();
Init();
Text = "Pick Actor ID: " + _Name;
UpdateForm();
}
public void Init()
{
ActorIDNumeric.Value = ActorID;
ObjectIDNumeric.Value = ObjectID;
ObjectLabel.Visible = ObjectIDNumeric.Visible = HasCustomObject;
if (ActorID == 0) FindEmptyIDs.Checked = true;
}
public void UpdateForm()
{
ActorIDNumeric.Enabled = ObjectIDNumeric.Enabled = !FindEmptyIDs.Checked;
if (FindEmptyIDs.Checked)
{
ActorInUseLabel.Visible = false;
ObjectInUseLabel.Visible = false;
Ok.Enabled = true;
ushort i;
for(i = 1; i < 0x999; i++)
{
if (!MainForm.ActorCache.ContainsKey(i)) break;
}
ActorIDNumeric.Value = i;
if (HasCustomObject && ObjectID == 0)
{
for (i = 4; i < 0x999; i++)
{
if (!MainForm.ObjectCache.ContainsKey(i)) break;
}
ObjectIDNumeric.Value = i;
}
}
else
{
ActorInUseLabel.Visible = false;
ObjectInUseLabel.Visible = false;
if (ActorIDNumeric.Value == ActorID)
{
ActorInUseLabel.Visible = true;
ActorInUseLabel.ForeColor = Color.Green;
ActorInUseLabel.Text = "Recommended by author";
Ok.Enabled = true;
}
else if (z64romactors.FindIndex(x => x.ID == ActorIDNumeric.Value) != -1)
{
ActorInUseLabel.Visible = true;
ActorInUseLabel.ForeColor = Color.Red;
ActorInUseLabel.Text = "Already in use!";
Ok.Enabled = false;
}
else if (MainForm.ActorCache.ContainsKey((ushort)ActorIDNumeric.Value))
{
ActorInUseLabel.Visible = true;
ActorInUseLabel.ForeColor = Color.DarkOrange;
ActorInUseLabel.Text = "Used by vanilla actor";
Ok.Enabled = true;
}
if (HasCustomObject)
{
if (ObjectIDNumeric.Value == ObjectID)
{
ObjectInUseLabel.Visible = true;
ObjectInUseLabel.ForeColor = Color.Green;
ObjectInUseLabel.Text = "Recommended by author";
Ok.Enabled = true;
}
else if (z64romobjects.FindIndex(x => x.ID == ObjectIDNumeric.Value) != -1)
{
if (!AllowCustomObject)
{
ObjectInUseLabel.Visible = true;
ObjectInUseLabel.ForeColor = Color.Red;
ObjectInUseLabel.Text = "Already in use!";
Ok.Enabled = false;
}
else
{
ObjectInUseLabel.Visible = true;
ObjectInUseLabel.ForeColor = Color.Orange;
ObjectInUseLabel.Text = "Custom object";
Ok.Enabled = true;
}
}
else if (MainForm.ObjectCache.ContainsKey((ushort)ObjectIDNumeric.Value))
{
ObjectInUseLabel.Visible = true;
ObjectInUseLabel.ForeColor = Color.Orange;
ObjectInUseLabel.Text = "Vanilla object";
Ok.Enabled = true;
}
}
}
}
private void Ok_Click(object sender, EventArgs e)
{
ActorID = (ushort)ActorIDNumeric.Value;
ObjectID = (ushort)ObjectIDNumeric.Value;
this.DialogResult = DialogResult.OK;
this.Close();
}
private void FindEmptyIDs_CheckedChanged(object sender, EventArgs e)
{
UpdateForm();
}
private void ActorIDNumeric_ValueChanged(object sender, EventArgs e)
{
UpdateForm();
}
private void ObjectIDNumeric_ValueChanged(object sender, EventArgs e)
{
UpdateForm();
}
}
}