protected override void Setup() { if (IsSetup) { return; } base.Setup(); // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); nativeOverlayTexture = DaggerfallUI.GetTextureFromImg(nativeImgOverlayName); if (!nativeTexture || !nativeOverlayTexture) { throw new Exception("CreateCharSpecialAdvantage: Could not load native texture."); } // Create panel for window advantagePanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName); advantagePanel.HorizontalAlignment = HorizontalAlignment.Left; advantagePanel.VerticalAlignment = VerticalAlignment.Top; advantagePanel.BackgroundTexture = nativeTexture; advantagePanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill; NativePanel.Components.Add(advantagePanel); // Setup UI components font = DaggerfallUI.SmallFont; Panel buttonPanel = NativePanel; if (!isDisadvantages) // Adding this overlay makes it appear as Special Advantages instead of Disadvantages { overlayPanel.Size = TextureReplacement.GetSize(nativeOverlayTexture, nativeImgOverlayName); overlayPanel.HorizontalAlignment = HorizontalAlignment.Left; overlayPanel.VerticalAlignment = VerticalAlignment.Top; overlayPanel.BackgroundTexture = nativeOverlayTexture; overlayPanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill; advantagePanel.Components.Add(overlayPanel); buttonPanel = overlayPanel; } addAdvantageButton = DaggerfallUI.AddButton(addAdvantageButtonRect, buttonPanel); addAdvantageButton.OnMouseClick += AddAdvantageButton_OnMouseClick; addAdvantageButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); exitButton = DaggerfallUI.AddButton(exitButtonRect, NativePanel); exitButton.OnMouseClick += ExitButton_OnMouseClick; exitButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); for (int i = 0; i < maxLabels; i++) { advantageLabels[i] = DaggerfallUI.AddTextLabel(font, new Vector2(8, 35 + i * labelSpacing), string.Empty, NativePanel); advantageLabels[i].OnMouseClick += AdvantageLabel_OnMouseClick; advantageLabels[i].Tag = -1; } UpdateLabels(); InitializeAdjustmentDict(); IsSetup = true; }
/// <summary> /// Gets a new DaggerfallFont. /// </summary> /// <param name="index">I ndex of font between 1-5 (default is 4).</param> /// <returns>DaggerfallFont</returns> public DaggerfallFont GetFont(int index = 4) { // Set path string path = string.Empty; if (dfUnity.IsPathValidated) { path = dfUnity.Arena2Path; } // Try to load font from either Daggerfall path or Resources switch (index) { case 1: if (daggerfallFonts[0] == null) { daggerfallFonts[0] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0000); } daggerfallFonts[0].FilterMode = globalFilterMode; return(daggerfallFonts[0]); case 2: if (daggerfallFonts[1] == null) { daggerfallFonts[1] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0001); } daggerfallFonts[1].FilterMode = globalFilterMode; return(daggerfallFonts[1]); case 3: if (daggerfallFonts[2] == null) { daggerfallFonts[2] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0002); } daggerfallFonts[2].FilterMode = globalFilterMode; return(daggerfallFonts[2]); case 4: default: if (daggerfallFonts[3] == null) { daggerfallFonts[3] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0003); } daggerfallFonts[3].FilterMode = globalFilterMode; return(daggerfallFonts[3]); case 5: if (daggerfallFonts[4] == null) { daggerfallFonts[4] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0004); } daggerfallFonts[4].FilterMode = globalFilterMode; return(daggerfallFonts[4]); } }
public DaggerfallFont GetFont(int index) { // Do nothing if DaggerfallUnity path not valid if (!DaggerfallUnity.Instance.IsPathValidated) { return(null); } switch (index) { case 1: if (daggerfallFonts[0] == null) { daggerfallFonts[0] = new DaggerfallFont(dfUnity.Arena2Path, DaggerfallFont.FontName.FONT0000); } daggerfallFonts[0].FilterMode = globalFilterMode; return(daggerfallFonts[0]); case 2: if (daggerfallFonts[1] == null) { daggerfallFonts[1] = new DaggerfallFont(dfUnity.Arena2Path, DaggerfallFont.FontName.FONT0001); } daggerfallFonts[1].FilterMode = globalFilterMode; return(daggerfallFonts[1]); case 3: if (daggerfallFonts[2] == null) { daggerfallFonts[2] = new DaggerfallFont(dfUnity.Arena2Path, DaggerfallFont.FontName.FONT0002); } daggerfallFonts[2].FilterMode = globalFilterMode; return(daggerfallFonts[2]); case 4: default: if (daggerfallFonts[3] == null) { daggerfallFonts[3] = new DaggerfallFont(dfUnity.Arena2Path, DaggerfallFont.FontName.FONT0003); } daggerfallFonts[3].FilterMode = globalFilterMode; return(daggerfallFonts[3]); case 5: if (daggerfallFonts[4] == null) { daggerfallFonts[4] = new DaggerfallFont(dfUnity.Arena2Path, DaggerfallFont.FontName.FONT0004); } daggerfallFonts[4].FilterMode = globalFilterMode; return(daggerfallFonts[4]); } }
protected override void Setup() { if (IsSetup) { return; } base.Setup(); prevWindow = (CreateCharCustomClass)this.PreviousWindow; // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharSpecialAdvantage: Could not load native texture."); } // Create panel for window repPanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName); repPanel.HorizontalAlignment = HorizontalAlignment.Center; repPanel.VerticalAlignment = VerticalAlignment.Middle; repPanel.BackgroundTexture = nativeTexture; repPanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill; repPanel.OnMouseClick += RepPanel_OnMouseClick; NativePanel.Components.Add(repPanel); // Setup UI components font = DaggerfallUI.DefaultFont; exitButton = DaggerfallUI.AddButton(exitButtonRect, repPanel); exitButton.OnMouseClick += ExitButton_OnMouseClick; exitButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); // Setup adjustable bars SetupRepBars(merchantsGreenPanel, merchantsRedPanel, new Vector2(3f, 75f), new Vector2(3f, 77f), prevWindow.MerchantsRep); SetupRepBars(peasantsGreenPanel, peasantsRedPanel, new Vector2(36f, 75f), new Vector2(36f, 77f), prevWindow.PeasantsRep); SetupRepBars(scholarsGreenPanel, scholarsRedPanel, new Vector2(69f, 75f), new Vector2(69f, 77f), prevWindow.ScholarsRep); SetupRepBars(nobilityGreenPanel, nobilityRedPanel, new Vector2(102f, 75f), new Vector2(102f, 77f), prevWindow.NobilityRep); SetupRepBars(underworldGreenPanel, underworldRedPanel, new Vector2(135f, 75f), new Vector2(135f, 77f), prevWindow.UnderworldRep); // Setup text labels merchantsPtsLabel = DaggerfallUI.AddTextLabel(font, new Vector2(18f, 143f), prevWindow.MerchantsRep.ToString(), repPanel); peasantsPtsLabel = DaggerfallUI.AddTextLabel(font, new Vector2(50f, 143f), prevWindow.PeasantsRep.ToString(), repPanel); scholarsPtsLabel = DaggerfallUI.AddTextLabel(font, new Vector2(82f, 143f), prevWindow.ScholarsRep.ToString(), repPanel); nobilityPtsLabel = DaggerfallUI.AddTextLabel(font, new Vector2(114f, 143f), prevWindow.NobilityRep.ToString(), repPanel); underworldPtsLabel = DaggerfallUI.AddTextLabel(font, new Vector2(146f, 143f), prevWindow.UnderworldRep.ToString(), repPanel); distributePtsLabel = DaggerfallUI.AddTextLabel(font, new Vector2(64f, 173f), pointsToDistribute.ToString(), repPanel); IsSetup = true; }
public DaggerfallListPickerWindow(IUserInterfaceManager uiManager, IUserInterfaceWindow previous = null, DaggerfallFont font = null, int rowsDisplayed = 0) : base(uiManager, previous) { Font = font; RowsDisplayed = rowsDisplayed; }
protected override void Setup() { if (IsSetup) { return; } // Load native textures nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); nativeDaggerTexture = DaggerfallUI.GetTextureFromImg(nativeDaggerImgName); if (!nativeTexture || !nativeDaggerTexture) { throw new Exception("CreateCharCustomClass: Could not load native texture."); } // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Add stats rollout statsRollout = new StatsRollout(false, true); statsRollout.Position = new Vector2(0, 0); NativePanel.Components.Add(statsRollout); // Add name textbox nameTextBox.Position = new Vector2(100, 5); nameTextBox.Size = new Vector2(214, 7); NativePanel.Components.Add(nameTextBox); // Initialize character class createdClass = new DFCareer(); createdClass.HitPointsPerLevel = defaultHpPerLevel; createdClass.SpellPointMultiplier = DFCareer.SpellPointMultipliers.Times_0_50; createdClass.SpellPointMultiplierValue = .5f; // Initiate UI components font = DaggerfallUI.DefaultFont; SetupButtons(); hpLabel = DaggerfallUI.AddTextLabel(font, new Vector2(285, 55), createdClass.HitPointsPerLevel.ToString(), NativePanel); daggerPanel.Size = new Vector2(24, 9); daggerPanel.BackgroundTexture = nativeDaggerTexture; NativePanel.Components.Add(daggerPanel); UpdateDifficulty(); // Setup help dictionary helpDict = new Dictionary <string, int> { { HardStrings.helpAttributes, 2402 }, { HardStrings.helpClassName, 2401 }, { HardStrings.helpGeneral, 2400 }, { HardStrings.helpReputations, 2406 }, { HardStrings.helpSkillAdvancement, 2407 }, { HardStrings.helpSkills, 2403 }, { HardStrings.helpSpecialAdvantages, 2404 }, { HardStrings.helpSpecialDisadvantages, 2405 } }; // Setup skills dictionary skillsDict = new Dictionary <string, DFCareer.Skills>(); foreach (DFCareer.Skills skill in Enum.GetValues(typeof(DFCareer.Skills))) { skillsDict.Add(DaggerfallUnity.Instance.TextProvider.GetSkillName(skill), skill); } skillsDict.Remove(string.Empty); // Don't include "none" skill value. skillsList = new List <string>(skillsDict.Keys); skillsList.Sort(); // Sort skills alphabetically a la classic. IsSetup = true; }
void ChangeFont(int index) { currentFont = DaggerfallUI.Instance.GetFont(index); }
protected override void Setup() { if (IsSetup) { return; } // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharAddBonusStats: Could not load native texture."); } // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Add stats rollout statsRollout = new StatsRollout(); statsRollout.Position = new Vector2(0, 0); statsRollout.OnStatChanged += StatsRollout_OnStatChanged; NativePanel.Components.Add(statsRollout); // Add secondary stat labels font = DaggerfallUI.DefaultFont; damageModifierLabel = DaggerfallUI.AddTextLabel(font, new Vector2(83, 22), string.Empty, NativePanel); maxEncumbranceLabel = DaggerfallUI.AddTextLabel(font, new Vector2(103, 32), string.Empty, NativePanel); spellPointsLabel = DaggerfallUI.AddTextLabel(font, new Vector2(112, 49), string.Empty, NativePanel); magicResistLabel = DaggerfallUI.AddTextLabel(font, new Vector2(121, 71), string.Empty, NativePanel); toHitModifierLabel = DaggerfallUI.AddTextLabel(font, new Vector2(97, 93), string.Empty, NativePanel); hitPointsModifierLabel = DaggerfallUI.AddTextLabel(font, new Vector2(101, 110), string.Empty, NativePanel); healingRateModifierLabel = DaggerfallUI.AddTextLabel(font, new Vector2(122, 120), string.Empty, NativePanel); // Fix secondary stat shadow colors to match game damageModifierLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; maxEncumbranceLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; spellPointsLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; magicResistLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; toHitModifierLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; hitPointsModifierLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; healingRateModifierLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; // Add "Reroll" button Button rerollButton = DaggerfallUI.AddButton(new Rect(263, 147, 39, 22), NativePanel); rerollButton.OnMouseClick += RerollButton_OnMouseClick; // Add "Save Roll" button Button saveRoll = DaggerfallUI.AddButton(new Rect(162, 162, 71, 9), NativePanel); saveRoll.OnMouseClick += SaveRoll_OnMouseClick; // Add "Load Roll" button Button loadRoll = DaggerfallUI.AddButton(new Rect(162, 171, 71, 9), NativePanel); loadRoll.OnMouseClick += LoadRoll_OnMouseClick; // Add "OK" button Button okButton = DaggerfallUI.AddButton(new Rect(263, 172, 39, 22), NativePanel); okButton.OnMouseClick += OkButton_OnMouseClick; IsSetup = true; }
public static TextBox AddTextBoxWithFocus(Rect rect, string defaultText, Panel panel = null, int maxCharacters = -1, DaggerfallFont font = null) { TextBox textBox = new TextBox(font); textBox.Position = rect.position; textBox.Size = rect.size; textBox.FixedSize = true; textBox.DefaultText = defaultText; if (maxCharacters > 0) { textBox.MaxCharacters = maxCharacters; } textBox.UseFocus = true; textBox.Outline.Enabled = true; if (panel != null) { panel.Components.Add(textBox); } return(textBox); }
public static TextBox AddTextBox(Rect rect, string defaultText, Panel panel = null, int maxCharacters = -1, DaggerfallFont font = null, int glyphSpacing = 1) { TextBox textBox = new TextBox(font); textBox.Position = new Vector2(rect.x, rect.y); textBox.Size = new Vector2(rect.width, rect.height); textBox.DefaultText = defaultText; textBox.MaxCharacters = maxCharacters; textBox.TextOffset = 2; if (panel != null) { panel.Components.Add(textBox); } return(textBox); }
/// <summary> /// Gets a new DaggerfallFont. /// </summary> /// <param name="index">Index of font between 1-5 (default is 4).</param> /// <returns>DaggerfallFont</returns> public DaggerfallFont GetFont(int index = 4) { // Attempt to use StreamingAssets for FNT files string path = FontsFolder; if (!Directory.Exists(path)) { Debug.LogErrorFormat("Fonts directory path {0} not found. Falling back to Arena2 folder.", path); // Try Arena2 path path = string.Empty; if (dfUnity.IsPathValidated) { path = dfUnity.Arena2Path; } } // Must have a fonts path by now if (string.IsNullOrEmpty(path)) { throw new System.Exception("DaggerfallUI could not find a valid path for fonts in StreamingAssets/Fonts or fallback Arena2 folder."); } // Try to load font from target path switch (index) { case 1: if (daggerfallFonts[0] == null) { daggerfallFonts[0] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0000); } daggerfallFonts[0].FilterMode = globalFilterMode; return(daggerfallFonts[0]); case 2: if (daggerfallFonts[1] == null) { daggerfallFonts[1] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0001); } daggerfallFonts[1].FilterMode = globalFilterMode; return(daggerfallFonts[1]); case 3: if (daggerfallFonts[2] == null) { daggerfallFonts[2] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0002); } daggerfallFonts[2].FilterMode = globalFilterMode; return(daggerfallFonts[2]); case 4: default: if (daggerfallFonts[3] == null) { daggerfallFonts[3] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0003); } daggerfallFonts[3].FilterMode = globalFilterMode; return(daggerfallFonts[3]); case 5: if (daggerfallFonts[4] == null) { daggerfallFonts[4] = new DaggerfallFont(path, DaggerfallFont.FontName.FONT0004); } daggerfallFonts[4].FilterMode = globalFilterMode; return(daggerfallFonts[4]); } }
/// <summary> /// Register a DaggerfallFont replacement to be used for specified locale. /// If this font name and locale replacement has already been registered, it will be replaced by this font. /// Note: Localized fonts can only be SDF capable. SDF font setting will be forced on by registering any custom font. /// </summary> /// <param name="locale">Locale of font.</param> /// <param name="fontName">Name of font, which must be one of the 5 Daggerfall fonts.</param> /// <param name="font">DaggerfallFont object to use for this font name and locale.</param> public void RegisterLocalizedFont(Locale locale, DaggerfallFont.FontName fontName, DaggerfallFont font) { if (locale == null || font == null) { Debug.LogError("RegisterLocalizedFont() locale and font cannot be null."); } string key = GetLocaleFontKey(locale, fontName); if (localizedFonts.ContainsKey(key)) { localizedFonts.Remove(key); } localizedFonts.Add(key, font); DaggerfallUnity.Settings.SDFFontRendering = true; }
void ChangeFont(DaggerfallFont.FontName fontName) { currentFont = DaggerfallUI.Instance.GetFont(fontName); }