示例#1
0
        public static void loadIntoEditorWindow(string savepath, MainWindow _parent)
        {
            TH1SaveStructure loadingSave = new TH1SaveStructure();

            log("Loading Into Editor \"" + savepath + "\"", LC_PRIMARY);

            // Pass On The Databases
            loadingSave.db = _parent.db;
            loadingSave.readSaveFile(savepath);

            if (loadingSave.lastError == 0)
            {
                EditorWindow eWin = new EditorWindow();
                MainWindow   mWin = _parent;
                eWin._save = loadingSave;

                // Loading Collections
                eWin._mainWindow = mWin;
                eWin.Show();
                log("File Loaded Successfully", LC_SUCCESS);
            }
            else
            {
                MessageBox.Show("Error " + loadingSave.lastError.ToString() + ": " + loadingSave.lastErrorMsg);
                log("Error " + loadingSave.lastError.ToString() + ": " + loadingSave.lastErrorMsg);
            }
        }
        private void loadFilesIntoList(string[] files)
        {
            foreach (string filename in files)
            {
                TH1SaveStructure newsave = new TH1SaveStructure();
                Functions.log("Reading " + filename, Functions.LC_PRIMARY);

                newsave.db = this.db;
                newsave.readSaveFile(filename);

                if (newsave.lastError == 0)
                {
                    if (!newsave.hashVerified)
                    {
                        Functions.log("Save file contains an invalid hash", Functions.LC_WARNING);
                    }
                    Functions.log("File Read OK! Importing Character..");
                    Functions.importCharSave(newsave);
                    Functions.log("Character Imported.", Functions.LC_SUCCESS);
                }
                else
                {
                    Functions.log("Error " + newsave.lastError.ToString() + ": " + newsave.lastErrorMsg, Functions.LC_CRITICAL); // FYI
                }
            }
        }
示例#3
0
        public static void importCharSave(TH1SaveStructure save)
        {
            bool alreadylisted = false;

            Directory.CreateDirectory("saves");

            if (save.lastError == 0)
            {
                // Generate list
                ObservableCollection <CharListImages> list = (ObservableCollection <CharListImages>)MainWindow._CharactersUC.lstCharacters.ItemsSource;
                CharListImages item = new CharListImages();
                TH1Helper      ca   = new TH1Helper();

                // Generate item
                item.hash       = BitConverter.ToString(save.hash).Replace("-", "");
                item.name       = save.character.name;
                item.exp        = save.character.exp.ToString("N0");
                item.level      = save.character.level;
                item.importedon = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                item.bounty     = save.character.bounty.ToString("N0");
                item.cclass     = ca.classNamesArray[save.character.charClass];
                item.calign     = ca.alignmentNamesArray[save.character.alignment];
                item.image      = classToImage(save.character.charClass);
                item.lastplayed = save.character.lastSave.ToString();

                // Backup save
                item.path = @"saves\" + item.hash + ".th1";
                save.writeSaveFile(item.path);

                // Check if already in the list
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].hash == item.hash)
                    {
                        alreadylisted = true;
                        list[i]       = item;
                    }
                }

                // Save list
                if (!alreadylisted)
                {
                    list.Insert(0, item);
                }
            }
        }