Ejemplo n.º 1
0
 static void LoadDoW2UCS()
 {
     if (File.Exists(DoW2UCSPath))
     {
         LoggingManager.SendMessage("UCSManager - UCS file for vanilla DoW2 found.");
         if (s_dow2UCS == null)
         {
             FileStream ucs = null;
             try
             {
                 ucs       = File.Open(DoW2UCSPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                 s_dow2UCS = UCSReader.Read(ucs);
             }
             catch (CopeDoW2Exception ex)
             {
                 LoggingManager.HandleException(ex);
                 UIHelper.ShowError(ex.Message);
                 ModManager.RequestAppExit(ex.Message);
             }
             finally
             {
                 if (ucs != null)
                 {
                     ucs.Close();
                 }
             }
         }
     }
     else
     {
         LoggingManager.SendMessage("UCSManager - UCS file for vanilla DoW2 not found; we might operate in some strange place other than the DoW2 directory.");
     }
 }
Ejemplo n.º 2
0
        static void LoadModUCS()
        {
            LoggingManager.SendMessage(
                "UCSManager - UCS file for current mod " + (File.Exists(ModUCSPath)
                                                                ? "found."
                                                                : "not found, will create a new one."));
            FileStream ucs = null;

            try
            {
                if (File.Exists(ModUCSPath))
                {
                    ucs      = File.Open(ModUCSPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    s_modUCS = UCSReader.Read(ucs);
                }
                else
                {
                    s_modUCS = new UCSStrings();
                }
            }
            catch (CopeDoW2Exception ex)
            {
                LoggingManager.HandleException(ex);
                UIHelper.ShowError(ex.Message);
                ModManager.RequestAppExit(ex.Message);
            }
            finally
            {
                if (ucs != null)
                {
                    ucs.Close();
                }
            }

            if (s_modUCS.NextIndex > s_nextIndex)
            {
                s_nextIndex = s_modUCS.NextIndex;
            }
            else
            {
                s_modUCS.NextIndex = s_nextIndex;
            }
            s_modUCS.StringAdded    += OnStringAdded;
            s_modUCS.StringModified += OnStringModified;
            s_modUCS.StringRemoved  += OnStringRemoved;
        }