/// <summary> /// Bakes all assets from the "Work files" directory specified in the flags. /// </summary> /// <param name="conversionFlags">Chooses which asset type to bake</param> public static void RunIndexing(DataManager.DataType conversionFlags) { foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (type != DataManager.DataType.All && (conversionFlags & type) != DataManager.DataType.None) { IndexNamedData(DataManager.DATA_PATH + type.ToString() + "/"); } } }
public static void Reserialize(DataManager.DataType conversionFlags) { foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (type != DataManager.DataType.All && (conversionFlags & type) != DataManager.DataType.None) { ReserializeData(DataManager.DATA_PATH + type.ToString() + "/", DataManager.DATA_EXT); } } }
public static void RunExtraIndexing(DataManager.DataType conversionFlags) { //index extra based on triggers foreach (BaseData baseData in DataManager.Instance.UniversalData) { if ((baseData.TriggerType & conversionFlags) != DataManager.DataType.None) { baseData.ReIndex(); DataManager.SaveData(PathMod.ModPath(DataManager.MISC_PATH + baseData.FileName + DataManager.DATA_EXT), baseData); } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is int idx) { DataManager.DataType dataType = (DataManager.DataType)Int32.Parse((string)parameter); EntryDataIndex nameIndex = DataManager.Instance.DataIndices[dataType]; if (idx >= 0 && idx < nameIndex.Count) { return(nameIndex.Entries[idx].Name.ToLocal()); } return("---"); } return(value); }
private void OpenList(DataManager.DataType dataType, GetEntry entryOp, CreateEntry createOp) { DataList choices = new DataList(); choices.Text = dataType.ToString(); string[] entries = DataManager.Instance.DataIndices[dataType].GetLocalStringArray(true); choices.AddEntries(entries); choices.SelectedOKEvent = () => { if (choices.ChosenEntry > -1) { ElementForm editor = new ElementForm(); int entryNum = choices.ChosenEntry; editor.Text = entries[entryNum]; IEntryData data = entryOp(entryNum); editor.Text = data.ToString();//data.GetType().ToString() + "#" + entryNum; DataEditor.LoadDataControls(data, editor.ControlPanel); editor.OnOK += (object okSender, EventArgs okE) => { object obj = data; DataEditor.SaveDataControls(ref obj, editor.ControlPanel); data = (IEntryData)obj; DataManager.SaveData(entryNum, dataType.ToString(), data); DataManager.Instance.ClearCache(dataType); IEntryData entryData = ((IEntryData)data); EntrySummary entrySummary = entryData.GenerateEntrySummary(); DataManager.Instance.DataIndices[dataType].Entries[entryNum] = entrySummary; DataManager.Instance.SaveIndex(dataType); choices.ModifyEntry(entryNum, entrySummary.GetLocalString(true)); editor.Close(); }; editor.OnCancel += (object okSender, EventArgs okE) => { editor.Close(); }; editor.Show(); } }; choices.SelectedAddEvent = () => { ElementForm editor = new ElementForm(); int entryNum = DataManager.Instance.DataIndices[dataType].Entries.Count; editor.Text = "New " + dataType.ToString(); IEntryData data = createOp(); editor.Text = data.ToString();//data.GetType().ToString() + "#" + entryNum; DataEditor.LoadDataControls(data, editor.ControlPanel); editor.OnOK += (object okSender, EventArgs okE) => { object obj = data; DataEditor.SaveDataControls(ref obj, editor.ControlPanel); data = (IEntryData)obj; DataManager.SaveData(entryNum, dataType.ToString(), data); DataManager.Instance.ClearCache(dataType); IEntryData entryData = ((IEntryData)data); EntrySummary entrySummary = entryData.GenerateEntrySummary(); DataManager.Instance.DataIndices[dataType].Entries.Add(entrySummary); DataManager.Instance.SaveIndex(dataType); entries = DataManager.Instance.DataIndices[dataType].GetLocalStringArray(true); choices.AddEntry(entrySummary.GetLocalString(true)); editor.Close(); }; editor.OnCancel += (object okSender, EventArgs okE) => { editor.Close(); }; editor.Show(); }; choices.Show(); }
private void reload(DataManager.DataType dataType) { lock (GameBase.lockObj) { if (dataType == DataManager.DataType.All) { DevGraphicsManager.ClearCaches(); } ViewModels.DevFormViewModel devViewModel = (ViewModels.DevFormViewModel) this.DataContext; if (dataType == DataManager.DataType.All) { devViewModel.Game.HideSprites = DataManager.Instance.HideChars; devViewModel.Game.HideObjects = DataManager.Instance.HideObjects; } if ((dataType & DataManager.DataType.Skill) != DataManager.DataType.None) { string[] skill_names = DataManager.Instance.DataIndices[DataManager.DataType.Skill].GetLocalStringArray(); devViewModel.Game.Skills.Clear(); for (int ii = 0; ii < skill_names.Length; ii++) { devViewModel.Game.Skills.Add(ii.ToString("D3") + ": " + skill_names[ii]); } devViewModel.Game.ChosenSkill = -1; devViewModel.Game.ChosenSkill = Math.Min(Math.Max(GetConfig("SkillChoice", 0), 0), devViewModel.Game.Skills.Count - 1); } if ((dataType & DataManager.DataType.Intrinsic) != DataManager.DataType.None) { string[] intrinsic_names = DataManager.Instance.DataIndices[DataManager.DataType.Intrinsic].GetLocalStringArray(); devViewModel.Game.Intrinsics.Clear(); for (int ii = 0; ii < intrinsic_names.Length; ii++) { devViewModel.Game.Intrinsics.Add(ii.ToString("D3") + ": " + intrinsic_names[ii]); } devViewModel.Game.ChosenIntrinsic = -1; devViewModel.Game.ChosenIntrinsic = Math.Min(Math.Max(GetConfig("IntrinsicChoice", 0), 0), devViewModel.Game.Intrinsics.Count - 1); } if ((dataType & DataManager.DataType.Status) != DataManager.DataType.None) { string[] status_names = DataManager.Instance.DataIndices[DataManager.DataType.Status].GetLocalStringArray(); devViewModel.Game.Statuses.Clear(); for (int ii = 0; ii < status_names.Length; ii++) { devViewModel.Game.Statuses.Add(ii.ToString("D3") + ": " + status_names[ii]); } devViewModel.Game.ChosenStatus = -1; devViewModel.Game.ChosenStatus = Math.Min(Math.Max(GetConfig("StatusChoice", 0), 0), devViewModel.Game.Statuses.Count - 1); } if ((dataType & DataManager.DataType.Item) != DataManager.DataType.None) { string[] item_names = DataManager.Instance.DataIndices[DataManager.DataType.Item].GetLocalStringArray(); devViewModel.Game.Items.Clear(); for (int ii = 0; ii < item_names.Length; ii++) { devViewModel.Game.Items.Add(ii.ToString("D4") + ": " + item_names[ii]); } devViewModel.Game.ChosenItem = -1; devViewModel.Game.ChosenItem = Math.Min(Math.Max(GetConfig("ItemChoice", 0), 0), devViewModel.Game.Items.Count - 1); } if ((dataType & DataManager.DataType.Monster) != DataManager.DataType.None) { string[] monster_names = DataManager.Instance.DataIndices[DataManager.DataType.Monster].GetLocalStringArray(); devViewModel.Player.Monsters.Clear(); for (int ii = 0; ii < monster_names.Length; ii++) { devViewModel.Player.Monsters.Add(ii.ToString("D3") + ": " + monster_names[ii]); } devViewModel.Player.ChosenMonster = -1; devViewModel.Player.ChosenMonster = 0; devViewModel.Player.ChosenForm = -1; devViewModel.Player.ChosenForm = 0; string[] skin_names = DataManager.Instance.DataIndices[DataManager.DataType.Skin].GetLocalStringArray(); devViewModel.Player.Skins.Clear(); for (int ii = 0; ii < DataManager.Instance.DataIndices[DataManager.DataType.Skin].Count; ii++) { devViewModel.Player.Skins.Add(skin_names[ii]); } devViewModel.Player.ChosenSkin = -1; devViewModel.Player.ChosenSkin = 0; devViewModel.Player.Genders.Clear(); for (int ii = 0; ii < 3; ii++) { devViewModel.Player.Genders.Add(((Gender)ii).ToString()); } devViewModel.Player.ChosenGender = -1; devViewModel.Player.ChosenGender = 0; } if (dataType == DataManager.DataType.All) { int globalIdle = GraphicsManager.GlobalIdle; devViewModel.Player.Anims.Clear(); for (int ii = 0; ii < GraphicsManager.Actions.Count; ii++) { devViewModel.Player.Anims.Add(GraphicsManager.Actions[ii].Name); } devViewModel.Player.ChosenAnim = -1; devViewModel.Player.ChosenAnim = globalIdle; } if ((dataType & DataManager.DataType.Zone) != DataManager.DataType.None) { string[] dungeon_names = DataManager.Instance.DataIndices[DataManager.DataType.Zone].GetLocalStringArray(); devViewModel.Travel.Zones.Clear(); for (int ii = 0; ii < dungeon_names.Length; ii++) { devViewModel.Travel.Zones.Add(ii.ToString("D2") + ": " + dungeon_names[ii]); } devViewModel.Travel.ChosenZone = -1; devViewModel.Travel.ChosenZone = Math.Min(Math.Max(GetConfig("ZoneChoice", 0), 0), devViewModel.Travel.Zones.Count - 1); devViewModel.Travel.ChosenStructure = -1; devViewModel.Travel.ChosenStructure = Math.Min(Math.Max(GetConfig("StructChoice", 0), 0), devViewModel.Travel.Structures.Count - 1); devViewModel.Travel.ChosenFloor = -1; devViewModel.Travel.ChosenFloor = Math.Min(Math.Max(GetConfig("FloorChoice", 0), 0), devViewModel.Travel.Floors.Count - 1); devViewModel.Travel.ChosenGround = -1; devViewModel.Travel.ChosenGround = Math.Min(Math.Max(GetConfig("GroundChoice", 0), 0), devViewModel.Travel.Grounds.Count - 1); } if (dataType == DataManager.DataType.All) { devViewModel.Mods.UpdateMod(); } LoadComplete = true; } }
void IRootEditor.ReloadData(DataManager.DataType dataType) { ExecuteOrInvoke(() => { reload(dataType); }); }
private void OpenList(DataManager.DataType dataType, GetEntry entryOp, CreateEntry createOp) { lock (GameBase.lockObj) { DataListFormViewModel choices = new DataListFormViewModel(); choices.Name = dataType.ToString(); string[] entries = DataManager.Instance.DataIndices[dataType].GetLocalStringArray(true); choices.SetEntries(entries); choices.SelectedOKEvent += () => { if (choices.SearchList.InternalIndex > -1) { lock (GameBase.lockObj) { int entryNum = choices.SearchList.InternalIndex; IEntryData data = entryOp(entryNum); Views.DataEditForm editor = new Views.DataEditForm(); editor.Title = DataEditor.GetWindowTitle(String.Format("{0} #{1:D3}", dataType.ToString(), entryNum), data.Name.ToLocal(), data, data.GetType()); DataEditor.LoadDataControls(data, editor.ControlPanel); editor.SelectedOKEvent += () => { lock (GameBase.lockObj) { object obj = data; DataEditor.SaveDataControls(ref obj, editor.ControlPanel); DataManager.Instance.ContentChanged(dataType, entryNum, (IEntryData)obj); string newName = DataManager.Instance.DataIndices[dataType].Entries[entryNum].GetLocalString(true); choices.ModifyEntry(entryNum, newName); editor.Close(); } }; editor.SelectedCancelEvent += () => { editor.Close(); }; editor.Show(); } } }; choices.SelectedAddEvent += () => { lock (GameBase.lockObj) { int entryNum = DataManager.Instance.DataIndices[dataType].Entries.Count; IEntryData data = createOp(); Views.DataEditForm editor = new Views.DataEditForm(); editor.Title = DataEditor.GetWindowTitle(String.Format("{0} #{1:D3}", dataType.ToString(), entryNum), data.Name.ToLocal(), data, data.GetType()); data.ToString(); DataEditor.LoadDataControls(data, editor.ControlPanel); editor.SelectedOKEvent += () => { lock (GameBase.lockObj) { object obj = data; DataEditor.SaveDataControls(ref obj, editor.ControlPanel); data = (IEntryData)obj; DataManager.Instance.ContentChanged(dataType, entryNum, (IEntryData)obj); string newName = DataManager.Instance.DataIndices[dataType].Entries[entryNum].GetLocalString(true); choices.AddEntry(newName); editor.Close(); } }; editor.SelectedCancelEvent += () => { editor.Close(); }; editor.Show(); } }; choices.SelectedReindexEvent += () => { lock (GameBase.lockObj) { DevHelper.RunIndexing(dataType); DevHelper.RunExtraIndexing(dataType); DataManager.Instance.LoadIndex(dataType); DataManager.Instance.LoadUniversalData(); DataManager.Instance.ClearCache(dataType); DiagManager.Instance.DevEditor.ReloadData(dataType); string[] entries = DataManager.Instance.DataIndices[dataType].GetLocalStringArray(true); choices.SetEntries(entries); } }; Views.DataListForm dataListForm = new Views.DataListForm { DataContext = choices, }; dataListForm.Show(); } }
public void ReloadData(DataManager.DataType dataType) { }
static void Main() { InitDllMap(); //SetProcessDPIAware(); //TODO: figure out how to set this switch in appconfig AppContext.SetSwitch("Switch.System.Runtime.Serialization.SerializationGuard.AllowFileWrites", true); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; string[] args = Environment.GetCommandLineArgs(); PathMod.InitExePath(args[0]); DiagManager.InitInstance(); DiagManager.Instance.CurSettings = DiagManager.Instance.LoadSettings(); DiagManager.Instance.LoadModSettings(); DiagManager.Instance.UpgradeBinder = new UpgradeBinder(); try { DiagManager.Instance.LogInfo("========================================="); DiagManager.Instance.LogInfo(String.Format("SESSION STARTED: {0}", String.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now))); DiagManager.Instance.LogInfo("Version: " + Versioning.GetVersion().ToString()); DiagManager.Instance.LogInfo(Versioning.GetDotNetInfo()); DiagManager.Instance.LogInfo("========================================="); bool logInput = true; bool guideBook = false; bool guideCsv = false; GraphicsManager.AssetType convertAssets = GraphicsManager.AssetType.None; DataManager.DataType convertIndices = DataManager.DataType.None; DataManager.DataType reserializeIndices = DataManager.DataType.None; string langArgs = ""; bool dev = false; string quest = ""; List <string> mod = new List <string>(); bool buildQuest = false; string playInputs = null; for (int ii = 1; ii < args.Length; ii++) { if (args[ii] == "-dev") { dev = true; } else if (args[ii] == "-play" && args.Length > ii + 1) { playInputs = args[ii + 1]; ii++; } else if (args[ii] == "-lang" && args.Length > ii + 1) { langArgs = args[ii + 1]; ii++; } else if (args[ii] == "-nolog") { logInput = false; } else if (args[ii] == "-guide") { guideBook = true; } else if (args[ii] == "-csv") { guideCsv = true; } else if (args[ii] == "-asset") { PathMod.ASSET_PATH = Path.GetFullPath(args[ii + 1]); ii++; } else if (args[ii] == "-raw") { PathMod.DEV_PATH = Path.GetFullPath(args[ii + 1]); ii++; } else if (args[ii] == "-quest") { quest = args[ii + 1]; ii++; } else if (args[ii] == "-mod") { int jj = 1; while (args.Length > ii + jj) { if (args[ii + jj].StartsWith("-")) { break; } else { mod.Add(args[ii + jj]); } jj++; } ii += jj - 1; } else if (args[ii] == "-build") { buildQuest = true; ii++; } else if (args[ii] == "-convert") { int jj = 1; while (args.Length > ii + jj) { GraphicsManager.AssetType conv = GraphicsManager.AssetType.None; foreach (GraphicsManager.AssetType type in Enum.GetValues(typeof(GraphicsManager.AssetType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != GraphicsManager.AssetType.None) { convertAssets |= conv; } else { break; } jj++; } ii += jj - 1; } else if (args[ii] == "-index") { int jj = 1; while (args.Length > ii + jj) { DataManager.DataType conv = DataManager.DataType.None; foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != DataManager.DataType.None) { convertIndices |= conv; } else { break; } jj++; } ii += jj - 1; } else if (args[ii] == "-reserialize") { int jj = 1; while (args.Length > ii + jj) { DataManager.DataType conv = DataManager.DataType.None; foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != DataManager.DataType.None) { reserializeIndices |= conv; } else { break; } jj++; } ii += jj - 1; } } DiagManager.Instance.SetupGamepad(); GraphicsManager.InitParams(); DiagManager.Instance.DevMode = dev; if (quest != "") { ModHeader header = PathMod.GetModDetails(Path.Combine(PathMod.MODS_PATH, quest)); if (header.IsValid()) { PathMod.Quest = header; DiagManager.Instance.LogInfo(String.Format("Loaded quest \"{0}\".", quest)); } else { DiagManager.Instance.LogInfo(String.Format("Cannot find quest \"{0}\" in {1}. Falling back to base game.", quest, PathMod.MODS_PATH)); } } if (mod.Count > 0) { List <ModHeader> workingMods = new List <ModHeader>(); for (int ii = 0; ii < mod.Count; ii++) { ModHeader header = PathMod.GetModDetails(Path.Combine(PathMod.MODS_PATH, mod[ii])); if (header.IsValid()) { workingMods.Add(header); DiagManager.Instance.LogInfo(String.Format("Loaded mod \"{0}\".", String.Join(", ", mod[ii]))); } else { DiagManager.Instance.LogInfo(String.Format("Cannot find mod \"{0}\" in {1}. It will be ignored.", mod, PathMod.MODS_PATH)); mod.RemoveAt(ii); ii--; } } PathMod.Mods = workingMods.ToArray(); } if (playInputs != null) { DiagManager.Instance.LoadInputs(playInputs); } Text.Init(); if (langArgs != "" && DiagManager.Instance.CurSettings.Language == "") { if (langArgs.Length > 0) { DiagManager.Instance.CurSettings.Language = langArgs.ToLower(); Text.SetCultureCode(langArgs.ToLower()); } else { DiagManager.Instance.CurSettings.Language = "en"; } } Text.SetCultureCode(DiagManager.Instance.CurSettings.Language == "" ? "" : DiagManager.Instance.CurSettings.Language.ToString()); if (buildQuest) { if (!PathMod.Quest.IsValid()) { DiagManager.Instance.LogInfo("No quest specified to build."); return; } RogueEssence.Dev.DevHelper.MergeQuest(quest); return; } if (convertAssets != GraphicsManager.AssetType.None) { //run conversions using (GameBase game = new GameBase()) { GraphicsManager.InitSystem(game.GraphicsDevice); GraphicsManager.RunConversions(convertAssets); } return; } if (reserializeIndices != DataManager.DataType.None) { DiagManager.Instance.LogInfo("Beginning Reserialization"); using (GameBase game = new GameBase()) { GraphicsManager.InitSystem(game.GraphicsDevice); GraphicsManager.RebuildIndices(GraphicsManager.AssetType.All); } //we need the datamanager for this, but only while data is hardcoded //TODO: remove when data is no longer hardcoded LuaEngine.InitInstance(); DataManager.InitInstance(); DataManager.InitDataDirs(PathMod.ModPath("")); RogueEssence.Dev.DevHelper.ReserializeBase(); DiagManager.Instance.LogInfo("Reserializing main data"); RogueEssence.Dev.DevHelper.Reserialize(reserializeIndices); DiagManager.Instance.LogInfo("Reserializing map data"); if ((reserializeIndices & DataManager.DataType.Zone) != DataManager.DataType.None) { RogueEssence.Dev.DevHelper.ReserializeData <Map>(DataManager.DATA_PATH + "Map/", DataManager.MAP_EXT); RogueEssence.Dev.DevHelper.ReserializeData <GroundMap>(DataManager.DATA_PATH + "Ground/", DataManager.GROUND_EXT); } DiagManager.Instance.LogInfo("Reserializing indices"); RogueEssence.Dev.DevHelper.RunIndexing(reserializeIndices); DataManager.Instance.UniversalData = (TypeDict <BaseData>)RogueEssence.Dev.DevHelper.LoadWithLegacySupport(PathMod.ModPath(DataManager.MISC_PATH + "Index.bin"), typeof(TypeDict <BaseData>)); RogueEssence.Dev.DevHelper.RunExtraIndexing(reserializeIndices); return; } if (convertIndices != DataManager.DataType.None) { //we need the datamanager for this, but only while data is hardcoded //TODO: remove when data is no longer hardcoded LuaEngine.InitInstance(); DataManager.InitInstance(); DiagManager.Instance.LogInfo("Reserializing indices"); DataManager.InitDataDirs(PathMod.ModPath("")); RogueEssence.Dev.DevHelper.RunIndexing(convertIndices); DataManager.Instance.UniversalData = (TypeDict <BaseData>)RogueEssence.Dev.DevHelper.LoadWithLegacySupport(PathMod.ModPath(DataManager.MISC_PATH + "Index.bin"), typeof(TypeDict <BaseData>)); RogueEssence.Dev.DevHelper.RunExtraIndexing(convertIndices); return; } if (guideBook || guideCsv) { //print the guidebook in the chosen language //we need the datamanager for this LuaEngine.InitInstance(); DataManager.InitInstance(); DataManager.Instance.InitData(); //just print a guidebook and exit StrategyGuide.PrintMoveGuide(guideCsv); StrategyGuide.PrintItemGuide(guideCsv); StrategyGuide.PrintAbilityGuide(guideCsv); StrategyGuide.PrintEncounterGuide(guideCsv); return; } //Dev.ImportManager.PrintMoveUsers(PathMod.DEV_PATH+"moves.txt"); //Dev.ImportManager.PrintAbilityUsers(PathMod.DEV_PATH+"abilities.txt"); logInput = false; //this feature is disabled for now... if (DiagManager.Instance.ActiveDebugReplay == null && logInput) { DiagManager.Instance.BeginInput(); } if (DiagManager.Instance.DevMode) { InitDataEditor(); AppBuilder builder = RogueEssence.Dev.Program.BuildAvaloniaApp(); builder.StartWithClassicDesktopLifetime(args); } else { DiagManager.Instance.DevEditor = new EmptyEditor(); using (GameBase game = new GameBase()) game.Run(); } } catch (Exception ex) { DiagManager.Instance.LogError(ex); throw; } }