Skip to content
Snippets Groups Projects
Commit a4008a5c authored by Marco Zimmer's avatar Marco Zimmer
Browse files

JSON but not possessed?

parent 23ce7948
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ public class GlobalBehaviour : MonoBehaviour ...@@ -36,7 +36,7 @@ public class GlobalBehaviour : MonoBehaviour
void Awake() void Awake()
{ {
//GenerateDemoFiles.GenerateAll(); // GenerateDemoFiles.GenerateAll();
hintAnimationStartColor = _hintAnimationStartColor; hintAnimationStartColor = _hintAnimationStartColor;
hintAnimationEndColor = _hintAnimationEndColor; hintAnimationEndColor = _hintAnimationEndColor;
......
...@@ -211,17 +211,22 @@ public FactOrganizer(bool invoke = false) ...@@ -211,17 +211,22 @@ public FactOrganizer(bool invoke = false)
/// <param name="source">instance to be parsed</param> /// <param name="source">instance to be parsed</param>
/// <param name="invoke">see <see cref="invoke"/></param> /// <param name="invoke">see <see cref="invoke"/></param>
/// <param name="old_to_new">generated to map <c>Key</c> <see cref="Fact.Id"/> of <paramref name="source"/> to corresponding <c>Value</c> <see cref="Fact.Id"/> of <paramref name="target"/></param>. /// <param name="old_to_new">generated to map <c>Key</c> <see cref="Fact.Id"/> of <paramref name="source"/> to corresponding <c>Value</c> <see cref="Fact.Id"/> of <paramref name="target"/></param>.
protected static void ReInitializeFactOrganizer(ref FactOrganizer target, FactOrganizer source, bool invoke, out Dictionary<string, string> old_to_new) protected static T ReInitializeFactOrganizer<T>
(FactOrganizer source, bool invoke, out Dictionary<string, string> old_to_new)
where T : FactOrganizer, new()
{ {
// TODO: other strategy needed when MMT save/load supported // TODO: other strategy needed when MMT save/load supported
// map old URIs to new ones // map old URIs to new ones
old_to_new = new Dictionary<string, string>(); old_to_new = new Dictionary<string, string>();
// initiate // initiate
target.invoke = invoke; T target = new T()
target.MaxLabelId = source.MaxLabelId; {
target.UnusedLabelIds = source.UnusedLabelIds; invoke = invoke,
target.FactDict = new Dictionary<string, Fact>(); MaxLabelId = source.MaxLabelId,
UnusedLabelIds = source.UnusedLabelIds,
FactDict = new Dictionary<string, Fact>(),
};
// work Workflow // work Workflow
foreach (var sn in source.Workflow) foreach (var sn in source.Workflow)
...@@ -259,8 +264,10 @@ protected static void ReInitializeFactOrganizer(ref FactOrganizer target, FactOr ...@@ -259,8 +264,10 @@ protected static void ReInitializeFactOrganizer(ref FactOrganizer target, FactOr
target.undo(); target.undo();
target.soft_resetted = source.soft_resetted; target.soft_resetted = source.soft_resetted;
return target;
} }
/// <summary> /// <summary>
/// wrappes <c><see cref="FactDict"/>[<paramref name="id"/>]</c> /// wrappes <c><see cref="FactDict"/>[<paramref name="id"/>]</c>
/// <seealso cref="ContainsKey(string)"/> /// <seealso cref="ContainsKey(string)"/>
...@@ -697,7 +704,7 @@ public static bool load(ref FactOrganizer set, bool draw, string name, List<Dire ...@@ -697,7 +704,7 @@ public static bool load(ref FactOrganizer set, bool draw, string name, List<Dire
return false; return false;
FactOrganizer de_json = JSONManager.ReadFromJsonFile<FactOrganizer>(path); FactOrganizer de_json = JSONManager.ReadFromJsonFile<FactOrganizer>(path);
ReInitializeFactOrganizer(ref set, de_json, draw, out old_to_new); set = ReInitializeFactOrganizer<FactOrganizer>(de_json, draw, out old_to_new);
set.path = path; set.path = path;
return true; return true;
......
...@@ -177,16 +177,9 @@ public static bool load(ref SolutionOrganizer set, bool draw, string name, List< ...@@ -177,16 +177,9 @@ public static bool load(ref SolutionOrganizer set, bool draw, string name, List<
if (!loadable) if (!loadable)
return false; return false;
FactOrganizer save = StageStatic.stage.factState;
StageStatic.stage.factState = new SolutionOrganizer(false) as FactOrganizer;
SolutionOrganizer JsonTmp = JSONManager.ReadFromJsonFile <SolutionOrganizer> (path); SolutionOrganizer JsonTmp = JSONManager.ReadFromJsonFile <SolutionOrganizer> (path);
ReInitializeFactOrganizer(ref StageStatic.stage.player_record.factState, JsonTmp, draw, out Dictionary<string, string> old_to_new); set = ReInitializeFactOrganizer<SolutionOrganizer>(JsonTmp, draw, out Dictionary<string, string> old_to_new);
set = (SolutionOrganizer)StageStatic.stage.factState;
set.path = path; set.path = path;
StageStatic.stage.factState = save;
foreach (var element in JsonTmp.ValidationSet) foreach (var element in JsonTmp.ValidationSet)
// Parse and add // Parse and add
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment