Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FontScaleX for default skin set to zero in TextButton #689

Open
etiket-io opened this issue Aug 11, 2021 · 5 comments
Open

FontScaleX for default skin set to zero in TextButton #689

etiket-io opened this issue Aug 11, 2021 · 5 comments

Comments

@etiket-io
Copy link

The Issue
TextButton does not show any text under default skin/style settings, although Label is visible.

Minimal Example:

using System;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Nez;
using Nez.UI;


namespace MyGame
{
    public class TitleScene : Scene
    {
        public UICanvas Canvas;

        Table _table;

        public TitleScene()
        { }


        public override void Initialize()
        {
            base.Initialize();

            // Using PixelPerfor
            SetDesignResolution(512, 256, SceneResolutionPolicy.NoPolicy);
            Screen.SetSize(512, 256;

            // add a UI render layer
            Canvas = CreateEntity("ui").AddComponent(new UICanvas());
            var skin = Skin.CreateDefaultSkin();
            _table = Canvas.Stage.AddElement(new Table());
            _table.SetFillParent(true).Center().Top();
            _table.Row();
            // `Label`s work
            _table.Add(new Label("Some Buttons", new LabelStyle())).SetFillX().SetMinHeight(30);
            _table.Row();
            var battleButton = new TextButton("A button", skin);
            // commenting this out causes no text to appear on the buttons 
            // battleButton.GetStyle().FontScaleX = 1.0f;
            _table.Add(new TextButton("Another button", skin)).SetFillX().SetMinHeight(30)
            _table.Row().SetPadTop(10);
            var exitButton = _table.Add(new TextButton("Exit", skin)).SetFillX().SetMinHeight(30).GetElement<TextButton>();
        }
    }
}
@Tobi-Mob
Copy link
Contributor

In the current Master-branch NoPolicy seems to no longer exists, so after changing it to None it looks like this for me:
(Which seems fine to me)
image

Uncommenting the FontScaleX-Line does not work for me, FontScaleX seems to also no longer exists.

image

So, this issue may vanished together with FontScale.
If you still experience this issue with the master branch, could you provide a new example?
Since I am unable to reproduce the problem with this example.

@Tobi-Mob
Copy link
Contributor

Just works on my Linux Mint 20.

But issue occurred on
OS Name: Microsoft Windows 7 Enterprise
OS Version: 6.1.7601 Service Pack 1 Build 7601
running as VM in VMWare Workstation 16.1
with GPU passing

TextButton().GetLabel().SetFontScale(2) fixed the issue

@ilmenit
Copy link
Contributor

ilmenit commented Oct 17, 2021

https://github.com/prime31/Nez/blob/master/Nez.Portable/UI/Widgets/TextButton.cs#L124
should be:
public float FontScaleX = 1;
public float FontScaleY = 1;

Tobi-Mob added a commit to Tobi-Mob/Nez that referenced this issue Oct 17, 2021
@Tobi-Mob
Copy link
Contributor

The problem only occurres in the master branch, not in the version used by the Samples Repository

image

https://github.com/prime31/Nez/tree/7a87b151a831b60cf0f95e942084c285d3effb21
Introduced with commit: 22b35ba

@Tobi-Mob
Copy link
Contributor

should be fixed: #696

prime31 pushed a commit that referenced this issue Oct 26, 2021
* #689 initialize TextButton FontScaleX to 1 instead of 0

* FollowCamera:
* Calculate Deadzone from Center instead of TopLeft of camera Bound
* Allow to provide Deadzone scale in % of ScreenSpace instead of pixels
* Allow Deadzone to scale with Zoom-Level

* FollowCamera Cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants