forked from BAndysc/WoWDatabaseEditor
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Conditions editor] Condition type 31 (OBJECT_ENTRY) entry parameter …
…can be chosen from the list
- Loading branch information
Showing
7 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
using Prism.Events; | ||
using Prism.Ioc; | ||
using WDE.Common.Events; | ||
using WDE.Common.Parameters; | ||
using WDE.Conditions.ViewModels; | ||
using WDE.Module; | ||
using WDE.Parameters; | ||
|
||
namespace WDE.Conditions | ||
{ | ||
public class ConditionsModule : ModuleBase | ||
{ | ||
public override void OnInitialized(IContainerProvider containerProvider) | ||
{ | ||
containerProvider.Resolve<IEventAggregator>() | ||
.GetEvent<AllModulesLoaded>() | ||
.Subscribe(() => | ||
{ | ||
var factory = containerProvider.Resolve<IParameterFactory>(); | ||
factory.Register("ConditionObjectEntryParameter", new ConditionObjectEntryParameter(factory)); | ||
}, | ||
ThreadOption.PublisherThread, | ||
true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
WDE.Conditions/ViewModels/ConditionObjectEntryParameter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System.Collections.Generic; | ||
using WDE.Common.Database; | ||
using WDE.Common.Parameters; | ||
|
||
namespace WDE.Conditions.ViewModels | ||
{ | ||
public class ConditionObjectEntryParameter : IContextualParameter<long, ConditionViewModel> | ||
{ | ||
private readonly IParameterFactory parameterFactory; | ||
public bool HasItems => true; | ||
|
||
public ConditionObjectEntryParameter(IParameterFactory parameterFactory) | ||
{ | ||
this.parameterFactory = parameterFactory; | ||
} | ||
|
||
public string ToString(long value) | ||
{ | ||
return value.ToString(); | ||
} | ||
|
||
public Dictionary<long, SelectOption>? Items { get; } | ||
|
||
public Dictionary<long, SelectOption>? ItemsForContext(ConditionViewModel context) | ||
{ | ||
LazyLoad(); | ||
|
||
if (context.ConditionValue1.Value == 3) | ||
return creatureParameter!.Items; | ||
|
||
if (context.ConditionValue1.Value == 5) | ||
return gameobjectParameter!.Items; | ||
|
||
return null; | ||
} | ||
|
||
private void LazyLoad() | ||
{ | ||
if (creatureParameter == null || gameobjectParameter == null) | ||
{ | ||
creatureParameter = parameterFactory.Factory("CreatureParameter"); | ||
gameobjectParameter = parameterFactory.Factory("GameobjectParameter"); | ||
} | ||
} | ||
|
||
private IParameter<long>? creatureParameter; | ||
private IParameter<long>? gameobjectParameter; | ||
|
||
public string ToString(long value, ConditionViewModel context) | ||
{ | ||
LazyLoad(); | ||
|
||
if (context.ConditionValue1.Value == 3) | ||
return creatureParameter!.ToString(value); | ||
|
||
if (context.ConditionValue1.Value == 5) | ||
return gameobjectParameter!.ToString(value); | ||
|
||
return ToString(value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters