public QuestSelection(Dictionary <string, QuestLoader.Quest> ql) { questList = ql; Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); TextButton tb; // Start here int offset = 5; // Loop through all available quests // FIXME: this isn't paged foreach (KeyValuePair <string, QuestLoader.Quest> q in questList) { string key = q.Key; // Size is 1.2 to be clear of characters with tails tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), " " + q.Value.name, delegate { Selection(key); }, Color.white, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 0.1f); offset += 2; } tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); }
public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql) { questList = ql; Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Clean up downloader if present foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.QUESTUI)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // error message if stats are not available if (game.stats.error_download) { float error_string_width = 0; ui = new UIElement(); if (game.stats.error_download_description == "ERROR NETWORK") { StringKey STATS_ERROR_NETWORK = new StringKey("val", "STATS_ERROR_NETWORK"); ui.SetText(STATS_ERROR_NETWORK, Color.red); error_string_width = ui.GetStringWidth(STATS_ERROR_NETWORK); } else { StringKey STATS_ERROR_HTTP = new StringKey("val", "STATS_ERROR_HTTP", game.stats.error_download_description); ui.SetText(STATS_ERROR_HTTP, Color.red); error_string_width = ui.GetStringWidth(STATS_ERROR_HTTP); } ui.SetLocation(UIScaler.GetHCenter() - (error_string_width / 2f), UIScaler.GetBottom(-3f), error_string_width, 2.4f); ui.SetTextAlignment(TextAnchor.MiddleCenter); ui.SetBGColor(Color.clear); } // error message if stats are not available if (game.stats.download_ongoing) { float ongoing_string_width = 0; ui = new UIElement(); StringKey STATS_DOWNLOAD_ONGOING = new StringKey("val", "STATS_DOWNLOAD_ONGOING"); ui.SetText(STATS_DOWNLOAD_ONGOING, Color.white); ongoing_string_width = ui.GetStringWidth(STATS_DOWNLOAD_ONGOING); ui.SetLocation(UIScaler.GetHCenter() - (ongoing_string_width / 2f), UIScaler.GetBottom(-3f), ongoing_string_width, 2.4f); ui.SetTextAlignment(TextAnchor.MiddleCenter); ui.SetBGColor(Color.clear); } UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f); new UIElementBorder(scrollArea); // Start here float offset = 0; // Loop through all available quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); // Frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.6f); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); offset += 0.05f; new UIElementBorder(ui, Color.grey); // Draw Image ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, 3.5f, 3.5f); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); if (q.Value.image.Length > 0) { ui.SetImage(ContentData.FileToTexture(Path.Combine(q.Value.path, q.Value.image))); } // Quest name ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetBGColor(Color.clear); ui.SetLocation(5f, offset - 0.2f, UIScaler.GetWidthUnits() - 8, 2.5f); ui.SetTextPadding(0.5f); ui.SetText(translation, Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.4f)); ui.SetFont(game.gameType.GetHeaderFont()); // Duration if (q.Value.lengthMax != 0) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(6.5f, offset + 2.3f, 4, 1); ui.SetText(new StringKey("val", "DURATION"), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(10.5f, offset + 2.3f, 5, 1); ui.SetText(q.Value.lengthMin + " - " + q.Value.lengthMax, Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); } // Difficulty if (q.Value.difficulty != 0) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 2.3f, 6, 1); ui.SetText(new StringKey("val", "DIFFICULTY"), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleRight); ui.SetBGColor(Color.clear); string symbol = "π"; // will if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter(), offset + 1.8f, 9, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Selection(key); }); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() + 1.05f + (q.Value.difficulty * 6.9f), offset + 1.8f, (1 - q.Value.difficulty) * 6.9f, 1.6f); ui.SetBGColor(new Color(1, 1, 1, 0.7f)); ui.SetButton(delegate { Selection(key); }); } // Statistics string filename = Path.GetFileName(key).ToLower(); if (game.stats != null && game.stats.scenarios_stats != null && game.stats.scenarios_stats.ContainsKey(filename)) { ScenarioStats q_stats = game.stats.scenarios_stats[filename]; int win_ratio = (int)(q_stats.scenario_avg_win_ratio * 100); StringKey STATS_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_AVERAGE_WIN_RATIO", win_ratio); StringKey STATS_NO_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_NO_AVERAGE_WIN_RATIO", win_ratio); StringKey STATS_NB_USER_REVIEWS = new StringKey("val", "STATS_NB_USER_REVIEWS", q_stats.scenario_play_count); StringKey STATS_AVERAGE_DURATION = new StringKey("val", "STATS_AVERAGE_DURATION", (int)(q_stats.scenario_avg_duration)); StringKey STATS_NO_AVERAGE_DURATION = new StringKey("val", "STATS_NO_AVERAGE_DURATION"); // rating string symbol = "★"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_TENTACLE").Translate(); } float rating = q_stats.scenario_avg_rating / 10; float score_text_width = 0; ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); score_text_width = ui.GetStringWidth(symbol + symbol + symbol + symbol + symbol, (int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)) + 1; ui.SetLocation(UIScaler.GetRight(-12f), offset + 0.6f, score_text_width, 2); ui.SetBGColor(Color.clear); ui.SetFontSize((int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Selection(key); }); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-12) + (rating * (score_text_width - 1)), offset + 0.6f, (1 - rating) * score_text_width, 2); ui.SetBGColor(new Color(1, 1, 1, 0.7f)); ui.SetButton(delegate { Selection(key); }); // Number of user reviews float user_review_text_width = 0; ui = new UIElement(scrollArea.GetScrollTransform()); user_review_text_width = ui.GetStringWidth(STATS_NB_USER_REVIEWS, UIScaler.GetSmallFont()) + 1; ui.SetText(STATS_NB_USER_REVIEWS, Color.black); ui.SetLocation(UIScaler.GetRight(-12) + (score_text_width / 2) - (user_review_text_width / 2), offset + 2.3f, user_review_text_width, 1); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetSmallFont()); ui.SetButton(delegate { Selection(key); }); if (q_stats.scenario_avg_duration > 0 || win_ratio >= 0) { // Additional information in Grey frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(3.5f + 1f, offset + 3.6f, UIScaler.GetWidthUnits() - 4.9f - 3.5f - 0.05f, 1.2f); ui.SetBGColor(Color.grey); ui.SetButton(delegate { Selection(key); }); // average duration ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(5f, offset + 3.8f, 14, 1); if (q_stats.scenario_avg_duration > 0) { ui.SetText(STATS_AVERAGE_DURATION, Color.white); } else { ui.SetText(STATS_NO_AVERAGE_DURATION, Color.white); } ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); ui.SetButton(delegate { Selection(key); }); // average win ratio ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 3.8f, 15, 1); if (win_ratio >= 0) { ui.SetText(STATS_AVERAGE_WIN_RATIO, Color.white); } else { ui.SetText(STATS_NO_AVERAGE_WIN_RATIO, Color.white); } ui.SetBGColor(Color.clear); ui.SetTextAlignment(TextAnchor.MiddleCenter); ui.SetButton(delegate { Selection(key); }); offset += 1.4f; } } offset += 4.5f; } } // Loop through all unavailable quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); // Size is 1.2 to be clear of characters with tails ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", translation), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs())) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(3, offset, UIScaler.GetWidthUnits() - 9, 1.2f); ui.SetText(new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; } offset += 0.8f; } } scrollArea.SetScrollSize(offset); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Cancel(); }); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2); ui.SetText(DOWNLOAD, Color.green); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Download(); }); new UIElementBorder(ui, Color.green); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public GameSelection() { // This will destroy all Destroyer.Destroy(); Game game = Game.Get(); game.gameType = new NoGameType(); fcD2E = new FetchContent("D2E"); fcMoM = new FetchContent("MoM"); // Name. We should replace this with a banner DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Valkyrie"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); Color startColor = Color.white; if (fcD2E.NeedImport()) { startColor = Color.gray; } TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 10), new Vector2(30, 4f), "Descent: Journeys in the Dark Second Edition", delegate { D2E(); }, startColor); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); if (fcD2E.importAvailable) { if (fcD2E.NeedImport()) { tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Import Content", delegate { Import("D2E"); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); } else { tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Reimport Content", delegate { Import("D2E"); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); } } else { db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 14.2f), new Vector2(10, 2f), "Import Unavailable", Color.red); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); } startColor = Color.white; if (fcMoM.NeedImport()) { startColor = Color.gray; } tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 30) / 2, 19), new Vector2(30, 4f), "Mansions of Madness Second Edition", delegate { MoM(); }, startColor); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); if (fcMoM.importAvailable) { if (fcMoM.NeedImport()) { tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Import Content", delegate { Import("MoM"); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); } else { tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Reimport Content", delegate { Import("MoM"); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); } } else { db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 23.2f), new Vector2(10, 2f), "Import Unavailable", Color.red); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); } new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Exit", delegate { Exit(); }, Color.red); }
public static void DisplayTransitionWindow(Quest.MoMPhase phase) { // do NOT delete dialog, they are hidden behing the mythos phase //Destroyer.Dialog(); Game game = Game.Get(); UIElement text; // dot NOT display transition screen while we are in Editor mode if (game.testMode) { return; } // Background picture in full screen UIElement bg = new UIElement(Game.TRANSITION); Texture2D bgTex; if (phase == Quest.MoMPhase.investigator) { bgTex = ContentData.FileToTexture(game.cd.Get <ImageData>(IMG_BG_INVESTIGATORS_PHASE).image); } else { bgTex = ContentData.FileToTexture(game.cd.Get <ImageData>(IMG_BG_MYTHOS_PHASE).image); } bg.SetImage(bgTex); bg.SetLocation(0, 0, UIScaler.GetWidthUnits(), UIScaler.GetHeightUnits()); // Text of phase text = new UIElement(Game.TRANSITION, bg.GetTransform()); if (phase == Quest.MoMPhase.investigator) { // Silver #C0C0C0 (192,192,192) text.SetText(PHASE_INVESTIGATOR, new Color32(192, 192, 192, 255)); text.SetLocation(5, 3, 30, 3); } else { // Dark red #8B0000 (139,0,0) text.SetText(PHASE_MYTHOS, new Color32(139, 0, 0, 255)); text.SetLocation(7, 3, 30, 3); } text.SetFont(game.gameType.GetHeaderFont()); text.SetFontSize(UIScaler.GetLargeFont()); text.SetFontStyle(FontStyle.Italic); text.SetTextAlignment(TextAnchor.MiddleLeft); text.SetBGColor(Color.clear); if (phase == Quest.MoMPhase.investigator) { // Draw pictures of investigators for investigator phase float offset = (game.quest.GetHeroCount() - 1) * (-1 * offset_size / 2) - (offset_size / 2); UIElement ui = null; foreach (Quest.Hero h in game.quest.heroes) { if (h.heroData != null) { // Draw pictures Texture2D newTex = ContentData.FileToTexture(h.heroData.image); ui = new UIElement(Game.TRANSITION, bg.GetTransform()); ui.SetLocation(UIScaler.GetHCenter(offset), UIScaler.GetVCenter(), heroSize, heroSize); ui.SetImage(newTex); offset += offset_size; } } } else { // Don't draw anything for Mythos phase } // Launch timer to remove this window in 'transition_duration' seconds if (gameobject_timer == null) { gameobject_timer = new GameObject("TIMER"); timer = gameobject_timer.AddComponent <SimpleTimer>(); } timer.Init(transition_duration, Close); }
public void Update(int hero = 0) { Destroyer.Dialog(); Game game = Game.Get(); DialogBox db = new DialogBox( new Vector2(UIScaler.GetHCenter(-15), 1), new Vector2(30, 6), StringKey.NULL); db.AddBorder(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-17f), 7), new Vector2(34, 17), StringKey.NULL); db.AddBorder(); // Add a title to the page db = new DialogBox( new Vector2(UIScaler.GetHCenter(-6), 1), new Vector2(12, 3), new StringKey("val", "SELECT_SKILLS")); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); // Get all heros int heroCount = 0; // Count number of selected heroes foreach (Quest.Hero h in game.quest.heroes) { if (h.heroData != null) { heroCount++; } } float xOffset = UIScaler.GetHCenter(-11); if (heroCount < 4) { xOffset += 3f; } if (heroCount < 3) { xOffset += 3f; } TextButton tb = null; int availableXP = 0; for (int i = 0; i < heroCount; i++) { int tmp = i; Texture2D heroTex = ContentData.FileToTexture(game.quest.heroes[i].heroData.image); Sprite heroSprite = Sprite.Create(heroTex, new Rect(0, 0, heroTex.width, heroTex.height), Vector2.zero, 1); tb = new TextButton(new Vector2(xOffset, 3.5f), new Vector2(4f, 4f), StringKey.NULL, delegate { Update(tmp); }, Color.clear); tb.background.GetComponent <UnityEngine.UI.Image>().sprite = heroSprite; tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.3f, 0.3f, 0.3f); if (i == hero) { tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; } tb.border.Destroy(); availableXP = game.quest.heroes[i].AvailableXP(); if (availableXP != 0) { tb = new TextButton(new Vector2(xOffset + 2, 5.5f), new Vector2(2f, 2f), availableXP, delegate { Update(tmp); }, Color.blue); } xOffset += 6f; } db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16), 8.5f), new Vector2(32, 5), StringKey.NULL); db.AddBorder(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16), 8.5f), new Vector2(2, 5), 1); db.AddBorder(); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16), 13.5f), new Vector2(32, 5), StringKey.NULL); db.AddBorder(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16), 13.5f), new Vector2(2, 5), 2); db.AddBorder(); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); string hybridClass = game.quest.heroes[hero].hybridClass; if (hybridClass.Length > 0) { db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16.5f), 18.5f), new Vector2(11, 5), StringKey.NULL); db.AddBorder(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16.5f), 18.5f), new Vector2(2, 5), 1); db.AddBorder(); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-5.5f), 18.5f), new Vector2(11, 5), StringKey.NULL); db.AddBorder(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-5.5f), 18.5f), new Vector2(2, 5), 2); db.AddBorder(); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(5.5f), 18.5f), new Vector2(11, 5), StringKey.NULL); db.AddBorder(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(5.5f), 18.5f), new Vector2(2, 5), 3); db.AddBorder(); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); } else { db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16), 18.5f), new Vector2(32, 5), StringKey.NULL); db.AddBorder(); db = new DialogBox( new Vector2(UIScaler.GetHCenter(-16), 18.5f), new Vector2(2, 5), 3); db.AddBorder(); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); } float[] xOffsetArray = new float[4]; xOffsetArray[1] = UIScaler.GetHCenter(-13); xOffsetArray[2] = UIScaler.GetHCenter(-13); xOffsetArray[3] = UIScaler.GetHCenter(-8); float yOffset = 4; availableXP = game.quest.heroes[hero].AvailableXP(); foreach (SkillData s in game.cd.skills.Values) { if (s.xp == 0) { continue; } if (game.quest.heroes[hero].className.Length == 0) { continue; } Color buttonColor = new Color(0.4f, 0.4f, 0.4f); if (game.quest.heroes[hero].skills.Contains(s.sectionName)) { buttonColor = Color.green; } else if (s.xp <= availableXP) { buttonColor = Color.white; } string skill = s.sectionName; if (s.sectionName.IndexOf("Skill" + game.quest.heroes[hero].className.Substring("Class".Length)) == 0) { if (hybridClass.Length > 0 && s.xp == 3) { continue; } tb = new TextButton(new Vector2(xOffsetArray[s.xp], yOffset + (s.xp * 5)), new Vector2(8f, 4f), s.name, delegate { SelectSkill(hero, skill); }, buttonColor); xOffsetArray[s.xp] += 10; continue; } if (hybridClass.Length == 0) { continue; } if (s.sectionName.IndexOf("Skill" + hybridClass.Substring("Class".Length)) != 0) { continue; } tb = new TextButton(new Vector2(UIScaler.GetHCenter(-25f) + (s.xp * 11f), yOffset + 15), new Vector2(8f, 4f), s.name, delegate { SelectSkill(hero, skill); }, buttonColor); } // Add a finished button to start the quest tb = new TextButton( new Vector2(UIScaler.GetHCenter(-4f), 24.5f), new Vector2(8, 2), CommonStringKeys.CLOSE, delegate { Destroyer.Dialog(); }); }
public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql) { questList = ql; Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Clean up downloader if present foreach (GameObject go in GameObject.FindGameObjectsWithTag("questui")) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), ""); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; TextButton tb; // Start here float offset = 5; // Loop through all available quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()).Count == 0) { string key = q.Key; // Size is 1.2 to be clear of characters with tails tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), " " + q.Value.name, delegate { Selection(key); }, Color.black, (int)offset); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; offset += 2; } } // Loop through all unavailable quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs()).Count > 0) { // Size is 1.2 to be clear of characters with tails db = new DialogBox(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), " " + q.Value.name, Color.black); db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f); db.background.transform.parent = scrollArea.transform; offset += 1.2f; foreach (string s in q.Value.GetMissingPacks(game.cd.GetEnabledPackIDs())) { db = new DialogBox(new Vector2(4, offset), new Vector2(UIScaler.GetWidthUnits() - 9, 1.2f), " Requires: " + game.cd.GetContentName(s), Color.black); db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f); db.background.transform.parent = scrollArea.transform; offset += 1.2f; } } offset += 0.8f; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); tb = new TextButton(new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), "Download", delegate { Download(); }, Color.green); tb.SetFont(game.gameType.GetHeaderFont()); }
public void Draw() { // Clean up Destroyer.Dialog(); foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.HEROSELECT)) { Object.Destroy(go); } Game game = Game.Get(); // Add a title to the page UIElement ui = new UIElement(Game.HEROSELECT); ui.SetLocation(8, 1, UIScaler.GetWidthUnits() - 16, 3); ui.SetText(new StringKey("val", "SELECT_CLASS")); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // Get all heros int heroCount = 0; // Count number of selected heroes foreach (Quest.Hero h in game.quest.heroes) { if (h.heroData != null) { heroCount++; } } float xOffset = UIScaler.GetHCenter(-18); if (heroCount < 4) { xOffset += 4.5f; } if (heroCount < 3) { xOffset += 4.5f; } for (int i = 0; i < heroCount; i++) { DrawHero(xOffset, i); xOffset += 9f; } // Add a finished button to start the quest ui = new UIElement(Game.HEROSELECT); ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.FINISHED, Color.green); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Finished); new UIElementBorder(ui, Color.green); ui = new UIElement(Game.HEROSELECT); ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.QuestSelect); new UIElementBorder(ui, Color.red); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public MainMenuScreen() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Game game = Game.Get(); game.cd = new ContentData(game.gameType.DataDirectory()); // Check if we found anything if (game.cd.GetPacks().Count == 0) { ValkyrieDebug.Log("Error: Failed to find any content packs, please check that you have them present in: " + game.gameType.DataDirectory() + System.Environment.NewLine); Application.Quit(); } // Load base game.cd.LoadContentID(""); List <string> music = new List <string>(); foreach (AudioData ad in game.cd.audio.Values) { if (ad.ContainsTrait("menu")) { music.Add(ad.file); } } game.audioControl.Music(music); // Name. Should this be the banner, or better to print Valkyrie with the game font? UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText("Valkyrie"); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // Button for start quest/scenario ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 5, 12, 2); ui.SetText(new StringKey("val", "START_QUEST", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Start); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 8, 12, 2); if (SaveManager.SaveExists()) { ui.SetText(new StringKey("val", "LOAD_QUEST", game.gameType.QuestName())); ui.SetButton(delegate { new SaveSelectScreen(); }); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); } else { ui.SetText(new StringKey("val", "LOAD_QUEST", game.gameType.QuestName()), Color.grey); new UIElementBorder(ui, Color.grey); } ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); // Content selection page ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 11, 12, 2); ui.SetText(SELECT_CONTENT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Content); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // Quest/Scenario editor ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 14, 12, 2); ui.SetText(new StringKey("val", "QUEST_NAME_EDITOR", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Editor); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // About page (managed in this class) ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 17, 12, 2); ui.SetText(ABOUT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(About); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // Configuration menu ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 20, 12, 2); ui.SetText(OPTIONS); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Config); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // Exit Valkyrie ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 23, 12, 2); ui.SetText(CommonStringKeys.EXIT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Exit); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); }
public void DrawList() { localManifest = IniRead.ReadFromString(""); if (File.Exists(saveLocation() + "/manifest.ini")) { localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini"); } // Heading DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Download " + game.gameType.QuestName()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), ""); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; TextButton tb; // Start here int offset = 5; // Loop through all available quests foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data) { string file = kv.Key + ".valkyrie"; // Size is 1.2 to be clear of characters with tails if (File.Exists(saveLocation() + "/" + file)) { int localVersion = 0; int remoteVersion = 0; int.TryParse(localManifest.Get(kv.Key, "version"), out localVersion); int.TryParse(remoteManifest.Get(kv.Key, "version"), out remoteVersion); if (localVersion < remoteVersion) { tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), " [Update] " + kv.Value["name"], delegate { Selection(file); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 1f); tb.background.transform.parent = scrollArea.transform; } else { db = new DialogBox(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), " " + kv.Value["name"], Color.black); db.AddBorder(); db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.07f, 0.07f, 0.07f); db.background.transform.parent = scrollArea.transform; db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); } } else { tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), " " + kv.Value["name"], delegate { Selection(file); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; } offset += 2; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); }
public QuestDetailsScreen(QuestData.Quest q) { Game game = Game.Get(); LocalizationRead.scenarioDict = q.localizationDict; // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox( new Vector2(2, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 4, 3), q.name); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); // Draw Image if (q.image.Length > 0) { Texture2D tex = ContentData.FileToTexture(Path.Combine(q.path, q.image)); Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1); db = new DialogBox(new Vector2(UIScaler.GetHCenter(-20), 4), new Vector2(8, 8), StringKey.NULL, Color.white, Color.white); db.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite; db.AddBorder(); } // Draw Description db = new DialogBox(Vector2.zero, new Vector2(30, 30), q.description); float height = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1; db.Destroy(); if (height > 25) { height = 25; } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-7), 15 - (height / 2)), new Vector2(30, height), q.description); db.AddBorder(); // Draw authors db = new DialogBox(Vector2.zero, new Vector2(14, 30), q.authors); height = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1; db.Destroy(); if (height > 25) { height = 25; } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-23), 18.5f - (height / 2)), new Vector2(14, height), q.authors); db.AddBorder(); // Difficulty if (q.difficulty != 0) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13), 27), new Vector2(11, 1), new StringKey("val", "DIFFICULTY")); string symbol = "*"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13), 28), new Vector2(11, 2), new StringKey(null, symbol + symbol + symbol + symbol + symbol, false)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28), new Vector2((1 - q.difficulty) * 6.9f, 2), StringKey.NULL, Color.clear, new Color(0, 0, 0, 0.7f)); } // Duration if (q.lengthMax != 0) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(2), 27), new Vector2(11, 1), new StringKey("val", "DURATION")); db = new DialogBox(new Vector2(UIScaler.GetHCenter(2), 28f), new Vector2(4, 2), q.lengthMin); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(6.5f), 28f), new Vector2(2, 2), new StringKey(null, "-", false)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(9), 28f), new Vector2(4, 2), q.lengthMax); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); } TextButton tb = new TextButton( new Vector2(0.5f, UIScaler.GetBottom(-2.5f)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); tb = new TextButton( new Vector2(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f)), new Vector2(8, 2), new StringKey("val", "START"), delegate { Start(q); }, Color.green); tb.SetFont(game.gameType.GetHeaderFont()); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public MainMenuScreen() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Game game = Game.Get(); List <string> music = new List <string>(); foreach (AudioData ad in game.cd.Values <AudioData>()) { if (ad.ContainsTrait("menu")) { music.Add(ad.file); } } game.audioControl.PlayDefaultQuestMusic(music); // Background image. UIElement bg = new UIElement(); bg.SetLocation(0, 0, UIScaler.GetWidthUnits(), UIScaler.GetHeightUnits()); bg.SetImage(Resources.Load($"sprites/GameBackground{game.gameType.TypeName()}") as Texture2D, true, AspectRatioFitter.AspectMode.EnvelopeParent); // Name. Should this be the banner, or better to print Valkyrie with the game font? UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText("Valkyrie"); ui.SetBGColor(Color.clear); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); ui.SetTextOutline(Color.black, 1); // Version type : alpha / beta should be displayed if (Game.Get().version.EndsWith("a")) { ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3); ui.SetText("alpha version"); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { TestCrash(); }); } if (Game.Get().version.EndsWith("b")) { ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3); ui.SetText("beta version"); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { TestCrash(); }); } float menuButtonsX = UIScaler.GetWidthUnits() * 0.05f; // Button for start quest/scenario ui = new UIElement(); ui.SetLocation(menuButtonsX, 5, ButtonWidth, 2); ui.SetText(START_QUEST); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Start); ui.SetBGColor(BUTTON_BG_COLOR); new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE); ui = new UIElement(); ui.SetLocation(menuButtonsX, 8, ButtonWidth, 2); ui.SetBGColor(BUTTON_BG_COLOR); if (SaveManager.SaveExists()) { ui.SetText(LOAD_QUEST); ui.SetButton(delegate { new SaveSelectScreen(); }); new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE); } else { ui.SetText(LOAD_QUEST, Color.grey); new UIElementBorder(ui, BUTTON_BORDER_COLOR_INACTIVE); } ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); // Content selection page ui = new UIElement(); ui.SetLocation(menuButtonsX, 11, ButtonWidth, 2); ui.SetText(SELECT_CONTENT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Content); ui.SetBGColor(BUTTON_BG_COLOR); new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE); // Quest/Scenario editor ui = new UIElement(); ui.SetLocation(menuButtonsX, 14, ButtonWidth, 2); ui.SetText(new StringKey("val", "QUEST_NAME_EDITOR", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Editor); ui.SetBGColor(BUTTON_BG_COLOR); new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE); // About page (managed in this class) ui = new UIElement(); ui.SetLocation(menuButtonsX, 17, ButtonWidth, 2); ui.SetText(ABOUT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(About); ui.SetBGColor(BUTTON_BG_COLOR); new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE); // Configuration menu ui = new UIElement(); ui.SetLocation(menuButtonsX, 20, ButtonWidth, 2); ui.SetText(OPTIONS); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Config); ui.SetBGColor(BUTTON_BG_COLOR); new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE); // Exit Valkyrie ui = new UIElement(); ui.SetLocation(menuButtonsX, 23, ButtonWidth, 2); ui.SetText(CommonStringKeys.EXIT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Exit); ui.SetBGColor(BUTTON_BG_COLOR); new UIElementBorder(ui, BUTTON_BORDER_COLOR_ACTIVE); }
public void Update() { Destroyer.Dialog(); Game game = Game.Get(); UIElement ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-18), 1, 36, 23); new UIElementBorder(ui); // Add a title to the page ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6), 1, 12, 3); ui.SetText(new StringKey("val", "ITEMS")); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollHorizontal scrollArea = new UIElementScrollHorizontal(); scrollArea.SetLocation(UIScaler.GetHCenter(-17), 5, 34, 13); new UIElementBorder(scrollArea); float xOffset = 1; foreach (string s in game.quest.items) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(xOffset, 9, 8, 2); ui.SetText(game.cd.items[s].name, Color.black); ui.SetBGColor(Color.white); Texture2D itemTex = ContentData.FileToTexture(game.cd.items[s].image); Sprite itemSprite = Sprite.Create(itemTex, new Rect(0, 0, itemTex.width, itemTex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(xOffset, 1, 8, 8); ui.SetImage(itemSprite); xOffset += 9; } scrollArea.SetScrollSize(xOffset); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-5), 19, 10, 4); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-4), 20, 5, 2); ui.SetText(new StringKey("val", "GOLD")); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(1), 20, 3, 2); ui.SetText(Mathf.RoundToInt(game.quest.vars.GetValue("$%gold")).ToString()); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-4f), 24.5f, 8, 2); ui.SetText(CommonStringKeys.CLOSE); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.Dialog); new UIElementBorder(ui); }
public void Update() { // do not display the button bar when we reach the end of the game screen if (Game.Get().quest.questHasEnded) { return; } // First tile has not been displayed, button bar is not required yet if (!Game.Get().quest.firstTileDisplayed) { return; } // do not display the button bar when we are in the editor if (Game.Get().editMode) { return; } // Clean up everything marked as 'uiphase' foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.UIPHASE)) { Object.Destroy(go); } Color bgColor = new Color(0.05f, 0, 0, 0.9f); StringKey phase; if (Game.Get().quest.phase == Quest.MoMPhase.horror) { phase = HORROR_STEP; } else if (Game.Get().quest.phase == Quest.MoMPhase.mythos) { phase = PHASE_MYTHOS; } else if (Game.Get().quest.phase == Quest.MoMPhase.monsters) { phase = MONSTER_STEP; } else { phase = PHASE_INVESTIGATOR; bgColor = new Color(0, 0, 0, 0.9f); } float string_width = 0f, offset = 0.5f; StringKey text; // Inventory button UIElement ui = new UIElement(Game.UIPHASE); text = new StringKey("val", "ITEMS_SMALL"); ui.SetText(text); string_width = ui.GetStringWidth(text, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f; ui.SetLocation(offset, UIScaler.GetBottom(-2.5f), string_width, 2); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Items); ui.SetBGColor(bgColor); new UIElementBorder(ui); offset += string_width; // Action button ui = new UIElement(Game.UIPHASE); text = CommonStringKeys.SET; ui.SetText(text); string_width = ui.GetStringWidth(text, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f; ui.SetLocation(offset, UIScaler.GetBottom(-2.5f), string_width, 2); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Set); ui.SetBGColor(bgColor); new UIElementBorder(ui); offset += string_width; // Log button (text from previous event) ui = new UIElement(Game.UIPHASE); text = CommonStringKeys.LOG; ui.SetText(text); string_width = ui.GetStringWidth(text, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f; ui.SetLocation(offset, UIScaler.GetBottom(-2.5f), string_width, 2); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Log); ui.SetBGColor(bgColor); new UIElementBorder(ui); offset += string_width; // Text description for current phase ui = new UIElement(Game.UIPHASE); Color color; if (phase == PHASE_INVESTIGATOR) { color = Color.white; } else { color = Color.red; } ui.SetText(phase, color); string_width = ui.GetStringWidth(phase, UIScaler.GetMediumFont(), Game.Get().gameType.GetHeaderFont()) + 0.5f; ui.SetLocation(offset + ((UIScaler.GetRight(-4f) - offset - string_width) * 0.5f), UIScaler.GetBottom(-1.8f), string_width, 1.8f); ui.SetBGColor(bgColor); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetFontStyle(FontStyle.Italic); // Next phase button // Tweak border size so that arrow is centered, should be changed if using another character or picture ui = new UIElement(Game.UIPHASE); ui.SetLocation(UIScaler.GetRight(-4f), UIScaler.GetBottom(-2.5f), 3f, 2.25f); new UIElementBorder(ui); // make button slightly smaller so it does not overlap border ui = new UIElement(Game.UIPHASE); ui.SetLocation(UIScaler.GetRight(-3.95f), UIScaler.GetBottom(-2.45f), 2.9f, 1.9f); ui.SetText(CommonStringKeys.TAB); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); ui.SetButton(Next); ui.SetBGColor(bgColor); }
// Create a pack with list of quests to edit public QuestEditSelection() { Game game = Game.Get(); // Get list of unpacked quest in user location (editable) // TODO: open/save in packages questList = QuestLoader.GetUserUnpackedQuests(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), ""); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; // List of quests int offset = 5; TextButton tb; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), " " + q.Value.name, delegate { Selection(key); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; offset += 2; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); // Main menu tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Delete a user quest tb = new TextButton(new Vector2((UIScaler.GetRight() * 3 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Delete", delegate { Delete(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Copy a quest tb = new TextButton(new Vector2((UIScaler.GetRight() * 5 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Copy", delegate { Copy(); }); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Create a new quest tb = new TextButton(new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), "New", delegate { NewQuest(); }); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
public void DrawList() { localManifest = IniRead.ReadFromString(""); if (File.Exists(saveLocation() + "/manifest.ini")) { localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini"); } // Heading DialogBox db = new DialogBox( new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("val", "QUEST_NAME_DOWNLOAD", game.gameType.QuestName()) ); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), StringKey.NULL); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); GameObject scrollBarObj = new GameObject("scrollbar"); scrollBarObj.transform.parent = db.background.transform; RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>(); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit()); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit()); UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>(); scrollBar.direction = UnityEngine.UI.Scrollbar.Direction.BottomToTop; scrollRect.verticalScrollbar = scrollBar; GameObject scrollBarHandle = new GameObject("scrollbarhandle"); scrollBarHandle.transform.parent = scrollBarObj.transform; //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>(); scrollBarHandle.AddComponent <UnityEngine.UI.Image>(); scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f); scrollBar.handleRect = scrollBarHandle.GetComponent <RectTransform>(); scrollBar.handleRect.offsetMin = Vector2.zero; scrollBar.handleRect.offsetMax = Vector2.zero; scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; TextButton tb; // Start here int offset = 5; // Loop through all available quests foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data) { string file = kv.Key + ".valkyrie"; LocalizationRead.scenarioDict = localizationDict; string questName = new StringKey("qst", kv.Key + ".name").Translate(); int remoteFormat = 0; int.TryParse(remoteManifest.Get(kv.Key, "format"), out remoteFormat); bool formatOK = (remoteFormat >= QuestData.Quest.minumumFormat) && (remoteFormat <= QuestData.Quest.currentFormat); if (!formatOK) { continue; } // Size is 1.2 to be clear of characters with tails if (File.Exists(saveLocation() + "/" + file)) { string localHash = localManifest.Get(kv.Key, "version"); string remoteHash = remoteManifest.Get(kv.Key, "version"); if (!localHash.Equals(remoteHash)) { tb = new TextButton( new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 8, 1.2f), //TODO: the name should be another key in near future. now is a nonLookup key new StringKey("val", "QUEST_NAME_UPDATE", questName), delegate { Selection(file); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 1f); tb.background.transform.parent = scrollArea.transform; tb = new TextButton( new Vector2(UIScaler.GetWidthUnits() - 6, offset), new Vector2(3, 1.2f), new StringKey("val", "DELETE"), delegate { Delete(file); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.red; tb.background.transform.parent = scrollArea.transform; } else { db = new DialogBox( new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 8, 1.2f), new StringKey("val", "INDENT", questName), Color.black); db.AddBorder(); db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.07f, 0.07f, 0.07f); db.background.transform.parent = scrollArea.transform; db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb = new TextButton( new Vector2(UIScaler.GetWidthUnits() - 6, offset), new Vector2(3, 1.2f), new StringKey("val", "DELETE"), delegate { Delete(file); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.red; tb.background.transform.parent = scrollArea.transform; } } else { tb = new TextButton( new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), new StringKey("val", "INDENT", questName), delegate { Selection(file); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; } offset += 2; } foreach (KeyValuePair <string, Dictionary <string, string> > kv in localManifest.data) { // Only looking for files missing from remote if (remoteManifest.data.ContainsKey(kv.Key)) { continue; } string type = localManifest.Get(kv.Key, "type"); // Only looking for packages of this game type if (!game.gameType.TypeName().Equals(type)) { continue; } string file = kv.Key + ".valkyrie"; // Size is 1.2 to be clear of characters with tails if (File.Exists(saveLocation() + "/" + file)) { db = new DialogBox( new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 8, 1.2f), new StringKey("val", "INDENT", file), Color.black); db.AddBorder(); db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.07f, 0.07f, 0.07f); db.background.transform.parent = scrollArea.transform; db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb = new TextButton( new Vector2(UIScaler.GetWidthUnits() - 6, offset), new Vector2(3, 1.2f), new StringKey("val", "DELETE"), delegate { Delete(file); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.red; tb.background.transform.parent = scrollArea.transform; } } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); tb = new TextButton( new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); }
/// <summary> /// Draw download options screen /// </summary> public void DrawList() { Destroyer.Dialog(); localManifest = IniRead.ReadFromString(""); if (File.Exists(saveLocation() + "/manifest.ini")) { localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini"); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "QUEST_NAME_DOWNLOAD", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f); new UIElementBorder(scrollArea); // Start here float offset = 0; // Loop through all available quests foreach (RemoteQuest rq in remoteQuests) { string file = rq.name + ".valkyrie"; string questName = rq.GetData("name." + game.currentLang); if (questName.Length == 0) { questName = rq.GetData("name." + rq.GetData("defaultlanguage")); } if (questName.Length == 0) { questName = rq.name; } int remoteFormat = 0; int.TryParse(rq.GetData("format"), out remoteFormat); bool formatOK = (remoteFormat >= QuestData.Quest.minumumFormat) && (remoteFormat <= QuestData.Quest.currentFormat); if (!formatOK) { continue; } bool exists = File.Exists(saveLocation() + Path.DirectorySeparatorChar + file); bool update = true; if (exists) { string localHash = localManifest.Get(rq.name, "version"); string remoteHash = rq.GetData("version"); update = !localHash.Equals(remoteHash); } bool has_stats_bar = false; Color bg = Color.white; Color text_color = Color.black; if (exists) { if (update) { // light pink bg = new Color(0.7f, 0.7f, 1f); text_color = Color.black; } else { // dark grey bg = new Color(0.1f, 0.1f, 0.1f); text_color = Color.grey; } } // Frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.6f); ui.SetBGColor(bg); if (update) { ui.SetButton(delegate { Selection(rq); }); } offset += 0.05f; new UIElementBorder(ui, Color.grey); // Draw Image ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, 3.5f, 3.5f); ui.SetBGColor(bg); if (update) { ui.SetButton(delegate { Selection(rq); }); } if (rq.image != null) { ui.SetImage(rq.image); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetBGColor(Color.clear); ui.SetLocation(5, offset, UIScaler.GetWidthUnits() - 8, 2.5f); ui.SetTextPadding(1.2f); if (update && exists) { ui.SetText(new StringKey("val", "QUEST_NAME_UPDATE", questName), text_color); } else { ui.SetText(questName, text_color); } if (update) { ui.SetButton(delegate { Selection(rq); }); } ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.4f)); // Duration int lengthMax = 0; int.TryParse(rq.GetData("lengthmax"), out lengthMax); if (lengthMax > 0) { int lengthMin = 0; int.TryParse(rq.GetData("lengthmin"), out lengthMin); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(7f, offset + 2.3f, 4, 1); ui.SetText(new StringKey("val", "DURATION"), text_color); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); if (update) { ui.SetButton(delegate { Selection(rq); }); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(11f, offset + 2.3f, 5, 1); ui.SetText(lengthMin + " - " + lengthMax, text_color); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); if (update) { ui.SetButton(delegate { Selection(rq); }); } } // Difficulty float difficulty = 0f; float.TryParse(rq.GetData("difficulty"), out difficulty); if (difficulty != 0) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 2.3f, 6, 1); ui.SetText(new StringKey("val", "DIFFICULTY"), text_color); if (update) { ui.SetButton(delegate { Selection(rq); }); } ui.SetTextAlignment(TextAnchor.MiddleRight); ui.SetBGColor(Color.clear); string symbol = "π"; // will if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter(), offset + 1.8f, 9, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol, text_color); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetMediumFont()); if (update) { ui.SetButton(delegate { Selection(rq); }); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() + 1.05f + (difficulty * 6.9f), offset + 1.8f, (1 - difficulty) * 6.9f, 1.6f); Color filter = bg; filter.a = 0.7f; ui.SetBGColor(filter); if (update) { ui.SetButton(delegate { Selection(rq); }); } } // Statistics string filename = file.ToLower(); if (game.stats != null && game.stats.scenarios_stats != null && game.stats.scenarios_stats.ContainsKey(filename)) { ScenarioStats q_stats = game.stats.scenarios_stats[filename]; int win_ratio = (int)(q_stats.scenario_avg_win_ratio * 100); StringKey STATS_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_AVERAGE_WIN_RATIO", win_ratio); StringKey STATS_NO_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_NO_AVERAGE_WIN_RATIO", win_ratio); StringKey STATS_NB_USER_REVIEWS = new StringKey("val", "STATS_NB_USER_REVIEWS", q_stats.scenario_play_count); StringKey STATS_AVERAGE_DURATION = new StringKey("val", "STATS_AVERAGE_DURATION", (int)(q_stats.scenario_avg_duration)); StringKey STATS_NO_AVERAGE_DURATION = new StringKey("val", "STATS_NO_AVERAGE_DURATION"); // rating string symbol = "★"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_TENTACLE").Translate(); } float rating = q_stats.scenario_avg_rating / 10; float score_text_width = 0; ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetText(symbol + symbol + symbol + symbol + symbol, text_color); score_text_width = ui.GetStringWidth(symbol + symbol + symbol + symbol + symbol, (int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)) + 1; ui.SetLocation(UIScaler.GetRight(-12f), offset + 0.6f, score_text_width, 2); ui.SetBGColor(Color.clear); ui.SetFontSize((int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)); ui.SetTextAlignment(TextAnchor.MiddleLeft); if (update) { ui.SetButton(delegate { Selection(rq); }); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-12) + (rating * (score_text_width - 1)), offset + 0.6f, (1 - rating) * score_text_width, 2); Color filter = bg; filter.a = 0.7f; ui.SetBGColor(filter); if (update) { ui.SetButton(delegate { Selection(rq); }); } // Number of user reviews float user_review_text_width = 0; ui = new UIElement(scrollArea.GetScrollTransform()); user_review_text_width = ui.GetStringWidth(STATS_NB_USER_REVIEWS, UIScaler.GetSmallFont()) + 1; ui.SetText(STATS_NB_USER_REVIEWS, text_color); ui.SetLocation(UIScaler.GetRight(-12) + (score_text_width / 2) - (user_review_text_width / 2), offset + 2.3f, user_review_text_width, 1); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetSmallFont()); if (update) { ui.SetButton(delegate { Selection(rq); }); } if (q_stats.scenario_avg_duration > 0 || win_ratio >= 0) { has_stats_bar = true; // Additional information in frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(3.5f + 1f, offset + 3.6f, UIScaler.GetWidthUnits() - 4.9f - 3.5f - 0.05f, 1.2f); if (exists) { ui.SetBGColor(bg); } else { ui.SetBGColor(new Color(0.8f, 0.8f, 0.8f)); } if (update) { ui.SetButton(delegate { Selection(rq); }); } // average duration ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(6f, offset + 3.8f, 14, 1); if (q_stats.scenario_avg_duration > 0) { ui.SetText(STATS_AVERAGE_DURATION, text_color); } else { ui.SetText(STATS_NO_AVERAGE_DURATION, text_color); } ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); if (update) { ui.SetButton(delegate { Selection(rq); }); } // average win ratio ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 3.8f, 15, 1); if (win_ratio >= 0) { ui.SetText(STATS_AVERAGE_WIN_RATIO, text_color); } else { ui.SetText(STATS_NO_AVERAGE_WIN_RATIO, text_color); } ui.SetBGColor(Color.clear); ui.SetTextAlignment(TextAnchor.MiddleCenter); if (update) { ui.SetButton(delegate { Selection(rq); }); } } } // Size is 1.2 to be clear of characters with tails if (exists) { float string_width = 0; if (update) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetText(CommonStringKeys.UPDATE, Color.black); string_width = ui.GetStringWidth(CommonStringKeys.UPDATE, UIScaler.GetSmallFont()) + 1.3f; ui.SetButton(delegate { Delete(file); Selection(rq); }); ui.SetLocation(0.95f, offset + 3.6f, string_width, 1.2f); ui.SetBGColor(new Color(0, 0.5f, 0.68f)); // 0080AF new UIElementBorder(ui, new Color(0, 0.3f, 0.43f)); // 00516f } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetText(CommonStringKeys.DELETE, Color.black); string_width = ui.GetStringWidth(CommonStringKeys.DELETE, UIScaler.GetSmallFont()) + 1.3f; ui.SetButton(delegate { Delete(file); }); ui.SetLocation(0.95f + UIScaler.GetWidthUnits() - 4.9f - string_width, offset + 3.6f, string_width, 1.2f); ui.SetBGColor(new Color(0.7f, 0, 0)); new UIElementBorder(ui, new Color(0.45f, 0, 0)); } if (has_stats_bar || exists) { offset += 1.2f; } offset += 4.6f; } foreach (KeyValuePair <string, Dictionary <string, string> > kv in localManifest.data) { // Only looking for files missing from remote bool onRemote = false; foreach (RemoteQuest rq in remoteQuests) { if (rq.name.Equals(kv.Key)) { onRemote = true; } } if (onRemote) { continue; } string type = localManifest.Get(kv.Key, "type"); // Only looking for packages of this game type if (!game.gameType.TypeName().Equals(type)) { continue; } string file = kv.Key + ".valkyrie"; // Size is 1.2 to be clear of characters with tails if (File.Exists(saveLocation() + Path.DirectorySeparatorChar + file)) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 8, 1.2f); ui.SetTextPadding(1.2f); ui.SetText(file, Color.black); ui.SetBGColor(new Color(0.1f, 0.1f, 0.1f)); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetWidthUnits() - 12, offset, 8, 1.2f); ui.SetText(CommonStringKeys.DELETE, Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Delete(file); }); ui.SetBGColor(new Color(0.7f, 0, 0)); offset += 2; } } scrollArea.SetScrollSize(offset); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetButton(delegate { Cancel(); }); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); new UIElementBorder(ui, Color.red); }
public void Update(int hero = 0) { Destroyer.Dialog(); Game game = Game.Get(); UIElement ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-15), 1, 30, 6); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-17), 7, 34, 17); new UIElementBorder(ui); // Add a title to the page ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6), 1, 12, 3); ui.SetText(new StringKey("val", "SELECT_SKILLS")); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // Get all heros int heroCount = 0; // Count number of selected heroes foreach (Quest.Hero h in game.quest.heroes) { if (h.heroData != null) { heroCount++; } } float xOffset = UIScaler.GetHCenter(-11); if (heroCount < 4) { xOffset += 3f; } if (heroCount < 3) { xOffset += 3f; } int availableXP = 0; for (int i = 0; i < heroCount; i++) { int tmp = i; ui = new UIElement(); ui.SetLocation(xOffset, 3.5f, 4, 4); ui.SetButton(delegate { Update(tmp); }); Texture2D heroTex = ContentData.FileToTexture(game.quest.heroes[i].heroData.image); ui.SetImage(heroTex); if (i != hero) { ui.SetBGColor(new Color(0.3f, 0.3f, 0.3f)); } availableXP = game.quest.heroes[i].AvailableXP(); if (availableXP != 0) { ui = new UIElement(); ui.SetLocation(xOffset + 2, 5.5f, 2, 2); ui.SetText(availableXP.ToString(), Color.blue); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Update(tmp); }); new UIElementBorder(ui, Color.blue); } xOffset += 6f; } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16), 8.5f, 32, 5); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16), 8.5f, 2, 5); ui.SetText("1"); ui.SetFontSize(UIScaler.GetLargeFont()); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16), 13.5f, 32, 5); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16), 13.5f, 2, 5); ui.SetText("2"); ui.SetFontSize(UIScaler.GetLargeFont()); new UIElementBorder(ui); string hybridClass = game.quest.heroes[hero].hybridClass; if (hybridClass.Length > 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16.5f), 18.5f, 11, 5); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16.5f), 18.5f, 2, 5); ui.SetText("1"); ui.SetFontSize(UIScaler.GetLargeFont()); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-5.5f), 18.5f, 11, 5); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-5.5f), 18.5f, 2, 5); ui.SetText("2"); ui.SetFontSize(UIScaler.GetLargeFont()); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(5.5f), 18.5f, 11, 5); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(5.5f), 18.5f, 2, 5); ui.SetText("3"); ui.SetFontSize(UIScaler.GetLargeFont()); new UIElementBorder(ui); } else { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16), 18.5f, 32, 5); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-16), 18.5f, 2, 5); ui.SetText("3"); ui.SetFontSize(UIScaler.GetLargeFont()); new UIElementBorder(ui); } float[] xOffsetArray = new float[4]; xOffsetArray[1] = UIScaler.GetHCenter(-13); xOffsetArray[2] = UIScaler.GetHCenter(-13); xOffsetArray[3] = UIScaler.GetHCenter(-8); float yOffset = 4; availableXP = game.quest.heroes[hero].AvailableXP(); foreach (SkillData s in game.cd.skills.Values) { if (s.xp == 0) { continue; } if (game.quest.heroes[hero].className.Length == 0) { continue; } Color buttonColor = new Color(0.4f, 0.4f, 0.4f); if (game.quest.heroes[hero].skills.Contains(s.sectionName)) { buttonColor = Color.green; } else if (s.xp <= availableXP) { buttonColor = Color.white; } string skill = s.sectionName; if (s.sectionName.IndexOf("Skill" + game.quest.heroes[hero].className.Substring("Class".Length)) == 0) { if (hybridClass.Length > 0 && s.xp == 3) { continue; } ui = new UIElement(); ui.SetLocation(xOffsetArray[s.xp], yOffset + (s.xp * 5), 8, 4); ui.SetText(s.name, buttonColor); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { SelectSkill(hero, skill); }); new UIElementBorder(ui, buttonColor); xOffsetArray[s.xp] += 10; continue; } if (hybridClass.Length == 0) { continue; } if (s.sectionName.IndexOf("Skill" + hybridClass.Substring("Class".Length)) != 0) { continue; } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-25f) + (s.xp * 11f), yOffset + 15, 8, 4); ui.SetText(s.name, buttonColor); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { SelectSkill(hero, skill); }); new UIElementBorder(ui, buttonColor); } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-4f), 24.5f, 8, 2); ui.SetText(CommonStringKeys.CLOSE); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.Dialog); new UIElementBorder(ui); }
public QuestDetailsScreen(QuestData.Quest q) { Game game = Game.Get(); LocalizationRead.AddDictionary("qst", q.localizationDict); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 0.5f, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(q.name); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // Draw Image if (q.image.Length > 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-20), 4, 8, 8); ui.SetImage(ContentData.FileToTexture(Path.Combine(q.path, q.image))); new UIElementBorder(ui); } // Draw Description ui = new UIElement(); float height = ui.GetStringHeight(q.description, 30); if (height > 25) { height = 25; } ui.SetLocation(UIScaler.GetHCenter(-7), 15 - (height / 2), 30, height); ui.SetText(q.description); new UIElementBorder(ui); // Draw authors ui = new UIElement(); height = ui.GetStringHeight(q.authors, 14); if (height > 25) { height = 25; } ui.SetLocation(UIScaler.GetHCenter(-23), 18.5f - (height / 2), 14, height); ui.SetText(q.authors); new UIElementBorder(ui); // Difficulty if (q.difficulty != 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-13), 27, 11, 1); ui.SetText(new StringKey("val", "DIFFICULTY")); string symbol = "*"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-13), 28, 11, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28, (1 - q.difficulty) * 6.9f, 2); ui.SetBGColor(new Color(0, 0, 0, 0.7f)); } // Duration if (q.lengthMax != 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(2), 27, 11, 1); ui.SetText(new StringKey("val", "DURATION")); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(2), 28, 4, 2); ui.SetText(q.lengthMin.ToString()); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(6.5f), 28, 2, 2); ui.SetText("-"); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(9), 28, 4, 2); ui.SetText(q.lengthMax.ToString()); ui.SetFontSize(UIScaler.GetMediumFont()); } // DELETE button (only for archive, directory might be edited by user) if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie") { ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-8.5f), 0.5f, 8, 2); ui.SetText(CommonStringKeys.DELETE, Color.grey); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Delete(q); }); new UIElementBorder(ui, Color.grey); } ui = new UIElement(); ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Cancel); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(new StringKey("val", "START"), Color.green); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Start(q); }); new UIElementBorder(ui, Color.green); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public MainMenuScreen() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Game game = Game.Get(); game.cd = new ContentData(game.gameType.DataDirectory()); // Check if we found anything if (game.cd.GetPacks().Count == 0) { ValkyrieDebug.Log("Error: Failed to find any content packs, please check that you have them present in: " + game.gameType.DataDirectory() + System.Environment.NewLine); Application.Quit(); } // Load base game.cd.LoadContentID(""); List <string> music = new List <string>(); foreach (AudioData ad in game.cd.audio.Values) { if (ad.ContainsTrait("menu")) { music.Add(ad.file); } } game.audioControl.Music(music); // Name. Should this be the banner, or better to print Valkyrie with the game font? DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("Valkyrie", false)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); // Button for start quest/scenario TextButton tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 5), new Vector2(12, 2f), new StringKey("val", "START_QUEST", game.gameType.QuestName()), delegate { Start(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // Load save game (enabled if exists) if (SaveManager.SaveExists()) { tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 8), new Vector2(12, 2f), new StringKey("val", "LOAD_QUEST", game.gameType.QuestName()), delegate { SaveManager.Load(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); } else { db = new DialogBox( new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 8), new Vector2(12, 2f), new StringKey("val", "LOAD_QUEST", game.gameType.QuestName()), Color.red); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.SetFont(game.gameType.GetHeaderFont()); db.AddBorder(); } // Content selection page tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 11), new Vector2(12, 2f), SELECT_CONTENT, delegate { Content(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // Quest/Scenario editor tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 14), new Vector2(12, 2f), new StringKey("val", "QUEST_NAME_EDITOR", game.gameType.QuestName()), delegate { Editor(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // About page (managed in this class) tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 17), new Vector2(12, 2f), ABOUT, delegate { About(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // Configuration menu tb = new TextButton( new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 20), new Vector2(12, 2f), OPTIONS, delegate { Config(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // Exit Valkyrie tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 23), new Vector2(12, 2f), CommonStringKeys.EXIT, delegate { Exit(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); }
private void CreateElements() { float offset = 1f; if (save) { offset += 2; new DialogBox(new Vector2(UIScaler.GetHCenter(-21), offset), new Vector2(42, 24), StringKey.NULL); offset += 1; } // Options screen text DialogBox dbTittle = new DialogBox( new Vector2(UIScaler.GetHCenter(-10), offset), new Vector2(20, 3), SELECT_SAVE ); dbTittle.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); dbTittle.SetFont(game.gameType.GetHeaderFont()); offset += 4; TextButton tb; for (int i = 0; i < saves.Count; i++) { int tmp = i; if (saves[i].valid) { string name = SAVE.Translate() + " " + i; if (i == 0) { if (save) { continue; } name = AUTOSAVE.Translate(); } tb = new TextButton( new Vector2(UIScaler.GetHCenter(-20), offset), new Vector2(40, 4f), new StringKey(null, "", false), delegate { Select(tmp); }); if (saves[i].image != null) { Sprite imgSprite = Sprite.Create(saves[i].image, new Rect(0, 0, saves[i].image.width, saves[i].image.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect); tb = new TextButton( new Vector2(UIScaler.GetHCenter(-20), offset), new Vector2(4f * (float)saves[i].image.width / (float)saves[i].image.height, 4f), new StringKey(null, "", false), delegate { Select(tmp); }); tb.background.GetComponent <UnityEngine.UI.Image>().sprite = imgSprite; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; } tb = new TextButton( new Vector2(UIScaler.GetHCenter(-12), offset + 0.5f), new Vector2(10, 2f), new StringKey(null, name, false), delegate { Select(tmp); }); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.border.Destroy(); tb = new TextButton( new Vector2(UIScaler.GetHCenter(-1), offset + 0.5f), new Vector2(20, 2f), new StringKey(null, saves[i].saveTime.ToString(), false), delegate { Select(tmp); }); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleRight; tb.border.Destroy(); tb = new TextButton( new Vector2(UIScaler.GetHCenter(-12), offset + 2.6f), new Vector2(31, 1f), new StringKey(null, saves[i].quest, false), delegate { Select(tmp); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.border.Destroy(); } else { tb = new TextButton( new Vector2(UIScaler.GetHCenter(-20), offset), new Vector2(40, 4f), new StringKey(null, "", false), delegate { Select(tmp); }, Color.gray); } offset += 5; } if (save) { // Button for cancel tb = new TextButton(new Vector2(UIScaler.GetHCenter(-4), 24), new Vector2(8, 2), CommonStringKeys.CANCEL, delegate { Destroyer.Dialog(); }); } else { // Button for back to main menu tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Destroyer.MainMenu(); }, Color.red); } tb.SetFont(game.gameType.GetHeaderFont()); }
// Create a pack with list of quests to edit public QuestEditSelection() { Game game = Game.Get(); // Get list of unpacked quest in user location (editable) // TODO: open/save in packages questList = QuestLoader.GetUserUnpackedQuests(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("val", "SELECT", game.gameType.QuestName())); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21); new UIElementBorder(scrollArea); // List of quests int offset = 0; TextButton tb; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; string translation = q.Value.name.Translate(); UIElement ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", translation), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetBGColor(Color.white); offset += 2; } scrollArea.SetScrollSize(offset); // Main menu tb = new TextButton( new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Cancel(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Delete a user quest tb = new TextButton( new Vector2((UIScaler.GetRight() * 3 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.DELETE, delegate { Delete(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Copy a quest tb = new TextButton( new Vector2((UIScaler.GetRight() * 5 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.COPY, delegate { Copy(); }); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Create a new quest tb = new TextButton( new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.NEW, delegate { NewQuest(); }); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
// Create a pack with list of quests to edit public QuestEditSelection() { Game game = Game.Get(); // Get list of unpacked quest in user location (editable) // TODO: open/save in packages questList = QuestLoader.GetUserUnpackedQuests(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("val", "SELECT", game.gameType.QuestName())); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), StringKey.NULL); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); GameObject scrollBarObj = new GameObject("scrollbar"); scrollBarObj.transform.parent = db.background.transform; RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>(); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit()); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit()); UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>(); scrollBar.direction = UnityEngine.UI.Scrollbar.Direction.BottomToTop; scrollRect.verticalScrollbar = scrollBar; GameObject scrollBarHandle = new GameObject("scrollbarhandle"); scrollBarHandle.transform.parent = scrollBarObj.transform; //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>(); scrollBarHandle.AddComponent <UnityEngine.UI.Image>(); scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f); scrollBar.handleRect = scrollBarHandle.GetComponent <RectTransform>(); scrollBar.handleRect.offsetMin = Vector2.zero; scrollBar.handleRect.offsetMax = Vector2.zero; scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; // List of quests int offset = 5; TextButton tb; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; string translation = q.Value.name.Translate(); tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), new StringKey("val", "INDENT", translation), delegate { Selection(key); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; offset += 2; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); // Main menu tb = new TextButton( new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Cancel(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Delete a user quest tb = new TextButton( new Vector2((UIScaler.GetRight() * 3 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.DELETE, delegate { Delete(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Copy a quest tb = new TextButton( new Vector2((UIScaler.GetRight() * 5 / 8) - 4, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.COPY, delegate { Copy(); }); tb.SetFont(Game.Get().gameType.GetHeaderFont()); // Create a new quest tb = new TextButton( new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.NEW, delegate { NewQuest(); }); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
/// <summary> /// Draw download options screen /// </summary> public void DrawList() { Destroyer.Dialog(); localManifest = IniRead.ReadFromString(""); if (File.Exists(saveLocation() + "/manifest.ini")) { localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini"); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "QUEST_NAME_DOWNLOAD", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f); new UIElementBorder(scrollArea); // Start here float offset = 0; // Loop through all available quests foreach (RemoteQuest rq in remoteQuests) { string file = rq.name + ".valkyrie"; string questName = rq.GetData("name." + game.currentLang); if (questName.Length == 0) { questName = rq.GetData("name." + rq.GetData("defaultlanguage")); } if (questName.Length == 0) { questName = rq.name; } int remoteFormat = 0; int.TryParse(rq.GetData("format"), out remoteFormat); bool formatOK = (remoteFormat >= QuestData.Quest.minumumFormat) && (remoteFormat <= QuestData.Quest.currentFormat); if (!formatOK) { continue; } bool exists = File.Exists(saveLocation() + "/" + file); bool update = true; if (exists) { string localHash = localManifest.Get(rq.name, "version"); string remoteHash = rq.GetData("version"); update = !localHash.Equals(remoteHash); } Color bg = Color.white; if (exists) { bg = new Color(0.7f, 0.7f, 1f); if (!update) { bg = new Color(0.1f, 0.1f, 0.1f); } } // Frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.1f); ui.SetBGColor(bg); if (update) { ui.SetButton(delegate { Selection(rq); }); } offset += 0.05f; // Draw Image ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, 3, 3); ui.SetBGColor(bg); if (update) { ui.SetButton(delegate { Selection(rq); }); } if (rq.image != null) { ui.SetImage(rq.image); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetBGColor(Color.clear); ui.SetLocation(4, offset, UIScaler.GetWidthUnits() - 8, 3f); ui.SetTextPadding(1.2f); if (update && exists) { ui.SetText(new StringKey("val", "QUEST_NAME_UPDATE", questName), Color.black); } else { ui.SetText(questName, Color.black); } if (update) { ui.SetButton(delegate { Selection(rq); }); } ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.3f)); // Duration int lengthMax = 0; int.TryParse(rq.GetData("lengthmax"), out lengthMax); if (lengthMax > 0) { int lengthMin = 0; int.TryParse(rq.GetData("lengthmin"), out lengthMin); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11), offset, 2, 1); ui.SetText(lengthMin.ToString(), Color.black); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-9), offset, 1, 1); ui.SetText("-", Color.black); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-8), offset, 2, 1); ui.SetText(lengthMax.ToString(), Color.black); ui.SetBGColor(Color.clear); } // Difficulty float difficulty = 0; float.TryParse(rq.GetData("difficulty"), out difficulty); if (difficulty != 0) { string symbol = "π"; // will if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-13), offset + 1, 9, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11.95f) + (difficulty * 6.9f), offset + 1, (1 - difficulty) * 6.9f, 2); Color filter = bg; filter.a = 0.7f; ui.SetBGColor(filter); } // Size is 1.2 to be clear of characters with tails if (exists) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(((UIScaler.GetWidthUnits() - 3) / 2) - 4, offset + 2.5f, 8, 1.2f); ui.SetBGColor(new Color(0.7f, 0, 0)); ui.SetText(CommonStringKeys.DELETE, Color.black); ui.SetButton(delegate { Delete(file); }); offset += 0.5f; } offset += 4; } foreach (KeyValuePair <string, Dictionary <string, string> > kv in localManifest.data) { // Only looking for files missing from remote bool onRemote = false; foreach (RemoteQuest rq in remoteQuests) { if (rq.name.Equals(kv.Key)) { onRemote = true; } } if (onRemote) { continue; } string type = localManifest.Get(kv.Key, "type"); // Only looking for packages of this game type if (!game.gameType.TypeName().Equals(type)) { continue; } string file = kv.Key + ".valkyrie"; // Size is 1.2 to be clear of characters with tails if (File.Exists(saveLocation() + "/" + file)) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 8, 1.2f); ui.SetTextPadding(1.2f); ui.SetText(file, Color.black); ui.SetBGColor(new Color(0.1f, 0.1f, 0.1f)); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetWidthUnits() - 12, offset, 8, 1.2f); ui.SetText(CommonStringKeys.DELETE, Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Delete(file); }); ui.SetBGColor(new Color(0.7f, 0, 0)); offset += 2; } } scrollArea.SetScrollSize(offset); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetButton(delegate { Cancel(); }); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); new UIElementBorder(ui, Color.red); }
// List of quests to copy public void Copy() { // Can copy all quests, not just user questList = QuestLoader.GetQuests(); Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Header DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("val", "SELECT_TO_COPY", game.gameType.QuestName()) ); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), StringKey.NULL); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); GameObject scrollBarObj = new GameObject("scrollbar"); scrollBarObj.transform.parent = db.background.transform; RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>(); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit()); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit()); UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>(); scrollBar.direction = UnityEngine.UI.Scrollbar.Direction.BottomToTop; scrollRect.verticalScrollbar = scrollBar; GameObject scrollBarHandle = new GameObject("scrollbarhandle"); scrollBarHandle.transform.parent = scrollBarObj.transform; //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>(); scrollBarHandle.AddComponent <UnityEngine.UI.Image>(); scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f); scrollBar.handleRect = scrollBarHandle.GetComponent <RectTransform>(); scrollBar.handleRect.offsetMin = Vector2.zero; scrollBar.handleRect.offsetMax = Vector2.zero; scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; // List of quests int offset = 5; TextButton tb; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), new StringKey("val", "INDENT", q.Value.name), delegate { Copy(key); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; offset += 2; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); // Back to edit selection tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { CancelCopy(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
private void CreateElements() { float offset = 1f; UIElement ui = null; if (save) { offset += 2; ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-21), offset, 42, 24); offset += 1; } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-10), offset, 20, 3); ui.SetText(SELECT_SAVE); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); offset += 4; for (int i = 0; i < saves.Count; i++) { if (i == 0 && save) { continue; } int tmp = i; if (saves[i].valid) { string name = SAVE.Translate() + " " + i; if (i == 0) { name = AUTOSAVE.Translate(); } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-20), offset, 40, 4); ui.SetButton(delegate { Select(tmp); }); new UIElementBorder(ui); if (saves[i].image != null) { Sprite imgSprite = Sprite.Create(saves[i].image, new Rect(0, 0, saves[i].image.width, saves[i].image.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-20), offset, 4f * (float)saves[i].image.width / (float)saves[i].image.height, 4); ui.SetButton(delegate { Select(tmp); }); ui.SetImage(imgSprite); new UIElementBorder(ui); } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-12), offset + 0.5f, 10, 2); ui.SetText(name); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Select(tmp); }); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-1), offset + 0.5f, 20, 2); ui.SetText(saves[i].saveTime.ToString()); ui.SetTextAlignment(TextAnchor.MiddleRight); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Select(tmp); }); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-12), offset + 2.6f, 31, 1); ui.SetText(saves[i].quest_name); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Select(tmp); }); } else { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-20), offset, 40, 4); ui.SetButton(delegate { Select(tmp); }); new UIElementBorder(ui, Color.gray); } offset += 5; } if (save) { // Button for cancel ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-4), 24, 8, 2); ui.SetText(CommonStringKeys.CANCEL); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.Dialog); new UIElementBorder(ui); } else { // Button for back to main menu ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(GameStateManager.MainMenu); new UIElementBorder(ui, Color.red); } ui.SetFont(game.gameType.GetHeaderFont()); }
public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql) { questList = ql; Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Clean up downloader if present foreach (GameObject go in GameObject.FindGameObjectsWithTag("questui")) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox( new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("val", "SELECT", game.gameType.QuestName()) ); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), StringKey.NULL); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollBarObj = new GameObject("scrollbar"); scrollBarObj.transform.parent = db.background.transform; RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>(); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit()); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit()); UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>(); scrollBar.direction = UnityEngine.UI.Scrollbar.Direction.BottomToTop; scrollRect.verticalScrollbar = scrollBar; GameObject scrollBarHandle = new GameObject("scrollbarhandle"); scrollBarHandle.transform.parent = scrollBarObj.transform; //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>(); scrollBarHandle.AddComponent <UnityEngine.UI.Image>(); scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f); scrollBar.handleRect = scrollBarHandle.GetComponent <RectTransform>(); scrollBar.handleRect.offsetMin = Vector2.zero; scrollBar.handleRect.offsetMax = Vector2.zero; GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; TextButton tb; // Start here float offset = 5; // Loop through all available quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; string translation = q.Value.name.Translate(); // Size is 1.2 to be clear of characters with tails tb = new TextButton( new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), new StringKey("val", "INDENT", translation), delegate { Selection(key); }, Color.black, (int)offset); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; offset += 2; } } // Loop through all unavailable quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; string translation = q.Value.name.Translate(); // Size is 1.2 to be clear of characters with tails db = new DialogBox( new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), new StringKey("val", "INDENT", translation), Color.black); db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f); db.background.transform.parent = scrollArea.transform; offset += 1.2f; foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs())) { db = new DialogBox( new Vector2(4, offset), new Vector2(UIScaler.GetWidthUnits() - 9, 1.2f), // TODO: Expansion names should be keys too new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)), Color.black); db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.4f, 0.4f, 0.4f); db.background.transform.parent = scrollArea.transform; offset += 1.2f; } } offset += 0.8f; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); tb = new TextButton( new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); tb = new TextButton( new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), DOWNLOAD, delegate { Download(); }, Color.green); tb.SetFont(game.gameType.GetHeaderFont()); }
public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql) { questList = ql; Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Clean up downloader if present foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.QUESTUI)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f); new UIElementBorder(scrollArea); // Start here float offset = 0; // Loop through all available quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; string translation = q.Value.name.Translate(); // Frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.1f); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); offset += 0.05f; // Draw Image ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, 3, 3); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); if (q.Value.image.Length > 0) { ui.SetImage(ContentData.FileToTexture(Path.Combine(q.Value.path, q.Value.image))); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetBGColor(Color.clear); ui.SetLocation(4, offset, UIScaler.GetWidthUnits() - 8, 3f); ui.SetTextPadding(1.2f); ui.SetText(translation, Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.3f)); // Duration if (q.Value.lengthMax != 0) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11), offset, 2, 1); ui.SetText(q.Value.lengthMin.ToString(), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-9), offset, 1, 1); ui.SetButton(delegate { Selection(key); }); ui.SetText("-", Color.black); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-8), offset, 2, 1); ui.SetText(q.Value.lengthMax.ToString(), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetBGColor(Color.clear); } // Difficulty if (q.Value.difficulty != 0) { string symbol = "π"; // will if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-12), offset + 1, 7, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Selection(key); }); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11.95f) + (q.Value.difficulty * 6.9f), offset + 1, (1 - q.Value.difficulty) * 6.9f, 2); ui.SetBGColor(new Color(1, 1, 1, 0.7f)); ui.SetButton(delegate { Selection(key); }); } offset += 4; } } // Loop through all unavailable quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; string translation = q.Value.name.Translate(); // Size is 1.2 to be clear of characters with tails ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", translation), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs())) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(3, offset, UIScaler.GetWidthUnits() - 9, 1.2f); ui.SetText(new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; } } offset += 0.8f; } scrollArea.SetScrollSize(offset); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Cancel(); }); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2); ui.SetText(DOWNLOAD, Color.green); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Download(); }); new UIElementBorder(ui, Color.green); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public MainMenuScreen() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Game game = Game.Get(); List <string> music = new List <string>(); foreach (AudioData ad in game.cd.audio.Values) { if (ad.ContainsTrait("menu")) { music.Add(ad.file); } } game.audioControl.PlayDefaultQuestMusic(music); // Name. Should this be the banner, or better to print Valkyrie with the game font? UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText("Valkyrie"); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // Version type : alpha / beta should be displayed if (Game.Get().version.EndsWith("a")) { ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3); ui.SetText("alpha version"); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(UIScaler.GetMediumFont()); } if (Game.Get().version.EndsWith("b")) { ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-6), 1, 6, 3); ui.SetText("beta version"); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(UIScaler.GetMediumFont()); } // Button for start quest/scenario ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 5, ButtonWidth, 2); ui.SetText(START_QUEST); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Start); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 8, ButtonWidth, 2); if (SaveManager.SaveExists()) { ui.SetText(LOAD_QUEST); ui.SetButton(delegate { new SaveSelectScreen(); }); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); } else { ui.SetText(LOAD_QUEST, Color.grey); new UIElementBorder(ui, Color.grey); } ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); // Content selection page ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 11, ButtonWidth, 2); ui.SetText(SELECT_CONTENT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Content); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // Quest/Scenario editor ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 14, ButtonWidth, 2); ui.SetText(new StringKey("val", "QUEST_NAME_EDITOR", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Editor); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // About page (managed in this class) ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 17, ButtonWidth, 2); ui.SetText(ABOUT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(About); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // Configuration menu ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 20, ButtonWidth, 2); ui.SetText(OPTIONS); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Config); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); // Exit Valkyrie ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - ButtonWidth) / 2, 23, ButtonWidth, 2); ui.SetText(CommonStringKeys.EXIT); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Exit); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); }
// Create a pack with list of quests to edit public QuestEditSelection() { Game game = Game.Get(); // clear list of local quests to make sure we take the latest changes game.questsList.UnloadLocalQuests(); // Get list of unpacked quest in user location (editable) // TODO: open/save in packages questList = QuestLoader.GetUserUnpackedQuests(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName())); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21); new UIElementBorder(scrollArea); // List of quests int offset = 0; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", translation), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetBGColor(Color.white); offset += 2; } scrollArea.SetScrollSize(offset); // Main menu ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Cancel); new UIElementBorder(ui, Color.red); // Delete a user quest ui = new UIElement(); ui.SetLocation((UIScaler.GetRight() * 3 / 8) - 4, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.DELETE, Color.red); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Delete); new UIElementBorder(ui, Color.red); // Copy a quest ui = new UIElement(); ui.SetLocation((UIScaler.GetRight() * 5 / 8) - 4, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.COPY); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Copy); new UIElementBorder(ui); // Create a new quest ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.NEW); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(NewQuest); new UIElementBorder(ui); }
public void Update() { Destroyer.Dialog(); Game game = Game.Get(); DialogBox db = new DialogBox( new Vector2(UIScaler.GetHCenter(-18), 1), new Vector2(36, 23), StringKey.NULL); db.AddBorder(); // Add a title to the page db = new DialogBox( new Vector2(UIScaler.GetHCenter(-6), 1), new Vector2(12, 3), new StringKey("val", "ITEMS")); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); UIElementScrollHorizontal scrollArea = new UIElementScrollHorizontal(); scrollArea.SetLocation(UIScaler.GetHCenter(-17), 5, 34, 13); new UIElementBorder(scrollArea); float xOffset = UIScaler.GetHCenter(-16); TextButton tb = null; foreach (string s in game.quest.itemInspect.Keys) { string tmp = s; tb = new TextButton(new Vector2(xOffset, 14), new Vector2(8, 2), game.cd.items[s].name, delegate { Inspect(tmp); }, Color.black); tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.SetParent(scrollArea.GetScrollTransform()); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); Texture2D itemTex = ContentData.FileToTexture(game.cd.items[s].image); Sprite itemSprite = Sprite.Create(itemTex, new Rect(0, 0, itemTex.width, itemTex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect); tb = new TextButton(new Vector2(xOffset, 6), new Vector2(8, 8), StringKey.NULL, delegate { Inspect(tmp); }, Color.clear); tb.background.GetComponent <UnityEngine.UI.Image>().sprite = itemSprite; tb.background.transform.SetParent(scrollArea.GetScrollTransform()); tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; xOffset += 9; } scrollArea.SetScrollSize(xOffset - UIScaler.GetHCenter(-16)); tb = new TextButton( new Vector2(UIScaler.GetHCenter(-4f), 24.5f), new Vector2(8, 2), CommonStringKeys.CLOSE, delegate { Destroyer.Dialog(); }); }