Exemple #1
0
    public WizardFeaturesUi()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/abilities_wizard_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;
    }
    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);
    }
Exemple #4
0
    public AlignmentSystem()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/alignment_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;

        _partyAlignmentLabel = doc.GetTextContent("partyAlignmentLabel");

        _alignmentButtons = new Dictionary <Alignment, WidgetButton>
        {
            { Alignment.LAWFUL_GOOD, doc.GetButton("lawfulGood") },
            { Alignment.NEUTRAL_GOOD, doc.GetButton("neutralGood") },
            { Alignment.CHAOTIC_GOOD, doc.GetButton("chaoticGood") },
            { Alignment.LAWFUL_NEUTRAL, doc.GetButton("lawfulNeutral") },
            { Alignment.NEUTRAL, doc.GetButton("neutral") },
            { Alignment.CHAOTIC_NEUTRAL, doc.GetButton("chaoticNeutral") },
            { Alignment.LAWFUL_EVIL, doc.GetButton("lawfulEvil") },
            { Alignment.NEUTRAL_EVIL, doc.GetButton("neutralEvil") },
            { Alignment.CHAOTIC_EVIL, doc.GetButton("chaoticEvil") },
        };

        foreach (var(alignment, button) in _alignmentButtons)
        {
            button.OnMouseEnter += msg => ShowAlignmentHelp(alignment);
            button.OnMouseExit  += msg => UpdateDescriptionBox();
            button.SetClickHandler(() => SelectAlignment(alignment));
        }
    }
