Exemplo n.º 1
0
    static public string SerializeStack <T>(Stack <T> stack)
    {
        List <T> tempList = new List <T>(stack);
        string   xml      = ViNoGameSaveLoad.SerializeObject <List <T> >(tempList);

        return(xml);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Load the specified info.
    /// </summary>
    /// <param name='info'>
    /// Info.
    /// </param>
    public void Load(ViNoSaveInfo info)
    {
        VM vm = VM.Instance;

        if (vm == null)
        {
            ViNoDebugger.LogError("VM Not Found . Can't Load.");
        }


        switch (saveMethod)
        {
        case SaveMethods.COLLECT_VINO_SCENE_NODES:

            break;

        case SaveMethods.TRAVERSE_CHILDREN:
            if (destroyChildrenOnLoad)
            {
                if (theSavedPanel != null)
                {
                    ViNoGOExtensions.DestroyImmediateChildren(theSavedPanel.name);
                }
            }
            break;
        }

        ViNoGameSaveLoad.Load(info);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Save the specified info and fileName.
    /// </summary>
    /// <param name='info'>
    /// Info.
    /// </param>
    /// <param name='fileName'>
    /// File name. auto stub ".xml".
    /// If UNITY_EDITOR => Application.dataPath + fileName + ".xml".
    /// else => Application.persistentDataPath + fileName + ".xml".
    /// </param>
    static public void SaveToExternalFile(string fileName, ViNoSaveInfo info, FlagTable flagTable)
    {
        Save(info);

/*
 *              ViNoSaveData data = new ViNoSaveData();
 *              data.m_BgmName = info.m_BgmName;
 *              data.m_CurrentScenarioName = info.m_CurrentScenarioName;
 *              data.m_LoadedLevelIndex = info.m_LoadedLevelIndex;
 *              data.m_LoadedLevelName = info.m_LoadedLevelName;
 *              data.m_NodeName = info.m_NodeName;
 *              data.m_SceneXmlData = info.m_SceneXmlData;
 *              data.m_Date = info.m_Date;
 *              data.m_ScenarioDescription = info.m_ScenarioDescription;
 * //		data.m_ScenarioResourceFilePath = ScenarioNode.Instance.scenarioResourceFilePath;
 * //*/
        string xmlStr = ViNoGameSaveLoad.SerializeObject <ViNoSaveData>(info.data);

#if UNITY_WEBPLAYER
        PlayerPrefs.SetString(fileName + ".xml", xmlStr);
#else
        ViNoGameSaveLoad.CreateXML(fileName + ".xml", xmlStr);
#endif
        SaveFlagTable(fileName, flagTable);
    }
Exemplo n.º 4
0
    static public Stack <T> DeserializeStack <T>(string xml)
    {
        List <T> stackLoaded = (List <T>)ViNoGameSaveLoad.DeserializeObject <List <T> >(xml);

        stackLoaded.Reverse();
        Stack <T> retstack = new Stack <T>(stackLoaded);

        return(retstack);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Return true if the file exists.
    /// </summary>
    static public bool IsExternalSavedFileExists(string fileName)
    {
#if UNITY_WEBPLAYER
        return(PlayerPrefs.HasKey(fileName));
#else
        string dataPath = ViNoGameSaveLoad.GetDataPath();
        return(System.IO.File.Exists(dataPath + "/" + fileName));
#endif
    }
Exemplo n.º 6
0
    static public FlagTableData LoadFlagTable(string fileName)
    {
#if UNITY_WEBPLAYER
        string flagXmlStr = PlayerPrefs.GetString(fileName + "Flag.xml");
#else
        string flagXmlStr = ViNoGameSaveLoad.LoadXML(fileName + "Flag.xml");
#endif
        FlagTableData flagData = ViNoGameSaveLoad.DeserializeObject <FlagTableData>(flagXmlStr) as FlagTableData;
        return(flagData);
//		return flagData.flags;
    }
Exemplo n.º 7
0
    public override string SerializeXML(string fileName)
    {
        string path = ViNoGameSaveLoad.GetDataPath() + "/" + fileName;

        if (dlgDataList != null)
        {
            string xmlStr = ViNoGameSaveLoad.SerializeObject <List <DialogPartData> >(dlgDataList);
            ViNoGameSaveLoad.CreateXML(fileName, xmlStr);
        }
        return(path);
    }
Exemplo n.º 8
0
    void Serial()
    {
        TestData dat = new TestData();

        dat.sceneName  = sceneName;
        dat.method     = method;
        dat.withFadeIn = withFadeIn;
        string xmlStr = ViNoGameSaveLoad.SerializeObject <TestData>(dat);

        ViNoGameSaveLoad.CreateXML(name + ".xml", xmlStr);
    }
Exemplo n.º 9
0
    void Deseri()
    {
        string xmlStr = ViNoGameSaveLoad.LoadXML(name + ".xml");

        TestData dat = ViNoGameSaveLoad.DeserializeObject <TestData>(xmlStr) as TestData;

        sceneName  = dat.sceneName;
        method     = dat.method;
        withFadeIn = dat.withFadeIn;

        ViNoGameSaveLoad.CreateXML(name + ".xml", xmlStr);
    }
Exemplo n.º 10
0
    static public void LoadFromExternalFile(string fileName)
    {
#if UNITY_EDITOR
        _FileLocation = Application.dataPath;
#else
        _FileLocation = Application.persistentDataPath;
#endif
        _FileName = fileName + ".xml";

        string xmlData = LoadXML();

        ViNoGameSaveLoad.LoadSceneFromXmlString(xmlData);
    }
Exemplo n.º 11
0
    static public void SaveFlagTable(string fileName, FlagTable flagTable)
    {
        if (flagTable != null)
        {
            FlagTableData flagData = new FlagTableData();
            flagData.flags        = flagTable.flags;
            flagData.stringValues = flagTable.stringValues;

            string flagXmlStr = ViNoGameSaveLoad.SerializeObject <FlagTableData>(flagData);
#if UNITY_WEBPLAYER
            PlayerPrefs.SetString(fileName + "Flag.xml", flagXmlStr);
#else
            ViNoGameSaveLoad.CreateXML(fileName + "Flag.xml", flagXmlStr);
#endif
        }
    }
Exemplo n.º 12
0
    static public void LoadDataFromStorage(string fileName, ref ViNoSaveInfo reloadedInfo)
    {
//		Debug.Log( "FileName:" + fileName);
#if UNITY_WEBPLAYER
        string xmlStr = PlayerPrefs.GetString(fileName + ".xml");          //ViNoGameSaveLoad.LoadXML( fileName + ".xml" );
#else
        string xmlStr = ViNoGameSaveLoad.LoadXML(fileName + ".xml");
#endif
        ViNoSaveData saveData = ViNoGameSaveLoad.DeserializeObject <ViNoSaveData>(xmlStr) as ViNoSaveData;

        reloadedInfo.data.m_BgmName                  = saveData.m_BgmName;
        reloadedInfo.data.m_CurrentScenarioName      = saveData.m_CurrentScenarioName;
        reloadedInfo.data.m_LoadedLevelIndex         = saveData.m_LoadedLevelIndex;
        reloadedInfo.data.m_LoadedLevelName          = saveData.m_LoadedLevelName;
        reloadedInfo.data.m_NodeName                 = saveData.m_NodeName;
        reloadedInfo.data.m_SceneXmlData             = saveData.m_SceneXmlData;
        reloadedInfo.data.m_ScenarioResourceFilePath = saveData.m_ScenarioResourceFilePath;
        reloadedInfo.data.m_Date = saveData.m_Date;
        reloadedInfo.data.m_ScenarioDescription = saveData.m_ScenarioDescription;
    }
    static public void DrawXMLImportField(DialogPartNode targetNode)
    {
        GUILayout.BeginHorizontal();

        GUILayout.Space(30f);

        targetNode.xmlData = EditorGUILayout.ObjectField("XMLData", targetNode.xmlData, typeof(TextAsset), false) as TextAsset;

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Export"))
        {
            string fileName = targetNode.name + ".xml";
            targetNode.SerializeXML(fileName);
            string path = ViNoGameSaveLoad.GetDataPath() + "/" + fileName;
            AssetDatabase.Refresh();

            Debug.Log("Saved as Xml file path:" + path);
        }

        GUI.enabled = (targetNode.xmlData != null) ? true : false;

        if (GUILayout.Button("Import"))
        {
            if (EditorUtility.DisplayDialog("Overwrite ?", "Are you sure you really want to import?"
                                            , "Yes", "Cancel"))
            {
                targetNode.DeserializeXML(targetNode.xmlData.text);
                m_ViewMode = 0;
            }
        }

        GUI.enabled = true;

        EditorGUILayout.EndHorizontal();
    }
Exemplo n.º 14
0
 static public void LoadSceneXMLFromTextAsset(TextAsset txt)
 {
     ViNoGameSaveLoad.LoadSceneFromXmlString(txt.text);
 }
Exemplo n.º 15
0
    public override void OnInspectorGUI()
    {
        Scene targetData = target as Scene;

        DrawDefaultInspector();

#if false
        if (targetData.sceneNodesData == null || targetData.sceneNodesData.Length == 0)
        {
            targetData.sceneNodesData    = new SceneData.SceneNodeData[1];
            targetData.sceneNodesData[0] = new SceneData.SceneNodeData();
        }

        for (int i = 0; i < targetData.sceneNodesData.Length; i++)
        {
            DrawSceneNodeField(targetData.sceneNodesData[i], i * 220);
        }
#endif

#if true
        GUICommon.DrawLineSpace(5f, 5f);
        GUICommon.DrawLineSpace(5f, 5f);
#if false
        if (GUILayout.Button("Save as XML"))
        {
            string xmlData = ViNoGameSaveLoad.SerializeObject <SceneData.SceneNodeData[]>(targetData.sceneNodesData);
            ViNoGameSaveLoad.CreateXML(targetData.name + ".xml", xmlData);
            AssetDatabase.Refresh();
            EditorUtility.FocusProjectWindow();
        }

        EditorGUILayout.BeginHorizontal();

        sceneXmlFile = EditorGUILayout.ObjectField(sceneXmlFile, typeof(TextAsset), false) as TextAsset;
        GUI.enabled  = (sceneXmlFile == null) ? false : true;

        if (GUILayout.Button("Load XML"))
        {
            targetData.sceneNodesData = ViNoGameSaveLoad.DeserializeObject <SceneData.SceneNodeData[]>(sceneXmlFile.text) as SceneData.SceneNodeData[];
            EditorUtility.SetDirty(targetData);
        }

        GUI.enabled = true;

        EditorGUILayout.EndHorizontal();
#endif

        if (!Application.isPlaying)
        {
            GUI.enabled = false;
            EditorGUILayout.HelpBox("Save Scene : PlayMode Only. \n Save under the \"ADVScene\" objects data.", MessageType.Info);
        }

        EditorGUILayout.BeginHorizontal();

//			GUILayout.Space( 20f );


        if (GUILayout.Button("Save Scene", GUILayout.Height(44f)))
        {
//				if( EditorUtility.DisplayDialog( "Warning" , "Do you really want to overwrite ?" , "ok" , "cancel" ) ){
            ViNoSceneManager.FindInstance();
            ViNoSceneManager.Instance.SaveSceneNodes();
            targetData.sceneNodesData = ViNoSceneManager.Instance.GetSceneData().m_DataArray;
//				}
//				Application.CaptureScreenshot( "Assets/A Scene.png" );
        }

        GUI.enabled = true;

        if (GUILayout.Button("Load Scene", GUILayout.Height(44f)))
        {
//				if( EditorUtility.DisplayDialog( "Warning" , "Do you really want to apply ?" , "ok" , "cancel" ) ){
            Undo.RegisterSceneUndo("Load Scene");
            SceneCreator.Create(targetData);
//				}
        }

//			GUILayout.Space( 20f );

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.HelpBox("Clear under the \"ADVScene\" objects", MessageType.Info);

        if (GUILayout.Button("Clear Scene", GUILayout.Height(44f)))
        {
            ViNoSceneManager sm = GameObject.FindObjectOfType(typeof(ViNoSceneManager)) as ViNoSceneManager;
            SceneCreator.DestroySceneImmediate(sm.theSavedPanel);
        }
#endif
    }
Exemplo n.º 16
0
 public override void DeserializeXML(string xmlStr)
 {
     dlgDataList = (List <DialogPartData>)ViNoGameSaveLoad.DeserializeObject <List <DialogPartData> >(xmlStr);
 }
Exemplo n.º 17
0
 static public void Load(ViNoSaveInfo info)
 {
     ViNoGameSaveLoad.LoadSceneFromXmlString(info.data.m_SceneXmlData);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Return XML string of Nodes Data.
 /// </summary>
 public string Save()
 {
     return(ViNoGameSaveLoad.Save());
 }