protected override void Setup() { base.Setup(); Texture2D texture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (texture == null) { Debug.LogError("failed to load texture: " + nativeImgName); CloseWindow(); } mainPanel = DaggerfallUI.AddPanel(NativePanel, AutoSizeModes.None); mainPanel.BackgroundTexture = texture; mainPanel.Size = new Vector2(320, 200); mainPanel.HorizontalAlignment = HorizontalAlignment.Center; mainPanel.VerticalAlignment = VerticalAlignment.Middle; dialogButton = new Button(); dialogButton.Position = new Vector2(32, 187); dialogButton.Size = new Vector2(68, 10); dialogButton.OnMouseClick += dialogButton_OnMouseClick; dialogButton.Name = "dialog_button"; mainPanel.Components.Add(dialogButton); upArrowButton = new Button(); upArrowButton.Position = new Vector2(181, 188); upArrowButton.Size = new Vector2(13, 7); upArrowButton.OnMouseClick += upArrowButton_OnMouseClick; upArrowButton.Name = "uparrow_button"; mainPanel.Components.Add(upArrowButton); downArrowButton = new Button(); downArrowButton.Position = new Vector2(209, 188); downArrowButton.Size = new Vector2(13, 7); downArrowButton.OnMouseClick += downArrowButton_OnMouseClick; downArrowButton.Name = "downarrow_button"; mainPanel.Components.Add(downArrowButton); exitButton = new Button(); exitButton.Position = new Vector2(278, 187); exitButton.Size = new Vector2(30, 9); exitButton.OnMouseClick += exitButton_OnMouseClick; exitButton.Name = "exit_button"; mainPanel.Components.Add(exitButton); questLogLabel = new MultiFormatTextLabel(); questLogLabel.Position = new Vector2(30, 32); questLogLabel.Size = new Vector2(238, 138); mainPanel.Components.Add(questLogLabel); questMessages = QuestMachine.Instance.GetAllQuestLogMessages(); SetText(); #if LAYOUT SetBackgroundColors(); #endif }
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 = secondaryTextColor; versionLabel.Text = VersionInfo.DaggerfallUnityVersion; browserPanel.Components.Add(versionLabel); // Add help text findArena2Tip = GetText("findArena2Tip"); pathValidated = GetText("pathValidated"); 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; } // Initialise the video panel. playerPanel = new FLCPlayer() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Middle, Size = new Vector2(320, 200), BottomMargin = 13 }; NativePanel.Components.Add(playerPanel); // Start video playing. playerPanel.Load(daedraSummoned.vidFile); if (playerPanel.FLCFile.ReadyToPlay) { playerPanel.Start(); } // Add text message area. messageLabel = new MultiFormatTextLabel() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom, ExtraLeading = 3, }; playerPanel.Components.Add(messageLabel); playerPanel.OnMouseClick += PlayerPanel_OnMouseClick; textCursor = new TextCursor(); textCursor.Enabled = false; playerPanel.Components.Add(textCursor); // Initialise message to display, if (daedraQuest != null) { // with the quest offer message. Message message = daedraQuest.GetMessage((int)QuestMachine.QuestMessages.QuestorOffer); messageTokens = message.GetTextTokens(); } else { // with the textId message evaluated with mcp provided. messageTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(textId); MacroHelper.ExpandMacros(ref messageTokens, mcp); } idx = 0; DisplayNextTextChunk(); }
private void DisplayQuestion(int questionIndex) { questionLabel.Clear(); questionLabel = new MultiFormatTextLabel { Position = new Vector2(leftTextOffset, topTextOffset), Size = new Vector2(320f, 0f), // make sure it has enough space - allow it to run off the screen TextColor = Color.black, ShadowPosition = new Vector2(0f, 0f), Parent = questionScroll, RestrictedRenderAreaCoordinateType = BaseScreenComponent.RestrictedRenderArea_CoordinateType.CustomParent }; string[] lines = questionLibrary[questionIndex].Split("\r\n".ToCharArray()).Where(x => x != string.Empty).ToArray(); List <TextFile.Token> tokens = new List <TextFile.Token>(); foreach (string line in lines) { tokens.Add(TextFile.CreateTextToken(line)); tokens.Add(TextFile.CreateFormatToken(TextFile.Formatting.NewLine)); } questionLabel.RestrictedRenderAreaCustomParent = textArea; questionLabel.SetText(tokens.ToArray()); questionScroll.Components.Add(questionLabel); scrollFrame = 0; questionScroll.BackgroundTexture = scrollTextures[0]; for (int i = 0; i < questionLabel.TextLabels.Count; i++) { TextLabel label = questionLabel.TextLabels[i]; if (label.Text.Contains("a)")) { aIndex = i; } else if (label.Text.Contains("b)")) { bIndex = i; } else if (label.Text.Contains("c)")) { cIndex = i; } } }
void SetupEffectDescriptionPanels() { // Create parent panel to house effect description Panel descriptionParentPanel = DaggerfallUI.AddPanel(new Rect(5, 19, 312, 69), NativePanel); descriptionParentPanel.HorizontalAlignment = HorizontalAlignment.Center; // Create description panel centred inside of parent descriptionPanel = DaggerfallUI.AddPanel(descriptionParentPanel, AutoSizeModes.None); descriptionPanel.Size = new Vector2(306, 69); descriptionPanel.HorizontalAlignment = HorizontalAlignment.Center; descriptionPanel.VerticalAlignment = VerticalAlignment.Middle; DaggerfallUI.Instance.SetDaggerfallPopupStyle(DaggerfallUI.PopupStyle.Parchment, descriptionPanel); // Create multiline label for description text descriptionLabel = new MultiFormatTextLabel(); descriptionLabel.HorizontalAlignment = HorizontalAlignment.Center; descriptionLabel.VerticalAlignment = VerticalAlignment.Middle; descriptionPanel.Components.Add(descriptionLabel); }
protected override void Setup() { base.Setup(); RemoveOldButtons(); LoadTextures(); // Item tabs allButton = DaggerfallUI.AddButton(allRect, NativePanel); allButton.OnMouseClick += All_OnMouseClick; weaponsButton = DaggerfallUI.AddButton(weaponsRect, NativePanel); weaponsButton.OnMouseClick += Weapons_OnMouseClick; armorButton = DaggerfallUI.AddButton(armorRect, NativePanel); armorButton.OnMouseClick += Armor_OnMouseClick; clothingButton = DaggerfallUI.AddButton(clothingRect, NativePanel); clothingButton.OnMouseClick += Clothing_OnMouseClick; alchemyButton = DaggerfallUI.AddButton(alchemyRect, NativePanel); alchemyButton.OnMouseClick += Alchemy_OnMouseClick; miscButton = DaggerfallUI.AddButton(miscRect, NativePanel); miscButton.OnMouseClick += Misc_OnMouseClick; // Accessory buttons foreach (var button in accessoryButtons) { button.OnRightMouseClick += AccessoryItemsButton_OnMouseRightClick; } // Attack bonus indicators rHandAttackPanel = DaggerfallUI.AddPanel(rHandAttackRect, NativePanel); lHandAttackPanel = DaggerfallUI.AddPanel(lHandAttackRect, NativePanel); rHandAttackLabel = GetAttackInfoLabel(); lHandAttackLabel = GetAttackInfoLabel(); rHandAttackPanel.Components.Add(rHandAttackLabel); lHandAttackPanel.Components.Add(lHandAttackLabel); SetAttackInfo(rHandAttackLabel); SetAttackInfo(lHandAttackLabel, false); // Initialize FilterLocalItems(); SelectTab(All, false); }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharReflexSelect: Could not load native texture."); } // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Setup info panel Panel infoPanel = new Panel(); DaggerfallUI.Instance.SetDaggerfallPopupStyle(DaggerfallUI.PopupStyle.Parchment, infoPanel); NativePanel.Components.Add(infoPanel); infoPanel.HorizontalAlignment = HorizontalAlignment.Center; infoPanel.Position = new Vector2(0, 15); // Setup info text MultiFormatTextLabel infoText = new MultiFormatTextLabel(); infoPanel.Components.Add(infoText); infoText.SetText(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(strPlayerReflexesDetermine)); infoText.HorizontalAlignment = HorizontalAlignment.Center; infoText.VerticalAlignment = VerticalAlignment.Middle; infoPanel.Size = infoText.Size; // Setup button picker reflexPicker = new ReflexPicker(); NativePanel.Components.Add(reflexPicker); reflexPicker.Position = new Vector2(127, 148f); // Add "OK" button Button okButton = DaggerfallUI.AddButton(new Rect(263, 172, 39, 22), NativePanel); okButton.OnMouseClick += OkButton_OnMouseClick; }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharReflexSelect: Could not load native texture."); } // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Setup info panel Panel infoPanel = new Panel(); DaggerfallUI.Instance.SetDaggerfallPopupStyle(DaggerfallUI.PopupStyle.Parchment, infoPanel); NativePanel.Components.Add(infoPanel); infoPanel.HorizontalAlignment = HorizontalAlignment.Center; infoPanel.Position = new Vector2(0, 15); // Setup info text MultiFormatTextLabel infoText = new MultiFormatTextLabel(); infoPanel.Components.Add(infoText); infoText.SetText(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(strPlayerReflexesDetermine)); infoText.HorizontalAlignment = HorizontalAlignment.Center; infoText.VerticalAlignment = VerticalAlignment.Middle; // Setup panel size int minimum = 44; float width = (infoText.Size.x + infoPanel.LeftMargin + infoPanel.RightMargin); float height = (infoText.Size.y + infoPanel.TopMargin + infoPanel.BottomMargin); if (width > minimum) { width = (float)Math.Ceiling(width / 22) * 22; } else { width = minimum; } if (height > minimum) { height = (float)Math.Ceiling(height / 22) * 22; } else { height = minimum; } infoPanel.Size = new Vector2(width, height); // Setup button picker reflexPicker = new ReflexPicker(); NativePanel.Components.Add(reflexPicker); reflexPicker.Position = new Vector2(127, 148f); // Add "OK" button Button okButton = DaggerfallUI.AddButton(new Rect(263, 172, 39, 22), NativePanel); okButton.OnMouseClick += OkButton_OnMouseClick; }
protected override void Setup() { base.Setup(); // Always dim background ParentPanel.BackgroundColor = ScreenDimColor; Texture2D texture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (texture == null) { Debug.LogError("failed to load texture: " + nativeImgName); CloseWindow(); } if (defaultToolTip != null) { defaultToolTip.ToolTipDelay = 1; } mainPanel = DaggerfallUI.AddPanel(NativePanel, AutoSizeModes.None); mainPanel.BackgroundTexture = texture; mainPanel.Size = new Vector2(320, 200); mainPanel.HorizontalAlignment = HorizontalAlignment.Center; mainPanel.VerticalAlignment = VerticalAlignment.Middle; mainPanel.OnMouseScrollDown += MainPanel_OnMouseScrollDown; mainPanel.OnMouseScrollUp += MainPanel_OnMouseScrollUp; dialogButton = new Button(); dialogButton.Position = new Vector2(32, 187); dialogButton.Size = new Vector2(68, 10); dialogButton.OnMouseClick += DialogButton_OnMouseClick; dialogButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.JournalNextCategory); dialogButton.Name = "dialog_button"; dialogButton.ToolTip = defaultToolTip; dialogButton.ToolTipText = TextManager.Instance.GetLocalizedText("dialogButtonInfo"); mainPanel.Components.Add(dialogButton); upArrowButton = new Button(); upArrowButton.Position = new Vector2(181, 188); upArrowButton.Size = new Vector2(13, 7); upArrowButton.OnMouseClick += UpArrowButton_OnMouseClick; upArrowButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.JournalPreviousPage); upArrowButton.Name = "uparrow_button"; mainPanel.Components.Add(upArrowButton); downArrowButton = new Button(); downArrowButton.Position = new Vector2(209, 188); downArrowButton.Size = new Vector2(13, 7); downArrowButton.OnMouseClick += DownArrowButton_OnMouseClick; downArrowButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.JournalNextPage); downArrowButton.Name = "downarrow_button"; mainPanel.Components.Add(downArrowButton); exitButton = new Button(); exitButton.Position = new Vector2(278, 187); exitButton.Size = new Vector2(30, 9); exitButton.OnMouseClick += ExitButton_OnMouseClick; exitButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.JournalExit); exitButton.OnKeyboardEvent += ExitButton_OnKeyboardEvent; exitButton.Name = "exit_button"; mainPanel.Components.Add(exitButton); questLogLabel = new MultiFormatTextLabel(); questLogLabel.Position = new Vector2(30, 38); questLogLabel.Size = new Vector2(238, 138); questLogLabel.HighlightColor = Color.white; questLogLabel.OnMouseClick += QuestLogLabel_OnMouseClick; questLogLabel.OnRightMouseClick += QuestLogLabel_OnRightMouseClick; mainPanel.Components.Add(questLogLabel); Panel titlePanel = new Panel { Position = new Vector2(30, 22), Size = new Vector2(238, 16), }; titleLabel = new TextLabel { HorizontalAlignment = HorizontalAlignment.Center, Font = DaggerfallUI.LargeFont, ShadowColor = new Color(0f, 0.2f, 0.5f), ToolTip = defaultToolTip, ToolTipText = TextManager.Instance.GetLocalizedText("activeQuestsInfo"), }; titlePanel.Components.Add(titleLabel); mainPanel.Components.Add(titlePanel); titlePanel.OnMouseClick += TitlePanel_OnMouseClick; questMessages = QuestMachine.Instance.GetAllQuestLogMessages(); // Store toggle closed bindings for this window toggleClosedBinding1 = InputManager.Instance.GetBinding(InputManager.Actions.LogBook); toggleClosedBinding2 = InputManager.Instance.GetBinding(InputManager.Actions.NoteBook); #if LAYOUT SetBackgroundColors(); #endif }
protected void SetAttackInfo(MultiFormatTextLabel label, bool rightHand = true) { var weapon = playerEntity.ItemEquipTable.GetItem(rightHand ? EquipSlots.RightHand : EquipSlots.LeftHand); short weaponSkill = 0; int chanceToHitMod = 0; int damageMod = 0; int minDamage = 0; int maxDamage = 0; // Note from Numidium: I copied snippets from FormulaHelper.cs to calculate the values used here if (weapon != null) { weaponSkill = weapon.GetWeaponSkillIDAsShort(); short skillValue = PlayerEntity.Skills.GetLiveSkillValue(weaponSkill); chanceToHitMod = skillValue; // Apply weapon proficiency if (((int)playerEntity.Career.ExpertProficiencies & weapon.GetWeaponSkillUsed()) != 0) { damageMod += (playerEntity.Level / 3) + 1; chanceToHitMod += playerEntity.Level; } // Apply weapon material modifier chanceToHitMod += FormulaHelper.CalculateWeaponToHit(weapon); // Apply racial bonuses FormulaHelper.ToHitAndDamageMods racialMods = FormulaHelper.CalculateRacialModifiers(PlayerEntity, weapon, PlayerEntity); damageMod += racialMods.damageMod; chanceToHitMod += racialMods.toHitMod; // Apply stat to-hit bonuses chanceToHitMod += (playerEntity.Stats.LiveAgility + playerEntity.Stats.LiveLuck) / 10; // Apply adrenaline rush const int adrenalineRushModifier = 5; const int improvedAdrenalineRushModifier = 8; if (playerEntity.Career.AdrenalineRush && playerEntity.CurrentHealth < playerEntity.MaxHealth / 8) { chanceToHitMod += (playerEntity.ImprovedAdrenalineRush) ? improvedAdrenalineRushModifier : adrenalineRushModifier; } // Apply enchantment modifier chanceToHitMod += playerEntity.ChanceToHitModifier; // Calculate min and max damage player can do with their current weapon damageMod += weapon.GetWeaponMaterialModifier() + FormulaHelper.DamageModifier(playerEntity.Stats.LiveStrength); minDamage = weapon.GetBaseDamageMin() + damageMod; maxDamage = weapon.GetBaseDamageMax() + damageMod; } // Apply hand-to-hand proficiency. Hand-to-hand proficiency is not applied in classic. else { var handToHandSkill = playerEntity.Skills.GetLiveSkillValue((short)DFCareer.Skills.HandToHand); chanceToHitMod += handToHandSkill; if (((int)playerEntity.Career.ExpertProficiencies & (int)DFCareer.ProficiencyFlags.HandToHand) != 0) { damageMod += (playerEntity.Level / 3) + 1; chanceToHitMod += playerEntity.Level; } minDamage = FormulaHelper.CalculateHandToHandMinDamage(handToHandSkill); maxDamage = FormulaHelper.CalculateHandToHandMaxDamage(handToHandSkill); } label.Clear(); var handText = rightHand ? "Right" : "Left"; label.SetText(new TextAsset(handText + "\nAtk:\n" + chanceToHitMod.ToString() + "\nDmg:\n" + minDamage.ToString() + "-" + maxDamage.ToString())); }