DrawImage enhancements

Moderator: GZDoom Developers

Tesseract
Posts: 25
Joined: Thu Aug 01, 2013 5:06 am

DrawImage enhancements

Post by Tesseract »

As modders may know, custom huds that use "DrawImage weaponicon" never looked right with some generic weapons, because logic behind it is:

draw Icon or altIcon from althudcf, if not found
draw sprite from Spawn state, if don't exist
draw sprite from Ready state

And here's the problem,because this function draws unscaled, therefore last sprite looks huge most of the time.
This simple submission changes

Code: Select all

DrawImage [translatable] <image>, <x>, <y> [, {center|centerbottom}]
into

Code: Select all

DrawImage [translatable] <image>, <x>, <y> [, {center|centerbottom} [, skipready]]
which, makes draw nothing instead of Ready state sprite.

That's all, but this function still could use some enhancements from more experienced coders later -
1) add optional height and width parameters - downscale if too big (there is already code for that used in althud)
2) turning skipready into flags - making skippable all checks (Icon/AltIcon/Spawn/Ready)
3) apply scale from weapon definition - some weapons have large,downscaled pickups, like Bow in Ghoul's forest 3

NOTE: Default althudcf defines altIcons for Fist and few other actions.As they are common sprites,they are pretty huge and modders interested in generic huds are advised to include althudcf.txt with following to override that:

Code: Select all

Fist ""
PunchDagger ""
FWeapFist ""
Also, my first post here, so big thanks to Randy, Graf, and all the other contributors for developing this awesome port all these years!
Attachments
skipready.zip
(1.16 KiB) Downloaded 130 times
Last edited by Tesseract on Tue Sep 10, 2013 7:39 pm, edited 1 time in total.
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: DrawImage skipReady enhancement

Post by Blzut3 »

While this solution is valid, I don't particularly like how it adds flags to one specific usage of the command. Would adding maxwidth and maxheight values perhaps be more useful in this situation?
User avatar
NeuralStunner
 
 
Posts: 12326
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: DrawImage skipReady enhancement

Post by NeuralStunner »

Blzut, that sounds more useful overall (assuming it could scale). Then it'd also affect pickup -> icon. (Some pickup sprites are huge, and scaled through the actor itself.)
Tesseract
Posts: 25
Joined: Thu Aug 01, 2013 5:06 am

Re: DrawImage skipReady enhancement

Post by Tesseract »

I agree that this code is just a band-aid, fixing only the most obvious issue and flag for only one usage is indeed not a good idea. I'm also fairly sure that Width and Height optional parameters to downscale icon into box is almost necessary to make this function truly universal.
However, I'm not so sure that skipready must go. Many mods have issues, take Russian Overkill as example - not only melee weapons, even some pistols lacks Spawn state. It's matter of opinion, but I think that picture of weapon's barrel with piece of player's arm doesn't work well as icon, and certainly doesn't look good mixed with common weapons that have pickups. It came from althud, where it was necessary to draw something at all costs, but from my experiences many huds use layouts that don't require such behavior.



Therefore I propose such syntax:

Code: Select all

DrawImage [translatable] <image>, <x>, <y> [, {center|centerbottom} [, width, height [, flags ]]]
Width and height would be maximum size, outlining a "box" - sprite is downscaled if necessary. Origin depends on alignment and zero means unlimited.

Flags would be {skipIcon|skipAltIcon|skipspawn|skipready}.

You may ask why would someone want to bypass checks for all of these, so here are few examples:
  • SkipReady was already discussed and make sense only for weapon. Other flags should also work for other special cases like ammo/armor ( inventory drawing functions may adopt such flags too later)

    SkipSpawn (or SkipSpawn|SkipReady) would be useful for huds that don't want sprites which weren't designed to be there in the first place. I can imagine some monochrome huds that would have custom, fitting icons matching it's style or use fancy outlines as icons. In such cases, it's better to draw nothing in unhandled situation.

    SkipAltIcon would bypass checks for icons defined in althudcf lump altogether. One reason for that is right in default package, as default althudcf effectively negates skipready for standard melee weapons. Another good use is exact oposite, skip everything except AltIcon and draw graphic only for known guns, which can have new,fitting icons done entirely outside of their code

    SkipIcon may not be useful alone, but combined with SkipAltIcon can be used to override icons potentially designed for other, nongeneric hud, drawing in "WYSIWIG" style


I know there's strong do-it-yourself attitude in the air around less prominent suggestions, but, sadly, I don't have time to get familiar with zdoom source enough to write this as cleanly as possible right now. If some talented coder could take over this, I would be grateful. If not, well, I may try it someday. There're so many suggestions around it's no rush.

