protected void SetupShopGoldInfoText() { PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit; int currentBuildingID = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey; LimitedGoldShops.ShopData sd; int goldSupply = 0; uint investedAmount = 0; if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd)) { goldSupply = sd.CurrentGoldSupply; investedAmount = sd.AmountInvested; } if (!(playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.Temple) && !(playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.GuildHall)) { localTextLabelOne = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(263, 34), string.Empty, NativePanel); localTextLabelOne.TextScale = 0.85f; localTextLabelOne.Text = "Invested: " + investedAmount.ToString(); localTextLabelTwo = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(263, 41), string.Empty, NativePanel); localTextLabelTwo.TextScale = 0.85f; localTextLabelTwo.Text = "Shop Gold: " + goldSupply.ToString(); } UpdateShopGoldDisplay(); }
void LayoutPage() { ClearPage(); pageLines = 0; int x = 20, y = 25; for (int i = pageStartLine; i < GameManager.Instance.PlayerEntity.BackStory.Count; i++) { TextLabel label = DaggerfallUI.AddTextLabel(currentFont, new Vector2(x, y), GameManager.Instance.PlayerEntity.BackStory[i], NativePanel); label.HorizontalAlignment = HorizontalAlignment.None; label.TextColor = DaggerfallUI.DaggerfallDefaultTextColor; label.ShadowColor = DaggerfallUI.DaggerfallDefaultShadowColor; label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; pageLabels.Add(label); pageLines++; if (pageLines == maxPageLines) { break; } y += currentFont.GlyphHeight + extraLeading; } }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("DaggerfallCourtWindow: Could not load native texture."); } // Native court panel courtPanel.HorizontalAlignment = HorizontalAlignment.Center; courtPanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName); courtPanel.BackgroundTexture = nativeTexture; NativePanel.Components.Add(courtPanel); // Cancel any camera recoil RaiseOnCourtScreenEvent(); // Add days until freedom label daysUntilFreedomLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(156, 165), string.Empty, NativePanel); daysUntilFreedomLabel.TextColor = DaggerfallUI.DaggerfallPrisonDaysUntilFreedomColor; daysUntilFreedomLabel.ShadowColor = DaggerfallUI.DaggerfallPrisonDaysUntilFreedomShadowColor; daysUntilFreedomLabel.HorizontalAlignment = HorizontalAlignment.Center; playerEntity = GameManager.Instance.PlayerEntity; AllowCancel = false; }
private void AddSectionDescriptionBox(string description) { const int margin = 1; const int textMargin = 1; Vector2 position = new Vector2(0 + textMargin + margin, 0 + textMargin); TextLabel textLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.Instance.Font4, position, description); textLabel.TextScale = 0.5f; textLabel.TextColor = sectionTitleColor; textLabel.ShadowColor = Color.clear; textLabel.WrapText = true; textLabel.WrapWords = true; textLabel.MaxWidth = columnWidth - (textMargin + margin) * 2; int height = textLabel.TextHeight + 2; Panel background = DaggerfallUI.AddPanel(new Rect(x + margin, y, columnWidth - margin * 2, height)); background.BackgroundColor = sectionDescriptionBackgroundColor; background.Outline.Enabled = true; background.Outline.Color = sectionDescriptionOutlineColor; background.Outline.Thickness = 1; background.Components.Add(textLabel); AddAtNextPosition(height, background); }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharRaceSelect: Could not load native texture."); } // Load picker colours racePickerBitmap = DaggerfallUI.GetImgBitmap(racePickerImgName); // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Add "Please select your home province..." prompt promptLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(0, 16), TextManager.Instance.GetLocalizedText("pleaseSelectYourHomeProvince"), NativePanel); promptLabel.HorizontalAlignment = HorizontalAlignment.Center; promptLabel.TextColor = DaggerfallUI.DaggerfallDefaultTextColor; promptLabel.ShadowColor = DaggerfallUI.DaggerfallDefaultShadowColor; promptLabel.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; // Handle clicks NativePanel.OnMouseClick += ClickHandler; }
void SetupRemoteItemsElements() { // List panel for scrolling behaviour Panel remoteItemsListPanel = DaggerfallUI.AddPanel(remoteItemsListPanelRect, NativePanel); remoteItemsListPanel.OnMouseScrollUp += RemoteItemsListPanel_OnMouseScrollUp; remoteItemsListPanel.OnMouseScrollDown += RemoteItemsListPanel_OnMouseScrollDown; // Setup buttons for (int i = 0; i < listDisplayUnits; i++) { // Button remoteItemsButtons[i] = DaggerfallUI.AddButton(itemsButtonRects[i], remoteItemsListPanel); remoteItemsButtons[i].SetMargins(Margins.All, itemButtonMarginSize); remoteItemsButtons[i].ToolTip = defaultToolTip; remoteItemsButtons[i].Tag = i; remoteItemsButtons[i].OnMouseClick += RemoteItemsButton_OnMouseClick; // Icon image panel remoteItemsIconPanels[i] = DaggerfallUI.AddPanel(remoteItemsButtons[i], AutoSizeModes.ScaleToFit); remoteItemsIconPanels[i].HorizontalAlignment = HorizontalAlignment.Center; remoteItemsIconPanels[i].VerticalAlignment = VerticalAlignment.Middle; remoteItemsIconPanels[i].MaxAutoScale = 1f; // Stack labels remoteItemsStackLabels[i] = DaggerfallUI.AddTextLabel(DaggerfallUI.Instance.Font4, Vector2.zero, string.Empty, remoteItemsButtons[i]); remoteItemsStackLabels[i].HorizontalAlignment = HorizontalAlignment.Right; remoteItemsStackLabels[i].VerticalAlignment = VerticalAlignment.Bottom; remoteItemsStackLabels[i].ShadowPosition = Vector2.zero; remoteItemsStackLabels[i].TextColor = DaggerfallUI.DaggerfallUnityDefaultToolTipTextColor; } }
void SetupLabels() { // Spell name spellNameLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, spellNameLabelPos, string.Empty, mainPanel); spellNameLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; spellNameLabel.MaxCharacters = 18; spellNameLabel.OnMouseClick += SpellNameLabel_OnMouseClick; // Spell points spellPointsLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, spellPointsLabelPos, string.Empty, mainPanel); spellPointsLabel.ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; // Effect labels spellEffectLabels = new TextLabel[spellEffectPanels.Length * 2]; for (int i = 0; i < spellEffectLabels.Length; i++) { spellEffectLabels[i] = new TextLabel(); spellEffectLabels[i].MaxCharacters = 24; spellEffectLabels[i].HorizontalAlignment = HorizontalAlignment.Center; spellEffectLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; if (i % 2 == 0) { spellEffectLabels[i].Position = new Vector2(0, 5); } else { spellEffectLabels[i].Position = new Vector2(0, 17); } spellEffectPanels[i / 2].Components.Add(spellEffectLabels[i]); } }
public StatsRollout() : base() { // Add stat labels font = DaggerfallUI.DefaultFont; Vector2 pos = new Vector2(19, 33); for (int i = 0; i < DaggerfallStats.Count; i++) { statLabels[i] = DaggerfallUI.AddTextLabel(font, pos, string.Empty, this); statLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; pos.y += 22f; } // Add stat select buttons pos = new Vector2(7, 20); Vector2 size = new Vector2(36, 20); for (int i = 0; i < DaggerfallStats.Count; i++) { Button button = DaggerfallUI.AddButton(pos, size, this); button.Tag = i; button.OnMouseClick += StatButton_OnMouseClick; pos.y += 22; } // Add up/down spinner spinner = new UpDownSpinner(); this.Components.Add(spinner); spinner.OnUpButtonClicked += Spinner_OnUpButtonClicked; spinner.OnDownButtonClicked += Spinner_OnDownButtonClicked; SelectStat(0); UpdateStatLabels(); }
void SetupItemsList(bool enhanced) { // List panel for scrolling behaviour Panel itemsListPanel = DaggerfallUI.AddPanel(itemListPanelRect, this); itemsListPanel.OnMouseScrollUp += ItemsListPanel_OnMouseScrollUp; itemsListPanel.OnMouseScrollDown += ItemsListPanel_OnMouseScrollDown; // Setup buttons itemButtons = new Button[listDisplayUnits]; itemIconPanels = new Panel[listDisplayUnits]; itemAnimPanels = new Panel[listDisplayUnits]; itemStackLabels = new TextLabel[listDisplayUnits]; itemMiscLabels = new TextLabel[listDisplayUnits]; Rect[] itemButtonRects = (enhanced) ? itemButtonRects16 : itemButtonRects4; for (int i = 0; i < listDisplayUnits; i++) { // Panel - for backing button in enhanced mode if (enhanced) { Panel buttonPanel = DaggerfallUI.AddPanel(itemButtonRects[i], itemsListPanel); buttonPanel.BackgroundTexture = itemListTextures[i]; } // Buttons (also handle highlight colours) itemButtons[i] = DaggerfallUI.AddButton(itemButtonRects[i], itemsListPanel); itemButtons[i].SetMargins(Margins.All, itemButtonMarginSize); itemButtons[i].ToolTip = toolTip; itemButtons[i].Tag = i; itemButtons[i].OnMouseClick += ItemButton_OnMouseClick; itemButtons[i].OnMouseEnter += ItemButton_OnMouseEnter; itemButtons[i].OnMouseScrollUp += ItemButton_OnMouseEnter; itemButtons[i].OnMouseScrollDown += ItemButton_OnMouseEnter; // Item foreground animation panel itemAnimPanels[i] = DaggerfallUI.AddPanel(itemButtonRects[i], itemsListPanel); itemAnimPanels[i].AnimationDelayInSeconds = foregroundAnimationDelay; // Icon image panel itemIconPanels[i] = DaggerfallUI.AddPanel(itemButtons[i], AutoSizeModes.ScaleToFit); itemIconPanels[i].HorizontalAlignment = HorizontalAlignment.Center; itemIconPanels[i].VerticalAlignment = VerticalAlignment.Middle; itemIconPanels[i].MaxAutoScale = 1f; // Stack labels itemStackLabels[i] = DaggerfallUI.AddTextLabel(DaggerfallUI.Instance.Font4, Vector2.zero, string.Empty, itemButtons[i]); itemStackLabels[i].HorizontalAlignment = HorizontalAlignment.Right; itemStackLabels[i].VerticalAlignment = VerticalAlignment.Bottom; itemStackLabels[i].ShadowPosition = Vector2.zero; itemStackLabels[i].TextScale = textScale; itemStackLabels[i].TextColor = DaggerfallUI.DaggerfallUnityDefaultToolTipTextColor; // Misc labels itemMiscLabels[i] = DaggerfallUI.AddTextLabel(DaggerfallUI.Instance.Font4, Vector2.zero, string.Empty, itemButtons[i]); itemMiscLabels[i].HorizontalAlignment = HorizontalAlignment.Left; itemMiscLabels[i].VerticalAlignment = VerticalAlignment.Top; itemMiscLabels[i].TextScale = textScale; } }
public void AddText(string text) { TextLabel label = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, Vector2.zero, text); label.HorizontalAlignment = HorizontalAlignment.Center; label.Parent = Parent; textRows.AddLast(label); timer = 0; }
protected override void Setup() { // Load all textures LoadTextures(); // Create interface panel mainPanel.HorizontalAlignment = HorizontalAlignment.Center; mainPanel.VerticalAlignment = VerticalAlignment.Top; mainPanel.Position = new Vector2(0, 0); mainPanel.BackgroundTexture = baseTexture; mainPanel.Size = baseSize; // Add primary skill spinner mainPanel.Components.Add(timeAccelSpinner); timeAccelSpinner.Position = timeAccelPos; timeAccelSpinner.OnDownButtonClicked += SlowerButton_OnMouseClick; timeAccelSpinner.OnUpButtonClicked += FasterButton_OnMouseClick; timeAccelSpinner.Value = TimeAcceleration; // Destination label destPanel = DaggerfallUI.AddPanel(destPanelRect, mainPanel); destPanel.Components.Add(destinationLabel); destinationLabel.HorizontalAlignment = HorizontalAlignment.Center; // Message label messageLabel = DaggerfallUI.AddTextLabel(null, new Vector2(0, 32), "", NativePanel); messageLabel.HorizontalAlignment = HorizontalAlignment.Center; // Map button mapButton = DaggerfallUI.AddButton(mapButtonRect, mainPanel); mapButton.OnMouseClick += (_, __) => { DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenTravelMapWindow); }; mapButton.ToolTip = defaultToolTip; mapButton.ToolTipText = TipMap; mapButton.Hotkey = new HotkeySequence(KeyCode.M, HotkeySequence.KeyModifiers.None); mapButton.OnKeyboardEvent += (_, __) => { DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenTravelMapWindow); }; // Camp (pause travel) button campButton = DaggerfallUI.AddButton(campButtonRect, mainPanel); campButton.OnMouseClick += (_, __) => { CloseWindow(); }; campButton.ToolTip = defaultToolTip; campButton.ToolTipText = TipCamp; campButton.Hotkey = new HotkeySequence(KeyCode.C, HotkeySequence.KeyModifiers.None); campButton.OnKeyboardEvent += (_, __) => { CloseWindow(); }; // Exit travel button exitButton = DaggerfallUI.AddButton(exitButtonRect, mainPanel); exitButton.OnMouseClick += (_, __) => { CancelWindow(); }; exitButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.TravelExit); exitButton.OnKeyboardEvent += (_, __) => { CancelWindow(); }; NativePanel.Components.Add(mainPanel); }
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; }
protected override void Setup() { if (IsSetup) { return; } // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharBiography: Could not load native texture."); } // Load question data biogFile = new BiogFile(Document); // Set background NativePanel.BackgroundTexture = nativeTexture; // Set question text questionLabels[0] = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(questionLeft, questionTop), string.Empty, NativePanel); questionLabels[1] = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(questionLeft, questionTop + questionLineSpace), string.Empty, NativePanel); // Setup buttons for (int i = 0; i < buttonCount; i++) { int left = i % 2 == 0 ? buttonsLeft : buttonsLeft + buttonWidth; answerButtons[i] = DaggerfallUI.AddButton(new Rect((float)left, (float)(buttonsTop + (i / 2) * buttonHeight), (float)buttonWidth, (float)buttonHeight), NativePanel); answerButtons[i].Tag = i; answerButtons[i].OnMouseClick += AnswerButton_OnMouseClick; answerLabels[i] = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(21f, 5f), string.Empty, answerButtons[i]); } PopulateControls(biogFile.Questions[questionIndex]); IsSetup = true; }
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; }
void LayoutPage() { if (!dfUnity.TextProvider.IsBookOpen) { return; } ClearPage(); TextFile.Token[] tokens = dfUnity.TextProvider.PageTokens; int x = 10, y = 20; HorizontalAlignment horizontalAlignment = HorizontalAlignment.None; foreach (var token in tokens) { switch (token.formatting) { case TextFile.Formatting.NewLine: // Daggerfall books appear to reset horizontal alignment after newline y += currentFont.GlyphHeight + extraLeading; horizontalAlignment = HorizontalAlignment.None; break; case TextFile.Formatting.FontPrefix: ChangeFont(token.x); break; case TextFile.Formatting.JustifyLeft: horizontalAlignment = HorizontalAlignment.None; break; case TextFile.Formatting.JustifyCenter: horizontalAlignment = HorizontalAlignment.Center; break; case TextFile.Formatting.Text: TextLabel label = DaggerfallUI.AddTextLabel(currentFont, new Vector2(x, y), token.text, NativePanel); label.HorizontalAlignment = horizontalAlignment; label.TextColor = DaggerfallUI.DaggerfallDefaultTextColor; label.ShadowColor = DaggerfallUI.DaggerfallDefaultShadowColor; label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; pageLabels.Add(label); break; default: Debug.Log("DaggerfallBookReaderWindow: Unknown formatting token: " + (int)token.formatting); break; } } }
public EnchantmentPanel(EnchantmentSettings enchantment, Rect renderArea) { Size = panelSizeWithoutScroller; primaryLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.SmallFont, Vector2.zero, enchantment.PrimaryDisplayName, this); secondaryLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.SmallFont, secondaryLabelPos, secondarySpacing + enchantment.SecondaryDisplayName, this); primaryLabel.RestrictedRenderAreaCoordinateType = secondaryLabel.RestrictedRenderAreaCoordinateType = TextLabel.RestrictedRenderArea_CoordinateType.DaggerfallNativeCoordinates; primaryLabel.RectRestrictedRenderArea = secondaryLabel.RectRestrictedRenderArea = renderArea; primaryLabel.TextColor = secondaryLabel.TextColor = textColor; OnMouseEnter += EnchantmentPanel_OnMouseEnter; OnMouseLeave += EnchantmentPanel_OnMouseLeave; RenderArea = renderArea; Enchantment = enchantment; }
protected void SetupButtons() { // Add skill selector buttons for (int i = 0; i < skillButtons.Length; i++) { skillButtons[i] = DaggerfallUI.AddButton(skillButtonRects[i], NativePanel); skillButtons[i].Tag = i; skillButtons[i].OnMouseClick += skillButton_OnMouseClick; skillButtons[i].ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); skillLabels[i] = DaggerfallUI.AddTextLabel(font, new Vector2(3, 2), string.Empty, skillButtons[i]); } // HP spinners hitPointsUpButton = DaggerfallUI.AddButton(hitPointsUpButtonRect, NativePanel); hitPointsUpButton.OnMouseClick += HitPointsUpButton_OnMouseClick; hitPointsUpButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); hitPointsDownButton = DaggerfallUI.AddButton(hitPointsDownButtonRect, NativePanel); hitPointsDownButton.OnMouseUp += HitPointsDownButton_OnMouseClick; hitPointsDownButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); // Help topics helpButton = DaggerfallUI.AddButton(helpButtonRect, NativePanel); helpButton.OnMouseClick += HelpButton_OnMouseClick; helpButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); // Special Advantages/Disadvantages specialAdvantageButton = DaggerfallUI.AddButton(specialAdvantageButtonRect, NativePanel); specialAdvantageButton.OnMouseClick += specialAdvantageButton_OnMouseClick; specialAdvantageButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); specialDisadvantageButton = DaggerfallUI.AddButton(specialDisadvantageButtonRect, NativePanel); specialDisadvantageButton.OnMouseClick += specialDisadvantageButton_OnMouseClick; specialDisadvantageButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); // Reputations reputationButton = DaggerfallUI.AddButton(reputationButtonRect, NativePanel); reputationButton.OnMouseClick += ReputationButton_OnMouseClick; reputationButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); // Exit button exitButton = DaggerfallUI.AddButton(exitButtonRect, NativePanel); exitButton.OnMouseClick += ExitButton_OnMouseClick; exitButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); }
void SetupLabels() { // Tip label tipLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, tipLabelPos, string.Empty, NativePanel); // Status labels maxSpellPointsLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(43, 149), string.Empty, NativePanel); moneyLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(39, 158), string.Empty, NativePanel); goldCostLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(59, 167), string.Empty, NativePanel); spellPointCostLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(70, 176), string.Empty, NativePanel); // Name label spellNameLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, nameLabelPos, string.Empty, NativePanel); spellNameLabel.ShadowPosition = Vector2.zero; // Effect1 Panel effect1NamePanel = DaggerfallUI.AddPanel(effect1NameRect, NativePanel); effect1NamePanel.HorizontalAlignment = HorizontalAlignment.Center; effect1NamePanel.OnMouseClick += Effect1NamePanel_OnMouseClick; effect1NameLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.LargeFont, Vector2.zero, string.Empty, effect1NamePanel); effect1NameLabel.HorizontalAlignment = HorizontalAlignment.Center; effect1NameLabel.ShadowPosition = Vector2.zero; // Effect2 Panel effect2NamePanel = DaggerfallUI.AddPanel(effect2NameRect, NativePanel); effect2NamePanel.HorizontalAlignment = HorizontalAlignment.Center; effect2NamePanel.OnMouseClick += Effect2NamePanel_OnMouseClick; effect2NameLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.LargeFont, Vector2.zero, string.Empty, effect2NamePanel); effect2NameLabel.HorizontalAlignment = HorizontalAlignment.Center; effect2NameLabel.ShadowPosition = Vector2.zero; // Effect3 Panel effect3NamePanel = DaggerfallUI.AddPanel(effect3NameRect, NativePanel); effect3NamePanel.HorizontalAlignment = HorizontalAlignment.Center; effect3NamePanel.OnMouseClick += Effect3NamePanel_OnMouseClick; effect3NameLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.LargeFont, Vector2.zero, string.Empty, effect3NamePanel); effect3NameLabel.HorizontalAlignment = HorizontalAlignment.Center; effect3NameLabel.ShadowPosition = Vector2.zero; }
protected override void Setup() { // Load all the textures used by effect editor window LoadTextures(); // Setup native panel background NativePanel.BackgroundTexture = baseTexture; // Setup controls SetupEffectDescriptionPanels(); SetupSpinners(); SetupButtons(); InitControlState(); // Spell cost label spellCostLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(275, 119), string.Empty, NativePanel); IsSetup = true; UpdateCosts(); }
public EnchantmentPanel(EnchantmentSettings enchantment, Rect renderArea) { bool hasSecondaryLabel = !string.IsNullOrEmpty(enchantment.SecondaryDisplayName); Size = new Vector2(panelWidthWithoutScroller, hasSecondaryLabel ? panelHeightWithSecondary : panelHeightWithoutSecondary); primaryLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.SmallFont, primaryLabelPos, enchantment.PrimaryDisplayName, this); secondaryLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.SmallFont, secondaryLabelPos, secondarySpacing + enchantment.SecondaryDisplayName, this); primaryLabel.TextColor = secondaryLabel.TextColor = textColor; if (!hasSecondaryLabel) { secondaryLabel.Enabled = false; } OnMouseEnter += EnchantmentPanel_OnMouseEnter; OnMouseLeave += EnchantmentPanel_OnMouseLeave; RenderArea = renderArea; Enchantment = enchantment; }
protected override void Setup() { base.Setup(); nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new System.Exception("DaggerfallTravelMap: Could not load native texture."); } greenCheckboxTexture = DaggerfallUI.GetTextureFromResources(greenCheckboxTextureFilename); ParentPanel.BackgroundColor = Color.clear; travelPanel = DaggerfallUI.AddPanel(nativePanelRect, NativePanel); travelPanel.BackgroundTexture = nativeTexture; availableGoldLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(148, 97), "0", NativePanel); availableGoldLabel.MaxCharacters = 12; tripCostLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(117, 107), "0", NativePanel); tripCostLabel.MaxCharacters = 18; travelTimeLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(129, 117), "0", NativePanel); travelTimeLabel.MaxCharacters = 16; speedToggleColorPanel = DaggerfallUI.AddPanel(new Rect(cautiousPanelPos, colorPanelSize), NativePanel); SetToggleLook(speedToggleColorPanel); sleepToggleColorPanel = DaggerfallUI.AddPanel(new Rect(innPanelPos, colorPanelSize), NativePanel); SetToggleLook(sleepToggleColorPanel); transportToggleColorPanel = DaggerfallUI.AddPanel(new Rect(footPos, colorPanelSize), NativePanel); SetToggleLook(transportToggleColorPanel); SetupButtons(); Refresh(); }
/// <summary> /// Adds text with custom delay. /// Delay affects this item only. Subsequent text items can override delay. /// Delay will return to default after time elapsed. /// </summary> /// <param name="text">Text to display.</param> /// <param name="delayInSeconds">Time in seconds before removing text.</param> public void AddText(string text, float delayInSeconds = popDelay) { if (textRows.Count == 0) { // set no-scroll delay timer = delayInSeconds; } else if (timer >= 0) { // retrigger no-scroll delay timer = Mathf.Max(timer, delayInSeconds); } else { // set next no-scroll delay nextPopDelay = Mathf.Max(nextPopDelay, delayInSeconds); } TextLabel label = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, Vector2.zero, text); label.HorizontalAlignment = HorizontalAlignment.Center; label.Parent = Parent; textRows.AddLast(label); GameManager.Instance.PlayerEntity.Notebook.AddMessage(text); }
void SetupControls() { // Add primary skill labels Vector2 skillLabelPos = new Vector2(68, 32); Vector2 skillValueLabelPos = new Vector2(187, 32); Vector2 skillSelectButtonSize = new Vector2(106, 7); for (int i = 0; i < DaggerfallSkills.PrimarySkillsCount; i++) { primarySkillLabels[i] = DaggerfallUI.AddTextLabel(font, skillLabelPos, string.Empty, this); primarySkillLabels[i].Tag = i; primarySkillLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; Button button = DaggerfallUI.AddButton(skillLabelPos, skillSelectButtonSize, this); button.Tag = i; button.OnMouseClick += PrimarySkills_OnMouseClick; primarySkillValueLabels[i] = DaggerfallUI.AddTextLabel(font, skillValueLabelPos, string.Empty, this); primarySkillValueLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; skillLabelPos.y += 10; skillValueLabelPos.y += 10; } // Add major skill labels skillLabelPos = new Vector2(68, 81); skillValueLabelPos = new Vector2(187, 81); for (int i = 0; i < DaggerfallSkills.MajorSkillsCount; i++) { majorSkillLabels[i] = DaggerfallUI.AddTextLabel(font, skillLabelPos, string.Empty, this); majorSkillLabels[i].Tag = i; majorSkillLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; Button button = DaggerfallUI.AddButton(skillLabelPos, skillSelectButtonSize, this); button.Tag = i; button.OnMouseClick += MajorSkills_OnMouseClick; majorSkillValueLabels[i] = DaggerfallUI.AddTextLabel(font, skillValueLabelPos, string.Empty, this); majorSkillValueLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; skillLabelPos.y += 10; skillValueLabelPos.y += 10; } // Add minor skill labels skillLabelPos = new Vector2(68, 130); skillValueLabelPos = new Vector2(187, 130); for (int i = 0; i < DaggerfallSkills.MinorSkillsCount; i++) { minorSkillLabels[i] = DaggerfallUI.AddTextLabel(font, skillLabelPos, string.Empty, this); minorSkillLabels[i].Tag = i; minorSkillLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; Button button = DaggerfallUI.AddButton(skillLabelPos, skillSelectButtonSize, this); button.Tag = i; button.OnMouseClick += MinorSkills_OnMouseClick; minorSkillValueLabels[i] = DaggerfallUI.AddTextLabel(font, skillValueLabelPos, string.Empty, this); minorSkillValueLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; skillLabelPos.y += 10; skillValueLabelPos.y += 10; } // Add primary skill spinner primarySkillSpinner = new LeftRightSpinner(); this.Components.Add(primarySkillSpinner); primarySkillSpinner.OnLeftButtonClicked += PrimarySkillSpinner_OnLeftButtonClicked; primarySkillSpinner.OnRightButtonClicked += PrimarySkillSpinner_OnRightButtonClicked; primarySkillSpinner.Value = bonusPoolPerSkillGroup; SelectPrimarySkill(0); // Add major skill spinner majorSkillSpinner = new LeftRightSpinner(); this.Components.Add(majorSkillSpinner); majorSkillSpinner.OnLeftButtonClicked += MajorSkillSpinner_OnLeftButtonClicked; majorSkillSpinner.OnRightButtonClicked += MajorSkillSpinner_OnRightButtonClicked; majorSkillSpinner.Value = bonusPoolPerSkillGroup; SelectMajorSkill(0); // Add minor skill spinner minorSkillSpinner = new LeftRightSpinner(); this.Components.Add(minorSkillSpinner); minorSkillSpinner.OnLeftButtonClicked += MinorSkillSpinner_OnLeftButtonClicked; minorSkillSpinner.OnRightButtonClicked += MinorSkillSpinner_OnRightButtonClicked; minorSkillSpinner.Value = bonusPoolPerSkillGroup; SelectMinorSkill(0); }
void SetupItemsList(bool enhanced, TextLabel miscLabelTemplate) { // List panel for scrolling behaviour Panel itemsListPanel = DaggerfallUI.AddPanel(itemListPanelRect, this); itemsListPanel.OnMouseScrollUp += ItemsListPanel_OnMouseScrollUp; itemsListPanel.OnMouseScrollDown += ItemsListPanel_OnMouseScrollDown; itemsListPanel.OnMouseLeave += ItemsListPanel_OnMouseLeave; // Setup buttons itemButtons = new Button[listDisplayTotal]; itemIconPanels = new Panel[listDisplayTotal]; itemAnimPanels = new Panel[listDisplayTotal]; itemStackLabels = new TextLabel[listDisplayTotal]; itemMiscLabels = new TextLabel[listDisplayTotal]; // Setup column misc label offsetting. Vector2 offsetPosition = miscLabelTemplate.Position + new Vector2(0, miscLabelOffsetDist); int osi = miscLabelOffsetIdx; for (int i = 0; i < listDisplayTotal; i++) { // Panel - for backing button in enhanced mode if (enhanced) { Panel buttonPanel = DaggerfallUI.AddPanel(itemButtonRects[i], itemsListPanel); buttonPanel.BackgroundTexture = itemListTextures[i]; } // Buttons (also handle highlight colours) itemButtons[i] = DaggerfallUI.AddButton(itemButtonRects[i], itemsListPanel); itemButtons[i].SetMargins(Margins.All, itemButtonMargin); itemButtons[i].ToolTip = toolTip; itemButtons[i].Tag = i; itemButtons[i].OnMouseClick += ItemButton_OnMouseClick; itemButtons[i].OnRightMouseClick += ItemButton_OnRightMouseClick; itemButtons[i].OnMouseEnter += ItemButton_OnMouseEnter; itemButtons[i].OnMouseScrollUp += ItemButton_OnMouseEnter; itemButtons[i].OnMouseScrollDown += ItemButton_OnMouseEnter; // Item foreground animation panel itemAnimPanels[i] = DaggerfallUI.AddPanel(itemButtonRects[i], itemsListPanel); itemAnimPanels[i].AnimationDelayInSeconds = foregroundAnimationDelay; // Icon image panel itemIconPanels[i] = DaggerfallUI.AddPanel(itemButtons[i], AutoSizeModes.ScaleToFit); itemIconPanels[i].HorizontalAlignment = HorizontalAlignment.Center; itemIconPanels[i].VerticalAlignment = VerticalAlignment.Middle; itemIconPanels[i].MaxAutoScale = 1f; // Stack labels itemStackLabels[i] = DaggerfallUI.AddTextLabel(DaggerfallUI.Instance.Font4, Vector2.zero, string.Empty, itemButtons[i]); itemStackLabels[i].HorizontalAlignment = HorizontalAlignment.Right; itemStackLabels[i].VerticalAlignment = VerticalAlignment.Bottom; itemStackLabels[i].ShadowPosition = Vector2.zero; itemStackLabels[i].TextScale = textScale; itemStackLabels[i].TextColor = DaggerfallUI.DaggerfallUnityDefaultToolTipTextColor; // Misc labels Vector2 position = miscLabelTemplate.Position; if (miscLabelOffsetDist != 0 && i == osi) { position = offsetPosition; osi += listWidth; } itemMiscLabels[i] = DaggerfallUI.AddTextLabel(miscLabelTemplate.Font, position, string.Empty, itemButtons[i]); itemMiscLabels[i].HorizontalAlignment = miscLabelTemplate.HorizontalAlignment; itemMiscLabels[i].VerticalAlignment = miscLabelTemplate.VerticalAlignment; itemMiscLabels[i].TextScale = miscLabelTemplate.TextScale; } }
void ShowOptionsPanel() { // Disable previous stage resolutionPanel.Enabled = false; // Create backdrop if (!backdropCreated) { CreateBackdrop(); } // Add options panel optionsPanel.Outline.Enabled = true; optionsPanel.BackgroundColor = backgroundColor; optionsPanel.HorizontalAlignment = HorizontalAlignment.Center; //optionsPanel.VerticalAlignment = VerticalAlignment.Middle; optionsPanel.Position = new Vector2(0, 8); optionsPanel.Size = new Vector2(318, 165); NativePanel.Components.Add(optionsPanel); // Add title text TextLabel titleLabel = new TextLabel(DaggerfallUI.Instance.Font2); titleLabel.Text = "Daggerfall Unity"; titleLabel.Position = new Vector2(0, 15); titleLabel.TextScale = 1.4f; titleLabel.HorizontalAlignment = HorizontalAlignment.Center; optionsPanel.Components.Add(titleLabel); // Add settings path text TextLabel settingsPathLabel = new TextLabel(); settingsPathLabel.Text = DaggerfallUnity.Settings.PersistentDataPath; settingsPathLabel.Position = new Vector2(0, 170); settingsPathLabel.HorizontalAlignment = HorizontalAlignment.Center; settingsPathLabel.ShadowPosition = Vector2.zero; settingsPathLabel.TextColor = secondaryTextColor; settingsPathLabel.BackgroundColor = backgroundColor; optionsPanel.Components.Add(settingsPathLabel); // Setup options checkboxes float x = 8; optionPos = 60; alwayShowOptions = AddOption(x, "alwayShowOptions", DaggerfallUnity.Settings.ShowOptionsAtStart); vsync = AddOption(x, "vsync", DaggerfallUnity.Settings.VSync); swapHealthAndFatigue = AddOption(x, "swapHealthAndFatigue", DaggerfallUnity.Settings.SwapHealthAndFatigueColors); invertMouseVertical = AddOption(x, "invertMouseVertical", DaggerfallUnity.Settings.InvertMouseVertical); mouseSmoothing = AddOption(x, "mouseSmoothing", DaggerfallUnity.Settings.MouseLookSmoothing); x = 165; optionPos = 60; leftHandWeapons = AddOption(x, "leftHandWeapons", GetLeftHandWeapons()); playerNudity = AddOption(x, "playerNudity", DaggerfallUnity.Settings.PlayerNudity); clickToAttack = AddOption(x, "clickToAttack", DaggerfallUnity.Settings.ClickToAttack); // Setup mods checkboxes // TODO: Might rework this, but could still be useful for certain core mods later sdfFontRendering = AddOption(x, "sdfFontRendering", DaggerfallUnity.Settings.SDFFontRendering); sdfFontRendering.OnToggleState += SDFFontRendering_OnToggleState; retro320x200WorldRendering = AddOption(x, "retro320x200World", DaggerfallUnity.Settings.Retro320x200World); //bool exampleModCheckbox = AddOption(x, "Example", "Example built-in mod", DaggerfallUnity.Settings.ExampleModOption); // Add mod note TextLabel modNoteLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(0, 125), GetText("modNote"), optionsPanel); modNoteLabel.HorizontalAlignment = HorizontalAlignment.Center; modNoteLabel.ShadowPosition = Vector2.zero; // Confirm button Button optionsConfirmButton = new Button(); optionsConfirmButton.Position = new Vector2(0, optionsPanel.InteriorHeight - 15); optionsConfirmButton.Size = new Vector2(40, 12); optionsConfirmButton.Outline.Enabled = true; optionsConfirmButton.Label.Text = GetText("play"); optionsConfirmButton.BackgroundColor = new Color(0.0f, 0.5f, 0.0f, 0.4f); optionsConfirmButton.HorizontalAlignment = HorizontalAlignment.Center; optionsConfirmButton.OnMouseClick += OptionsConfirmButton_OnMouseClick; optionsPanel.Components.Add(optionsConfirmButton); // Restart button Button restartButton = new Button(); restartButton.Size = new Vector2(45, 12); restartButton.Label.Text = string.Format("< {0}", GetText("restart")); restartButton.Label.ShadowPosition = Vector2.zero; restartButton.Label.TextColor = secondaryTextColor; restartButton.ToolTip = defaultToolTip; restartButton.ToolTipText = GetText("restartInfo"); restartButton.VerticalAlignment = VerticalAlignment.Top; restartButton.HorizontalAlignment = HorizontalAlignment.Left; restartButton.OnMouseClick += RestartButton_OnMouseClick; optionsPanel.Components.Add(restartButton); if (DaggerfallUnity.Settings.LypyL_ModSystem) { Button ShowModsButton = new Button(); ShowModsButton.Label.Text = GetText("mods"); ShowModsButton.Position = new Vector2(3, optionsConfirmButton.Position.y); ShowModsButton.Size = optionsConfirmButton.Size; ShowModsButton.BackgroundColor = optionsConfirmButton.BackgroundColor; ShowModsButton.Label.TextColor = optionsConfirmButton.Label.TextColor; ShowModsButton.Outline.Enabled = true; optionsPanel.Components.Add(ShowModsButton); ShowModsButton.OnMouseClick += ModsButton_OnOnMouseBlick; } // Advanced Settings Button AdvancedSettingsButton = new Button(); AdvancedSettingsButton.Label.Text = GetText("advanced"); AdvancedSettingsButton.Size = new Vector2(45, 12); AdvancedSettingsButton.Position = new Vector2(optionsPanel.InteriorWidth - AdvancedSettingsButton.Size.x - 3, optionsConfirmButton.Position.y); AdvancedSettingsButton.BackgroundColor = optionsConfirmButton.BackgroundColor; AdvancedSettingsButton.Label.TextColor = optionsConfirmButton.Label.TextColor; AdvancedSettingsButton.Outline.Enabled = true; optionsPanel.Components.Add(AdvancedSettingsButton); AdvancedSettingsButton.OnMouseClick += AdvancedSettingsButton_OnOnMouseBlick; }
public StatsRollout(bool onCharacterSheet = false) : base() { if (onCharacterSheet) { characterSheetPositioning = true; } // Add stat labels font = DaggerfallUI.DefaultFont; Vector2 pos; if (!onCharacterSheet) { pos = new Vector2(19, 33); } else { pos = new Vector2(150, 17); } for (int i = 0; i < DaggerfallStats.Count; i++) { statLabels[i] = DaggerfallUI.AddTextLabel(font, pos, string.Empty, this); statLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; if (!onCharacterSheet) { pos.y += 22f; } else { pos.y += 24f; } } // Add stat select buttons if (!onCharacterSheet) { pos = new Vector2(7, 20); } else { pos = new Vector2(141, 6); } Vector2 size; if (!onCharacterSheet) { size = new Vector2(36, 20); } else { size = new Vector2(28, 20); } for (int i = 0; i < DaggerfallStats.Count; i++) { Button button = DaggerfallUI.AddButton(pos, size, this); button.Tag = i; button.OnMouseClick += StatButton_OnMouseClick; if (!onCharacterSheet) { pos.y += 22f; } else { pos.y += 24f; } } // Add up/down spinner spinner = new UpDownSpinner(); this.Components.Add(spinner); spinner.OnUpButtonClicked += Spinner_OnUpButtonClicked; spinner.OnDownButtonClicked += Spinner_OnDownButtonClicked; SelectStat(0); UpdateStatLabels(); }
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; }
public StatsRollout(bool onCharacterSheet = false, bool freeEdit = false) : base() { if (onCharacterSheet) { characterSheetPositioning = true; } if (freeEdit) { this.freeEdit = true; modifiedStatTextColor = DaggerfallUI.DaggerfallDefaultTextColor; } // Add stat panels and labels font = DaggerfallUI.DefaultFont; Vector2 panelPos, panelSize; if (!onCharacterSheet) { panelPos = new Vector2(8, 33); panelSize = new Vector2(34, 6); } else { panelPos = new Vector2(141, 17); panelSize = new Vector2(28, 6); } for (int i = 0; i < DaggerfallStats.Count; i++) { statPanels[i] = DaggerfallUI.AddPanel(new Rect(panelPos.x, panelPos.y, panelSize.x, panelSize.y), this); statLabels[i] = DaggerfallUI.AddTextLabel(font, Vector2.zero, string.Empty, statPanels[i]); statLabels[i].HorizontalAlignment = HorizontalAlignment.Center; statLabels[i].ShadowColor = DaggerfallUI.DaggerfallAlternateShadowColor1; if (!onCharacterSheet) { panelPos.y += 22f; } else { panelPos.y += 24f; } } // Add stat select buttons Vector2 pos; if (!onCharacterSheet) { pos = new Vector2(7, 20); } else { pos = new Vector2(141, 6); } Vector2 size; if (!onCharacterSheet) { size = new Vector2(36, 20); } else { size = new Vector2(28, 20); } for (int i = 0; i < DaggerfallStats.Count; i++) { Button button = DaggerfallUI.AddButton(pos, size, this); button.Tag = i; button.OnMouseClick += StatButton_OnMouseClick; if (!onCharacterSheet) { pos.y += 22f; } else { pos.y += 24f; } } // Add up/down spinner spinner = new UpDownSpinner(); this.Components.Add(spinner); spinner.OnUpButtonClicked += Spinner_OnUpButtonClicked; spinner.OnDownButtonClicked += Spinner_OnDownButtonClicked; SelectStat(0); UpdateStatLabels(); }
void ShowOptionsPanel() { // Disable previous stage resolutionPanel.Enabled = false; // Create backdrop if (!backdropCreated) { CreateBackdrop(); } // Add options panel optionsPanel.Outline.Enabled = true; optionsPanel.BackgroundColor = backgroundColor; optionsPanel.HorizontalAlignment = HorizontalAlignment.Center; //optionsPanel.VerticalAlignment = VerticalAlignment.Middle; optionsPanel.Position = new Vector2(0, 8); optionsPanel.Size = new Vector2(318, 165); NativePanel.Components.Add(optionsPanel); // Add options title text TextLabel titleLabel = new TextLabel(); titleLabel.Text = "Options"; titleLabel.Position = new Vector2(0, 2); titleLabel.HorizontalAlignment = HorizontalAlignment.Center; optionsPanel.Components.Add(titleLabel); // Add settings path text TextLabel settingsPathLabel = new TextLabel(); settingsPathLabel.Text = DaggerfallUnity.Settings.PersistentDataPath; settingsPathLabel.Position = new Vector2(0, 170); settingsPathLabel.HorizontalAlignment = HorizontalAlignment.Center; settingsPathLabel.ShadowPosition = Vector2.zero; settingsPathLabel.TextColor = Color.gray; settingsPathLabel.BackgroundColor = backgroundColor; optionsPanel.Components.Add(settingsPathLabel); // Setup options checkboxes float x = 8; optionPos = 20; alwayShowOptions = AddOption(x, "Always show this window", "Always show this window on startup\rOtherwise use settings.ini to configure", DaggerfallUnity.Settings.ShowOptionsAtStart); vsync = AddOption(x, "Vertical Sync", "Sync FPS with monitor refresh", DaggerfallUnity.Settings.VSync); swapHealthAndFatigue = AddOption(x, "Swap Health & Fatigue", "Swap health & fatigue bar colors", DaggerfallUnity.Settings.SwapHealthAndFatigueColors); invertMouseVertical = AddOption(x, "Invert Mouse", "Invert mouse-look vertical", DaggerfallUnity.Settings.InvertMouseVertical); mouseSmoothing = AddOption(x, "Mouse Smoothing", "Smooth mouse-look sampling", DaggerfallUnity.Settings.MouseLookSmoothing); leftHandWeapons = AddOption(x, "Left Hand Weapons", "Draw weapons on left side of screen", GetLeftHandWeapons()); playerNudity = AddOption(x, "Player Nudity", "Allow nudity on paper doll", DaggerfallUnity.Settings.PlayerNudity); // Setup mods checkboxes // TODO: Might rework this, but could still be useful for certain core mods later x = 165; optionPos = 20; meshAndTextureReplacement = AddOption(x, "Support for Graphical Mods", "Enable replacement of textures and models", DaggerfallUnity.Settings.MeshAndTextureReplacement); //bool exampleModCheckbox = AddOption(x, "Example", "Example built-in mod", DaggerfallUnity.Settings.ExampleModOption); // Add mod note string modNote = "Note: Enabling mods can increase performance requirements"; TextLabel modNoteLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(0, 125), modNote, optionsPanel); modNoteLabel.HorizontalAlignment = HorizontalAlignment.Center; modNoteLabel.ShadowPosition = Vector2.zero; // Confirm button Button optionsConfirmButton = new Button(); optionsConfirmButton.Position = new Vector2(0, optionsPanel.InteriorHeight - 15); optionsConfirmButton.Size = new Vector2(40, 12); optionsConfirmButton.Outline.Enabled = true; optionsConfirmButton.Label.Text = "Play"; optionsConfirmButton.BackgroundColor = new Color(0.0f, 0.5f, 0.0f, 0.4f); optionsConfirmButton.HorizontalAlignment = HorizontalAlignment.Center; optionsConfirmButton.OnMouseClick += OptionsConfirmButton_OnMouseClick; optionsPanel.Components.Add(optionsConfirmButton); // Restart button Button restartButton = new Button(); restartButton.Size = new Vector2(45, 12); restartButton.Label.Text = "< Restart"; restartButton.Label.ShadowPosition = Vector2.zero; restartButton.Label.TextColor = Color.gray; restartButton.ToolTip = defaultToolTip; restartButton.ToolTipText = "Restart setup from beginning"; restartButton.VerticalAlignment = VerticalAlignment.Top; restartButton.HorizontalAlignment = HorizontalAlignment.Left; restartButton.OnMouseClick += RestartButton_OnMouseClick; optionsPanel.Components.Add(restartButton); if (DaggerfallUnity.Settings.LypyL_ModSystem) { Button ShowModsButton = new Button(); ShowModsButton.Label.Text = "Mods"; ShowModsButton.Position = new Vector2(3, optionsConfirmButton.Position.y); ShowModsButton.Size = optionsConfirmButton.Size; ShowModsButton.BackgroundColor = optionsConfirmButton.BackgroundColor; ShowModsButton.Label.TextColor = optionsConfirmButton.Label.TextColor; ShowModsButton.Outline.Enabled = true; optionsPanel.Components.Add(ShowModsButton); ShowModsButton.OnMouseClick += ModsButton_OnOnMouseBlick; } // Advanced Settings Button AdvancedSettingsButton = new Button(); AdvancedSettingsButton.Label.Text = "Advanced"; AdvancedSettingsButton.Size = new Vector2(45, 12); AdvancedSettingsButton.Position = new Vector2(optionsPanel.InteriorWidth - AdvancedSettingsButton.Size.x - 3, optionsConfirmButton.Position.y); AdvancedSettingsButton.BackgroundColor = optionsConfirmButton.BackgroundColor; AdvancedSettingsButton.Label.TextColor = optionsConfirmButton.Label.TextColor; AdvancedSettingsButton.Outline.Enabled = true; optionsPanel.Components.Add(AdvancedSettingsButton); AdvancedSettingsButton.OnMouseClick += AdvancedSettingsButton_OnOnMouseBlick; }
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; }