private void PrepareSavesList() { selectedIndex = -1; string directoryPath = workWithTerrains ? GetTerrainsPath() : GetSavesPath(); string CutName(string s) { int lastSlashPos = s.LastIndexOf('\\'); // в редакторе так if (lastSlashPos == -1) { lastSlashPos = s.LastIndexOf('/'); } return(s.Substring(lastSlashPos + 1, s.Length - lastSlashPos - 5)); // от последнего слеша до ".sav" } if (saveMode) { //SAVING if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); savenames = new string[1]; IDs = new int[1]; } else { var sn = Directory.GetFiles(directoryPath, "*." + (workWithTerrains ? TERRAIN_FNAME_EXTENSION : SAVE_FNAME_EXTENSION)); int len = sn.Length; savenames = new string[len + 1]; IDs = new int[len + 1]; int j; for (int i = 0; i < sn.Length; i++) { j = i + 1; savenames[j] = CutName(sn[i]); IDs[j] = j; } sn = null; } savenames[0] = Localization.GetPhrase(LocalizedPhrase.CreateNewSave); IDs[0] = NEW_SAVE_ID; saveLoadButtonText.text = Localization.GetWord(LocalizedWord.Save); } else { // LOADING if (!Directory.Exists(directoryPath)) { savenames = null; IDs = null; } else { savenames = Directory.GetFiles(directoryPath, "*." + (workWithTerrains ? TERRAIN_FNAME_EXTENSION : SAVE_FNAME_EXTENSION)); int len = savenames.Length; if (len > 0) { IDs = new int[len]; for (int i = 0; i < len; i++) { IDs[i] = i + 1; savenames[i] = CutName(savenames[i]); } } } if (savenames.Length == 0) { listController.ChangeEmptyLabelText(Localization.GetPhrase(LocalizedPhrase.NoSavesFound)); savenames = null; IDs = null; } saveLoadButtonText.text = Localization.GetWord(LocalizedWord.Load); } listController.PrepareList(this); }