From 814cb38cc9b6cf21d388faf25f664038cd2d0538 Mon Sep 17 00:00:00 2001 From: in0finite Date: Sun, 21 Jul 2019 19:17:11 +0200 Subject: [PATCH] anim group can be loaded from stream reader --- .../Importing/Animation/AnimationGroup.cs | 37 +++++++++++-------- Docs/TODO.md | 2 +- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/Importing/Animation/AnimationGroup.cs b/Assets/Scripts/Importing/Animation/AnimationGroup.cs index 03ab54e2..2b09540b 100644 --- a/Assets/Scripts/Importing/Animation/AnimationGroup.cs +++ b/Assets/Scripts/Importing/Animation/AnimationGroup.cs @@ -263,26 +263,33 @@ namespace SanAndreasUnity.Importing.Animation { get { return _sGroups; } } - public static void Load(string path) + public static void Load(string path) + { + using (var reader = File.OpenText(path)) + { + LoadFromStreamReader(reader); + } + } + + public static void LoadFromStreamReader(StreamReader reader) { - using (var reader = File.OpenText(path)) + + string line; + while ((line = reader.ReadLine()) != null) { - string line; - while ((line = reader.ReadLine()) != null) + var match = _sHeaderRegex.Match(line); + if (!match.Success) continue; + + var group = new AnimationGroup(match, reader); + + if (!_sGroups.ContainsKey(group.Name)) { - var match = _sHeaderRegex.Match(line); - if (!match.Success) continue; - - var group = new AnimationGroup(match, reader); - - if (!_sGroups.ContainsKey(group.Name)) - { - _sGroups.Add(group.Name, new Dictionary()); - } - - _sGroups[group.Name].Add(group.Type, group); + _sGroups.Add(group.Name, new Dictionary()); } + + _sGroups[group.Name].Add(group.Type, group); } + } private static AnimationGroup GetInternal(string name, AnimGroup type) diff --git a/Docs/TODO.md b/Docs/TODO.md index 7c7d6173..9fa641ce 100644 --- a/Docs/TODO.md +++ b/Docs/TODO.md @@ -27,7 +27,7 @@ - Chat -- Android: touch input is required ; set default fps to 25 ; add some predefined folders in file browser ; HUD must run before other UI scripts ; +- Android: touch input is required ; set default fps to 25 ; add some predefined folders in file browser ; HUD must run before other UI scripts ; load config from resources ; - Play sounds: horn ; empty weapon slot ; ped damage ; footsteps in run and sprint states ;