Exemple #5
0
    public CharSheetSkillsUi()
    {
        var detailsDoc = WidgetDoc.Load("ui/char_skills.json");

        Container = detailsDoc.GetRootContainer();
        Container.SetMouseMsgHandler(msg =>
        {
            // Forward mouse wheel messages to the scrollbar
            if ((msg.flags & MouseEventFlag.ScrollWheelChange) != 0)
            {
                _scrollbar.HandleMouseMessage(msg);
            }

            return(true);
        });
        Container.Name    = "char_skills_ui_main_window";
        Container.Visible = false;

        _skillRanks     = detailsDoc.GetTextContent("skill-ranks-label");
        _attributeBonus = detailsDoc.GetTextContent("skill-attribute-bonus-label");
        _attributeType  = detailsDoc.GetTextContent("skill-attribute-type-label");
        _miscBonus      = detailsDoc.GetTextContent("skill-misc-bonus-label");
        _total          = detailsDoc.GetTextContent("skill-total-label");
        HideSkillDetails();

        for (var i = 0; i < 20; i++)
        {
            var button = new SkillButton(new Rectangle(1, 1 + 13 * i, 156, 13));
            button.OnMouseEnter += _ => ShowSkillDetails(button);
            button.OnMouseExit  += _ => HideSkillDetails();
            button.SetMouseMsgHandler(msg =>
            {
                if ((msg.flags & MouseEventFlag.ScrollWheelChange) != 0)
                {
                    return(_scrollbar.HandleMouseMessage(msg));
                }

                return(false);
            });
            Container.Add(button);
            _skillButtons[i] = button;
        }

        if (VisibleSkills.Length > _skillButtons.Length)
        {
            _scrollbar = new WidgetScrollBar(new Rectangle(160, -4, 13, 267));
            _scrollbar.SetMin(0);
            _scrollbar.Max = VisibleSkills.Length - _skillButtons.Length;
            Container.Add(_scrollbar);
            _scrollbar.SetValueChangeHandler((value) => UpdateSkillButtons());
        }

        UpdateSkillButtons();
    }
    public LogbookKeyAcquiredPopup(LogbookKeyTranslations translations)
    {
        var doc = WidgetDoc.Load("ui/key_acquired_popup.json");

        _window = doc.GetRootContainer();

        doc.GetTextContent("title").Text = translations.NotificationPopupTitle;

        var textContainer = doc.GetContainer("textContainer");

        var text = new WidgetText();

        text.FixedWidth = 237;
        text.Text       = translations.NotificationPopupText;
        textContainer.AddContent(text);

        var prompt = new WidgetText();

        prompt.FixedWidth = 237;
        prompt.Text       = translations.NotificationPopupPrompt;
        prompt.Y          = text.GetPreferredSize().Height + 13;
        textContainer.AddContent(prompt);

        // Created @ 0x1019727c
        // _window.OnHandleMessage += 0x101f5850;
        // _window.OnBeforeRender += 0x10196a10;
        _window.ZIndex  = 100051;
        _window.Name    = "logbook_ui_keys_key_entry_window";
        _window.Visible = false;

        // Created @ 0x10197385
        var acceptButton = doc.GetButton("accept");

        // logbook_ui_key_entry_accept_butn1.OnHandleMessage += 0x10197070;
        // logbook_ui_key_entry_accept_butn1.OnBeforeRender += 0x10196d70;
        acceptButton.Text = translations.NotificationPopupYes;
        acceptButton.Name = "logbook_ui_key_entry_accept_butn";
        acceptButton.SetClickHandler(() =>
        {
            OnChangeNotificationSetting?.Invoke(false);
            Hide();
        });

        // Created @ 0x101974c2
        var declineButton = doc.GetButton("decline");

        // logbook_ui_key_entry_decline_butn1.OnHandleMessage += 0x10197070;
        // logbook_ui_key_entry_decline_butn1.OnBeforeRender += 0x10196d70;
        declineButton.Text = translations.NotificationPopupNo;
        declineButton.Name = "logbook_ui_key_entry_decline_butn";
        declineButton.SetClickHandler(Hide);
    }
    public CharSheetHelpUi()
    {
        var widgetDoc = WidgetDoc.Load("ui/char_help.json");

        _scrollView = (WidgetScrollView)widgetDoc.TakeRootWidget();

        _textContainer = new WidgetContainer(0, 0,
                                             _scrollView.GetInnerWidth(), _scrollView.GetInnerHeight());
        _textLabel = new WidgetText();
        _textContainer.AddContent(_textLabel);
        _scrollView.Add(_textContainer);
        _scrollView.AddStyle("char-help-text");
    }
    public StatBlockAbilityScore(Stat ability)
    {
        var doc = WidgetDoc.Load("ui/pc_creation/stat_block_ability_score.json");

        Container = doc.GetRootContainer();

        _caption        = doc.GetTextContent("caption");
        _caption.Text   = GameSystems.Stat.GetStatShortName(ability);
        _captionBg      = doc.GetContent("activeCaptionBg");
        _modifierLabel  = doc.GetTextContent("modifierLabel");
        _modifierBorder = doc.GetContent("activeModifierBorder");
        _valueLabel     = doc.GetTextContent("valueLabel");
        _valueBorder    = doc.GetContent("activeValueBorder");
    }
    public PopupUi()
    {
        Stub.TODO();
        _vanillaTranslations = Tig.FS.ReadMesFile("mes/vanilla_ui.mes");

        // Currently only used for the text styles that come with it
        WidgetDoc.Load("ui/popup_ui.json");

        for (var i = 0; i < uiPopups.Length; i++)
        {
            uiPopups[i] = new UiPromptListEntry();
            CreatePopupWidget(uiPopups[i]);
        }
    }
Exemple #10
0
    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");
    }
    public HeightSystem()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/height_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;

        _minHeightLabel     = doc.GetTextContent("minHeightLabel");
        _maxHeightLabel     = doc.GetTextContent("maxHeightLabel");
        _currentHeightLabel = doc.GetTextContent("currentHeightLabel");

        _slider = new HeightSlider();
        _slider.SetPos(doc.GetContainer("sliderContainer").GetPos());
        Container.Add(_slider);
        _slider.OnValueChanged += (newValue) => { UpdateModelScale(); };
    }
    public PortraitSystem()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/portrait_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;

        // TODO chargenPortraitCapacity /*0x10c0eaa8*/ = 0;
        // TODO chargenPortraitCount /*0x10c0eb64*/ = 0;
        // TODO chargenPortraitIds /*0x10c0ed28*/ = 0;
        // TODO if (RegisterUiTexture /*0x101ee7b0*/("art\\interface\\pc_creation\\portrait_frame.tga",
        // TODO     &chargenPortrait_portrait_frame /*0x10c0eef0*/))
        // TODO {
        // TODO     result = 0;
        // TODO }
        // TODO else
        // TODO {
        // TODO     result = ChargenPortraitWidgetsInit /*0x1017e800*/(a1.width, a1.height) != 0;
        // TODO }
    }
