public static void Create() { Game game = Game.Get(); if (GameObject.FindGameObjectWithTag("dialog") != null) { return; } // Menu border DialogBox db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 9), new Vector2(12, 13), StringKey.NULL); db.AddBorder(); db.SetFont(game.gameType.GetHeaderFont()); TextButton tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 10), new Vector2(10, 2f), SAVE, delegate { QuestEditor.Save(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 13), new Vector2(10, 2f), RELOAD, delegate { QuestEditor.Reload(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 16), new Vector2(10, 2f), MAIN_MENU, delegate { Destroyer.MainMenu(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 19), new Vector2(10, 2f), CommonStringKeys.CANCEL, delegate { Destroyer.Dialog(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); }
/// <summary> /// Create a .valkyrie package and associated meta data /// </summary> private static void CreatePackage() { Destroyer.Dialog(); Game game = Game.Get(); // save content before creating the package QuestEditor.Save(); string packageName = Path.GetFileName(Path.GetDirectoryName(game.quest.qd.questPath)); try { string desktopDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); string destination = Path.Combine(desktopDir, packageName); int postfix = 2; while (Directory.Exists(destination)) { destination = Path.Combine(desktopDir, packageName + postfix++); } Directory.CreateDirectory(destination); string packageFile = Path.Combine(destination, packageName + ".valkyrie"); using (var zip = new ZipFile()) { zip.AddDirectory(Path.GetDirectoryName(game.quest.qd.questPath)); zip.Save(packageFile); } // Append sha version using (FileStream stream = File.OpenRead(packageFile)) { byte[] checksum = SHA256Managed.Create().ComputeHash(stream); game.quest.qd.quest.version = System.BitConverter.ToString(checksum); } string icon = game.quest.qd.quest.image.Replace('\\', '/'); if (icon.Length > 0) { string iconName = Path.GetFileName(icon); // Temp hack to get ToString to output local file game.quest.qd.quest.image = iconName; string src = Path.Combine(Path.GetDirectoryName(game.quest.qd.questPath), icon); string dest = Path.Combine(destination, iconName); File.Copy(src, dest); } string manifest = game.quest.qd.quest.ToString(); // Restore icon game.quest.qd.quest.image = icon; foreach (KeyValuePair <string, string> kv in LocalizationRead.selectDictionary("qst").ExtractAllMatches("quest.name")) { manifest += "name." + kv.Key + "=" + kv.Value + System.Environment.NewLine; } foreach (KeyValuePair <string, string> kv in LocalizationRead.selectDictionary("qst").ExtractAllMatches("quest.synopsys")) { manifest += "synopsys." + kv.Key + "=" + kv.Value.Replace("\n", "").Replace("\r", "") + System.Environment.NewLine; } foreach (KeyValuePair <string, string> kv in LocalizationRead.selectDictionary("qst").ExtractAllMatches("quest.description")) { manifest += "description." + kv.Key + "=" + kv.Value.Replace("\n", "\\n").Replace("\r", "") + System.Environment.NewLine; } foreach (KeyValuePair <string, string> kv in LocalizationRead.selectDictionary("qst").ExtractAllMatches("quest.authors")) { manifest += "authors." + kv.Key + "=" + kv.Value.Replace("\n", "\\n").Replace("\\r", "") + System.Environment.NewLine; } foreach (KeyValuePair <string, string> kv in LocalizationRead.selectDictionary("qst").ExtractAllMatches("quest.authors_short")) { manifest += "authors_short." + kv.Key + "=" + kv.Value.Replace("\n", "").Replace("\r", "") + System.Environment.NewLine; } File.WriteAllText(Path.Combine(destination, packageName + ".ini"), manifest); } catch (System.IO.IOException e) { ValkyrieDebug.Log("Warning: Unable to write to valkyrie package." + e.Message); } }
public static void Create() { if (GameObject.FindGameObjectWithTag("dialog") != null) { return; } DialogBox db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 9), new Vector2(12, 13), ""); db.AddBorder(); TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 10), new Vector2(10, 2f), "Save", delegate { QuestEditor.Save(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 13), new Vector2(10, 2f), "Reload", delegate { QuestEditor.Reload(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 16), new Vector2(10, 2f), "Main Menu", delegate { Destroyer.MainMenu(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 19), new Vector2(10, 2f), "Cancel", delegate { Destroyer.Dialog(); }, Color.white); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); }
public void Test() { if (GameObject.FindGameObjectWithTag(Game.DIALOG) != null) { return; } QuestEditor.Save(); Game game = Game.Get(); string path = game.quest.questPath; Destroyer.Destroy(); game.cd = new ContentData(game.gameType.DataDirectory()); foreach (string pack in game.cd.GetPacks()) { game.cd.LoadContent(pack); } game.testMode = true; // Fetch all of the quest data and initialise the quest game.quest = new Quest(new QuestData.Quest(path)); game.heroCanvas.SetupUI(); int heroCount = Random.Range(game.quest.qd.quest.minHero, game.quest.qd.quest.maxHero + 1); List <HeroData> hOptions = new List <HeroData>(game.cd.heroes.Values); for (int i = 0; i < heroCount; i++) { game.quest.heroes[i].heroData = hOptions[Random.Range(0, hOptions.Count)]; hOptions.Remove(game.quest.heroes[i].heroData); } // Starting morale is number of heros game.quest.vars.SetValue("$%morale", heroCount); // Set quest flag based on hero count game.quest.vars.SetValue("#heroes", heroCount); game.quest.heroesSelected = true; // Clear off heros if not required if (!game.gameType.DisplayHeroes()) { game.heroCanvas.Clean(); } else { game.heroCanvas.UpdateImages(); game.heroCanvas.UpdateStatus(); } // Draw morale if required if (game.gameType is D2EGameType) { new ClassSelectionScreen(); } else { new InvestigatorItems(); } }
public void Test() { if (GameObject.FindGameObjectWithTag(Game.DIALOG) != null) { return; } QuestEditor.Save(); Game game = Game.Get(); string path = game.quest.questPath; Destroyer.Destroy(); // All content data has been loaded by editor, cleanup everything game.cd = new ContentData(game.gameType.DataDirectory()); // Load the base content game.ContentLoader.LoadContentID(""); // Load current configuration Dictionary <string, string> packs = game.config.data.Get(game.gameType.TypeName() + "Packs"); if (packs != null) { foreach (KeyValuePair <string, string> kv in packs) { game.ContentLoader.LoadContentID(kv.Key); } } game.testMode = true; // Fetch all of the quest data and initialise the quest game.quest = new Quest(new QuestData.Quest(path)); game.heroCanvas.SetupUI(); int heroCount = Random.Range(game.quest.qd.quest.minHero, game.quest.qd.quest.maxHero + 1); List <HeroData> hOptions = new List <HeroData>(game.cd.Values <HeroData>()); for (int i = 0; i < heroCount; i++) { game.quest.heroes[i].heroData = hOptions[Random.Range(0, hOptions.Count)]; game.quest.vars.SetValue("#" + game.quest.heroes[i].heroData.sectionName, 1); hOptions.Remove(game.quest.heroes[i].heroData); } // Starting morale is number of heros game.quest.vars.SetValue("$%morale", heroCount); // Set quest flag based on hero count game.quest.vars.SetValue("#heroes", heroCount); game.quest.heroesSelected = true; // Clear off heros if not required if (!game.gameType.DisplayHeroes()) { game.heroCanvas.Clean(); } else { game.heroCanvas.UpdateImages(); game.heroCanvas.UpdateStatus(); } // Draw morale if required if (game.gameType is D2EGameType) { new ClassSelectionScreen(); } else { new InvestigatorItems(); } }