For now, I'd love some feedback on this suggested format, especially if modders are even interested in options this thing offers.

One thing is sure, current DrawImage with "weaponicon" needs to be changed.

Edit: I forgot to mention that if icon came from Spawn state, Scale property should be applied on it. (And it may be downscaled later again if too big according to max width+height arguments)
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: DrawImage skipReady enhancement

Post by Blzut3 »

The problem I see with your usage examples are mods like Russian Overkill can presumably provide a proper icon for its hud no? These flags, to me, only seem especially useful for modifier mods designed to work with an existing weapon set, but those can't possibly be your skipspawn example since it would vastly limit the usefulness of that part of the hud if it only works for vanilla. (I'd probably also question why such mod is even redefining the status bar.)

Your syntax extension suggestion for maxwidth/maxheight seems fine. I still think the flags are more of a WFDS-huds though. I wouldn't mind hearing from more people though.
Tesseract
Posts: 25
Joined: Thu Aug 01, 2013 5:06 am

Re: DrawImage skipReady enhancement

Post by Tesseract »

I see that these flags weren't introduced well and common modders may find them too abstract and unsure about their use.
It'll be best if you follow my train of thoughts and I'll try to explain everything slowly. Sorry for yet another walls of text!

Well, there are two different kinds of huds, each with specific needs.

One kind is mod-specific, mostly inflexible hud, usually complex ACS hybrid. Great example for that is one in Project MSX. Such huds often offers great and unique effects, but it has it's cost - they are more or less hardcoded to work well only with known mod(s). To be specific, we're talking about IsSelected/InInventory blocks used for non-generic actors. I must admit that majority of current huds are designed in this fashion, in various degree.

Another kind tries to be generic and as most cross compatible as possible, default Zdoom fullscreen hud is one of them. I've made one too, and can safely say that it looks well in anything from FreeDoom though Strife with Samsara up to Pirate mod. I personally believe that custom hud should be player's choice, unless it's part of the mod's gameplay (like in already mentioned Project MSX). These flags may not be important for modder that can modify any actors he wants compatible, but allows huds that work with many, if not all mods, out of the box.


Let's see more specific examples:
  • I want to make fancy hud that look similiar to one in Serious Sam 1. Everything should be more or less green and ammo/weapon icon should be drawn as green silhouette. Obviously, this means it can't work with every weapon out there, so I decide I'll support Vanilla,Brutal Doom and Samsara,for example. I can draw these icons and assign them via ALTHUDCF lump. In case player would use my hud with unsupported mod or simply plays something like KDIZD, he can aquire gun without proper icon. Well, I'd rather draw nothing in that case, so I'll use flags "skipIcons|skipspawn|skipready". That way, I have mod-specific mod that performs well enough in every situation.

    I've made my own mod about magic and created thematically fitting hud. This hud draws current spell (weapon) as page in opened magic book,which is part of the painting on status bar. I've drawn these special icons (book pages) for all weapons and set them as their Icon property, but, again, don't want to draw anything with unknown gun, as it would break the layout. I'll use "skipAltIcons|skipspawn|skipready". I'll probably need to draw book's background in a way that looks fine even with no weaponicon drawn.

    I want to make mostly common, all compatible hud, that just can draw current weapon. I don't, however, want to see disembodied hand holding weapon in first person. Let's say that my hud tries to look in-universe, and drawing current weapon is feature of marine's spacesuit. I'll use just "skipready" and I'm done with it!
    And in case it's really important to me that weapons must always look in unified way (always pickups) I can override modder's wishes with "skipIcon|skipAltIcon|skipReady". AltIcons are quite often firing/ready frames anyway.

I probably can come up with much more and much less obscure examples, yet I hope it's enough to reconsider usefulness of these flags. In short, it opens icon searching process to modders and offers customizeability to fit needs of individual huds.

Blzut, thanks for your feedback, I'm only puzzled by your remarks about skipspawn being useful just for vanilla. In fact, I think the opposite, as all these flags are designed to increase cross-mod compatibility. Maybe it was just little misunderstanding and it's cleared now, if not, please explain it in more detail.

NOTE: I didn't even dare to suggest it,but even better than automatic "draw nothing on failure" would be if DrawImage could work as flow control element,in this fashion:

Code: Select all

DrawImage <arguments>
{
//Executed when image was succesfully drawn
}
Else
{
//Executed if nothing was drawn
}
I believe that's completely impossible in the way how current SBARINFO code works, but it would allow for example conditionaly drawing background behind weapon, offseting other elements based on presence of the icon and so on.
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: DrawImage skipReady enhancement