Exemple #14
0
    public SetPiecesDialog(MainMenuUi mainMenuUi)
    {
        _mainMenuUi = mainMenuUi;

        WidgetDoc doc = WidgetDoc.Load("ui/main_menu_setpieces.json");

        doc.GetButton("go").SetClickHandler(() =>
        {
            mWidget.Hide();
            LaunchScenario();
        });
        doc.GetButton("cancel").SetClickHandler(() =>
        {
            mWidget.Hide();
            _mainMenuUi.Show(MainMenuPage.MainMenu);
        });

        mListBox = doc.GetScrollView("scenariosList");

        mWidget = doc.GetRootContainer();
        mWidget.Hide();
    }
Exemple #15
0
    public StatBlockWidget()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/stat_block_ui.json");

        Container = doc.GetRootContainer();

        StatBlockAbilityScore AddAbilityScore(string containerId, Stat ability)
        {
            var widget = new StatBlockAbilityScore(ability);

            doc.GetContainer(containerId).Add(widget.Container);
            return(widget);
        }

        _abilityScoreWidgets = new[]
        {
            AddAbilityScore("strength", Stat.strength),
            AddAbilityScore("dexterity", Stat.dexterity),
            AddAbilityScore("constitution", Stat.constitution),
            AddAbilityScore("intelligence", Stat.intelligence),
            AddAbilityScore("wisdom", Stat.wisdom),
            AddAbilityScore("charisma", Stat.charisma)
        };

        _experience        = new StatBlockValue(doc, "experience");
        _level             = new StatBlockValue(doc, "level");
        _hp                = new StatBlockValue(doc, "hp");
        _ac                = new StatBlockValue(doc, "ac");
        _fortitudeSave     = new StatBlockValue(doc, "fortitudeSave");
        _reflexSave        = new StatBlockValue(doc, "reflexSave");
        _willSave          = new StatBlockValue(doc, "willSave");
        _initiativeBonus   = new StatBlockValue(doc, "initiativeBonus");
        _speed             = new StatBlockValue(doc, "speed");
        _meleeAttackBonus  = new StatBlockValue(doc, "meleeAttackBonus");
        _rangedAttackBonus = new StatBlockValue(doc, "rangedAttackBonus");
        _height            = new StatBlockValue(doc, "height");
        _weight            = new StatBlockValue(doc, "weight");
    }
Exemple #16
0
    public ViewCinematicsDialog(MainMenuUi mainMenu, IDictionary <int, string> mmMes)
    {
        _mainMenu = mainMenu;

        WidgetDoc doc = WidgetDoc.Load("ui/main_menu_cinematics.json");

        doc.GetButton("view").SetClickHandler(() =>
        {
            if (mSelection < 0 || mSelection >= seenIndices.Count)
            {
                return;
            }
            var movieIdx = seenIndices[mSelection];
            if (movieIdx < 0 || movieIdx >= movieIds.Count)
            {
                return;
            }
            var movieId = movieIds[movieIdx];
            GameSystems.Movies.PlayMovieId(movieId, 0);
        });
        doc.GetButton("cancel").SetClickHandler(() =>
        {
            mWidget.Hide();
            _mainMenu.Show(MainMenuPage.Options);
        });

        mListBox = doc.GetScrollView("cinematicsList");

        mWidget = doc.GetRootContainer();
        mWidget.Hide();

        for (var i = 0; i < 24; i++)
        {
            mMovieNames[i] = mmMes[2000 + i];
        }
    }
Exemple #17
0
    public SpellsSystem()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/spells_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;

        // TODO int v1;
        // TODO int v3;
        // TODO int v4;
        // TODO string meslineValue;
        // TODO int meslineKey;
