protected override void Setup() { // Save panel savePanel.HorizontalAlignment = HorizontalAlignment.Center; savePanel.VerticalAlignment = VerticalAlignment.Middle; savePanel.Size = new Vector2(300, 160); DaggerfallUI.Instance.SetDaggerfallPopupStyle(DaggerfallUI.PopupStyle.Parchment, savePanel); NativePanel.Components.Add(savePanel); // Title TextLabel titleLabel = new TextLabel(); titleLabel.HorizontalAlignment = HorizontalAlignment.Center; titleLabel.VerticalAlignment = VerticalAlignment.Top; titleLabel.Text = HardStrings.saveGame; titleLabel.Font = DaggerfallUI.TitleFont; savePanel.Components.Add(titleLabel); // Child panels int top = 16; saveListPanel = DaggerfallUI.AddPanel(new Rect(0, top, 110, savePanel.Size.y - top), savePanel); saveListPanel.HorizontalAlignment = HorizontalAlignment.Left; saveListPanel.BackgroundColor = panelBackgroundColor; detailsPanel = DaggerfallUI.AddPanel(new Rect(110, top, 180, savePanel.Size.y - top), savePanel); detailsPanel.HorizontalAlignment = HorizontalAlignment.Right; detailsPanel.BackgroundColor = panelBackgroundColor; // Outlines DaggerfallUI.AddOutline(new Rect(0, 0, saveListPanel.Size.x, saveListPanel.Size.y), outlineColor, saveListPanel); DaggerfallUI.AddOutline(new Rect(0, 0, detailsPanel.Size.x, detailsPanel.Size.y), outlineColor, detailsPanel); }
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), HardStrings.pleaseSelectYourHomeProvince, NativePanel); promptLabel.HorizontalAlignment = HorizontalAlignment.Center; promptLabel.TextColor = DaggerfallUI.DaggerfallDefaultTextColor; promptLabel.ShadowColor = DaggerfallUI.DaggerfallDefaultShadowColor; promptLabel.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; // Handle clicks NativePanel.OnMouseClick += ClickHandler; }
protected override void Setup() { base.Setup(); nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) throw new System.Exception("DaggerfallTravelMap: Could not load native texture."); ParentPanel.BackgroundColor = Color.clear; travelPanel = DaggerfallUI.AddPanel(nativePanelRect, NativePanel); travelPanel.BackgroundTexture = nativeTexture; avaliableGoldLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(148, 97), "0", NativePanel); avaliableGoldLabel.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); speedToggleColorPanel.BackgroundColor = toggleColor; sleepToggleColorPanel = DaggerfallUI.AddPanel(new Rect(innPanelPos, colorPanelSize), NativePanel); sleepToggleColorPanel.BackgroundColor = toggleColor; transportToggleColorPanel = DaggerfallUI.AddPanel(new Rect(footPos, colorPanelSize), NativePanel); transportToggleColorPanel.BackgroundColor = toggleColor; SetupButtons(); Refresh(); }
void ShowResolutionPanel() { // Disable previous stage browserPanel.Enabled = false; // Get resolutions initialResolution = Screen.currentResolution; availableResolutions = Screen.resolutions; // Create backdrop if (!backdropCreated) CreateBackdrop(); // Add resolution panel resolutionPanel.Outline.Enabled = true; resolutionPanel.BackgroundColor = backgroundColor; resolutionPanel.HorizontalAlignment = HorizontalAlignment.Left; resolutionPanel.VerticalAlignment = VerticalAlignment.Middle; resolutionPanel.Size = new Vector2(120, 175); NativePanel.Components.Add(resolutionPanel); // Add resolution title text TextLabel resolutionTitleLabel = new TextLabel(); resolutionTitleLabel.Text = "Resolution"; resolutionTitleLabel.Position = new Vector2(0, 2); //resolutionTitleLabel.ShadowPosition = Vector2.zero; resolutionTitleLabel.HorizontalAlignment = HorizontalAlignment.Center; resolutionPanel.Components.Add(resolutionTitleLabel); // Add resolution picker resolutionList.BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.5f); resolutionList.TextColor = unselectedTextColor; resolutionList.SelectedTextColor = selectedTextColor; resolutionList.ShadowPosition = Vector2.zero; resolutionList.HorizontalAlignment = HorizontalAlignment.Center; resolutionList.RowsDisplayed = 8; resolutionList.RowAlignment = HorizontalAlignment.Center; resolutionList.Position = new Vector2(0, 12); resolutionList.Size = new Vector2(80, 62); resolutionList.SelectedShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; resolutionList.SelectedShadowColor = Color.black; resolutionList.OnMouseClick += ResolutionList_OnMouseClick; resolutionList.OnScroll += ResolutionList_OnScroll; resolutionPanel.Components.Add(resolutionList); // Add resolution scrollbar resolutionScroller.Position = new Vector2(100, 12); resolutionScroller.Size = new Vector2(5, 62); resolutionScroller.OnScroll += ResolutionScroller_OnScroll; resolutionPanel.Components.Add(resolutionScroller); // Add resolutions for (int i = 0; i < availableResolutions.Length; i++) { string item = string.Format("{0}x{1}", availableResolutions[i].width, availableResolutions[i].height); resolutionList.AddItem(item); if (availableResolutions[i].width == initialResolution.width && availableResolutions[i].height == initialResolution.height) { resolutionList.SelectedIndex = i; } } resolutionList.ScrollToSelected(); // Setup scroller resolutionScroller.DisplayUnits = 8; resolutionScroller.TotalUnits = resolutionList.Count; resolutionScroller.BackgroundColor = resolutionList.BackgroundColor; // Add fullscreen checkbox fullscreenCheckbox.Label.Text = "Fullscreen"; fullscreenCheckbox.Label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; fullscreenCheckbox.Label.ShadowColor = Color.black; fullscreenCheckbox.Position = new Vector2(0, 76); fullscreenCheckbox.HorizontalAlignment = HorizontalAlignment.Center; fullscreenCheckbox.IsChecked = Screen.fullScreen; fullscreenCheckbox.CheckBoxColor = selectedTextColor; fullscreenCheckbox.Label.TextColor = selectedTextColor; fullscreenCheckbox.OnToggleState += FullscreenCheckbox_OnToggleState; resolutionPanel.Components.Add(fullscreenCheckbox); // Add quality title text TextLabel qualityTitleLabel = new TextLabel(); qualityTitleLabel.Text = "Quality"; qualityTitleLabel.Position = new Vector2(0, 92); //qualityTitleLabel.ShadowPosition = Vector2.zero; qualityTitleLabel.HorizontalAlignment = HorizontalAlignment.Center; resolutionPanel.Components.Add(qualityTitleLabel); // Add quality picker qualityList.BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.5f); qualityList.TextColor = unselectedTextColor; qualityList.SelectedTextColor = selectedTextColor; qualityList.ShadowPosition = Vector2.zero; qualityList.HorizontalAlignment = HorizontalAlignment.Center; qualityList.RowsDisplayed = 6; qualityList.RowAlignment = HorizontalAlignment.Center; qualityList.Position = new Vector2(0, 102); qualityList.Size = new Vector2(85, 46); qualityList.SelectedShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; qualityList.SelectedShadowColor = Color.black; qualityList.OnMouseClick += QualityList_OnMouseClick; resolutionPanel.Components.Add(qualityList); foreach(var name in QualitySettings.names) { qualityList.AddItem(name); } qualityList.SelectedIndex = DaggerfallUnity.Settings.QualityLevel; // Test/confirm button testOrConfirmButton.Position = new Vector2(0, 160); testOrConfirmButton.Size = new Vector2(40, 12); testOrConfirmButton.Outline.Enabled = true; testOrConfirmButton.Label.Text = testText; testOrConfirmButton.BackgroundColor = new Color(0.0f, 0.5f, 0.0f, 0.4f); testOrConfirmButton.HorizontalAlignment = HorizontalAlignment.Center; testOrConfirmButton.OnMouseClick += ResolutionTestOrConfirmButton_OnMouseClick; resolutionPanel.Components.Add(testOrConfirmButton); }
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 x = 165; optionPos = 20; enhancedSky = AddOption(x, "Enhanced Sky (LypyL)", "Enhanced sky with lunar cycles", DaggerfallUnity.Settings.LypyL_EnhancedSky); distantTerrain = AddOption(x, "Distant Terrain (Nystul)", "Enhanced and distant terrain", DaggerfallUnity.Settings.Nystul_IncreasedTerrainDistance); realtimeReflections = AddOption(x, "Realtime Reflections (Nystul)", "Realtime reflections on water and select surfaces", DaggerfallUnity.Settings.Nystul_RealtimeReflections); tallGrass = AddOption(x, "Tall Grass (Uncanny_Valley)", "Animated tall grass", DaggerfallUnity.Settings.UncannyValley_RealGrass); flyingBirds = AddOption(x, "Flying Birds (Uncanny Valley)", "Animated flying birds", DaggerfallUnity.Settings.UncannyValley_BirdsInDaggerfall); // Add mod note string modNote = "Note: Enabling mods can increase performance requirements"; TextLabel modNoteLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(0, 115), 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(0, optionsConfirmButton.Position.y); ShowModsButton.HorizontalAlignment = HorizontalAlignment.Left; 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; } }
void LayoutTextElements(TextFile.Token[] tokens) { labels.Clear(); totalWidth = 0; totalHeight = 0; cursorX = 0; cursorY = 0; TextFile.Token token = new TextFile.Token(); TextFile.Token nextToken = new TextFile.Token(); for (int i = 0; i < tokens.Length; i++) { token = tokens[i]; nextToken.formatting = TextFile.Formatting.Nothing; if (i < tokens.Length - 1) { nextToken = tokens[i + 1]; } // Still working out rules for justify logic // This will adapt over time as required switch (token.formatting) { case TextFile.Formatting.NewLine: NewLine(); break; case TextFile.Formatting.JustifyLeft: NewLine(); break; case TextFile.Formatting.JustifyCenter: if (lastLabel != null) { lastLabel.HorizontalAlignment = HorizontalAlignment.Center; } NewLine(); break; case TextFile.Formatting.PositionPrefix: if (token.x != 0) { // Tab by specific number of pixels cursorX += token.x; } else { // Tab to next tab stop tabStop++; cursorX = tabStop * tabWidth; } break; case TextFile.Formatting.Text: TextLabel label = AddTextLabel(font, new Vector2(cursorX, cursorY), token.text); label.TextColor = DaggerfallUI.DaggerfallDefaultTextColor; label.ShadowColor = DaggerfallUI.DaggerfallDefaultShadowColor; label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; labels.Add(label); lastLabel = label; cursorX += label.TextWidth; break; default: Debug.Log("MultilineTextLabel: Unknown formatting token: " + (int)token.formatting); break; } if (lastLabel != null) { int rowWidth = (int)lastLabel.Position.x + lastLabel.TextWidth; if (rowWidth > totalWidth) { totalWidth = rowWidth; } } } Size = new Vector2(totalWidth, totalHeight); }
public void AddItem(string text) { if (font == null) font = DaggerfallUI.DefaultFont; TextLabel textLabel = new TextLabel(); textLabel.ScalingMode = Scaling.None; textLabel.HorizontalAlignment = rowAlignment; textLabel.Font = font; textLabel.MaxCharacters = maxCharacters; textLabel.Text = text; textLabel.Parent = this; listItems.Add(textLabel); }
TextLabel AddTextLabel(PixelFont font, Vector2 position, string text) { TextLabel textLabel = new TextLabel(); textLabel.ScalingMode = Scaling.None; textLabel.Font = font; textLabel.Position = position; textLabel.Text = text; textLabel.Parent = this; return textLabel; }
/// <summary> /// Adds a single text item. /// Each subsequent text item will be appended to the previous text item position. /// Call NewLine() to start a new line. /// </summary> /// <param name="text">Text for this label.</param> /// <param name="font">Font for this label.</param> /// <returns>TextLabel.</returns> public TextLabel AddTextLabel(string text, PixelFont font = null) { if (font == null) font = GetFont(); TextLabel textLabel = new TextLabel(); textLabel.AutoSize = AutoSizeModes.None; textLabel.Font = font; textLabel.Position = new Vector2(cursorX, cursorY); textLabel.Text = text; textLabel.Parent = this; textLabel.TextColor = TextColor; textLabel.ShadowColor = ShadowColor; textLabel.ShadowPosition = ShadowPosition; if (textAlignment != HorizontalAlignment.None) textLabel.HorizontalAlignment = textAlignment; labels.Add(textLabel); lastLabel = textLabel; cursorX += textLabel.TextWidth; return textLabel; }
public ListItem(TextLabel textLabel) { this.textLabel = textLabel; }
public override void Draw() { base.Draw(); if (verticalScrollMode == VerticalScrollModes.EntryWise) { float x = 0, y = 0; float currentLine = 0; for (int i = 0; i < listItems.Count; i++) { TextLabel label = listItems[i].textLabel; if (currentLine < scrollIndex || currentLine >= scrollIndex + rowsDisplayed) { currentLine += label.NumTextLines; continue; } currentLine += label.NumTextLines; label.StartCharacterIndex = horizontalScrollIndex; label.RefreshClassicLayout(); DecideTextColor(label, i); label.Position = new Vector2(x, y); label.Draw(); y += label.TextHeight + rowSpacing; } } else if (verticalScrollMode == VerticalScrollModes.PixelWise) { int x = 0; int y = -scrollIndex; for (int i = 0; i < listItems.Count; i++) { TextLabel label = listItems[i].textLabel; if (y + label.TextHeight < 0 || y >= this.Size.y) { y += label.TextHeight + rowSpacing; continue; } if (horizontalScrollMode == HorizontalScrollModes.CharWise) { label.StartCharacterIndex = horizontalScrollIndex; } else if (horizontalScrollMode == HorizontalScrollModes.PixelWise) { x = -horizontalScrollIndex; } label.RefreshClassicLayout(); DecideTextColor(label, i); label.HorzPixelScrollOffset = x; label.Position = new Vector2(x, y); label.Draw(); y += label.TextHeight + rowSpacing; } } }
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].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; } }
/// <summary> /// Initializes a fully customised new instance of ItemListScroller. /// </summary> /// <param name="listRows">Number of rows of items this list will display at one time.</param> /// <param name="listCols">Number of items displayed per row.</param> /// <param name="itemListRect">Item list coordinate rect, excluding scrollbar.</param> /// <param name="itemsRects">Individual items display coordinate rects. (1 per width*height)</param> /// <param name="miscLabelTemplate">Template for misc label: relative position, font, horiz & vert alignment, text scale. (defaults: Vector2.zero, Font4, Left, Top, 1)</param> /// <param name="toolTip">Tool tip class to use if items should display tooltips.</param> /// <param name="itemMarginSize">Individual item display margin size.</param> /// <param name="textScale">Text scale factor for stack labels.</param> /// <param name="scroll">True for a scrollable list, false otherwise.</param> /// <param name="miscLabelOffsetDist">Vertical distance to offset the misc label, 0 to disable.</param> /// <param name="miscLabelOffsetIdx">Index of column for which to offset the misc label.</param> public ItemListScroller(int listRows, int listCols, Rect itemListRect, Rect[] itemsRects, TextLabel miscLabelTemplate, ToolTip toolTip = null, int itemMarginSize = 1, float textScale = 1f, bool scroll = true, int miscLabelOffsetDist = 0, int miscLabelOffsetIdx = 0) : base() { listDisplayTotal = listRows * listCols; if (itemsRects.Length != listDisplayTotal) { throw new ArgumentException(); } listDisplayUnits = listRows; listWidth = listCols; itemListPanelRect = itemListRect; itemButtonRects = itemsRects; itemButtonMargin = itemMarginSize; this.toolTip = toolTip; this.textScale = textScale; scroller = scroll; this.miscLabelOffsetDist = miscLabelOffsetDist; this.miscLabelOffsetIdx = miscLabelOffsetIdx; LoadTextures(false); if (scroller) { SetupScrollBar(); SetupScrollButtons(); } SetupItemsList(false, miscLabelTemplate); }
public static TextLabel AddTextLabel(PixelFont font, Vector2 position, string text, Panel panel = null, int glyphSpacing = 1) { TextLabel textLabel = new TextLabel(); textLabel.ScalingMode = Scaling.None; textLabel.Font = font; textLabel.Position = position; textLabel.Text = text; if (panel != null) panel.Components.Add(textLabel); return textLabel; }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) throw new Exception("DaggerfallTravelMap: Could not load native texture."); // Always dim background ParentPanel.BackgroundColor = ScreenDimColor; // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Populate the offset dict PopulateRegionOffsetDict(); // Don't allow automatic cancel, we will handle this locally AllowCancel = false; // Load picker colours regionPickerBitmap = DaggerfallUI.GetImgBitmap(regionPickerImgName); // Add region label regionLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(0, 2), string.Empty, NativePanel); regionLabel.HorizontalAlignment = HorizontalAlignment.Center; // Handle clicks NativePanel.OnMouseClick += ClickHandler; // Setup buttons for first time LoadButtonTextures(); SetupButtons(); UpdateSearchButtons(); // Region overlay panel regionTextureOverlayPanel = DaggerfallUI.AddPanel(regionTextureOverlayPanelRect, NativePanel); regionTextureOverlayPanel.Enabled = false; // Location cluster panel locationClusterPanel = DaggerfallUI.AddPanel(regionTextureOverlayPanelRect, regionTextureOverlayPanel); locationClusterPanel.HorizontalAlignment = HorizontalAlignment.Left; locationClusterPanel.VerticalAlignment = VerticalAlignment.Top; // Location cluster will be updated when user opens a region locationClusterColors = new Color32[(int)regionTextureOverlayPanelRect.width * (int)regionTextureOverlayPanelRect.height]; locationClusterTexture = new Texture2D((int)regionTextureOverlayPanelRect.width, (int)regionTextureOverlayPanelRect.height); locationClusterTexture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; // Overlay to identify player region identifyRegionOverlayTexture = CreatePlayerRegionOverlayTexture(); // Identify region panel is displayed to show user what region they are in identifyRegionPanel = new Panel(); identifyRegionPanel.Position = new Vector2(0, 0); identifyRegionPanel.Size = NativePanel.Size; identifyRegionPanel.BackgroundTexture = identifyRegionOverlayTexture; identifyRegionPanel.Enabled = false; NativePanel.Components.Add(identifyRegionPanel); }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) throw new Exception("DaggerfallCharacterSheetWindow: Could not load native texture."); // Always dim background ParentPanel.BackgroundColor = ScreenDimColor; // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Character portrait NativePanel.Components.Add(characterPortrait); characterPortrait.Position = new Vector2(200, 8); // Setup labels nameLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(41, 4), NativePanel); raceLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(41, 14), NativePanel); classLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(46, 24), NativePanel); levelLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(45, 34), NativePanel); //goldLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(39, 44), NativePanel); fatigueLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(57, 54), NativePanel); healthLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(52, 64), NativePanel); //encumbranceLabel = DaggerfallUI.AddDefaultShadowedTextLabel(new Vector2(90, 74), NativePanel); // Setup stat labels Vector2 pos = new Vector2(150, 17); for (int i = 0; i < DaggerfallStats.Count; i++) { statLabels[i] = DaggerfallUI.AddDefaultShadowedTextLabel(pos, NativePanel); pos.y += 24f; } // Primary skills button Button primarySkillsButton = DaggerfallUI.AddButton(new Rect(11, 106, 115, 8), NativePanel); primarySkillsButton.OnMouseClick += PrimarySkillsButton_OnMouseClick; // Major skills button Button majorSkillsButton = DaggerfallUI.AddButton(new Rect(11, 116, 115, 8), NativePanel); majorSkillsButton.OnMouseClick += MajorSkillsButton_OnMouseClick; // Minor skills button Button minorSkillsButton = DaggerfallUI.AddButton(new Rect(11, 126, 115, 8), NativePanel); minorSkillsButton.OnMouseClick += MinorSkillsButton_OnMouseClick; // Miscellaneous skills button Button miscSkillsButton = DaggerfallUI.AddButton(new Rect(11, 136, 115, 8), NativePanel); miscSkillsButton.OnMouseClick += MiscSkillsButton_OnMouseClick; // Inventory button Button inventoryButton = DaggerfallUI.AddButton(new Rect(3, 151, 65, 12), NativePanel); inventoryButton.BackgroundColor = DaggerfallUI.DaggerfallUnityNotImplementedColor; // Spellbook button Button spellBookButton = DaggerfallUI.AddButton(new Rect(69, 151, 65, 12), NativePanel); spellBookButton.BackgroundColor = DaggerfallUI.DaggerfallUnityNotImplementedColor; // Logbook button Button logBookButton = DaggerfallUI.AddButton(new Rect(3, 165, 65, 12), NativePanel); logBookButton.BackgroundColor = DaggerfallUI.DaggerfallUnityNotImplementedColor; // History button Button historyButton = DaggerfallUI.AddButton(new Rect(69, 165, 65, 12), NativePanel); historyButton.BackgroundColor = DaggerfallUI.DaggerfallUnityNotImplementedColor; // Exit button Button exitButton = DaggerfallUI.AddButton(new Rect(50, 179, 39, 19), NativePanel); exitButton.OnMouseClick += ExitButton_OnMouseClick; // Attribute popup text pos = new Vector2(141, 6); for (int i = 0; i < DaggerfallStats.Count; i++) { Rect rect = new Rect(pos.x, pos.y, 28, 20); AddAttributePopupButton((DFCareer.Stats)i, rect); pos.y += 24f; } // Update player paper doll for first time UpdatePlayerValues(); characterPortrait.Refresh(); }
public void AddItem(string text, int position = -1) { if (font == null) font = DaggerfallUI.DefaultFont; TextLabel textLabel = new TextLabel(); textLabel.MaxWidth = (int)Size.x; textLabel.AutoSize = AutoSizeModes.None; textLabel.HorizontalAlignment = rowAlignment; textLabel.Font = font; textLabel.MaxCharacters = maxCharacters; textLabel.Text = text; textLabel.Parent = this; if (position < 0) listItems.Add(textLabel); else listItems.Insert(position, textLabel); }
void LayoutTextElements(TextFile.Token[] tokens) { labels.Clear(); totalWidth = 0; totalHeight = 0; cursorX = 0; cursorY = 0; TextFile.Token token = new TextFile.Token(); TextFile.Token nextToken = new TextFile.Token(); for (int i = 0; i < tokens.Length; i++) { token = tokens[i]; nextToken.formatting = TextFile.Formatting.Nothing; if (i < tokens.Length - 1) nextToken = tokens[i + 1]; // Still working out rules for justify logic // This will adapt over time as required switch (token.formatting) { case TextFile.Formatting.NewLine: NewLine(); break; case TextFile.Formatting.JustifyLeft: NewLine(); break; case TextFile.Formatting.JustifyCenter: if (lastLabel != null) lastLabel.HorizontalAlignment = HorizontalAlignment.Center; NewLine(); break; case TextFile.Formatting.PositionPrefix: if (token.x != 0) { // Tab by specific number of pixels cursorX += token.x; } else { // Tab to next tab stop tabStop++; cursorX = tabStop * tabWidth; } break; case TextFile.Formatting.Text: TextLabel label = AddTextLabel(font, new Vector2(cursorX, cursorY), token.text); label.TextColor = DaggerfallUI.DaggerfallDefaultTextColor; label.ShadowColor = DaggerfallUI.DaggerfallDefaultShadowColor; label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos; labels.Add(label); lastLabel = label; cursorX += label.TextWidth; break; default: Debug.Log("MultilineTextLabel: Unknown formatting token: " + (int)token.formatting); break; } if (lastLabel != null) { int rowWidth = (int)lastLabel.Position.x + lastLabel.TextWidth; if (rowWidth > totalWidth) totalWidth = rowWidth; } } Size = new Vector2(totalWidth, totalHeight); }
void ShowGameFolderStage() { // Set temporary background texture if (titleTexture != null) { titleTexture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; ParentPanel.BackgroundTexture = titleTexture; ParentPanel.BackgroundTextureLayout = BackgroundLayout.ScaleToFit; } // Setup panel browserPanel.BackgroundColor = backgroundColor; browserPanel.HorizontalAlignment = HorizontalAlignment.Center; browserPanel.VerticalAlignment = VerticalAlignment.Middle; browserPanel.Size = browserPanelSize; browserPanel.Outline.Enabled = true; NativePanel.Components.Add(browserPanel); // Setup screen text MultiFormatTextLabel screen = new MultiFormatTextLabel(); screen.HorizontalAlignment = HorizontalAlignment.Center; screen.Position = new Vector2(0, 10); screen.TextAlignment = HorizontalAlignment.Center; screen.SetText(Resources.Load<TextAsset>("Screens/WelcomeScreen")); browserPanel.Components.Add(screen); // Setup folder browser browser.Position = new Vector2(4, 30); browser.Size = new Vector2(250, 104); browser.HorizontalAlignment = HorizontalAlignment.Center; browser.ConfirmEnabled = false; browser.OnConfirmPath += Browser_OnConfirmPath; browser.OnPathChanged += Browser_OnPathChanged; browserPanel.Components.Add(browser); // Add version number TextLabel versionLabel = new TextLabel(); versionLabel.Position = new Vector2(0, 1); versionLabel.HorizontalAlignment = HorizontalAlignment.Right; versionLabel.ShadowPosition = Vector2.zero; versionLabel.TextColor = Color.gray; versionLabel.Text = VersionInfo.DaggerfallUnityVersion; browserPanel.Components.Add(versionLabel); // Add help text helpLabel.Position = new Vector2(0, 145); helpLabel.HorizontalAlignment = HorizontalAlignment.Center; helpLabel.ShadowPosition = Vector2.zero; helpLabel.Text = findArena2Tip; browserPanel.Components.Add(helpLabel); }
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; }
protected override void Setup() { base.Setup(); var background = DaggerfallUI.GetTextureFromImg(IMGNAME); if (background == null) { Debug.LogError(string.Format("Failed to load background image {0} for Banking pop-up", IMGNAME)); CloseWindow(); return; } ParentPanel.BackgroundColor = ScreenDimColor; mainPanel = DaggerfallUI.AddPanel(NativePanel, AutoSizeModes.None); mainPanel.BackgroundTexture = background; mainPanel.Size = new Vector2(background.width, background.height); mainPanel.HorizontalAlignment = HorizontalAlignment.Center; mainPanel.VerticalAlignment = VerticalAlignment.Middle; accountAmount = new TextLabel(); accountAmount.Position = new Vector2(150, 14); accountAmount.Size = new Vector2(60, 13); accountAmount.Name = "accnt_total_label"; accountAmount.MaxCharacters = 13; mainPanel.Components.Add(accountAmount); inventoryAmount = new TextLabel(); inventoryAmount.Position = new Vector2(156, 24); inventoryAmount.Size = new Vector2(60, 13); inventoryAmount.Name = "inv_total_label"; inventoryAmount.MaxCharacters = 11; mainPanel.Components.Add(inventoryAmount); loanAmountDue = new TextLabel(); loanAmountDue.Position = new Vector2(96, 34); loanAmountDue.Size = new Vector2(60, 13); loanAmountDue.Name = "amount_due_label"; loanAmountDue.MaxCharacters = 24; mainPanel.Components.Add(loanAmountDue); loanDueBy = new TextLabel(); loanDueBy.Position = new Vector2(71, 44); loanDueBy.Size = new Vector2(60, 13); loanDueBy.Name = "loan_by_label"; loanDueBy.MaxCharacters = 33; mainPanel.Components.Add(loanDueBy); depoGoldButton = new Button(); depoGoldButton.Position = new Vector2(120, 58); depoGoldButton.Size = new Vector2(45, 8); depoGoldButton.Name = "depo_gold_button"; depoGoldButton.OnMouseClick += depoGoldButton_OnMouseClick; mainPanel.Components.Add(depoGoldButton); drawGoldButton = new Button(); drawGoldButton.Position = new Vector2(172, 58); drawGoldButton.Size = new Vector2(45, 8); drawGoldButton.Name = "draw_gold_button"; drawGoldButton.OnMouseClick += drawGoldButton_OnMouseClick; mainPanel.Components.Add(drawGoldButton); depoLOCButton = new Button(); depoLOCButton.Position = new Vector2(120, 76); depoLOCButton.Size = new Vector2(45, 8); depoLOCButton.Name = "depo_loc_button"; depoLOCButton.OnMouseClick += depoLOCButton_OnMouseClick; mainPanel.Components.Add(depoLOCButton); drawLOCButton = new Button(); drawLOCButton.Position = new Vector2(172, 76); drawLOCButton.Size = new Vector2(45, 8); drawLOCButton.Name = "draw_LOC_button"; drawLOCButton.OnMouseClick += drawLOCButton_OnMouseClick; mainPanel.Components.Add(drawLOCButton); loanRepayButton = new Button(); loanRepayButton.Position = new Vector2(120, 94); loanRepayButton.Size = new Vector2(45, 8); loanRepayButton.Name = "loan_repay_button"; loanRepayButton.OnMouseClick += loanRepayButton_OnMouseClick; mainPanel.Components.Add(loanRepayButton); loanBorrowButton = new Button(); loanBorrowButton.Position = new Vector2(172, 94); loanBorrowButton.Size = new Vector2(45, 8); loanBorrowButton.Name = "loan_borrow_button"; loanBorrowButton.OnMouseClick += loanBorrowButton_OnMouseClick; mainPanel.Components.Add(loanBorrowButton); buyHouseButton = new Button(); buyHouseButton.Position = new Vector2(120, 112); buyHouseButton.Size = new Vector2(45, 8); buyHouseButton.Name = "buy_house_button"; buyHouseButton.OnMouseClick += buyHouseButton_OnMouseClick; mainPanel.Components.Add(buyHouseButton); sellHouseButton = new Button(); sellHouseButton.Position = new Vector2(172, 112); sellHouseButton.Size = new Vector2(45, 8); sellHouseButton.Name = "sell_house_button"; sellHouseButton.OnMouseClick += sellHouseButton_OnMouseClick; mainPanel.Components.Add(sellHouseButton); buyShipButton = new Button(); buyShipButton.Position = new Vector2(120, 130); buyShipButton.Size = new Vector2(45, 8); buyShipButton.Name = "buy_ship_button"; buyShipButton.OnMouseClick += buyShipButton_OnMouseClick; mainPanel.Components.Add(buyShipButton); sellShipButton = new Button(); sellShipButton.Position = new Vector2(172, 130); sellShipButton.Size = new Vector2(45, 8); sellShipButton.Name = "sell_ship_button"; sellShipButton.OnMouseClick += sellShipButton_OnMouseClick; mainPanel.Components.Add(sellShipButton); exitButton = new Button(); exitButton.Position = new Vector2(92, 159); exitButton.Size = new Vector2(40, 19); exitButton.Name = "exit_button"; exitButton.OnMouseClick += exitButton_OnMouseClick; mainPanel.Components.Add(exitButton); transactionInput = new TextBox(); transactionInput.Position = new Vector2(113, 146); transactionInput.Size = new Vector2(103, 12); transactionInput.Numeric = true; transactionInput.Enabled = false; transactionInput.MaxCharacters = 9; mainPanel.Components.Add(transactionInput); playerEntity = GameManager.Instance.PlayerEntity; regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex; transactionType = TransactionType.None; UpdateLabels(); #if LAYOUT SetBackgroundColors(); #endif }