Пример #1
0
        public void TranslateToLanguage()
        {
            CimToolBase       toolBase    = new CimToolBase(new CimToolSettings("", "TranslateToLanguageTest", modAssembly: Assembly.GetExecutingAssembly()));
            TranslationTester translation = new TranslationTester(toolBase);

            ExportTranslations.TranslationA = "";
            ExportTranslations.TranslationB = "";

            Assert.AreEqual("", ExportTranslations.TranslationA);
            Assert.AreEqual("", ExportTranslations.TranslationB);

            string xmlText = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                             "<Language xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" UniqueName=\"export\" ReadableName=\"Exported Language\">\n" +
                             "<Translations>\n" +
                             "<Translation ID=\"translateTextA\" String=\"ChangedTextA\" />\n" +
                             "<Translation ID=\"translateTextB\" String=\"Changed Text B\"/>\n" +
                             "</Translations>\n" +
                             "</Language>\n";

            Language loadedLanguage = translation.LoadFromText(new StringReader(xmlText));

            Assert.IsNotNull(loadedLanguage);
            Assert.IsTrue(translation.ManuallyLoadLanguage(loadedLanguage));
            Assert.IsTrue(translation.TranslateTo("export"), "Translate to imported language");

            Assert.AreEqual("ChangedTextA", ExportTranslations.TranslationA);
            Assert.AreEqual("Changed Text B", ExportTranslations.TranslationB);
        }
Пример #2
0
        public void SaveLanguageFile()
        {
            CimToolBase       toolBase    = new CimToolBase(new CimToolSettings("", "SaveLanguageFileTest", modAssembly: Assembly.GetExecutingAssembly()));
            TranslationTester translation = new TranslationTester(toolBase);

            translation.GenerateLanguageTemplate();
        }
Пример #3
0
        /// <summary>
        /// Handles options on the mod option panel ingame
        /// </summary>
        /// <param name="toolBase">The tool base</param>
        public ModOptionPanelUtilities(CimToolBase toolBase)
        {
            _toolBase = toolBase;
            _toolBase.DetailedLogger.Log("Init ModOptionPanelUtilities");

            _savedData = new OptionPanelSavedData();
            toolBase.XMLFileOptions.AddObjectToSave(_savedData);
        }
Пример #4
0
        public DetailedLogger(CimToolBase toolBase)
        {
            _saveTimer.Elapsed  += SaveTimer_Elapsed;
            _saveTimer.Enabled   = true;
            _saveTimer.AutoReset = true;

            _fileName = toolBase.ModSettings.ModName + "-detailed.log";

            try { System.IO.File.Delete(_fileName); }
            catch { LogError("Couldn't delete log file!"); }

            try { System.IO.File.CreateText(_fileName).Close(); }
            catch { LogError("Couldn't create new log file!"); }
        }
Пример #5
0
        public void InterpretLanguageFile()
        {
            CimToolBase       toolBase    = new CimToolBase(new CimToolSettings("", "InterpretLanguageFileTest", modAssembly: Assembly.GetExecutingAssembly()));
            TranslationTester translation = new TranslationTester(toolBase);

            string xmlText = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                             "<Language xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" UniqueName=\"export\" ReadableName=\"Exported Language\">\n" +
                             "<Translations>\n" +
                             "<Translation ID=\"translateTextA\" String=\"\" />\n" +
                             "<Translation ID=\"translateTextB\" String=\"\" />\n" +
                             "</Translations>\n" +
                             "</Language>\n";

            Language loadedLanguage = translation.LoadFromText(new StringReader(xmlText));

            Assert.IsNotNull(loadedLanguage);
        }
Пример #6
0
        /// <summary>
        /// Automatically initialises the update panel with settings from
        /// the tool base.
        /// </summary>
        /// <param name="toolBase">Your internally saved CimToolBase</param>
        public void Initialise(CimToolBase toolBase)
        {
            _savedData = new UpdatePanelSavedData();
            toolBase.XMLFileOptions.AddObjectToSave(_savedData);
            toolBase.XMLFileOptions.Load();

            m_changelogDownloader = toolBase.Changelog;
            m_updatedTitleMessage = string.Format("{0} has updated!", toolBase.ModSettings.ReadableName);

            showInitially = _savedData.lastCheckedVersion != toolBase.Version.Delimited(Utilities.Version.Limit.Revision);

            if (showInitially)
            {
                Show();
            }
            else
            {
                Hide();
            }

            m_toolBase = toolBase;
        }
Пример #7
0
 /// <summary>
 /// Handles IO between classes and the options XML file.
 /// </summary>
 /// <param name="toolBase"></param>
 public XmlFileManager(CimToolBase toolBase, XmlOptionsAttribute.OptionType optionType = XmlOptionsAttribute.OptionType.XmlFile)
 {
     m_toolBase   = toolBase;
     m_optionType = optionType;
 }
Пример #8
0
 public SaveFileManager(CimToolBase toolBase)
 {
     _toolBase   = toolBase;
     _xmlManager = new XmlFileManager(toolBase, Attributes.XmlOptionsAttribute.OptionType.SaveFile);
 }
Пример #9
0
 public Translation(CimToolBase toolBase, bool loadLanguageAutomatically = true)
 {
     _toolBase = toolBase;
     _loadLanguageAutomatically = loadLanguageAutomatically;
 }
Пример #10
0
        public Strings(CimToolBase toolBase)
        {
            _toolBase = toolBase;

            SetUpStrings();
        }
Пример #11
0
 public Version(CimToolBase toolBase)
 {
     m_toolBase = toolBase;
 }
Пример #12
0
 public NamedLogger(CimToolBase toolBase)
 {
     _toolBase = toolBase;
 }
Пример #13
0
 public TranslationTester(CimToolBase toolBase) : base(toolBase, false)
 {
 }
Пример #14
0
 public Path(CimToolBase toolBase)
 {
     m_toolBase = toolBase;
 }
Пример #15
0
 public void Initialise(CimToolBase toolBase)
 {
     m_toolBase = toolBase;
 }
Пример #16
0
 public ChangelogTest(CimToolBase settings) : base(settings)
 {
 }
Пример #17
0
 public Changelog(CimToolBase toolBase)
 {
     m_toolBase = toolBase;
 }