// TODO
        // TODO v1 = 0;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.textColor = &chargenSpellLevelLabelStyle_0 /*0x102fd1a8*/;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.colors4 = &chargenSpellLevelLabelStyle_0 /*0x102fd1a8*/;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.colors2 = &chargenSpellLevelLabelStyle_0 /*0x102fd1a8*/;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.textColor = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.colors4 = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.colors2 = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO stru_10C360B8 /*0x10c360b8*/.textColor = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO stru_10C360B8 /*0x10c360b8*/.colors4 = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO stru_10C360B8 /*0x10c360b8*/.colors2 = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.textColor = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.colors4 = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.colors2 = (ColorRect*) &unk_102FD188 /*0x102fd188*/;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.shadowColor = (ColorRect*) &dword_102FD178 /*0x102fd178*/;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.shadowColor = (ColorRect*) &dword_102FD178 /*0x102fd178*/;
        // TODO stru_10C34950 /*0x10c34950*/.shadowColor = (ColorRect*) &dword_102FD178 /*0x102fd178*/;
        // TODO stru_10C36060 /*0x10c36060*/.shadowColor = (ColorRect*) &dword_102FD178 /*0x102fd178*/;
        // TODO stru_10C360B8 /*0x10c360b8*/.shadowColor = (ColorRect*) &dword_102FD178 /*0x102fd178*/;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.shadowColor = (ColorRect*) &dword_102FD178 /*0x102fd178*/;
        // TODO stru_10C34950 /*0x10c34950*/.textColor = (ColorRect*) &unk_102FD198 /*0x102fd198*/;
        // TODO stru_10C34950 /*0x10c34950*/.colors4 = (ColorRect*) &unk_102FD198 /*0x102fd198*/;
        // TODO stru_10C34950 /*0x10c34950*/.colors2 = (ColorRect*) &unk_102FD198 /*0x102fd198*/;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.flags = 0;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.field2c = -1;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.field0 = 0;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.kerning = 0;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.leading = 0;
        // TODO chargenSpellsPerDayStyle /*0x10c34a60*/.tracking = 4;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.flags = 0;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.field2c = -1;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.field0 = 0;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.kerning = 0;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.leading = 0;
        // TODO chargenLevelLabelStyle /*0x10c35738*/.tracking = 4;
        // TODO stru_10C34950 /*0x10c34950*/.flags = 0;
        // TODO stru_10C34950 /*0x10c34950*/.field2c = -1;
        // TODO stru_10C34950 /*0x10c34950*/.field0 = 0;
        // TODO stru_10C34950 /*0x10c34950*/.kerning = 0;
        // TODO stru_10C34950 /*0x10c34950*/.leading = 0;
        // TODO stru_10C34950 /*0x10c34950*/.tracking = 4;
        // TODO stru_10C36060 /*0x10c36060*/.flags = 0;
        // TODO stru_10C36060 /*0x10c36060*/.field2c = -1;
        // TODO stru_10C36060 /*0x10c36060*/.textColor = &stru_102FD1B8 /*0x102fd1b8*/;
        // TODO stru_10C36060 /*0x10c36060*/.colors4 = &stru_102FD1B8 /*0x102fd1b8*/;
        // TODO stru_10C36060 /*0x10c36060*/.colors2 = &stru_102FD1B8 /*0x102fd1b8*/;
        // TODO stru_10C36060 /*0x10c36060*/.field0 = 0;
        // TODO stru_10C36060 /*0x10c36060*/.kerning = 0;
        // TODO stru_10C36060 /*0x10c36060*/.leading = 0;
        // TODO stru_10C36060 /*0x10c36060*/.tracking = 4;
        // TODO stru_10C360B8 /*0x10c360b8*/.flags = 0;
        // TODO stru_10C360B8 /*0x10c360b8*/.field2c = -1;
        // TODO stru_10C360B8 /*0x10c360b8*/.field0 = 0;
        // TODO stru_10C360B8 /*0x10c360b8*/.kerning = 0;
        // TODO stru_10C360B8 /*0x10c360b8*/.leading = 0;
        // TODO stru_10C360B8 /*0x10c360b8*/.tracking = 4;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.flags = 0;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.field2c = -1;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.field0 = 0;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.kerning = 0;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.leading = 0;
        // TODO chargenSpellsPerDayStyle_0 /*0x10c361c0*/.tracking = 4;
        // TODO meslineKey = 21000;
        // TODO if (Mesfile_GetLine /*0x101e6760*/(pc_creationMes /*0x11e72ef0*/, &mesline))
        // TODO {
        // TODO     chargenSpellsAvailableTitle /*0x10c36108*/ = (string) meslineValue;
        // TODO     meslineKey = 21001;
        // TODO     if (Mesfile_GetLine /*0x101e6760*/(pc_creationMes /*0x11e72ef0*/, &mesline))
        // TODO     {
        // TODO         chargenSpellsChosenTitle /*0x10c0eef8*/ = (string) meslineValue;
        // TODO         meslineKey = 21002;
        // TODO         if (Mesfile_GetLine /*0x101e6760*/(pc_creationMes /*0x11e72ef0*/, &mesline))
        // TODO         {
        // TODO             chargenSpellsPerDayTitle /*0x10c34e48*/ = (string) meslineValue;
        // TODO             v3 = 21200;
        // TODO             while (1)
        // TODO             {
        // TODO                 meslineKey = v3 - 100;
        // TODO                 if (!Mesfile_GetLine /*0x101e6760*/(pc_creationMes /*0x11e72ef0*/, &mesline))
        // TODO                 {
        // TODO                     break;
        // TODO                 }
