ZScript: Status Bar Questions

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Re: ZScript: Status Bar Questions

Postby Graf Zahl » Tue Mar 28, 2017 2:09 am

Nash wrote:ZZYZX: I'm aware of the clipping DTA tag, but I wasn't sure if Screen.DrawTexture can be used inside status bars. Right now I'm just using BaseStatusbar.DrawImage, like what gzdoom.pk3 is doing.

Will give your library a try later, I kinda don't understand how to use it yet...




You can use Screen.DrawTexture, but then you have to do all the nasty stuff yourself, like scaling coordinates etc. For specialty applications that is an option, but if you want to write some simple code to draw a status bar you want simple function calls that take reasonable defaults for most parameters and do the dirty stuff internally. Screen.DrawTexture requires you to lay out everything yourself in most verbose detail. Ultimately all those other draw functions call this as well, as it is the one central 2D sprite drawing function.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript: Status Bar Questions

Postby Nash » Tue Mar 28, 2017 4:58 pm

Graf, will there be support for stacking multiple status bar classes, like AddEventHandlers? I can think of one use case right now: a ZScriptified version of Hudmessageonactor. If only one status bar is allowed, the method has to be hardcoded into the mod's only status bar and cannot be modular.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ZScript: Status Bar Questions

Postby Graf Zahl » Tue Mar 28, 2017 6:19 pm

Only if you do it manually by creating a status bar that owns two others and draws them on top of each other.
The status bar is a vital system component and there can only be one.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript: Status Bar Questions

Postby ZZYZX » Tue Mar 28, 2017 6:42 pm

HudMessages-like statusbar-independent drawing was promised later.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: ZScript: Status Bar Questions

Postby Nash » Tue Mar 28, 2017 11:03 pm

ZZYZX wrote:HudMessages-like statusbar-independent drawing was promised later.


Source?
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ZScript: Status Bar Questions

Postby ZZYZX » Wed Mar 29, 2017 1:17 am

User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

Re: ZScript: Status Bar Questions

Postby Nash » Wed Mar 29, 2017 3:46 am

Code: Select allExpand view

class LADHUD 
: BaseStatusBar
{
    HUDFont mHUDFont;

    const HUD_WIDTH = 320;
    const HUD_HEIGHT = 200;
    const HUD_COMPASS_POS_Y = HUD_HEIGHT - 2;
    const barHeight = 0;

    override void Init()
    {
        Super.Init();
        SetSize(barHeight, HUD_WIDTH, HUD_HEIGHT);
        Font fnt = "SmallFont";
        mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true, 1, 1);
    }

    override void NewGame()
    {
        if (CPlayer != NULL)
        {
            AttachToPlayer(CPlayer);
        }
    }

    override void Draw(int state, double TicFrac)
    {
        Super.Draw(state, TicFrac);

        BeginHUD(HUD_WIDTH, HUD_HEIGHT, 1., false);

        CVar compassCvar = CVar.FindCVar("cl_compass", CPlayer);
        if (compassCvar.GetInt() > 0) DrawCompass();
    }

    void DrawCompass(void)
    {
        if (CPlayer)
        {
            int flags = DI_SCREEN_HCENTER | DI_SCREEN_BOTTOM;

            // draw background
            double backgroundAlpha = 0.35;
            Vector2 backgroundPos = (0, -2);
            DrawImage("graphics/hud/compass/background.png", backgroundPos, flags, backgroundAlpha);
        }
    }
}
 


How do I make the DrawImage'd image automatically adjust its scale according to the uiscale CVar? I looked at the Doom status bar and can't see it doing anything differently than just a plain DrawImage call... but the scaling works automatically on that one.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ZScript: Status Bar Questions

Postby Graf Zahl » Wed Mar 29, 2017 7:52 am

DrawImage automatically adjusts to the HUD scale. This is not necessarily the same as the uiscale. It only uses the uiscale if hud_scale is 0.

That scaling stuff is in dire need of better menu exposure,
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript: Status Bar Questions

Postby Nash » Wed Mar 29, 2017 8:06 am

Graf Zahl wrote:It only uses the uiscale if hud_scale is 0.


Ah! That fixed it. Mine was set to -1 for some reason. Also IMO the various UI and HUD scaling combinations are a little confusing.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ZScript: Status Bar Questions

Postby Graf Zahl » Wed Mar 29, 2017 8:20 am

Patience. I first need to do the features before doing a proper menu screen for them. It's the typical problem of having to preserve legacy features while fixing the design flaws.

All this code comes from a time when 640x480 was the most popular and 1024x768 the largest screen size and nothing ever got properly adjusted to growing monitor sizes until uiscale was introduced last year - unfortunately it was still an incomplete job, because the entire status bar stuff got skipped (presumably because it was far too messy.)

Don't forget, for me this has turned out to be more like a major cleanup job than scriptification of an existing feature.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript: Status Bar Questions

Postby Ed the Bat » Wed Mar 29, 2017 1:57 pm

Graf Zahl wrote:forget, for me this has turned out to be more like a major cleanup job than scriptification of an existing feature.

And I'm very happy you've done it. Amazing work, sir!
User avatar
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US

Re: ZScript: Status Bar Questions

Postby Major Cooke » Wed Mar 29, 2017 2:21 pm

I don't think he's done yet, but yes. Magnificent stuff, Graf. Without you we'd be in a stone age.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: ZScript: Status Bar Questions

Postby Graf Zahl » Wed Mar 29, 2017 3:16 pm

I'm almost through. I think tomorrow I can end this chapter. I got the big things all resolved today.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript: Status Bar Questions

Postby dpJudas » Wed Mar 29, 2017 3:27 pm

Nash wrote:Ah! That fixed it. Mine was set to -1 for some reason. Also IMO the various UI and HUD scaling combinations are a little confusing.

I think part of the problem here is that the scale options are scattered throughout the menus. It would probably be better to have a single scaling menu. It would make it more clear that uiscale is the base scale setting, and the other ones are individual overrides.

The defaults should probably also all be changed so that uiscale is affecting everything unless the user explicitly decided it should not apply to some elements. And last I personally think the 'auto' mode for uiscale should scale more to what most people expect (i.e. a 2x scale at 1080p, 4x scale at 4K), not what Doom technically did at 320x200 (which was more like 4x scale at 1080p).
dpJudas
 
 
 
Joined: 28 May 2016

Re: ZScript: Status Bar Questions

Postby Graf Zahl » Wed Mar 29, 2017 3:35 pm

dpJudas wrote:
Nash wrote:Ah! That fixed it. Mine was set to -1 for some reason. Also IMO the various UI and HUD scaling combinations are a little confusing.

I think part of the problem here is that the scale options are scattered throughout the menus. It would probably be better to have a single scaling menu. It would make it more clear that uiscale is the base scale setting, and the other ones are individual overrides.

The defaults should probably also all be changed so that uiscale is affecting everything unless the user explicitly decided it should not apply to some elements. And last I personally think the 'auto' mode for uiscale should scale more to what most people expect (i.e. a 2x scale at 1080p, 4x scale at 4K), not what Doom technically did at 320x200 (which was more like 4x scale at 1080p).


That's already planned, but I first want to take care of the last remaining pieces of the status bar.
The auto mode here definitely needs work, too, and even with uiscale the code is still way too obtuse. But don't worry, now that the messed up scaling for the status bar is fixed, it will be a LOT easier to do this right.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests