Example #1
0
        void SaveCraddleFiles(bool newLevel)
        {
            //CradleOfRome2_e0600-n2702-h0685_2.zip
            GetLevelsFromSaveDirectory();
            _lastLevel = _currentLevel;
            if (newLevel)
            {
                if (_blitzLevelType == CradleOfRomeBlitzLevelType.Easy)
                {
                    _currentLevel.EasyLevel++;
                }
                else if (_blitzLevelType == CradleOfRomeBlitzLevelType.Normal)
                {
                    _currentLevel.NormalLevel++;
                }
                else if (_blitzLevelType == CradleOfRomeBlitzLevelType.Hard)
                {
                    _currentLevel.HardLevel++;
                }
                else
                {
                    //throw new Exception(string.Format("Error bad blitz level type \"{0}\"", gBlitzLevelType));
                    Message("Error bad blitz level type \"{0}\"", _blitzLevelType);
                }
                _currentLevel.FileNumber = 1;
            }
            else
            {
                _currentLevel.FileNumber++;
            }
            //string zipFile = string.Format("CradleOfRome2_e{0:0000}-n{1:0000}-h{2:0000}{3}.zip", gEasyLevel, gNormalLevel, gHardLevel, gFileNumber == 1 ? "" : string.Format("_{0}", gFileNumber));
            string zipFile = _currentLevel.GetFilename();

            Message("save craddle files to \"{0}\"", zipFile);
            //////////throw new Exception("error test test test test test");
            zipFile = zPath.Combine(_cradleFileSaveDirectory, zipFile);
            ZipFile zip = new ZipFile();

            if (!zDirectory.Exists(_cradleFileSaveDirectory))
            {
                zDirectory.CreateDirectory(_cradleFileSaveDirectory);
            }
            zip.AddFile(zPath.Combine(_cradleFileDirectory, "config.xml"), "");
            zip.AddFile(zPath.Combine(_cradleFileDirectory, "hiscores.xml"), "");
            zip.AddFile(zPath.Combine(_cradleFileDirectory, "profiles.xml"), "");
            zip.Save(zipFile);
            zip.Dispose();
            if (CraddleFilesSaved != null)
            {
                CraddleFilesSaved();
            }
            ArchiveOldLevels();
            //_cradleFileCopyDirectory
            if (newLevel)
            {
                CopySavedFile(zipFile);
            }
        }
Example #2
0
 public void DeleteCraddleLastLevel()
 {
     if (_currentLevel != _lastLevel)
     {
         DeleteFileLevel(_currentLevel);
     }
     DeleteFileLevel(_lastLevel);
     GetLevelsFromSaveDirectory();
     _lastLevel = _currentLevel;
 }
Example #3
0
 public void RunCraddleLastLevel()
 {
     if (_currentLevel != _lastLevel)
     {
         DeleteFileLevel(_currentLevel);
         _currentLevel = _lastLevel;
     }
     Message("Start craddle of rome 2 {0}", _lastLevel.GetFilename());
     CopyFileLevel(_lastLevel);
     Process.Start(_cradleProgram);
 }
Example #4
0
 public CradleOfRomeWatcher()
 {
     //gCradleProgram = @"C:\Logiciel\Jeux\Cradle of Rome\Cradle Of Rome 2 v1.0.4.2014-okok\Cradle Of Rome 2\CradleOfRome2.exe";
     //gCradleProgram = @"C:\$pib\game\Cradle of Rome\Cradle Of Rome 2 v1.0.4.2014-okok\Cradle Of Rome 2\CradleOfRome2.exe";
     //gCradleProgram = @"C:\pib\game\Cradle of Rome\Cradle Of Rome 2 v1.0.4.2014-okok\Cradle Of Rome 2\CradleOfRome2.exe";
     _cradleProgram              = @"C:\pib\prog\game\Cradle of Rome\Cradle Of Rome 2 v1.0.4.2014-okok\Cradle Of Rome 2\CradleOfRome2.exe";
     _cradleFileDirectory        = @"c:\Users\Pierre\AppData\Roaming\Awem\CradleOfRome2";
     _cradleFileSaveDirectory    = @"c:\Users\Pierre\AppData\Roaming\Awem\_CradleOfRome2\_copy\_06_v1.0.4.2014";
     _cradleFileArchiveDirectory = @"c:\Users\Pierre\AppData\Roaming\Awem\_CradleOfRome2\_copy\_06_v1.0.4.2014\a";
     _cradleFileCopyDirectory    = @"c:\pib\drive\google\dev_data\exe\CradleOfRome\save";
     GetLevelsFromSaveDirectory();
     _lastLevel = _currentLevel;
 }
Example #5
0
        private void CopyFileLevel(CradleOfRomeBlitzLevel level)
        {
            _fileSystemWatcher.EnableRaisingEvents = false;
            ZipFile zip = new ZipFile(zPath.Combine(_cradleFileSaveDirectory, level.GetFilename()));

            //zip["config.xml"].Extract(gCradleFileDirectory, true);
            zip["config.xml"].Extract(_cradleFileDirectory, ExtractExistingFileAction.OverwriteSilently);
            //zip["hiscores.xml"].Extract(gCradleFileDirectory, true);
            zip["hiscores.xml"].Extract(_cradleFileDirectory, ExtractExistingFileAction.OverwriteSilently);
            //zip["profiles.xml"].Extract(gCradleFileDirectory, true);
            zip["profiles.xml"].Extract(_cradleFileDirectory, ExtractExistingFileAction.OverwriteSilently);
            zip.Dispose();
            _fileSystemWatcher.EnableRaisingEvents = true;
        }
Example #6
0
        public void Start()
        {
            string filter = "*.xml";

            Stop();
            GetLevelsFromSaveDirectory();
            _lastLevel                             = _currentLevel;
            _fileState                             = CradleOfRomeFileState.None;
            _fileWatcherRunning                    = false;
            _fileSystemWatcher                     = new FileSystemWatcher();
            _fileSystemWatcher.Path                = _cradleFileDirectory;
            _fileSystemWatcher.Filter              = filter;
            _fileSystemWatcher.Changed            += new FileSystemEventHandler(FileChanged);
            _fileSystemWatcher.EnableRaisingEvents = true;
            Message("Craddle of rome 2 watcher started, blitz {0}, current level easy {1} normal {2} hard {3} number {4}", _blitzLevelType, _currentLevel.EasyLevel, _currentLevel.NormalLevel, _currentLevel.HardLevel, _currentLevel.FileNumber);
        }
Example #7
0
 private void DeleteFileLevel(CradleOfRomeBlitzLevel level)
 {
     Message("Delete craddle of rome 2 level {0}", level.GetFilename());
     zFile.Delete(zPath.Combine(_cradleFileSaveDirectory, level.GetFilename()));
 }