// TODO
        // TODO                 v4 = pc_creationMes /*0x11e72ef0*/;
        // TODO                 chargenSpellLevelLabels_0 /*0x10c35720*/[v1] = (int) meslineValue;
        // TODO                 meslineKey = v3;
        // TODO                 if (!Mesfile_GetLine /*0x101e6760*/(v4, &mesline))
        // TODO                 {
        // TODO                     break;
        // TODO                 }
// TODO
        // TODO                 ++v3;
        // TODO                 chargenLevelLabels /*0x10c34938*/[v1] = (int) meslineValue;
        // TODO                 ++v1;
        // TODO                 if ((int) (v3 - 21200) >= 6)
        // TODO                 {
        // TODO                     return ChargenSpellsWidgetsInit /*0x1017fcc0*/(a1.width, a1.height) != 0;
        // TODO                 }
        // TODO             }
        // TODO         }
        // TODO     }
        // TODO }
// TODO
        // TODO return 0;
    }
Exemple #18
0
    public MainMenuUi()
    {
        var mmLocalization = Tig.FS.ReadMesFile("mes/mainmenu.mes");

        var widgetDoc = WidgetDoc.Load("ui/main_menu.json", (type, definition) => {
            if (type == "mainMenuButton")
            {
                return(CreateMainMenuButton(definition));
            }
            else
            {
                throw new ArgumentException("Unknown custom widget type: " + type);
            }
        });

        mMainWidget = widgetDoc.GetRootContainer();

        mViewCinematicsDialog = new ViewCinematicsDialog(this, mmLocalization);
        mSetPiecesDialog      = new SetPiecesDialog(this);

        // This eats all mouse messages that reach the full-screen main menu
        mMainWidget.SetMouseMsgHandler(msg => { return(true); });
        mMainWidget.SetWidgetMsgHandler(msg => { return(true); });

        mMainWidget.SetKeyStateChangeHandler(msg =>
        {
            // Close the menu if it's the ingame menu
            if (msg.key == DIK.DIK_ESCAPE && !msg.down)
            {
                if (mCurrentPage == MainMenuPage.InGameNormal || mCurrentPage == MainMenuPage.InGameIronman)
                {
                    Hide();
                }
            }

            return(true);
        });

        mPagesWidget = widgetDoc.GetContainer("pages");

        mPageWidgets[MainMenuPage.MainMenu]      = widgetDoc.GetContainer("page-main-menu");
        mPageWidgets[MainMenuPage.Difficulty]    = widgetDoc.GetContainer("page-difficulty");
        mPageWidgets[MainMenuPage.InGameNormal]  = widgetDoc.GetContainer("page-ingame-normal");
        mPageWidgets[MainMenuPage.InGameIronman] = widgetDoc.GetContainer("page-ingame-ironman");
        mPageWidgets[MainMenuPage.Options]       = widgetDoc.GetContainer("page-options");
        //mPageWidgets[MainMenuPage.SetPieces] = widgetDoc.GetWindow("page-set-pieces");

        MainMenuButton GetButton(string id)
        {
            return((MainMenuButton)widgetDoc.GetWidget(id));
        }

        // Wire up buttons on the main menu
        GetButton("new-game").SetClickHandler(() => { Show(MainMenuPage.Difficulty); });
        GetButton("load-game").SetClickHandler(() =>
        {
            Hide();
            UiSystems.SaveGame.ShowLoad(true);
        });
        GetButton("tutorial").SetClickHandler(() => LaunchTutorial());
        GetButton("options").SetClickHandler(() => { Show(MainMenuPage.Options); });
        GetButton("quit-game").SetClickHandler(() =>
        {
            Tig.MessageQueue.Enqueue(new Message(MessageType.EXIT));
        });

        // Wire up buttons on the difficulty selection page
        GetButton("difficulty-normal").SetClickHandler(() =>
        {
            Globals.GameLib.IsIronmanGame = false;
            Hide();
            UiSystems.PCCreation.Start();
        });
        GetButton("difficulty-ironman").SetClickHandler(() =>
        {
            Globals.GameLib.IsIronmanGame = true;
            Hide();
            UiSystems.PCCreation.Start();
        });
        GetButton("difficulty-exit").SetClickHandler(() => { Show(MainMenuPage.MainMenu); });

        // Wire up buttons on the ingame menu (normal difficulty)
        GetButton("ingame-normal-load").SetClickHandler(() =>
        {
            Hide();
            UiSystems.SaveGame.ShowLoad(false);
        });
        GetButton("ingame-normal-save").SetClickHandler(() =>
        {
            Hide();
            UiSystems.SaveGame.ShowSave(true);
        });
        GetButton("ingame-normal-close").SetClickHandler(Hide);
        GetButton("ingame-normal-quit").SetClickHandler(() =>
        {
            Hide();
            GameSystems.ResetGame();
            UiSystems.Reset();
            Show(MainMenuPage.MainMenu);
        });

        // Wire up buttons on the ingame menu (ironman difficulty)
        GetButton("ingame-ironman-close").SetClickHandler(Hide);
        GetButton("ingame-ironman-save-quit").SetClickHandler(() =>
        {
            Globals.GameLib.IronmanSave();
            Globals.GameLib.Reset();
            UiSystems.Reset();
            Show(MainMenuPage.MainMenu);
        });

        // Wire up buttons on the ingame menu (ironman difficulty)
        GetButton("options-show").SetClickHandler(() =>
        {
            Hide();
            UiSystems.Options.Show(true);
        });
        GetButton("options-view-cinematics").SetClickHandler(() =>
        {
            Hide();
            UiSystems.UtilityBar.Hide();
            // TODO ui_mm_msg_ui4();
            mViewCinematicsDialog.Show();
        });
        GetButton("options-credits").SetClickHandler(() =>
        {
            Hide();

            List <int> creditsMovies = new List <int> {
                100, 110, 111, 112, 113
            };
            foreach (var movieId in creditsMovies)
            {
                GameSystems.Movies.MovieQueueAdd(movieId);
            }

            GameSystems.Movies.MovieQueuePlay();

            Show(MainMenuPage.Options);
        });
        GetButton("options-back").SetClickHandler(() => { Show(MainMenuPage.MainMenu); });

        RepositionWidgets(Globals.UiManager.CanvasSize);
        Globals.UiManager.OnCanvasSizeChanged += RepositionWidgets;

        Hide(); // Hide everything by default
    }
    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 VoiceSystem()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/voice_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;

        // TODO int result;
        // TODO int v2;
        // TODO string meslineValue;
        // TODO int meslineKey;
