Skip to content

Commit

Permalink
Deprecate YarnProject.GetHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Dec 19, 2024
1 parent 5473b1d commit 5c571d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Removed

- `YarnProject.GetHeaders` is now deprecated, in favour of `DialogueRunner.Dialogue.GetHeaders`.

## [3.0.0-beta1] 2024-11-30

### Added
Expand Down
48 changes: 2 additions & 46 deletions Runtime/YarnProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,54 +130,10 @@ public class ShadowTableDictionary : SerializableDictionary<string, ShadowTableE
/// cref="Program"/> and cached inside <see cref="nodeHeaders"/>. Future
/// calls will then return the cached values.
/// </remarks>
[System.Obsolete("Use " + nameof(Dialogue) + "." + nameof(Dialogue.GetHeaders), true)]
public Dictionary<string, List<string>> GetHeaders(string nodeName)
{
// if the headers have already been extracted just return that
Dictionary<string, List<string>> existingValues;
if (this.nodeHeaders.TryGetValue(nodeName, out existingValues))
{
return existingValues;
}

// headers haven't been extracted so we look inside the program
Node rawNode;
if (!Program.Nodes.TryGetValue(nodeName, out rawNode))
{
return new Dictionary<string, List<string>>();
}

var rawHeaders = rawNode.Headers;

// this should NEVER happen because there will always be at least
// the title, right?
if (rawHeaders == null || rawHeaders.Count == 0)
{
return new Dictionary<string, List<string>>();
}

// ok so this is an array of (string, string) tuples with
// potentially duplicated keys inside the array we'll convert it all
// into a dict of string arrays
Dictionary<string, List<string>> headers = new Dictionary<string, List<string>>();
foreach (var pair in rawHeaders)
{
List<string> values;

if (headers.TryGetValue(pair.Key, out values))
{
values.Add(pair.Value);
}
else
{
values = new List<string>();
values.Add(pair.Value);
}
headers[pair.Key] = values;
}

// this.nodeHeaders[nodeName] = headers;

return headers;
throw new System.NotImplementedException();
}

/// <summary>
Expand Down

0 comments on commit 5c571d8

Please sign in to comment.