Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Added "None" to the resource picker
Browse files Browse the repository at this point in the history
  • Loading branch information
REHERC committed Mar 27, 2021
1 parent 3fd4d17 commit 25b9d96
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
6 changes: 5 additions & 1 deletion App.AdventureMaker.Core/Controls/ResourceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ protected override void OnButtonClicked()

CampaignResource resource = new ResourceBrowser(editor, type).ShowModal();

if (resource != null)
if (resource is CampaignResource.Dummy)
{
Resource = null;
}
else if (resource != null)
{
Resource = resource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public ResourceBrowser(IEditor<CampaignFile> editor, ResourceType type)
(importResource = new Button(ImportNew)
{
Text = $"Import new {type.ToString().ToLower()}",
Image = Resources.GetIcon("AddGreen.ico", 16)
Image = Resources.GetIcon("AddGreen.ico", 16),
Enabled = false
}),
null,
(DefaultButton = new Button(Confirm)
Expand All @@ -103,6 +104,7 @@ public ResourceBrowser(IEditor<CampaignFile> editor, ResourceType type)
private void UpdateDataStore()
{
resourceList = editor.Document.Data.Resources.Where(res => Equals(res.resource_type, type)).ToList();
resourceList.Insert(0, new CampaignResource.Dummy());

resourcePicker.DataStore = resourceList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Models\CampaignMetadata.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\CampaignPlaylist.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\Resources\CampaignResource.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\Resources\Dummy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\Resources\Level.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\Resources\Texture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\UI\ProjectCreateData.cs" />
Expand Down
7 changes: 4 additions & 3 deletions Common.Distance.AdventureMaker/Enums/ResourceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
namespace Distance.AdventureMaker.Common.Enums
{
[Flags]
public enum ResourceType : byte
public enum ResourceType : short
{
Level,
Texture,
None = -1,
Level = 0,
Texture = 1,
//Audio,
//UnityAsset,
//Assembly,
Expand Down
25 changes: 25 additions & 0 deletions Common.Distance.AdventureMaker/Models/Resources/Dummy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma warning disable IDE1006
using Distance.AdventureMaker.Common.Enums;
using Newtonsoft.Json;

namespace Distance.AdventureMaker.Common.Models.Resources
{
public abstract partial class CampaignResource
{
public class Dummy : CampaignResource
{
[JsonProperty("resource_type")]
public override ResourceType resource_type => ResourceType.None;

#if APP
[JsonIgnore]
public override int dependencies_count => 0;
#endif

public Dummy()
{
file = "<None>";
}
}
}
}

0 comments on commit 25b9d96

Please sign in to comment.