/// <summary> /// Set white element text.</summary> /// <param name="content">StringKey to be translated.</param> public void SetText(StringKey content) { SetText(content.Translate(), Color.white); }
/// <summary> /// Set element text.</summary> /// <param name="content">StringKey to be translated.</param> /// <param name="textColor">Color to display text.</param> public void SetText(StringKey content, Color textColor) { SetText(content.Translate(), textColor); }
/// <summary> /// Draw a button with localization string key /// </summary> /// <param name="location">position vector in scale units</param> /// <param name="size">size vector in scale units</param> /// <param name="textKey">localization string key</param> /// <param name="call">function to call on press</param> /// <param name="colour">colour for the text and border</param> /// <param name="id">unique identifier for Unity (default 0)</param> public TextButton(Vector2 location, Vector2 size, StringKey textKey, UnityEngine.Events.UnityAction call, Color colour, int id = 0) { createButton(location, size, textKey.Translate(), call, colour, id); }
public void Draw() { // This will destroy all Destroyer.Destroy(); Game game = Game.Get(); game.gameType = new NoGameType(); // Get the current content for games if (Application.platform == RuntimePlatform.OSXPlayer) { fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.MacOS, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.MacOS, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); #if IA fcIA = new FFGImport(FFGAppImport.GameType.IA, Platform.MacOS, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); #endif } else if (Application.platform == RuntimePlatform.Android) { fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.Android, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.Android, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); #if IA fcIA = new FFGImport(FFGAppImport.GameType.IA, Platform.Android, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); #endif } else { fcD2E = new FFGImport(FFGAppImport.GameType.D2E, Platform.Windows, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); fcMoM = new FFGImport(FFGAppImport.GameType.MoM, Platform.Windows, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); #if IA fcIA = new FFGImport(FFGAppImport.GameType.IA, Platform.Windows, Game.AppData() + Path.DirectorySeparatorChar, Application.isEditor); #endif } fcD2E.Inspect(); fcMoM.Inspect(); #if IA fcIA.Inspect(); #endif // Banner Image Sprite bannerSprite; Texture2D newTex = Resources.Load("sprites/banner") as Texture2D; GameObject banner = new GameObject("banner"); banner.tag = Game.DIALOG; banner.transform.SetParent(game.uICanvas.transform); RectTransform trans = banner.AddComponent <RectTransform>(); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit()); banner.AddComponent <CanvasRenderer>(); UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>(); bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1); image.sprite = bannerSprite; image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); // first button y offset float offset = 12f; // Draw D2E button bool D2E_need_import = fcD2E.NeedImport(); bool D2E_import_available = fcD2E.ImportAvailable(); Color startColor = D2E_need_import ? Color.grey : Color.white; int fontSize = UIScaler.GetMediumFont(); UIElement ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, offset, 30, 3); // If we need to import we can't play this type if (!D2E_need_import) { ui.SetText(D2E_NAME, startColor); ui.SetButton(delegate { D2E(); }); } else { string message = ""; if (D2E_import_available) { message = D2E_NAME.Translate(); } else { message = D2E_NAME.Translate() + System.Environment.NewLine + D2E_APP_NOT_FOUND.Translate(); fontSize = (int)(UIScaler.GetMediumFont() / 1.05f); } ui.SetText(message, startColor); } ui.SetFontSize(fontSize); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui, startColor); // Draw D2E import button ui = new UIElement(); if (D2E_import_available || !D2E_need_import) { ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, offset + 3.2f, 14, 2); StringKey keyText = D2E_need_import ? CONTENT_IMPORT : CONTENT_REIMPORT; ui.SetText(keyText); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Import("D2E", !D2E_import_available); }); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); } else // Import unavailable { // only install button for Android if (Application.platform == RuntimePlatform.Android) { ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, offset + 3.2f, 24, 1.3f); ui.SetText(CONTENT_INSTALL_VIA_GOOGLEPLAY, Color.red); ui.SetButton(delegate { GotoWebBrowser(D2E_APP_URL_ANDROID); }); new UIElementBorder(ui, Color.red); } else { // install and locate button for other systems ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() / 2) - 13, offset + 3.2f, 12, 1.3f); ui.SetText(CONTENT_INSTALL_VIA_STEAM, Color.red); ui.SetButton(delegate { GotoWebBrowser(D2E_APP_URL_STEAM); }); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() / 2) + 1, offset + 3.2f, 12, 1.3f); ui.SetText(CONTENT_LOCATE, Color.red); ui.SetButton(delegate { Import("D2E", true); }); new UIElementBorder(ui, Color.red); } } offset += 7f; // Draw MoM button bool MoM_need_import = fcMoM.NeedImport(); bool MoM_import_available = fcMoM.ImportAvailable(); startColor = MoM_need_import ? Color.grey : Color.white; fontSize = UIScaler.GetMediumFont(); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, offset, 30, 3); // If we need to import we can't play this type if (!MoM_need_import) { ui.SetText(MOM_NAME, startColor); ui.SetButton(delegate { MoM(); }); } else { string message = ""; if (MoM_import_available) { message = MOM_NAME.Translate(); } else { message = MOM_NAME.Translate() + System.Environment.NewLine + MOM_APP_NOT_FOUND.Translate(); fontSize = (int)(UIScaler.GetMediumFont() / 1.05f); } ui.SetText(message, startColor); } ui.SetFontSize(fontSize); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui, startColor); // Draw MoM import button ui = new UIElement(); if (MoM_import_available || !MoM_need_import) { ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, offset + 3.2f, 14, 2); StringKey keyText = MoM_need_import ? CONTENT_IMPORT : CONTENT_REIMPORT; ui.SetText(keyText); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Import("MoM", !MoM_import_available); }); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); } else // Import unavailable { // only install button for Android if (Application.platform == RuntimePlatform.Android) { ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, offset + 3.2f, 24, 1.3f); ui.SetText(CONTENT_INSTALL_VIA_GOOGLEPLAY, Color.red); ui.SetButton(delegate { GotoWebBrowser(MOM_APP_URL_ANDROID); }); new UIElementBorder(ui, Color.red); } else { // install and locate button for other systems ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() / 2) - 13, offset + 3.2f, 12, 1.3f); ui.SetText(CONTENT_INSTALL_VIA_STEAM, Color.red); ui.SetButton(delegate { GotoWebBrowser(MOM_APP_URL_STEAM); }); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() / 2) + 1, offset + 3.2f, 12, 1.3f); ui.SetText(CONTENT_LOCATE, Color.red); ui.SetButton(delegate { Import("MoM", true); }); new UIElementBorder(ui, Color.red); } } #if IA // Draw IA button startColor = Color.white; if (fcIA.NeedImport()) { startColor = Color.gray; } // Always disabled startColor = Color.gray; ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 30) / 2, 21, 30, 3); ui.SetText(IA_NAME, startColor); ui.SetFontSize(UIScaler.GetMediumFont()); //ui.SetButton(delegate { IA(); }); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui, startColor); // Draw IA import button ui = new UIElement(); if (fcIA.ImportAvailable()) { ui.SetLocation((UIScaler.GetWidthUnits() - 14) / 2, 24.2f, 14, 2); StringKey keyText = fcIA.NeedImport() ? CONTENT_IMPORT : CONTENT_REIMPORT; ui.SetText(keyText); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Import("IA"); }); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui); } else // Import unavailable { ui.SetLocation((UIScaler.GetWidthUnits() - 24) / 2, 24.2f, 24, 1); if (Application.platform == RuntimePlatform.Android) { ui.SetText(IA_APP_NOT_FOUND_ANDROID, Color.red); } else { ui.SetText(IA_APP_NOT_FOUND, Color.red); } new UIElementBorder(ui, Color.red); } #endif ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.EXIT, Color.red); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Exit); ui.SetBGColor(new Color(0, 0.03f, 0f)); new UIElementBorder(ui, Color.red); // will display a button if a new version is available VersionManager.GetLatestVersionAsync(CheckForNewValkyrieVersion); }
public void AddItem(StringKey stringKey, Color color) { items.Add(new SelectionItem(stringKey.Translate(), stringKey.key, color)); }
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()); }
public void SetInfo() { LocalizationRead.updateScenarioText(monsterComponent.info_key, INFO.Translate()); Update(); }
/// <summary> /// Get the height of a text box of fixed width with a text string at small size with standard font and standard padding.</summary> /// <param name="content">Text to translate.</param> /// <param name="width">Width of the text box in UIScaler units.</param> /// <returns> /// The required text box height in UIScaler units.</returns> public float GetStringHeight(StringKey content, float width) { return(GetStringHeight(content.Translate(), width)); }
/// <summary> /// Create text on the screen, as above with /// </summary> /// <param name="location">position in scale units</param> /// <param name="size">size in scale units</param> /// <param name="text">localization key to display</param> /// <param name="fgColour">color for the text, border if used</param> /// <param name="bgColour">color for the background</param> public DialogBox(Vector2 location, Vector2 size, StringKey text, Color fgColour, Color bgColour) { createDialog(location, size, text.Translate(), fgColour, bgColour); }
public void SetName() { LocalizationRead.updateScenarioText(monsterComponent.monstername_key, NAME.Translate()); Update(); }
public void SetImage() { UIWindowSelectionListImage select = new UIWindowSelectionListImage(SelectImage, SELECT_IMAGE.Translate()); select.AddItem("{NONE}", ""); Dictionary <string, IEnumerable <string> > traits = new Dictionary <string, IEnumerable <string> >(); traits.Add(new StringKey("val", "SOURCE").Translate(), new string[] { new StringKey("val", "FILE").Translate() }); string relativePath = new FileInfo(Path.GetDirectoryName(Game.Get().quest.qd.questPath)).FullName; foreach (string s in Directory.GetFiles(relativePath, "*.png", SearchOption.AllDirectories)) { select.AddItem(s.Substring(relativePath.Length + 1), traits); } foreach (string s in Directory.GetFiles(relativePath, "*.jpg", SearchOption.AllDirectories)) { select.AddItem(s.Substring(relativePath.Length + 1), traits); } foreach (KeyValuePair <string, ImageData> kv in Game.Get().cd.images) { select.AddItem(kv.Value); } select.ExcludeExpansions(); select.Draw(); }
public void AddItem(StringKey stringKey) { AddItem(new SelectionItem(stringKey.Translate(), stringKey.key)); }
public StringKey GetLabel() { return(new StringKey(null, EventManager.SymbolReplace(label.Translate()), false)); }
/// <summary> /// Get the length of a text string at small size with standard font.</summary> /// <param name="content">Text to translate.</param> /// <returns> /// The size of the text in UIScaler units.</returns> public float GetStringWidth(StringKey content) { return(GetStringWidth(content.Translate())); }
public StringKey GetLabel() { return(new StringKey(null, EventManager.OutputSymbolReplace(EventManager.Event.ReplaceComponentText(label.Translate())), false)); }
/// <summary> /// Get the length of a text string at small size with given font.</summary> /// <param name="content">Text to translate.</param> /// <param name="fontSize">Size of font.</param> /// <param name="fontName">Name of font.</param> /// <returns> /// The size of the text in UIScaler units.</returns> public float GetStringWidth(StringKey content, int fontSize, Font fontName) { return(GetStringWidth(content.Translate(), fontSize, fontName)); }
public void AddItem(StringKey stringKey, Dictionary <string, IEnumerable <string> > traits) { items.Add(new SelectionItemTraits(stringKey.Translate(), stringKey.key, traits)); }
public UIWindowSelectionList(UnityEngine.Events.UnityAction <string> call, StringKey title) { _title = title.Translate(); _call = call; }
public void AddItem(StringKey stringKey, Dictionary <string, IEnumerable <string> > traits, Color color) { items.Add(new SelectionItemTraits(stringKey.Translate(), stringKey.key, traits)); items[items.Count - 1].SetColor(color); }
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++) { int tmp = i; if (saves[i].valid) { string name = SAVE.Translate() + " " + i; if (i == 0) { if (save) { continue; } 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); 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(Destroyer.MainMenu); new UIElementBorder(ui, Color.red); } ui.SetFont(game.gameType.GetHeaderFont()); }
public void Image() { if (puzzleComponent.puzzleClass.Equals("code")) { UIWindowSelectionList selectType = new UIWindowSelectionList(SelectImage, SELECT_IMAGE.Translate()); selectType.AddItem("{NUMBERS}", ""); selectType.AddItem(new StringKey("val", "SYMBOL").Translate(), "symbol"); selectType.AddItem(new StringKey("val", "ELEMENT").Translate(), "element"); selectType.Draw(); return; } UIWindowSelectionListImage select = new UIWindowSelectionListImage(SelectImage, SELECT_IMAGE.Translate()); Dictionary <string, IEnumerable <string> > traits = new Dictionary <string, IEnumerable <string> >(); traits.Add(CommonStringKeys.SOURCE.Translate(), new string[] { CommonStringKeys.FILE.Translate() }); string relativePath = new FileInfo(Path.GetDirectoryName(Game.Get().quest.qd.questPath)).FullName; foreach (string s in Directory.GetFiles(relativePath, "*.png", SearchOption.AllDirectories)) { select.AddItem(s.Substring(relativePath.Length + 1), traits); } foreach (string s in Directory.GetFiles(relativePath, "*.jpg", SearchOption.AllDirectories)) { select.AddItem(s.Substring(relativePath.Length + 1), traits); } foreach (PuzzleData puzzleData in Game.Get().cd.Values <PuzzleData>()) { select.AddItem(puzzleData); } select.ExcludeExpansions(); select.Draw(); }
/// <summary> /// Draw a button (white) with localization string key /// </summary> /// <param name="location">position vector in scale units</param> /// <param name="size">size vector in scale units</param> /// <param name="textKey">localization string key</param> /// <param name="call">function to call on press</param> public TextButton(Vector2 location, Vector2 size, StringKey textKey, UnityEngine.Events.UnityAction call) { createButton(location, size, textKey.Translate(), call, Color.white, 0); }
public void AddItem(StringKey stringKey, Dictionary <string, IEnumerable <string> > traits, Color color) { AddItem(new SelectionItemTraits(stringKey.Translate(), stringKey.key, traits), color); }
/// <summary> /// Create text on the screen, as above with /// </summary> /// <param name="location">position in scale units</param> /// <param name="size">size in scale units</param> /// <param name="text">localization key to display</param> /// <param name="fgColour">color for the text, border if used</param> public DialogBox(Vector2 location, Vector2 size, StringKey text, Color fgColour) { createDialog(location, size, text.Translate(), fgColour, new Color(0, 0, 0, (float)0.9)); }
// Draw the expansions on the screen, highlighting those that are enabled public void DrawList(string type = "") { // Clean up Destroyer.Dialog(); // Initialise selected list selected = new List <string>(); // Fetch which packs are selected from the current config (items under [Packs]) foreach (var pack in game.config.GetPacks(game.gameType.TypeName())) { selected.Add(pack); } // Draw a header UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 2); ui.SetText(SELECT_EXPANSION); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 4, UIScaler.GetWidthUnits() - 2, 22); new UIElementBorder(scrollArea); buttons = new Dictionary <string, List <UIElement> >(); languageButtons = new Dictionary <string, UIElement>(); // Start here float offset = 0.5f; bool left = true; var packLanguages = game.config.GetPackLanguages(game.gameType.TypeName()); // Note this is currently unordered foreach (ContentData.ContentPack cp in game.cd.allPacks) { // If the id is "" this is base content and can be ignored if (cp.id.Length > 0 && cp.type.Equals(type)) { string id = cp.id; buttons.Add(id, new List <UIElement>()); Color bgColor = Color.white; if (!selected.Contains(id)) { bgColor = new Color(0.3f, 0.3f, 0.3f); } // Create a sprite with the pack's image Texture2D tex = ContentData.FileToTexture(cp.image); ui = new UIElement(scrollArea.GetScrollTransform()); if (left) { ui.SetLocation(1, offset, 6, 6); } else { ui.SetLocation(UIScaler.GetWidthUnits() - 10, offset, 6, 6); } ui.SetImage(tex); ui.SetButton(delegate { Select(id); }); ui.SetBGColor(bgColor); new UIElementBorder(ui); buttons[id].Add(ui); ui = new UIElement(scrollArea.GetScrollTransform()); if (left) { ui.SetLocation(7, offset + 1.5f, UIScaler.GetWidthUnits() - 19, 3); } else { ui.SetLocation(9, offset + 1.5f, UIScaler.GetWidthUnits() - 20, 3); } ui.SetBGColor(bgColor); ui.SetButton(delegate { Select(id); }); buttons[id].Add(ui); int text_font_size = (int)(UIScaler.GetMediumFont() * 0.9f); ui = new UIElement(scrollArea.GetScrollTransform()); if (left) { ui.SetLocation(8, offset + 1.5f, UIScaler.GetWidthUnits() - 19, 3); } else { ui.SetLocation(10, offset + 1.5f, UIScaler.GetWidthUnits() - 20, 3); } ui.SetBGColor(bgColor); ui.SetText(game.cd.GetContentName(id), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(ui.GetText().Length > LARGE_FONT_LIMIT ? UIScaler.GetSmallFont() : UIScaler.GetMediumFont()); ui.SetFontSize(text_font_size); ui.SetButton(delegate { Select(id); }); buttons[id].Add(ui); float text_width = ui.GetStringWidth() + 0.5f; ui = new UIElement(scrollArea.GetScrollTransform()); if (left) { ui.SetLocation(8 + text_width, offset + 1.5f, UIScaler.GetWidthUnits() - 19 - text_width, 3); } else { ui.SetLocation(10 + text_width, offset + 1.5f, UIScaler.GetWidthUnits() - 20 - text_width, 3); } ui.SetBGColor(bgColor); ui.SetText("(" + game.cd.GetContentAcronym(id) + ")", Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFont(game.gameType.GetSymbolFont()); ui.SetFontSize(text_font_size); ui.SetButton(delegate { Select(id); }); buttons[id].Add(ui); packLanguages.TryGetValue(id, out string packLanguage); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetWidthUnits() - 17, offset + 2.5f, 5, 1); ui.SetBGColor(Color.black); ui.SetText(string.IsNullOrWhiteSpace(packLanguage) ? DEFAULT_LANGUAGE_KEY.Translate() : packLanguage, Color.white); ui.SetTextAlignment(TextAnchor.MiddleCenter); ui.SetFont(game.gameType.GetSymbolFont()); ui.SetFontSize(UIScaler.GetSmallFont()); ui.SetButton(delegate { SelectLanguage(id, type); }); new UIElementBorder(ui, Color.black, 0.1f); new UIElementBorder(ui, Color.white); languageButtons.Add(id, ui); left = !left; offset += 4f; } } scrollArea.SetScrollSize(offset + 2.5f); // Button for back to 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()); new UIElementBorder(ui, Color.red); if (game.cd.Count <PackTypeData>() > 1) { ui.SetButton(DrawTypeList); } else { ui.SetButton(Quit); } }