Post by Blzut3 »

Thanks for the clarification. I'm still not entirely sold on the idea of the flags since ZDoom lacks a whole lot of "cross modding" features. I'm sure with little effort you could come up with a dozen examples of little paper cuts that prevent mods from working seamlessly with others (not limited to status bars). The question is do we bother even trying to go down this route or just WFDS where in theory one could actually have the proper information at their disposal?
Tesseract wrote:Blzut, thanks for your feedback, I'm only puzzled by your remarks about skipspawn being useful just for vanilla. In fact, I think the opposite, as all these flags are designed to increase cross-mod compatibility. Maybe it was just little misunderstanding and it's cleared now, if not, please explain it in more detail.
The point was such a hud would only be in full functionality on supported mods. In general this would mean just vanilla, but in your example you include Brutal Doom and Samsara.
Tesseract wrote:NOTE: I didn't even dare to suggest it,but even better than automatic "draw nothing on failure" would be if DrawImage could work as flow control element,in this fashion:
Actually it wouldn't be entirely unprecedented. DrawSelectedInventory has flag to execute a sub block if nothing is drawn. If you choose to implement something like this be careful though, drawswitchableimage hangs off of the drawimage code.
Tesseract
Posts: 25
Joined: Thu Aug 01, 2013 5:06 am

Re: DrawImage skipReady enhancement

Post by Tesseract »

Okay, so it seems that our final question is, WFDS or implement this as a flag?

DoomScript is, indeed, ultimate answer to all world's problems and most likely would allow to handle these options. As a coder I understand that needless addition of another feature is inefficient and makes maintainance difficult. Despite that, here are few points favouring flags:
  • I don't know DS specifications, not even sure anyone besides Randy do - so if you know more, please correct me on this one. I think that DS will be primarily C-like thing that substitutes/extends/unites Decorate and ACS. Full addition into special lumps wouldn't have much use, would be SBARINFO exception? It was designed to be simple, lightweight scripting lump that can't affect game state in any way, ensured by finite amount of own functions and lack of variables. These properties allows for example easy hud switching when loading games, and such advantages can't be seen in potential full, non SBARINFO based DoomScript huds, which are just evolution of ACS huds. So it's possible that it won't be changed much for sake of simplicity.

    Even if SBARINFO would get DS additions that only offer passive information retrieval, question is how difficult would be to replicate these flags there. Code would be certainly longer and with multiple conditionals. That's not a problem if such flags would be used in one or two huds, but if they would be in like 75% of them, flags are more optimal.

    Lastly, WFDS over the years started to look like "When it's done" from 3d Realms, leaving similiar aftertaste. As common Zdoom player, I see it as distant as it was decade ago. To say it pragmatically, I'd like to get my hud working in official releases before 2025. Indeed, it won't be added for one modder, so I think real question is how many hud creators would use these flags.
Therefore, my final opinion on this matter is this:
It was already demonstrated that features offered by these flags can be useful. If sufficient amount of modders would like to use them, to the point that their usage would be common practice or almost standard in some kinds of huds, it's better to make them flags, available right now and easy to type. On the contrary, if they'd be obscure choice used in bare minimum of cases, DoomScript is much better option.

Blzut, if you came to the same conclusion, I'll leave it to modders' consensus, maybe even start a poll or something. We can discuss how many hud creators would be sufficient to justify this addition. I'm just concerned if enough hud creators would actually read this thread.
Also, would your answer be enough or should I wait for Graf's opinion about this voting too?

In case this will be approved, I think I'm going to code it after all, shouldn't be too hard.
Spoiler: Slightly offtopic babble
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: DrawImage skipReady enhancement

Post by Blzut3 »

That is basically my conclusion.
Spoiler: ZScript speculation
Tesseract
Posts: 25
Joined: Thu Aug 01, 2013 5:06 am

Re: DrawImage skipReady enhancement

Post by Tesseract »

Alright then, I suppose this got already decided.
DS/ZS as you outlined looks really nice and I'm looking for it, on the other hand I believe SBARINFO may still have it's use for less adept coders wanting simple huds.
Otherwise, your arguments and conclusion would imply that any additions to SBarInfo at this point are more or less futile. If that's the case, this information should be more well known.
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: DrawImage skipReady enhancement

Post by Blzut3 »

It's difficult for anyone other than Randy to say exactly what will in regards to the relationship between SBarInfo and ZScript.

