Skip to content

Commit

Permalink
DOTK : fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vroonsh committed Feb 13, 2021
1 parent 23b0bf4 commit eedff71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
8 changes: 4 additions & 4 deletions DirectOutputToolkit/Forms/DirectOutputToolkitForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ public bool LoadConfig()
this.Bounds = Settings.LastMainWindowRect;
}

PreviewForm.Show(this);
Screen current = Screen.FromControl(this);
PreviewForm.Show();
if (Settings.LastPreviewWindowRect != Rectangle.Empty) {
PreviewForm.Bounds = Settings.LastPreviewWindowRect;
} else {
PreviewForm.Location = new Point(Math.Min(Bounds.Right, current.WorkingArea.Right), Bounds.Y);
PreviewForm.Location = new Point(Math.Min(Bounds.Right, Screen.FromControl(this).WorkingArea.Right), Bounds.Y);
}
PreviewForm.PreviewControl.OnSetupChanged(DofViewSetup);

Expand Down Expand Up @@ -516,6 +515,7 @@ private void buttonLoadRefTable_Click(object sender, EventArgs e)

fd.ShowDialog();
if (!fd.FileName.IsNullOrEmpty()) {
RomNameComboBox.Text = string.Empty;
PopulateReferenceTable(string.Empty);
var serializer = new DirectOutputToolkitSerializer();
EditionTableTreeNode tableNode = new EditionTableTreeNode(Handler, Handler.GetTable(DirectOutputToolkitHandler.ETableType.ReferenceTable));
Expand Down Expand Up @@ -711,6 +711,7 @@ private void OnCopyEffectToEditor(object sender, EventArgs e)
parentTE.AssignedEffects = new AssignedEffectList();
EditionTable.TableElements.Add(parentTE);
TENode = new TableElementTreeNode(parentTE, DirectOutputToolkitHandler.ETableType.EditionTable);
targetTENodes.Add(TENode);
EditionTableNode.Nodes.Add(TENode);
EditionTableNode.Refresh();
}
Expand All @@ -729,7 +730,6 @@ private void OnCopyEffectToEditor(object sender, EventArgs e)
var newEffectNode = new EffectTreeNode(null, DirectOutputToolkitHandler.ETableType.EditionTable, SrcEffectNode.Effect, Handler);
newEffectNode.Rebuild(Handler, null);
EditionTable.AssignedStaticEffects.Init(EditionTable);
EditionTableNode.StaticEffectsNode.Nodes.Add(newEffectNode);
EditionTableNode.StaticEffectsNode.Rebuild(Handler);
SetCurrentSelectedNode(EditionTableNode.StaticEffectsNode);
}
Expand Down
12 changes: 8 additions & 4 deletions DirectOutputToolkit/Handler/DirectOutputToolkitSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public void FromTableNode(EditionTableTreeNode node, DirectOutputToolkitHandler
{
TableName = node.EditionTable.TableName;
RomName = node.EditionTable.RomName;
ImageName = node.Image.Tag as string;
if (node.Image != null) {
ImageName = node.Image.Tag as string;
}
foreach (var se in node.EditionTable.AssignedStaticEffects) {
if (se.Effect != null) {
var neweffDesc = new EffectDescriptor();
Expand Down Expand Up @@ -138,9 +140,11 @@ public bool Deserialize(EditionTableTreeNode TableNode, string FilePath, DirectO
if (tableDescriptor != null) {
TableNode.EditionTable.TableName = tableDescriptor.TableName;
TableNode.EditionTable.RomName = tableDescriptor.RomName;
TableNode.Image = Image.FromFile(tableDescriptor.ImageName);
TableNode.Image.Tag = tableDescriptor.ImageName;
TableNode.OnImageChanged(TableNode.Image);
if (tableDescriptor.ImageName != string.Empty) {
TableNode.Image = Image.FromFile(tableDescriptor.ImageName);
TableNode.Image.Tag = tableDescriptor.ImageName;
TableNode.OnImageChanged(TableNode.Image);
}
TableNode.Refresh();

var TCCNumber = 0;
Expand Down
12 changes: 3 additions & 9 deletions DirectOutputToolkit/TreeNodes/StaticEffectsTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,10 @@ internal void Refresh()

internal void Rebuild(DirectOutputToolkitHandler Handler, IToy[] ToysFilter = null)
{
var effectsNodes = Nodes.Cast<EffectTreeNode>().ToList();
var missingEffects = Table.AssignedStaticEffects.Where(AE => !effectsNodes.Any(N => N.Effect == AE.Effect));

foreach(var node in effectsNodes) {
node.Rebuild(Handler, null);
}

foreach (var eff in missingEffects) {
Nodes.Clear();
foreach (var eff in Table.AssignedStaticEffects) {
Handler.InitEffect(eff, _TableType);
if (ToysFilter == null || ToysFilter.Contains(eff.Effect.GetAssignedToy())) {
Handler.InitEffect(eff, _TableType);
var effNode = new EffectTreeNode(null, _TableType, eff.Effect, Handler);
Nodes.Add(effNode);
}
Expand Down

0 comments on commit eedff71

Please sign in to comment.