Example #1
0
        public void ExportProject(string paramFilename)
        {
            string path = paramFilename + FOCUS_TREE_PATH;

            Directory.CreateDirectory(path);
            //For each parsed focus trees
            foreach (KeyValuePair <string, string> item in
                     FocusTreeParser.ParseAllTrees(fociContainerList))
            {
                using (TextWriter tw = new StreamWriter(path + item.Key + ".txt"))
                {
                    tw.Write(item.Value);
                }
            }
            path = paramFilename + LOCALISATION_PATH;
            Directory.CreateDirectory(Path.GetDirectoryName(path));
            LocalisationContainer loct = null;

            //For each parsed localisation files
            foreach (KeyValuePair <string, string> item in
                     LocalisationParser.ParseEverything(localisationList))
            {
                //localisationList.IndexOf(loct, 0);
                //fork
                //fixed localization files save in UTF-8 with BOM format
                loct = localisationList[0];
                using (Stream stream = File.OpenWrite(path + item.Key + "_" + loct.LanguageName + ".yml")) //save in file name eg.'test_l_english.yml'
                    using (TextWriter tw = new StreamWriter(stream, new UTF8Encoding(true)))
                    {
                        tw.Write(item.Value);
                    }
            }
            path = paramFilename + EVENTS_PATH;
            Directory.CreateDirectory(Path.GetDirectoryName(path));
            //For each parsed event file
            foreach (KeyValuePair <string, string> item in
                     EventParser.ParseAllEvents(eventList))
            {
                //using (TextWriter tw = new StreamWriter(path + item.Key + ".txt"))
                //fork need to be UTF-8 with BOM
                using (TextWriter tw = new StreamWriter(path + item.Key + ".txt", false, new UTF8Encoding(true)))
                {
                    tw.Write(item.Value);
                }
            }
            //For each parsed script file
            foreach (KeyValuePair <string, string> item in
                     ScriptParser.ParseEverything(scriptList))
            {
                using (TextWriter tw = new StreamWriter(paramFilename + "\\" + item.Key + ".txt"))
                {
                    tw.Write(item.Value);
                }
            }
        }
Example #2
0
 public void UpdateDataContract(ProjectModel model)
 {
     filename           = model.Filename;
     modFolderList      = model.ListModFolders.ToList();
     preloadGameContent = model.PreloadGameContent;
     //Build foci list
     fociContainerList.Clear();
     foreach (FocusGridModel item in model.fociList)
     {
         fociContainerList.Add(new FociGridContainer(item));
     }
     //Build localization list
     localisationList.Clear();
     foreach (LocalisationModel item in model.localisationList)
     {
         localisationList.Add(new LocalisationContainer(item));
     }
     //Build events list
     eventList.Clear();
     foreach (EventTabModel item in model.eventList)
     {
         eventList.Add(new EventContainer(item));
     }
     //Build scripts list
     scriptList.Clear();
     foreach (ScriptModel item in model.scriptList)
     {
         scriptList.Add(new ScriptContainer()
         {
             IdentifierID   = item.UniqueID,
             ContainerID    = item.VisibleName,
             InternalScript = item.InternalScript,
             FileInfo       = item.FileInfo
         });
     }
     if (localisationList.Any() && model.DefaultLocale != null)
     {
         defaultLocale = localisationList.FirstOrDefault(l => l.IdentifierID
                                                         == model.DefaultLocale.UniqueID);
     }
 }