I definitely wouldn't say that additions to SBarInfo are futile. As I stated my primary objection comes from the fact that these flags apply only to the case of DrawImage where weaponicon is used. There's nothing technically wrong with that, but from that standpoint of "ZDoom doesn't actually support modifier mods," unless you can show that the flags would be widely used, I would rather not have the bloat there. Especially since I know trying to cater for modifiers will just lead down a road of requesting many similar small things that ZScript should, in theory, be able to solve in one go.

I would have no objection to the maxwidth/maxheight or sub-block on failure suggestions mentioned for example.
Tesseract
Posts: 25
Joined: Thu Aug 01, 2013 5:06 am

Re: DrawImage skipReady enhancement

Post by Tesseract »

Thank you for making your point clearer, this however introduces few things I'd like to discuss per statement.

Blzut3 wrote:As I stated my primary objection comes from the fact that these flags apply only to the case of DrawImage where weaponicon is used.
Well, unlike original submission, in proposed solution flags would affect any use of DrawImage that goes through icon searching process - armoricon,weaponicon,ammoicons at least. Still not entirely universal, but worth mentioning this wouldn't indeed be one-use feature. You probably knew that, but I think it's better to state it for the sake of completeness.
Blzut3 wrote:There's nothing technically wrong with that, but from that standpoint of "ZDoom doesn't actually support modifier mods," unless you can show that the flags would be widely used, I would rather not have the bloat there.
Actually, I tried to address this very issue by asking for public opinion. Something like poll with "Would you use these flags in your hud? Yes/No" question should give definitive answer if this is obscure choice or wanted standard. As you haven't mentioned this in your posts, I assumed you turned down this idea entirely, therefore addition wouldn't depend on suggestion popularity and would be declined only because it would be better in ZS. But if your ZS speculation is right, everything would be better in ZS and SBARINFO would be effectively deprecated. That led me to previous conclusion that Sbarinfo additions are not much welcomed.
Blzut3 wrote:I would rather not have the bloat there. Especially since I know trying to cater for modifiers will just lead down a road of requesting many similar small things that ZScript should, in theory, be able to solve in one go.
Can't argue with that. I can only repeat that these flags can be shortcut for (potentially) commonly used option, more elegant and quicker than eventual equivalent ZS code. It's up to developers to decide if it's enough to approve it.
Blzut3 wrote:I would have no objection to the maxwidth/maxheight or sub-block on failure suggestions mentioned for example.
Great, I'm glad we agree, at least on the less controversial part.

NOTE: Honestly, I've read through some recently WFDS'ed suggestions and it seems it's not equivalent of death sentence by now. You were right, ZS may be closer than one may think.
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: DrawImage skipReady enhancement

Post by Blzut3 »

Tesseract wrote:Well, unlike original submission, in proposed solution flags would affect any use of DrawImage that goes through icon searching process - armoricon,weaponicon,ammoicons at least. Still not entirely universal, but worth mentioning this wouldn't indeed be one-use feature. You probably knew that, but I think it's better to state it for the sake of completeness.
Oh good point. SBarInfo only go through the alternative icons process for weaponicon though. If you can make this generic for all icon types I'll add it. The tricky part is handling which flags are set by default.
Tesseract wrote:Actually, I tried to address this very issue by asking for public opinion. Something like poll with "Would you use these flags in your hud? Yes/No" question should give definitive answer if this is obscure choice or wanted standard. As you haven't mentioned this in your posts, I assumed you turned down this idea entirely, therefore addition wouldn't depend on suggestion popularity and would be declined only because it would be better in ZS. But if your ZS speculation is right, everything would be better in ZS and SBARINFO would be effectively deprecated. That led me to previous conclusion that Sbarinfo additions are not much welcomed.
I'm not sure exactly one would go about proving popularity of the feature. Probably the best way is to let this thread sit and if people bump it with "I'd like this too."
Tesseract
Posts: 25
Joined: Thu Aug 01, 2013 5:06 am

Re: DrawImage skipReady enhancement

Post by Tesseract »

I agree on all points. I didn't even know that ammo/armor don't use Spawn state sprites as fallbacks, this will be added along with ALTHUDCF defined icons, so icon searching process will be same for anything: Icon -> AltIcon -> Spawn -> [Ready]

As I said before I'm not so sure many hud creators would read this thread in the first place, probably only thing I can do about it is renaming it to more fitting "DrawImage enhancements", which could attract more people. I'm not sure how to do that myself, though.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: DrawImage skipReady enhancement

Post by Blue Shadow »

Tesseract wrote:probably only thing I can do about it is renaming it to more fitting "DrawImage enhancements", which could attract more people. I'm not sure how to do that myself, though.
Simply, use the Edit button on the opening post and change the title.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”