public DeitySystem() { var doc = WidgetDoc.Load("ui/pc_creation/deity_ui.json"); Container = doc.GetRootContainer(); Container.Visible = false; _deityButtons = new Dictionary <DeityId, WidgetButton>(); foreach (var deityId in GameSystems.Deity.PlayerSelectableDeities) { var buttonIndex = _deityButtons.Count; var button = new WidgetButton(new Rectangle( 48 + 171 * (buttonIndex / 10), 25 + 21 * (buttonIndex % 10), 162, 12 )); button.SetStyle("deity-button"); button.Text = GameSystems.Deity.GetName(deityId).ToUpper(); button.OnMouseEnter += msg => ShowDeityHelp(deityId); button.OnMouseExit += msg => UpdateDescriptionBox(); button.SetClickHandler(() => SelectDeity(deityId)); Container.Add(button); _deityButtons[deityId] = button; } }
public AlertUi() { var doc = WidgetDoc.Load("ui/alert_ui.json"); _mainWindow = doc.GetRootContainer(); _mainWindow.ZIndex = 99800; _mainWindow.Name = "alert_main_window"; _mainWindow.Visible = false; _titleLabel = doc.GetTextContent("title"); _okButton = doc.GetButton("alert_ok_button"); _okButton.Name = "alert_ok_button"; _okButton.SetClickHandler(OkButtonClicked); _mainWindow.Add(_okButton); ScrollBoxSettings settings = new ScrollBoxSettings(); settings.TextArea = new Rectangle(6, 16, 287, 208); settings.ScrollBarPos = new Point(297, 1); settings.ScrollBarHeight = 224; settings.Indent = 7; settings.Font = PredefinedFont.ARIAL_10; _scrollBox = new ScrollBox(new Rectangle(20, 36, 310, 226), settings); _scrollBox.ZIndex = 99950; _scrollBox.Name = "scrollbox_main_window"; _mainWindow.Add(_scrollBox); }
public void Show() { mListBox.Clear(); int y = 0; const int NUM_SCENARIOS = 0; for (int i = 0; i < NUM_SCENARIOS; i++) { var button = new WidgetButton(); button.Text = "Arena"; button.SetId("Arena"); var innerWidth = mListBox.GetInnerWidth(); button.Width = innerWidth; button.SetAutoSizeWidth(false); button.SetStyle("mm-setpieces-list-button"); button.Y = y; btnIds.Add(button); var idx = i; button.SetClickHandler(() => Select(idx)); y += button.Height; mListBox.Add(button); } mWidget.Show(); }
public ActionBarUi() { _pulseAnimation = GameSystems.Vagrant.AllocateActionBar(); // These values were configurable in a MES file before GameSystems.Vagrant.ActionBarSetPulseValues(_pulseAnimation, 64, 255, 0.125f); _combatBarFill = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Fill.tga", false); _combatBarHighlight = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Highlight.tga", false); _combatBarHighlight2 = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Highlight2.tga", false); _combatBarGrey = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_GREY.tga", false); _combatBarFillInvalid = Tig.Textures.Resolve("art/interface/COMBAT_UI/CombatBar_Fill_INVALID.tga", false); _window = new WidgetContainer(8, 117, 50, 260); _window.Name = "combat_ui_debug_output_window"; // Hide or show the entire action bar based on combat status _window.Visible = false; GameSystems.Combat.OnCombatStatusChanged += combatStatus => { _window.Visible = combatStatus; }; var actionBarImage = new WidgetImage("art/interface/COMBAT_UI/combatbar.img"); _window.AddContent(actionBarImage); var actionBar = new WidgetContainer(new Rectangle(13, 15, 22, 170)); _window.Add(actionBar); actionBar.Name = "action bar"; actionBar.OnBeforeRender += () => UiCombatActionBarRender(actionBar); // Add a full sized button on top of the action bar to handle tooltips and help requests var actionBarButton = new WidgetButton(); actionBarButton.SetStyle(new WidgetButtonStyle()); actionBarButton.SetSizeToParent(true); actionBarButton.SetClickHandler(OnActionBarButtonClick); actionBarButton.TooltipStyle = "action-bar-tooltip"; actionBarButton.OnBeforeRender += () => { // Use the time update message (one per frame) to update the tooltip text actionBarButton.TooltipText = GetActionBarTooltipText(); }; actionBar.Add(actionBarButton); var nextTurn = new WidgetButton(new Rectangle(0, 194, 50, 50)); nextTurn.SetStyle(new WidgetButtonStyle { NormalImagePath = "art/interface/COMBAT_UI/Action-End-Turn.tga", HoverImagePath = "art/interface/COMBAT_UI/Action-End-Turn-Hover.tga", PressedImagePath = "art/interface/COMBAT_UI/Action-End-Turn-Click.tga", DisabledImagePath = "art/interface/COMBAT_UI/Action-End-Turn-Disabled.tga", }); nextTurn.Name = "next_turn"; nextTurn.OnBeforeRender += () => OnBeforeRenderNextTurn(nextTurn); nextTurn.SetClickHandler(OnNextTurnClick); _window.Add(nextTurn); }
private void CreatePopupWidget(UiPromptListEntry uiPopup) { var window = new WidgetContainer(new Rectangle(0, 0, 0, 0)); // popup_ui_main_window1.OnBeforeRender += 0x10170a90; window.Name = "popup_ui_main_window"; window.Visible = false; window.SetMouseMsgHandler(msg => true); // Swallow mouse clicks and such uiPopup.wnd = window; uiPopup.background = new WidgetImage(); window.AddContent(uiPopup.background); uiPopup.titleLabel = new WidgetText("", "popupTitle"); uiPopup.titleLabel.X = 30; uiPopup.titleLabel.Y = 13; uiPopup.titleLabel.FixedSize = new Size(230, 26); uiPopup.titleLabel.SetCenterVertically(true); window.AddContent(uiPopup.titleLabel); uiPopup.bodyLabel = new WidgetText("", "popupBody"); window.AddContent(uiPopup.bodyLabel); var okButton = new WidgetButton(new Rectangle(0, 0, 0, 0)); // popup_ui_button1.OnHandleMessage += 0x10171b50; // popup_ui_button1.OnBeforeRender += 0x10170c30; // popup_ui_button1.OnRenderTooltip += 0x100027f0; okButton.Name = "popup_ok_button"; okButton.Visible = false; window.Add(okButton); uiPopup.btn1 = okButton; okButton.SetClickHandler(() => OnClickButton(uiPopup, 0)); var cancelButton = new WidgetButton(new Rectangle(0, 0, 0, 0)); // popup_ui_button2.OnHandleMessage += 0x10171b50; // popup_ui_button2.OnBeforeRender += 0x10170e40; // popup_ui_button2.OnRenderTooltip += 0x100027f0; cancelButton.Name = "popup_cancel_button"; cancelButton.Visible = false; window.Add(cancelButton); uiPopup.btn2 = cancelButton; cancelButton.SetClickHandler(() => OnClickButton(uiPopup, 1)); var popup_ui_button3 = new WidgetButton(new Rectangle(0, 0, 0, 0)); // popup_ui_button3.OnHandleMessage += 0x10171b50; // popup_ui_button3.OnBeforeRender += 0x10171a90; // popup_ui_button3.OnRenderTooltip += 0x100027f0; popup_ui_button3.Name = "popup_ui_button"; popup_ui_button3.Visible = false; window.Add(popup_ui_button3); uiPopup.btn3 = popup_ui_button3; }
public WidgetSlider(int x, int y, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = -1) : base(x, y, filePath, lineNumber) { // Size of the slider itself Width = 177; Height = 27; var leftButton = new WidgetButton(); leftButton.SetStyle(Globals.WidgetButtonStyles.GetStyle("slider-left")); leftButton.SetClickHandler(() => { SetValue(GetValue() - 1); }); leftButton.SetRepeat(true); leftButton.Width = 27; leftButton.Height = 27; var rightButton = new WidgetButton(); rightButton.SetStyle(Globals.WidgetButtonStyles.GetStyle("slider-right")); rightButton.SetClickHandler(() => { SetValue(GetValue() + 1); }); rightButton.SetRepeat(true); rightButton.Width = 27; rightButton.Height = 27; rightButton.X = Width - rightButton.Width; var track = new WidgetButton(); track.SetStyle(Globals.WidgetButtonStyles.GetStyle("slider-track")); track.SetClickHandler((x, y) => { if (x < _handleButton.X) { SetValue(GetValue() - Quantum); } else if (x >= _handleButton.X + _handleButton.Width) { SetValue(GetValue() + Quantum); } }); track.SetRepeat(true); var handle = new WidgetSliderHandle(this); handle.Y = 2; _leftButton = leftButton; _rightButton = rightButton; _track = track; _handleButton = handle; Add(track); Add(leftButton); Add(rightButton); Add(handle); }
public WidgetScrollBar() : base(0, 0) { var upButton = new WidgetButton(); upButton.SetParent(this); upButton.SetStyle(Globals.WidgetButtonStyles.GetStyle("scrollbar-up")); upButton.SetClickHandler(() => { SetValue(GetValue() - 1); }); upButton.SetRepeat(true); var downButton = new WidgetButton(); downButton.SetParent(this); downButton.SetStyle(Globals.WidgetButtonStyles.GetStyle("scrollbar-down")); downButton.SetClickHandler(() => { SetValue(GetValue() + 1); }); downButton.SetRepeat(true); var track = new WidgetButton(); track.SetParent(this); track.SetStyle(Globals.WidgetButtonStyles.GetStyle("scrollbar-track")); track.SetClickHandler((x, y) => { // The y value is in relation to the track, we need to add it's own Y value, // and compare against the current position of the handle y += mTrack.Y; if (y < mHandleButton.Y) { SetValue(GetValue() - 5); } else if (y >= mHandleButton.Y + mHandleButton.Height) { SetValue(GetValue() + 5); } }); track.SetRepeat(true); var handle = new WidgetScrollBarHandle(this); handle.SetParent(this); handle.Height = 100; Width = Math.Max(upButton.Width, downButton.Width); mUpButton = upButton; mDownButton = downButton; mTrack = track; mHandleButton = handle; Add(track); Add(upButton); Add(downButton); Add(handle); }
public GenderSystem() { var doc = WidgetDoc.Load("ui/pc_creation/gender_ui.json"); Container = doc.GetRootContainer(); Container.Visible = false; _maleButton = doc.GetButton("maleButton"); _maleButton.SetClickHandler(() => ChooseGender(Gender.Male)); _femaleButton = doc.GetButton("femaleButton"); _femaleButton.SetClickHandler(() => ChooseGender(Gender.Female)); // NOTE: Vanilla previously tried showing gender-specific help texts, but those texts actually don't exist }
public TextEntryUi() { var doc = WidgetDoc.Load("ui/text_entry_ui.json"); _dialog = doc.GetRootContainer(); _dialog.Visible = false; _dialog.SetKeyStateChangeHandler(HandleShortcut); _dialog.OnHandleMessage += HandleMessage; _okButton = doc.GetButton("okButton"); _okButton.SetClickHandler(Confirm); _cancelButton = doc.GetButton("cancelButton"); _cancelButton.SetClickHandler(Cancel); _titleLabel = doc.GetTextContent("titleLabel"); _currentInputLabel = doc.GetTextContent("currentInputLabel"); }
private void CreateExitButton() { var exitButton = new WidgetButton(_uiParams.CharUiMainExitButton); exitButton.SetAutoSizeHeight(false); exitButton.SetAutoSizeWidth(false); exitButton.SetStyle(new WidgetButtonStyle { DisabledImagePath = _uiParams.TexturePaths[CharUiTexture.MainExitButtonDisabled], HoverImagePath = _uiParams.TexturePaths[CharUiTexture.MainExitButtonHoverOn], NormalImagePath = _uiParams.TexturePaths[CharUiTexture.MainExitButtonHoverOff], PressedImagePath = _uiParams.TexturePaths[CharUiTexture.MainExitButtonHoverPressed] }); exitButton.SetClickHandler(ExitClicked); _mainWidget.Add(exitButton); }
public void Show() { mListBox.Clear(); btnIds.Clear(); seenIndices.Clear(); for (var i = 0; i < movieIds.Count; i++) { if (IsMovieSeen(movieIds[i], -1)) { seenIndices.Add(i); } } int y = 0; for (int i = 0; i < seenIndices.Count; i++) { var movieInd = seenIndices[i]; var button = new WidgetButton(); button.Text = mMovieNames[movieInd]; button.SetId(mMovieNames[movieInd]); var innerWidth = mListBox.GetInnerWidth(); button.Width = innerWidth; button.SetAutoSizeWidth(false); button.SetStyle("mm-cinematics-list-button"); button.Y = y; //var pBtn = button.get(); btnIds.Add(button); var selectIdx = i; button.SetClickHandler(() => Select(selectIdx)); y += button.Height; mListBox.Add(button); } mWidget.Show(); }
public CampingUi() { _translations = Tig.FS.ReadMesFile("mes/utility_bar.mes"); var doc = WidgetDoc.Load("ui/camping_ui.json"); // Begin top level window // Created @ 0x1012f29f _mainWindow = doc.GetRootContainer(); // _mainWindow.OnBeforeRender += 0x1012e4d0; // Swallow mouse events (to prevent click through) _mainWindow.SetMouseMsgHandler(msg => true); _mainWindow.SetKeyStateChangeHandler(OnKeyStateChange); _mainWindow.ZIndex = 100000; _mainWindow.Visible = false; _mainWindow.OnBeforeRender += UpdateCheckboxes; var titleLabel = new WidgetText(WindowTitle, "camping-button-text"); titleLabel.X = 31; titleLabel.Y = 11; titleLabel.FixedSize = new Size(230, 12); _mainWindow.AddContent(titleLabel); // Labels for the hours/days to rest _daysToRestLabelText = new WidgetText(DaysLabel, "camping-torest-labels"); _mainWindow.AddContent(_daysToRestLabelText); _hoursToRestLabelText = new WidgetText(HoursLabel, "camping-torest-labels"); _mainWindow.AddContent(_hoursToRestLabelText); _daysToRestText = new WidgetText("0", "camping-torest"); _mainWindow.AddContent(_daysToRestText); _hoursToRestText = new WidgetText("0", "camping-torest"); _mainWindow.AddContent(_hoursToRestText); _restButton = doc.GetButton("restButton"); _restButton.SetClickHandler(OnRestClicked); _cancelButton = doc.GetButton("cancelButton"); _cancelButton.Text = ButtonLabelCancel; _cancelButton.SetClickHandler(Hide); _incrementDaysButton = doc.GetButton("incDaysButton"); _incrementDaysButton.SetRepeat(true); _incrementDaysButton.SetClickHandler(OnIncrementDays); _decrementDaysButton = doc.GetButton("decDaysButton"); _decrementDaysButton.SetRepeat(true); _decrementDaysButton.SetClickHandler(OnDecrementDays); _incrementHoursButton = doc.GetButton("incHoursButton"); _incrementHoursButton.SetRepeat(true); _incrementHoursButton.SetClickHandler(OnIncrementHours); _decrementHoursButton = doc.GetButton("decHoursButton"); _decrementHoursButton.SetRepeat(true); _decrementHoursButton.SetClickHandler(OnDecrementHours); _restUntilHealedCheckbox = new CampingCheckbox(new Rectangle(86, 96, 113, 15), UntilHealedLabel, "camping-checkbox-labels"); _restUntilHealedCheckbox.OnCheckedChange += value => CampingSetTimeUntilHealed(); _mainWindow.Add(_restUntilHealedCheckbox); _restUntilNightCheckbox = new CampingCheckbox(new Rectangle(86, 117, 113, 15), UntilEveningLabel, "camping-checkbox-labels"); _restUntilNightCheckbox.OnCheckedChange += value => UiCampingSetTimeToUntilNighttime(); _mainWindow.Add(_restUntilNightCheckbox); _restUntilDayCheckbox = new CampingCheckbox(new Rectangle(86, 138, 113, 15), UntilMorningLabel, "camping-checkbox-labels"); _restUntilDayCheckbox.OnCheckedChange += value => UiCampingSetTimeToUntilDaytime(); _mainWindow.Add(_restUntilDayCheckbox); // Begin top level window // Created @ 0x1019b2c8 // var @ [TempleDllLocation(0x11e72ad8)] var sticky_ui_main_window1 = new WidgetContainer(new Rectangle(0, 0, 0, 0)); // sticky_ui_main_window1.OnHandleMessage += 0x101f5850; // sticky_ui_main_window1.OnBeforeRender += 0x1019a9a0; sticky_ui_main_window1.ZIndex = 0; sticky_ui_main_window1.Name = "sticky_ui_main_window"; sticky_ui_main_window1.Visible = false; // Created @ 0x1019b39a // var @ [TempleDllLocation(0x11e7277c)] var radialmenuslideracceptbutton1 = new WidgetButton(new Rectangle(328, 370, 112, 22)); // radialmenuslideracceptbutton1.OnHandleMessage += 0x1019af30; // radialmenuslideracceptbutton1.OnBeforeRender += 0x1019ac10; radialmenuslideracceptbutton1.Name = "radial menu slider accept button"; sticky_ui_main_window1.Add(radialmenuslideracceptbutton1); // Created @ 0x1019b4a1 // var @ [TempleDllLocation(0x11e72ad4)] var radialmenusliderdeclinebutton1 = new WidgetButton(new Rectangle(452, 370, 112, 22)); // radialmenusliderdeclinebutton1.OnHandleMessage += 0x1019af30; // radialmenusliderdeclinebutton1.OnBeforeRender += 0x1019ac10; radialmenusliderdeclinebutton1.Name = "radial menu slider decline button"; sticky_ui_main_window1.Add(radialmenusliderdeclinebutton1); // Created @ 0x1019b5a9 // var @ [TempleDllLocation(0x11e72b9c)] var radialmenuslidercheckboxbutton1 = new WidgetButton(new Rectangle(335, 354, 40, 11)); // radialmenuslidercheckboxbutton1.OnHandleMessage += 0x1019b1d0; // radialmenuslidercheckboxbutton1.OnBeforeRender += 0x1019afa0; radialmenuslidercheckboxbutton1.Name = "radial menu slider checkbox button"; sticky_ui_main_window1.Add(radialmenuslidercheckboxbutton1); }
public PartyAlignmentUi() { var doc = WidgetDoc.Load("ui/party_creation/party_alignment.json"); _container = doc.GetRootContainer(); _container.Visible = false; // RENDER: 0x1011be20 // MESSAGE: 0x1011ed20 _container.SetKeyStateChangeHandler(evt => { if (evt.key == DIK.DIK_ESCAPE && evt.down) { Cancel(); return(true); } return(false); }); // Alignment buttons: // MESSAGE: 0x1011e5c0 // RENDER: 0x1011e460 _alignmentButtons = new Dictionary <Alignment, WidgetButton> { { Alignment.TRUE_NEUTRAL, doc.GetButton("alignment_tn") }, { Alignment.LAWFUL_NEUTRAL, doc.GetButton("alignment_ln") }, { Alignment.CHAOTIC_NEUTRAL, doc.GetButton("alignment_cn") }, { Alignment.NEUTRAL_GOOD, doc.GetButton("alignment_ng") }, { Alignment.LAWFUL_GOOD, doc.GetButton("alignment_lg") }, { Alignment.CHAOTIC_GOOD, doc.GetButton("alignment_cg") }, { Alignment.NEUTRAL_EVIL, doc.GetButton("alignment_ne") }, { Alignment.LAWFUL_EVIL, doc.GetButton("alignment_le") }, { Alignment.CHAOTIC_EVIL, doc.GetButton("alignment_ce") } }; foreach (var(alignment, button) in _alignmentButtons) { var alignmentName = GameSystems.Stat.GetAlignmentName(alignment).ToUpper(); button.Text = alignmentName; button.SetClickHandler(() => SelectAlignment(alignment)); } // OK Button: // MESSAGE: 0x1011bf70 // RENDER: 0x1011beb0 _okButton = doc.GetButton("ok"); _okButton.SetClickHandler(() => { var alignment = _alignment; if (alignment.HasValue) { Hide(); OnConfirm?.Invoke(alignment.Value); } }); // Cancel button: 0x10bdd614 // MESSAGE: 0x1011ed50 // RENDER: 0x1011bfa0 var cancelButton = doc.GetButton("cancel"); cancelButton.SetClickHandler(Cancel); _selectionRect = doc.GetImageContent("selected"); }
public AbilityScoreSystem() { var doc = WidgetDoc.Load("ui/pc_creation/stats_ui.json"); Container = doc.GetRootContainer(); Container.Visible = false; _pointBuyInfo = doc.GetContainer("pointBuyInfo"); _pointBuyPointsAvailable = doc.GetTextContent("pointBuyPointsAvailable"); _titleLabel = doc.GetTextContent("title"); _rerollButton = doc.GetButton("reroll"); _rerollButton.SetClickHandler(RerollStats); _rerollsLabel = doc.GetTextContent("rerollsLabel"); _togglePointBuyButton = doc.GetButton("togglePointBuy"); _togglePointBuyButton.SetClickHandler(TogglePointBuy); _increaseButtons = new WidgetButton[6]; _decreaseButtons = new WidgetButton[6]; for (var i = 0; i < 6; i++) { var abilityIndex = i; _increaseButtons[i] = doc.GetButton($"increase-{AttributeIdSuffixes[i]}"); _increaseButtons[i].SetClickHandler(() => IncreaseStat(abilityIndex)); _decreaseButtons[i] = doc.GetButton($"decrease-{AttributeIdSuffixes[i]}"); _decreaseButtons[i].SetClickHandler(() => DecreaseStat(abilityIndex)); var assignedValContainer = doc.GetContainer($"assigned-val-{AttributeIdSuffixes[i]}"); var assignedVal = new AbilityScoreValueWidget( assignedValContainer.GetSize(), () => _pkt.abilityStats[abilityIndex], value => _pkt.abilityStats[abilityIndex] = value, true ); assignedValContainer.Add(assignedVal); assignedVal.SetMouseMsgHandler(msg => AbilityScoreMouseHandler(msg, assignedVal)); // Displays the modifier for the assigned attribute var assignedModContainer = doc.GetContainer($"assigned-mod-{AttributeIdSuffixes[i]}"); var assignedMod = new AbilityScoreModifierWidget( assignedValContainer.GetSize(), () => _pkt.abilityStats[abilityIndex] ); assignedModContainer.Add(assignedMod); } // This label is used to draw the ability score currently being dragged _draggedAbilityScoreLabel = new WidgetText("", "charGenAssignedStat"); for (var i = 0; i < 6; i++) { var index = i; var rolledStatContainer = doc.GetContainer("rolledAttribute" + i); var rolledStatWidget = new AbilityScoreValueWidget( rolledStatContainer.GetSize(), () => charGenRolledStats[index], value => charGenRolledStats[index] = value, false ); charGenRolledStatsWidgets[i] = rolledStatWidget; rolledStatContainer.Add(rolledStatWidget); rolledStatWidget.SetMouseMsgHandler(msg => AbilityScoreMouseHandler(msg, rolledStatWidget)); } }