@@ -17,46 +17,8 @@ public class TrackerSpriteService(OptionsFactory optionsFactory)
1717 public void LoadSprites ( )
1818 {
1919 _packs = [ ] ;
20- var path = RandomizerDirectories . TrackerSpritePath ;
21- var packFolders = Directory . EnumerateDirectories ( RandomizerDirectories . TrackerSpritePath ) ;
22- foreach ( var folder in packFolders )
23- {
24- var packName = Path . GetFileName ( folder ) ;
25-
26- if ( string . IsNullOrEmpty ( packName ) || ! File . Exists ( Path . Combine ( folder , "default_idle.png" ) ) ||
27- ! File . Exists ( Path . Combine ( folder , "default_talk.png" ) ) )
28- {
29- continue ;
30- }
31-
32- Dictionary < string , TrackerSpeechReactionImages > _reactions = [ ] ;
33-
34- foreach ( var idleImage in Directory . GetFiles ( folder , "*_idle.png" ) )
35- {
36- var talkingImage = idleImage . Replace ( "_idle.png" , "_talk.png" ) ;
37- if ( ! File . Exists ( talkingImage ) )
38- {
39- continue ;
40- }
41-
42- var reactionName = Path . GetFileName ( idleImage ) . Replace ( "_idle.png" , "" ) . ToLower ( ) ;
43- _reactions [ reactionName ] = new TrackerSpeechReactionImages
44- {
45- IdleImage = idleImage , TalkingImage = talkingImage ,
46- } ;
47- }
48-
49- _packs . Add ( new TrackerSpeechImagePack
50- {
51- Name = packName ,
52- Default = new TrackerSpeechReactionImages
53- {
54- IdleImage = Path . Combine ( folder , "default_idle.png" ) ,
55- TalkingImage = Path . Combine ( folder , "default_talk.png" ) ,
56- } ,
57- Reactions = _reactions
58- } ) ;
59- }
20+ LoadFolderPacks ( RandomizerDirectories . TrackerSpritePath , false ) ;
21+ LoadFolderPacks ( RandomizerDirectories . UserTrackerSpritePath , true ) ;
6022 }
6123
6224 public Dictionary < string , string > GetPackOptions ( )
@@ -73,4 +35,62 @@ public TrackerSpeechImagePack GetPack(string? packName = null)
7335 return _packs . FirstOrDefault ( x => x . Name == packName ) ??
7436 _packs . FirstOrDefault ( x => x . Name == "Default" ) ?? _packs . First ( ) ;
7537 }
38+
39+ private void LoadFolderPacks ( string folder , bool isUserPack )
40+ {
41+ if ( ! Directory . Exists ( folder ) )
42+ {
43+ return ;
44+ }
45+
46+ var packFolders = Directory . EnumerateDirectories ( folder ) ;
47+ foreach ( var packFolder in packFolders )
48+ {
49+ LoadPack ( packFolder , isUserPack ) ;
50+ }
51+ }
52+
53+ private void LoadPack ( string folder , bool isUserPack )
54+ {
55+ var packName = Path . GetFileName ( folder ) ;
56+
57+ if ( string . IsNullOrEmpty ( packName ) || ! File . Exists ( Path . Combine ( folder , "default_idle.png" ) ) ||
58+ ! File . Exists ( Path . Combine ( folder , "default_talk.png" ) ) )
59+ {
60+ return ;
61+ }
62+
63+ Dictionary < string , TrackerSpeechReactionImages > reactions = [ ] ;
64+
65+ foreach ( var idleImage in Directory . GetFiles ( folder , "*_idle.png" ) )
66+ {
67+ var talkingImage = idleImage . Replace ( "_idle.png" , "_talk.png" ) ;
68+ if ( ! File . Exists ( talkingImage ) )
69+ {
70+ continue ;
71+ }
72+
73+ var reactionName = Path . GetFileName ( idleImage ) . Replace ( "_idle.png" , "" ) . ToLower ( ) ;
74+ reactions [ reactionName ] = new TrackerSpeechReactionImages
75+ {
76+ IdleImage = idleImage , TalkingImage = talkingImage ,
77+ } ;
78+ }
79+
80+ if ( _packs . Any ( x => x . Name == packName ) && isUserPack )
81+ {
82+ packName += " (Custom)" ;
83+ }
84+
85+ _packs . Add ( new TrackerSpeechImagePack
86+ {
87+ Name = packName ,
88+ Default = new TrackerSpeechReactionImages
89+ {
90+ IdleImage = Path . Combine ( folder , "default_idle.png" ) ,
91+ TalkingImage = Path . Combine ( folder , "default_talk.png" ) ,
92+ } ,
93+ Reactions = reactions
94+ } ) ;
95+ }
7696}
0 commit comments