Skip to content

Commit

Permalink
[Parameters] ZoneParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
BAndysc committed Mar 4, 2024
1 parent 117a3af commit dee881c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions WDE.TrinitySmartScriptEditor/SmartData/actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3249,8 +3249,8 @@
"name_readable": "Override weather",
"parameters": [
{
"name": "Zone or area",
"type": "ZoneAreaParameter"
"name": "Zone",
"type": "ZoneParameter"
},
{
"name": "Weather state",
Expand Down
13 changes: 8 additions & 5 deletions WoWDatabaseEditor.Common/WDE.DbcStore/DbcStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ internal DbcStore(IParameterFactory parameterFactory,
public Dictionary<long, Dictionary<long, long>> ScenarioToStepStore { get; internal set; } = new();

public IReadOnlyList<IArea> Areas { get; internal set; } = Array.Empty<IArea>();
public IReadOnlyList<IArea> ZonesOnly { get; internal set; } = Array.Empty<IArea>();
public Dictionary<uint, IArea> AreaById { get; internal set; } = new();

public IReadOnlyList<IMap> Maps { get; internal set; } = Array.Empty<IMap>();
Expand Down Expand Up @@ -235,6 +236,7 @@ public void FinishMainThread()
store.BattlePetSpeciesIdStore = data.BattlePetSpeciesIdStore;
store.CurrencyTypeStore = data.CurrencyTypeStore;
store.Areas = data.Areas;
store.ZonesOnly = data.Areas.Where(a => a.ParentAreaId == 0).ToList();
store.CharShipmentContainers = data.CharShipmentContainers;
store.AreaById = data.Areas.ToDictionary(a => a.Id, a => (IArea)a);
store.Missions = data.Missions;
Expand Down Expand Up @@ -399,11 +401,11 @@ void RegisterCharShipmentContainerParameter(string key, TabularDataAsyncColumn<u
}
RegisterCharShipmentContainerParameter("CharShipmentContainerParameter");

void RegisterZoneAreParameter(string key, TabularDataAsyncColumn<uint>? counterColumn = null)
void RegisterZoneAreaParameter(string key, TabularDataAsyncColumn<uint>? counterColumn = null, bool onlyZones = false)
{
parameterFactory.Register(key,
new DbcParameterWithPicker<IArea>(dataPicker, data.AreaStore, "zone or area", area => area.Id,
() => store.Areas,
() => onlyZones ? store.ZonesOnly : store.Areas,
(area, text) => area.Name.Contains(text, StringComparison.InvariantCultureIgnoreCase) || area.Id.Contains(text) ||
area.MapId.Contains(text) || (area.Map != null && area.Map.Name.Contains(text, StringComparison.InvariantCultureIgnoreCase)) ||
area.ParentAreaId.Contains(text) || (area.ParentArea != null && area.ParentArea.Name.Contains(text, StringComparison.InvariantCultureIgnoreCase)),
Expand All @@ -421,15 +423,16 @@ void RegisterZoneAreParameter(string key, TabularDataAsyncColumn<uint>? counterC
new TabularDataColumn(nameof(IArea.Map) + "." + nameof(IMap.Name), "Map name", 120),
counterColumn), QuickAccessMode.Limited);
}
RegisterZoneAreParameter("ZoneAreaParameter");
RegisterZoneAreParameter("ZoneArea(spell_area)Parameter",
RegisterZoneAreaParameter("ZoneAreaParameter");
RegisterZoneAreaParameter("ZoneParameter", onlyZones: true);
RegisterZoneAreaParameter("ZoneArea(spell_area)Parameter",
new TabularDataAsyncColumn<uint>(nameof(IArea.Id), "Count", async (zoneId, token) =>
{
if (zoneId == 0)
return "0";
return (await store.databaseRowsCountProvider.GetRowsCountByPrimaryKey(DatabaseTable.WorldTable("spell_area"), zoneId, token)).ToString();
}, 50));
RegisterZoneAreParameter("ZoneArea(phase_definitions)Parameter",
RegisterZoneAreaParameter("ZoneArea(phase_definitions)Parameter",
new TabularDataAsyncColumn<uint>(nameof(IArea.Id), "Count", async (zoneId, token) =>
{
if (zoneId == 0)
Expand Down

0 comments on commit dee881c

Please sign in to comment.