Skip to content

Commit

Permalink
Merge pull request #27 from igorseabra4/asset_format_refactor
Browse files Browse the repository at this point in the history
add fly editor
  • Loading branch information
igorseabra4 authored Nov 13, 2021
2 parents 80ff18f + ba116d8 commit b075512
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static void PopulateTemplateMenusAt(ToolStripMenuItem menu, EventHandler
new ToolStripMenuItem(AssetTemplate.Conditional.ToString()),
new ToolStripMenuItem(AssetTemplate.Dispatcher.ToString()),
new ToolStripMenuItem(AssetTemplate.Fog.ToString()),
new ToolStripMenuItem(AssetTemplate.Flythrough.ToString()),
new ToolStripMenuItem(AssetTemplate.Group.ToString()),
new ToolStripMenuItem(AssetTemplate.Portal.ToString()),
new ToolStripMenuItem(AssetTemplate.Script.ToString()),
Expand Down Expand Up @@ -425,6 +426,7 @@ public Asset PlaceTemplate(Vector3 position, int layerIndex, ref List<uint> asse
case AssetTemplate.LKIT_JF_SB_lights:
case AssetTemplate.LKIT_jf01_light_kit:
case AssetTemplate.MINF_Generic:
case AssetTemplate.Flythrough_Widget:
ignoreNumber = true;
break;
case AssetTemplate.StartCamera:
Expand Down Expand Up @@ -731,6 +733,11 @@ public Asset PlaceTemplate(Vector3 position, int layerIndex, ref List<uint> asse
break;
case AssetTemplate.Flythrough:
asset = new AssetFLY(assetName);
var flyWidget = (DynaGObjectFlythrough)PlaceTemplate(position, layerIndex, ref assetIDs, asset.assetName + "_WIDGET", AssetTemplate.Flythrough_Widget);
flyWidget.FLY_ID = asset.assetID;
break;
case AssetTemplate.Flythrough_Widget:
asset = new DynaGObjectFlythrough(assetName);
break;
case AssetTemplate.JawData:
asset = new AssetJAW(assetName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ private void InternalAssetEditor_FormClosing(object sender, FormClosingEventArgs
archive.CloseInternalEditor(this);
}

private Asset asset;
private ArchiveEditorFunctions archive;
private readonly Asset asset;
private readonly ArchiveEditorFunctions archive;

public uint GetAssetID()
{
Expand Down
136 changes: 118 additions & 18 deletions IndustrialPark/ArchiveEditor/InternalEditors/InternalFlyEditor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;

namespace IndustrialPark
Expand All @@ -24,12 +25,19 @@ public void RefreshPropertyGrid()
propertyGridSpecific.Refresh();
}

private ArchiveEditorFunctions archive;
private readonly ArchiveEditorFunctions archive;

private void InternalDynaEditor_FormClosing(object sender, FormClosingEventArgs e)
{
Program.MainForm.renderer.StopFly();
archive.CloseInternalEditor(this);
if (recording || playing)
{
e.Cancel = true;
}
else
{
Program.MainForm.renderer.StopFly();
archive.CloseInternalEditor(this);
}
}

public uint GetAssetID()
Expand All @@ -42,7 +50,7 @@ private void buttonFindCallers_Click(object sender, EventArgs e)
Program.MainForm.FindWhoTargets(GetAssetID());
}

private AssetFLY asset;
private readonly AssetFLY asset;

private void UpdateListbox()
{
Expand All @@ -59,10 +67,14 @@ private void UpdateAssetEntries()
int selectedIndex = listBoxFlyEntries.SelectedIndex;

List<EntryFLY> entries = new List<EntryFLY>();
var count = 0;
maxFrame = 0;
foreach (EntryFLY entry in listBoxFlyEntries.Items)
{
entry.FrameNumer = count++;
entries.Add(entry);
maxFrame = entry.FrameNumer > maxFrame ? entry.FrameNumer : maxFrame;
if (entry.FrameNumer > maxFrame)
maxFrame = entry.FrameNumer;
}
asset.FLY_Entries = entries.ToArray();
archive.UnsavedChanges = true;
Expand Down Expand Up @@ -90,8 +102,9 @@ private void listBoxFlyEntries_SelectedIndexChanged(object sender, EventArgs e)

private void buttonAdd_Click(object sender, EventArgs e)
{
listBoxFlyEntries.Items.Add(new EntryFLY() { FrameNumer = listBoxFlyEntries.Items.Count });
UpdateAssetEntries();
var entry = new EntryFLY() { FrameNumer = listBoxFlyEntries.Items.Count };
SetViewToFly(entry);
listBoxFlyEntries.Items.Add(entry);
}

private void buttonRemove_Click(object sender, EventArgs e)
Expand All @@ -105,21 +118,22 @@ private void buttonRemove_Click(object sender, EventArgs e)

private void propertyGridSpecific_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
UpdateAssetEntries();
RefreshPropertyGrid();
}

private void buttonGetPos_Click(object sender, EventArgs e)
private void buttonGetView_Click(object sender, EventArgs e)
{
((EntryFLY)propertyGridSpecific.SelectedObject).CameraPosition = Program.MainForm.renderer.Camera.Position;
UpdateAssetEntries();
if (listBoxFlyEntries.SelectedIndex != -1)
SetViewToFly((EntryFLY)propertyGridSpecific.SelectedObject);
RefreshPropertyGrid();
}

private void buttonGetDir_Click(object sender, EventArgs e)
private void SetViewToFly(EntryFLY entry)
{
((EntryFLY)propertyGridSpecific.SelectedObject).CameraNormalizedLeft = -Program.MainForm.renderer.Camera.Right;
((EntryFLY)propertyGridSpecific.SelectedObject).CameraNormalizedUp = Program.MainForm.renderer.Camera.Up;
((EntryFLY)propertyGridSpecific.SelectedObject).CameraNormalizedBackward = -Program.MainForm.renderer.Camera.Forward;
UpdateAssetEntries();
entry.CameraPosition = Program.MainForm.renderer.Camera.Position;
entry.CameraNormalizedRight = Program.MainForm.renderer.Camera.Right;
entry.CameraNormalizedUp = Program.MainForm.renderer.Camera.Up;
entry.CameraNormalizedBackward = -Program.MainForm.renderer.Camera.Forward;
}

private void buttonView_Click(object sender, EventArgs e)
Expand All @@ -128,13 +142,72 @@ private void buttonView_Click(object sender, EventArgs e)
Program.MainForm.renderer.Camera.SetPositionFlyEntry(flyEntry);
}

private bool playing = false;

private void buttonPlay_Click(object sender, EventArgs e)
{
Program.MainForm.renderer.PlayFly(this);
if (playing)
{
Stop();

buttonPlay.Text = "Preview";

buttonAdd.Enabled = true;
buttonRemove.Enabled = true;
buttonRecord.Enabled = true;
buttonGetPos.Enabled = true;
buttonView.Enabled = true;
}
else
{
playing = true;

buttonPlay.Text = "Stop Preview";

buttonAdd.Enabled = false;
buttonRemove.Enabled = false;
buttonRecord.Enabled = false;
buttonGetPos.Enabled = false;
buttonView.Enabled = false;

Program.MainForm.renderer.PlayFly(this);
}
}

private void buttonStop_Click(object sender, EventArgs e)
private bool recording = false;

private void buttonRecord_Click(object sender, EventArgs e)
{
if (recording)
{
Stop();

buttonRecord.Text = "Start Recording";
UpdateAssetEntries();

buttonRemove.Enabled = true;
buttonGetPos.Enabled = true;
buttonPlay.Enabled = true;
buttonView.Enabled = true;
}
else
{
buttonRemove.Enabled = false;
buttonGetPos.Enabled = false;
buttonPlay.Enabled = false;
buttonView.Enabled = false;

recording = true;
Program.MainForm.renderer.RecordFly(this);
buttonRecord.Text = "Stop Recording";
}
}

private void Stop()
{
playing = false;
recording = false;

currentFrame = 0;
labelFrame.Text = "";
Program.MainForm.renderer.StopFly();
Expand Down Expand Up @@ -164,5 +237,32 @@ public void Play()
labelFrame.Text = "Frame: " + currentFrame;
}
}

public void Record()
{
var newFly = new EntryFLY
{
FrameNumer = listBoxFlyEntries.Items.Count,
ApertureX = 0.98f,
ApertureY = 0.735f,
Focal = 26.69057f
};
SetViewToFly(newFly);

var lastIndex = listBoxFlyEntries.Items.Count - 1;

if (lastIndex < 0 || !((EntryFLY)listBoxFlyEntries.Items[lastIndex]).NearlySimilar(newFly))
{
switcher = !switcher;
if (switcher)
listBoxFlyEntries.Items.Add(newFly);
labelFrame.Text = "Frame: " + newFly.FrameNumer;
}
}

private void buttonHelp_Click(object sender, EventArgs e)
{
Process.Start(AboutBox.WikiLink + asset.assetType.ToString());
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b075512

Please sign in to comment.