-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDescriptionManager.cs
More file actions
107 lines (95 loc) · 3.9 KB
/
DescriptionManager.cs
File metadata and controls
107 lines (95 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Collections.Generic;
namespace DDLCPlusAccess
{
public static class DescriptionManager
{
private static readonly Dictionary<string, Dictionary<string, string>> sectionDescriptions =
new Dictionary<string, Dictionary<string, string>>();
static DescriptionManager()
{
// Register all section description dictionaries
RegisterSection("Poems", PoemDescriptions.Descriptions);
RegisterSection("Wallpapers", WallpaperDescriptions.Descriptions);
RegisterSection("Secrets", SecretDescriptions.Descriptions);
RegisterSection("Backgrounds", BackgroundDescriptions.Descriptions);
RegisterSection("Promos", PromoDescriptions.Descriptions);
RegisterSection("CGs", CGDescriptions.Descriptions);
RegisterSection("Sketches", SketchDescriptions.Descriptions);
}
private static void RegisterSection(
string sectionName,
Dictionary<string, string> descriptions
)
{
sectionDescriptions[sectionName] = descriptions;
}
/// <summary>
/// Get description for an image by checking all sections
/// </summary>
/// <param name="imageName">The asset name of the image</param>
/// <returns>Description if found, empty string otherwise</returns>
public static string GetDescription(string imageName)
{
if (string.IsNullOrEmpty(imageName))
return "";
// Check all sections for the image
foreach (var sectionDict in sectionDescriptions.Values)
{
if (sectionDict.TryGetValue(imageName, out string description))
{
return description;
}
}
return "";
}
/// <summary>
/// Get description for an image from a specific section
/// </summary>
/// <param name="sectionName">The gallery section name</param>
/// <param name="imageName">The asset name of the image</param>
/// <returns>Description if found, empty string otherwise</returns>
public static string GetDescription(string sectionName, string imageName)
{
if (string.IsNullOrEmpty(imageName) || string.IsNullOrEmpty(sectionName))
return "";
if (sectionDescriptions.TryGetValue(sectionName, out var sectionDict))
{
if (sectionDict.TryGetValue(imageName, out string description))
{
return description;
}
}
return "";
}
/// <summary>
/// Check if an image has a description available
/// </summary>
/// <param name="imageName">The asset name of the image</param>
/// <returns>True if description exists, false otherwise</returns>
public static bool HasDescription(string imageName)
{
return !string.IsNullOrEmpty(GetDescription(imageName));
}
/// <summary>
/// Get all available sections
/// </summary>
/// <returns>List of section names</returns>
public static List<string> GetSections()
{
return new List<string>(sectionDescriptions.Keys);
}
/// <summary>
/// Get count of descriptions in a specific section
/// </summary>
/// <param name="sectionName">The gallery section name</param>
/// <returns>Number of descriptions in the section</returns>
public static int GetSectionCount(string sectionName)
{
if (sectionDescriptions.TryGetValue(sectionName, out var sectionDict))
{
return sectionDict.Count;
}
return 0;
}
}
}