Skip to content

Commit

Permalink
update click to select
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Nov 14, 2018
1 parent 44212d4 commit ecdafc3
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 40 deletions.
2 changes: 1 addition & 1 deletion IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs

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

67 changes: 43 additions & 24 deletions IndustrialPark/ArchiveEditor/ArchiveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,30 +499,27 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)

private void listBoxAssets_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBoxAssets.SelectedItems != null)
archive.ClearSelectedAssets();
foreach (string s in listBoxAssets.SelectedItems)
archive.SelectAsset(GetAssetIDFromName(s), true);

if (listBoxAssets.SelectedItems.Count == 1)
{
archive.ClearSelectedAssets();
foreach (string s in listBoxAssets.SelectedItems)
archive.SelectAsset(GetAssetIDFromName(s), true);
buttonEditAsset.Enabled = true;

if (listBoxAssets.SelectedItems.Count == 1)
if (archive.GetFromAssetID(CurrentlySelectedAssetIDs()[0]) is IClickableAsset a)
{
buttonEditAsset.Enabled = true;

if (archive.GetFromAssetID(CurrentlySelectedAssetIDs()[0]) is IClickableAsset a)
{
if (a is AssetDYNA dyna)
buttonView.Visible = dyna.IsRenderableClickable;
else
buttonView.Visible = true;
}
if (a is AssetDYNA dyna)
buttonView.Visible = dyna.IsRenderableClickable;
else
buttonView.Visible = false;
buttonView.Visible = true;
}
else
{
buttonEditAsset.Enabled = false;
}
buttonView.Visible = false;
}
else
{
buttonEditAsset.Enabled = false;
}
}

Expand All @@ -538,21 +535,43 @@ public void MouseMoveY(SharpCamera camera, int deltaY)

public void SetSelectedIndexes(List<uint> assetIDs, bool add = false)
{
if (!add)
if (assetIDs.Contains(0) && !add)
{
listBoxAssets.SelectedIndices.Clear();
archive.UpdateGizmoPosition();
return;
}

if (add)
assetIDs.AddRange(CurrentlySelectedAssetIDs());

listBoxAssets.SelectedIndices.Clear();

AssetType assetType = AssetType.Null;

foreach (uint u in assetIDs)
{
try
if (archive.ContainsAsset(u))
{
assetType = archive.GetFromAssetID(u).AHDR.assetType;
comboBoxLayers.SelectedIndex = archive.GetLayerFromAssetID(u);
comboBoxAssetTypes.SelectedItem = archive.GetFromAssetID(u).AHDR.assetType;
break;
}
catch

foreach (uint u in assetIDs)
if (archive.ContainsAsset(u) && archive.GetFromAssetID(u).AHDR.assetType != assetType)
{
PopulateAssetList();
assetType = AssetType.Null;
break;
}

comboBoxAssetTypes.SelectedItem = assetType;
PopulateAssetList(assetType);

foreach (uint u in assetIDs)
{
if (!archive.ContainsAsset(u))
continue;

for (int i = 0; i < listBoxAssets.Items.Count; i++)
if (GetAssetIDFromName(listBoxAssets.Items[i] as string) == u)
listBoxAssets.SelectedIndices.Add(i);
Expand Down
33 changes: 20 additions & 13 deletions IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,20 +625,27 @@ public void OpenInternalEditor(List<uint> list)

private void OpenInternalEditor(Asset asset)
{
for (int i = 0; i < internalEditors.Count; i++)
if (internalEditors[i].GetAssetID() == asset.AHDR.assetID)
internalEditors[i].Close();
CloseInternalEditor(asset.AHDR.assetID);

if (asset is AssetCAM CAM)
internalEditors.Add(new InternalCamEditor(CAM, this));
else if (asset is AssetDYNA DYNA)
internalEditors.Add(new InternalDynaEditor(DYNA, this));
else if (asset is AssetTEXT TEXT)
internalEditors.Add(new InternalTextEditor(TEXT, this));
else if (asset.AHDR.assetType == AssetType.SND | asset.AHDR.assetType == AssetType.SNDS)
internalEditors.Add(new InternalSoundEditor(asset, this));
else
internalEditors.Add(new InternalAssetEditor(asset, this));
switch (asset.AHDR.assetType)
{
case AssetType.CAM:
internalEditors.Add(new InternalCamEditor((AssetCAM)asset, this));
break;
case AssetType.DYNA:
internalEditors.Add(new InternalDynaEditor((AssetDYNA)asset, this));
break;
case AssetType.TEXT:
internalEditors.Add(new InternalTextEditor((AssetTEXT)asset, this));
break;
case AssetType.SND:
case AssetType.SNDS:
internalEditors.Add(new InternalSoundEditor(asset, this));
break;
default:
internalEditors.Add(new InternalAssetEditor(asset, this));
break;
}

internalEditors.Last().Show();
}
Expand Down
4 changes: 2 additions & 2 deletions IndustrialPark/MainForm/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ public void ScreenClicked(Rectangle viewRectangle, int X, int Y, bool isMouseDow
}
else
assetID = ArchiveEditorFunctions.GetClickedAssetID(ray);
if (assetID != 0)
Program.MainForm.SetSelectedIndex(assetID);

Program.MainForm.SetSelectedIndex(assetID);
}
}
}
Expand Down

0 comments on commit ecdafc3

Please sign in to comment.