There are currently 57 players online.
 
Warsow


 
 

back[HUD] Problem with CH size in hud

Forum index
Modifications / Coding
[HUD] Problem with CH size in hud
Posted by
Post Scroll to bottom
hugteddy

Member
(139 posts)

I can't get setSize to work perfect. Don't understand how the values work. I have a 32x32 CH crosshair_electrobolt.tga. It works perfectly if I use it, by replacing a default CH and set cg_crosshair_size "32". It looks good and it's the right size. But when I try to show it by drawpicbyname in HUD. I don't seem to get the right size. It always gets blury whatever value I try.

Something like this:

if %WEAPON_ITEM
setAlign #CENTER, #MIDDLE
setCursor #WIDTH / 2, #HEIGHT / 2
setColor 1 1 1 1



//electrobolt
if %WEAPON_ITEM == #WEAP_ELECTROBOLT
setSize 16, 16
drawpicbyname gfx/hud/crosshair/crosshair_electrobolt
endif

//etc with all weapons



Is it possible to get the exact 32x32 pixel size with this method?
(updated 2012-06-09 17:06:29)

clownfart

aka simon
(1027 posts)

It's possible, but you need to do more math. Warsow HUDs use a virtual 800x600 grid. So if your screen resolution is 1600x1200, setSize 1,1 would actually be 2px squared on your screen.

Alternatively you can just make an aliases like this:

///////    Weapon binds
bind c "PG"
bind e "RL"
bind r "GB"
bind q "RG"
bind f "GL"
bind x "EB"
bind 1 "MG"
bind MOUSE5 "LG"

aliasa "GB" "use Gunblade;cg_crosshair 1"
aliasa "MG" "use Machinegun;cg_crosshair 5"
aliasa "RG" "use Riotgun;cg_crosshair 1"
aliasa "GL" "use Grenade Launcher;cg_crosshair 1"
aliasa "RL" "use Rocket Launcher;cg_crosshair 1"
aliasa "EB" "use Electrobolt;cg_crosshair 5"
aliasa "LG" "use Lasergun;cg_crosshair 1"
aliasa "PG" "use Plasmagun;cg_crosshair 1"

(updated 2012-06-09 18:12:39)

Mef!sto

Member
(529 posts)

arent there new hudcoding cmds in 0.7 to make the huds independent from monitor resolution

use these

hugteddy

Member
(139 posts)

Clown:
Yes but I would like it to change according to what weapon is up atm. Else it will change CH even if I don't have ammo and press that hotkey.

It works now anyway thank you.

setSize 13.33333, 17.77777

I also tried this
setSize 32 / ( #WIDTH / 800 ), 32 / ( #HEIGHT / 600 )
But did not work.

Mefisto:
You know the cmd? Anyone else know what it is?
(updated 2012-06-09 22:17:02)

Mef!sto

Member
(529 posts)

its allready implemented in racesow

http://www.warsow.net/forum/thread/13744/1

btw wtf happened to my post in this thread over there?
dataloss in forum software?
(updated 2012-06-09 22:27:45)

hugteddy

Member
(139 posts)

setPixelSize setSizeX setSizeY does not work in 0.7 for me. Is it implemented devs? Or am I just doing something wrong?

clownfart

aka simon
(1027 posts)

hugteddy wrote:
Clown:
Yes but I would like it to change according to what weapon is up atm. Else it will change CH even if I don't have ammo and press that hotkey.

It works now anyway thank you.

setSize 13.33333, 17.77777

I also tried this
setSize 32 / ( #WIDTH / 800 ), 32 / ( #HEIGHT / 600 )
But did not work.

Mefisto:
You know the cmd? Anyone else know what it is?


Yes, I used to run the same thing. Then when .6 came out, they added 'crosshair damage' which changes the crosshair color if you do damage to an enemy. This feature wont work if you have your crosshairs in your HUD.

#WIDTH and #HEIGHT are constants, the equal 800 and 600 always. %VIDWIDTH and %VIDHEIGHT are variables, and they contain your actual resolution. You cannot use brackets in Warsow HUD math.

In Warsow HUD's, 10 * 20 / 7 - 2 would equal 40. The order of operations is right to left, but 7 - 2 is 5, not -5. It would look like this in real math: (10 * (20 / (7 - 2)))

Here's a real world example of something I use in my HUD (made with the help of jihnsius).

// 253 + ((8 - ((height / width) * 8)) * 68.5)
setSize 253 + 68.5 * 8 - 8 * %VIDHEIGHT / %VIDWIDTH, 26


Don't ask what it's for lol.

If you want something to always respect it's aspect ratio use this:

setSize 100 * 1.3333333333 * %VIDHEIGHT / %VIDWIDTH, 100

That would make a box always be 100x100. If the vid height was 800, it would always be 100px x 100px

If you wanted to make something remain the same pixel size at any resolution, you'd need to do a ton of crappy math I'm sure. Or you could just figure out the right size for your resolution and not bother with all this.

Mef!sto

Member
(529 posts)

[suggestion]
dear warsow devteam

please bring some simple logic into hud coding

thanks
mef

joki

Member
(49 posts)

hugteddy wrote:

Is it possible to get the exact 32x32 pixel size with this method?


Yes! There is a new hud function in wsw.7 (setScale), that lets you control how cursor and size are scaled with resolution and aspect ratio.
To set the size in pixels you would use
setScale #NOSCALE


in your case:

if %WEAPON_ITEM
setAlign #CENTER, #MIDDLE
setCursor #WIDTH / 2, #HEIGHT / 2
setColor 1 1 1 1



//electrobolt
if %WEAPON_ITEM == #WEAP_ELECTROBOLT
setScale #NOSCALE
setSize 16, 16
setScale #DEFAULTSCALE
drawpicbyname gfx/hud/crosshair/crosshair_electrobolt
endif

//etc with all weapons



Scroll to top



RSSRSSRSSRSS

Copyright © 2013 Chasseur De Bots

Warsow in social media



Warsow is an indie game developed by group of hobbyists. Please consider giving us a small donation: