예제 #1
0
    public override void Render()
    {
        WidgetImage renderImage = null;

        if (ButtonState == LgcyButtonState.Hovered)
        {
            renderImage = _hoverImage;
        }
        else if (ButtonState == LgcyButtonState.Down)
        {
            renderImage = _downImage;
        }

        var contentArea = GetContentArea();

        if (renderImage != null)
        {
            renderImage.SetBounds(
                new Rectangle(
                    contentArea.X,
                    contentArea.Y - 1,
                    renderImage.GetPreferredSize().Width,
                    renderImage.GetPreferredSize().Height
                    )
                );
            renderImage.Render();
        }

        var labelSize = _label.GetPreferredSize();
        // Center horizontally and vertically within the content area
        var labelArea = new Rectangle(
            contentArea.X + (contentArea.Width - labelSize.Width) / 2,
            contentArea.Y + (contentArea.Height - labelSize.Height) / 2,
            contentArea.Width  = labelSize.Width,
            contentArea.Height = labelSize.Height
            );

        // Special cases for certain labels
        if (_stat == Stat.level)
        {
            labelArea.X = contentArea.X + 2;
        }
        else if (_stat == Stat.initiative_bonus)
        {
            labelArea.X = contentArea.X + 1;
        }

        _label.SetBounds(labelArea);
        _label.Render();
    }
    public CharUiMainWidget(CharUiParams uiParams) : base(uiParams.CharUiMainWindow)
    {
        _normalBackground  = new WidgetImage("art/interface/char_ui/main_window.img");
        _ironmanBackground = new WidgetImage("art/interface/char_ui/ironman_main_window.img");
        SetSize(_normalBackground.GetPreferredSize());

        _translation = Tig.FS.ReadMesFile("mes/0_char_ui_text.mes");
        var pcCreationMes = Tig.FS.ReadMesFile("mes/pc_creation.mes");

        var rerollsLabel = pcCreationMes[10001];

        _pointBuyLabel = pcCreationMes[10015];

        var attributeModeStyle = new TigTextStyle(new ColorRect(new PackedLinearColorA(0xFF5A7390)));

        attributeModeStyle.kerning  = 1;
        attributeModeStyle.tracking = 3;

        var attributeCountStyle = attributeModeStyle.Copy();

        attributeCountStyle.textColor = new ColorRect(PackedLinearColorA.White);

        _attributeRollModeLabel  = new WidgetText(rerollsLabel, "char-ui-attribute-mode");
        _attributeRollCountLabel = new WidgetText("", "char-ui-attribute-rerolls");
    }
예제 #3
0
    public override void Render()
    {
        WidgetImage renderImage = null;

        if (ButtonState == LgcyButtonState.Hovered)
        {
            renderImage = _hoverImage;
        }
        else if (ButtonState == LgcyButtonState.Down)
        {
            renderImage = _downImage;
        }

        var contentArea = GetContentArea();

        if (renderImage != null)
        {
            renderImage.SetBounds(
                new Rectangle(
                    contentArea.X,
                    contentArea.Y - 1,
                    renderImage.GetPreferredSize().Width,
                    renderImage.GetPreferredSize().Height
                    )
                );
            renderImage.Render();
        }

        var critter = UiSystems.CharSheet.CurrentCritter;

        _label.Content = critter != null?_valueSupplier(critter) : null;

        var labelSize = _label.GetPreferredSize();
        // Center horizontally and vertically within the content area
        var labelArea = new Rectangle(
            contentArea.X + (contentArea.Width - labelSize.Width) / 2,
            contentArea.Y + (contentArea.Height - labelSize.Height) / 2,
            contentArea.Width  = labelSize.Width,
            contentArea.Height = labelSize.Height
            );

        _label.SetBounds(labelArea);
        _label.Render();
    }
 public WidgetScrollBarHandle(WidgetScrollBar scrollBar)
 {
     mScrollBar     = scrollBar;
     mTop           = new WidgetImage("art/scrollbar/top.tga");
     mTopClicked    = new WidgetImage("art/scrollbar/top_click.tga");
     mHandle        = new WidgetImage("art/scrollbar/fill.tga");
     mHandleClicked = new WidgetImage("art/scrollbar/fill_click.tga");
     mBottom        = new WidgetImage("art/scrollbar/bottom.tga");
     mBottomClicked = new WidgetImage("art/scrollbar/bottom_click.tga");
     Width          = mHandle.GetPreferredSize().Width;
 }
예제 #5
0
    public WidgetCheckbox(int x, int y,
                          [CallerFilePath]
                          string filePath = null, [CallerLineNumber]
                          int lineNumber  = -1)
        : base(new Rectangle(x, y, 0, 0), filePath, lineNumber)
    {
        _checkedImage = new WidgetImage("art/interface/options_ui/checkbox_on.tga");
        AddContent(_checkedImage);

        _uncheckedImage = new WidgetImage("art/interface/options_ui/checkbox_off.tga");
        AddContent(_uncheckedImage);

        SetClickHandler(() =>
        {
            Checked = !Checked;
            OnCheckedChanged?.Invoke(Checked);
        });

        SetSize(_checkedImage.GetPreferredSize());
    }
예제 #6
0
    public void Run()
    {
        _mainWindow.IsCursorVisible = false;

        int streamId = -1;

        if (_musicPath != null)
        {
            Tig.Sound.tig_sound_alloc_stream(out streamId, tig_sound_type.TIG_ST_VOICE);
            Tig.Sound.StreamPlayMusicOnce(streamId, _musicPath, 0, true, -1);
            if (!Tig.Sound.IsStreamActive(streamId))
            {
                streamId = -1;
            }
        }

        var keyPressed = false;
        var stopwatch  = Stopwatch.StartNew();

        while (!keyPressed)
        {
            if (streamId == -1)
            {
                // Show slides for 3s without audio
                if (stopwatch.ElapsedMilliseconds >= 3000)
                {
                    break;
                }
            }
            else
            {
                // Otherwise until the stream is done
                if (!Tig.Sound.IsStreamPlaying(streamId))
                {
                    break;
                }
            }

            _device.ClearCurrentColorTarget(LinearColorA.Black);

            var movieRect = MovieRenderer.GetMovieRect(
                _device,
                _image.GetPreferredSize().Width,
                _image.GetPreferredSize().Height
                );
            _image.SetBounds(new Rectangle(
                                 (int)movieRect.X,
                                 (int)movieRect.Y,
                                 (int)movieRect.Width,
                                 (int)movieRect.Height
                                 ));
            _image.Render();

            _subtitleRenderer?.Render(stopwatch.Elapsed.TotalSeconds);

            _device.Present();

            Tig.SystemEventPump.PumpSystemEvents();

            MovieRenderer.ProcessMessages(ref keyPressed);
        }

        if (streamId != -1)
        {
            Tig.Sound.FreeStream(streamId);
        }

        _mainWindow.IsCursorVisible = true;
    }