// TODO
        // TODO stru_10C0C700 /*0x10c0c700*/.textColor = (ColorRect*) &unk_102FCDF8 /*0x102fcdf8*/;
        // TODO stru_10C0C700 /*0x10c0c700*/.colors4 = (ColorRect*) &unk_102FCDF8 /*0x102fcdf8*/;
        // TODO stru_10C0C700 /*0x10c0c700*/.colors2 = (ColorRect*) &unk_102FCDF8 /*0x102fcdf8*/;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.textColor = (ColorRect*) &unk_102FCDF8 /*0x102fcdf8*/;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.colors4 = (ColorRect*) &unk_102FCDF8 /*0x102fcdf8*/;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.colors2 = (ColorRect*) &unk_102FCDF8 /*0x102fcdf8*/;
        // TODO stru_10C0C700 /*0x10c0c700*/.flags = 0x4000;
        // TODO stru_10C0C700 /*0x10c0c700*/.field2c = -1;
        // TODO stru_10C0C700 /*0x10c0c700*/.shadowColor = (ColorRect*) &unk_102FCE18 /*0x102fce18*/;
        // TODO stru_10C0C700 /*0x10c0c700*/.field0 = 0;
        // TODO stru_10C0C700 /*0x10c0c700*/.kerning = 1;
        // TODO stru_10C0C700 /*0x10c0c700*/.leading = 0;
        // TODO stru_10C0C700 /*0x10c0c700*/.tracking = 3;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.flags = 0x4000;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.field2c = -1;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.shadowColor = (ColorRect*) &unk_102FCE18 /*0x102fce18*/;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.field0 = 0;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.kerning = 1;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.leading = 0;
        // TODO stru_10C0CD90 /*0x10c0cd90*/.tracking = 3;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.flags = 0x4000;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.field2c = -1;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.textColor = (ColorRect*) &unk_102FCE08 /*0x102fce08*/;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.shadowColor = (ColorRect*) &unk_102FCE18 /*0x102fce18*/;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.colors4 = (ColorRect*) &unk_102FCE08 /*0x102fce08*/;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.colors2 = (ColorRect*) &unk_102FCE08 /*0x102fce08*/;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.field0 = 0;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.kerning = 1;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.leading = 0;
        // TODO stru_10C0C7E0 /*0x10c0c7e0*/.tracking = 3;
        // TODO stru_10C0C680 /*0x10c0c680*/.flags = 0x4000;
        // TODO stru_10C0C680 /*0x10c0c680*/.field2c = -1;
        // TODO stru_10C0C680 /*0x10c0c680*/.textColor = (ColorRect*) &unk_102FCE28 /*0x102fce28*/;
        // TODO stru_10C0C680 /*0x10c0c680*/.shadowColor = (ColorRect*) &unk_102FCE18 /*0x102fce18*/;
        // TODO stru_10C0C680 /*0x10c0c680*/.colors4 = (ColorRect*) &unk_102FCE08 /*0x102fce08*/;
        // TODO stru_10C0C680 /*0x10c0c680*/.colors2 = (ColorRect*) &unk_102FCE08 /*0x102fce08*/;
        // TODO stru_10C0C680 /*0x10c0c680*/.field0 = 0;
        // TODO stru_10C0C680 /*0x10c0c680*/.kerning = 1;
        // TODO stru_10C0C680 /*0x10c0c680*/.leading = 0;
        // TODO stru_10C0C680 /*0x10c0c680*/.tracking = 3;
        // TODO dword_10C0C834 /*0x10c0c834*/ = Globals.UiAssets.LoadImg("art\\interface\\pc_creation\\bigvoicebox.img");
        // TODO if (dword_10C0C834 /*0x10c0c834*/
        // TODO     && (meslineKey = 23000, Mesfile_GetLine /*0x101e6760*/(pc_creationMes /*0x11e72ef0*/, &mesline))
        // TODO     && (dword_10C0C7C0 /*0x10c0c7c0*/ = (string) meslineValue, meslineKey = 23001,
        // TODO         Mesfile_GetLine /*0x101e6760*/(pc_creationMes /*0x11e72ef0*/, &mesline))
        // TODO     && (dword_10C0C830 /*0x10c0c830*/ = (string) meslineValue, meslineKey = 23002,
        // TODO         Mesfile_GetLine /*0x101e6760*/(pc_creationMes /*0x11e72ef0*/, &mesline)))
        // TODO {
        // TODO     v2 = conf.height;
        // TODO     dword_10C0D304 /*0x10c0d304*/ = (string) meslineValue;
        // TODO     result = UiPcCreationNameWidgetsInit /*0x1017de80*/(conf.width, v2) != 0;
        // TODO }
        // TODO else
        // TODO {
        // TODO     result = 0;
        // TODO }
    }
    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);
    }
Exemple #22
0
    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));
        }
    }