View previous topic :: View next topic |
Author |
Message |
ceriux

Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA
|
Posted: Sat Mar 14, 2009 9:20 pm Post subject: csqc hud positioning |
|
|
nvm im wrong i guess - the parts in orange edit with a number below 1 "0.6" ect.
sorry got it ill post an explaination at the bottom for others to use
hey, im fairly new to qc, but im able to do that to and extent but iv tried picking up csqc and still learning on it. anyways im having issues positioning my hud that daemon has helped me with.
here's what i got so far.
Quote: | void DrawHealth()
{
local string text;
vid_size_x = cvar("vid_conwidth");
vid_size_y = cvar("vid_conheight");
vid_res_x = cvar("vid_width");
vid_res_y = cvar("vid_height");
currenthealth = getstati(STAT_HEALTH);
//maxhealth = getstati(STAT_CELLS);
//drawstring(position, "string", fontsize, color, alpha, drawflags);
//drawline(float width, vector pos1, vector pos2, vector rgb, float alpha, float flags) = #315;
pos_x = vid_size_x*0.5 - hud_width*0.5;
text = strcat(ftos(currenthealth), ": HEALTH");
//text = strcat(text, ftos(maxhealth));
//drawline(1 1 1, 0, 1,'1 1 1', 0, 0);
drawstring(pos, text, '8 8 0', '0 2 2', 3, 0);
};
void DrawArmor()
{
local string text;
vid_size_x = cvar("vid_conwidth");
vid_size_y = cvar("vid_conheight");
vid_res_x = cvar("vid_width");
vid_res_y = cvar("vid_height");
currenthealth = getstati(STAT_ARMOR);
//maxhealth = getstati(STAT_CELLS);
//drawstring(position, "string", fontsize, color, alpha, drawflags);
//drawline(float width, vector pos1, vector pos2, vector rgb, float alpha, float flags) = #315;
pos_x = vid_size_x*0.5 - hud_width*0.5;
text = strcat(ftos(currenthealth), ": Armor");
//text = strcat(text, ftos(maxhealth));
//drawline(1 1 1, 0, 1,'1 1 1', 0, 0);
drawstring(pos, text, '8 8 0', '0 2 2', 3, 0);
}; |
its basic, but its good enough for what i want to start.
this is the code that u alter 0 equals top left of the screen
vid_size_x = cvar("vid_conwidth");
vid_size_y = cvar("vid_conheight");
vid_res_x = cvar("vid_width");
vid_res_y = cvar("vid_height");
Pic of my hud
 _________________ QuakeDB - Quake ModDB Group |
|
Back to top |
|
 |
ceriux

Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA
|
Posted: Sun Mar 15, 2009 5:25 am Post subject: |
|
|
(sorry for double post getting no help on irc)
anyways.
this is the hud pic iv made so far. i want to draw pic it behind my text.
im having issues figuring it out anyone mind helping?
(i can move my text display to fit the hud)
 _________________ QuakeDB - Quake ModDB Group |
|
Back to top |
|
 |
xaGe

Joined: 01 Mar 2006 Posts: 329 Location: Upstate, New York
|
Posted: Tue Mar 17, 2009 4:04 am Post subject: |
|
|
..Hey good start with your csqc hud.. I wish I had the time and grey matter to mess with csqc to get even the results you have so far.  |
|
Back to top |
|
 |
ceriux

Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA
|
Posted: Tue Mar 17, 2009 4:13 am Post subject: |
|
|
its not really that hard as what i thought it would be (mind its basic) but in this case, basic is all i need. i can post up the whole code with some explainations. kinda like a mini tutorial hey! ill write submit a tutorial on how to make a basic csqc HUD! right now before i go to bed
"forgot to mention i wouldnt have gotten this far if it was for those on irc, (im stoned a lot sorry i dont remember your name 'minus daemon'.) so please if you helped me and want the credit please post your name here when u see this ! _________________ QuakeDB - Quake ModDB Group |
|
Back to top |
|
 |
xaGe

Joined: 01 Mar 2006 Posts: 329 Location: Upstate, New York
|
Posted: Tue Mar 17, 2009 5:02 am Post subject: |
|
|
..Yes daemon seems pretty good with csqc code in the projects of his I've seen/played in... A mini tut on what you did would be super for others looking to see the basics you got working ceriux. |
|
Back to top |
|
 |
ceriux

Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA
|
Posted: Tue Mar 17, 2009 5:07 am Post subject: |
|
|
what im working on now.
edit: i submitted my tutorial, it shows how to make a better looking version of the hud i drew up recently. though some of the effects are from the alpha channel included with the hud tga in the tutorial. _________________ QuakeDB - Quake ModDB Group |
|
Back to top |
|
 |
ceriux

Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA
|
|
Back to top |
|
 |
worldspawn
Joined: 02 Dec 2008 Posts: 26
|
Posted: Sun Sep 27, 2009 10:27 pm Post subject: |
|
|
http://inside3d.com/showtutorial.php?id=245
There's a few backslashes kicking around in your functions rendering code that prevents a clean compile.
Not sure if that was intentional but whatever, it should look as follows:
Code: |
void DrawHealth()
{
local string text;
vid_size_x = cvar("vid_conwidth");
vid_size_y = cvar("vid_conheight");
vid_res_x = cvar("vid_width");
vid_res_y = cvar("vid_height");
currenthealth = getstati(STAT_HEALTH);
pos_x = vid_size_x*0.050 - hud_width*0.050;
pos_y= vid_size_y*0.83 - hud_height*0.83;
text = strcat(ftos(currenthealth), ": HEALTH");
drawstring(pos, text, '10 10 0', '1 1 1', 3, 1);
};
void DrawArmor()
{
local string text;
vid_size_x = cvar("vid_conwidth");
vid_size_y = cvar("vid_conheight");
vid_res_x = cvar("vid_width");
vid_res_y = cvar("vid_height");
currentarmor = getstati(STAT_ARMOR);
pos_x = vid_size_x*0.05 - hud_width*0.05;
pos_y= vid_size_y*0.85 - hud_height*0.85;
text = strcat(ftos(currentarmor), ": ARMOR");
drawstring(pos, text, '10 10 0', '1 1 1', 3, 1);
};
void DrawHud()
{
vid_size_x = cvar("vid_conwidth");
vid_size_y = cvar("vid_conheight");
vid_res_x = cvar("vid_width");
vid_res_y = cvar("vid_height");'
pos2_y= vid_size_y*0.77 - hud_height*0.77;
pos2_x = vid_size_x*0.0 - hud_width*0.0;
drawpic(pos2, "progs/hud4.tga", '128 110 0', '1 1 1', 1, 0);
};
|
|
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Sun Sep 27, 2009 11:57 pm Post subject: |
|
|
querying vid_conwidth and vid_conheight every frame multiple times a frame is horrible.
instead, you ought to utilize the arguments to your CSQC_UpdateView for those two vars, and basically pass them through to child functions.
you also don't even use vid_width, and nor should you really. they can very very easily be stale, invalid, etc.
quake doesn't normally scale its hud, depending upon the -conwidth argument in glquake to rescale.
that is the following two lines is generally enough to draw items to match quake. Insert the proper variables and you have an item drawn in a virtual hud.
vector sbarpos = (vid_width-sbar_width)*'0.5 0 0' + (vid_height-sbar_height)*'0 1 0';
drawpic(mypic, sbarpos + item_offset, item_size, '1 1 1', 1, 0);
sbarpos is of course the top left of your hud area, which can be passed around to the various functions that form your hud.
You can scale your hud, but beware widescreens! It can pay to use a hybrid aproach to scaling your hud if you choose to do that. Scale based on the smaller axis (relative to 4:3 anyway), and center on the other. This gives a single float scaler which can be used to multiply item_size without dotproduct semantics (basically multiply sbar_width, sbar_height, item_offset, and item_size by that scaler. Thus:
float hudscale = (vid_width*3 > vid_height*4)?((vid_width*3)/(vid_height*4)):((vid_height*4)/(vid_width*3));
vector sbarpos = (vid_width-sbar_width*hudscale)*'0.5 0 0' + (vid_height-sbar_height*hudscale)*'0 1 0';
drawpic(mypic, sbarpos + item_offset*hudscale, item_size*hudscale, '1 1 1', 1, 0);
or so.
Actually, I'm not certain about that hudscale line. But you get the idea. Of course, you might need art to cover the fact that there might be gaps each side of the hud when it is wide.
Side note: halflife has separate artwork for 320+ and 640+ :)
also, be cautious about strings that are not scaled 8*8, they can scale badly, depending on the user's raster font. The same applies to images, but its less noticable thus less important.
It annoys me that there is no componant-based vector multiply in QC.
Your mileage may vary. _________________ What's a signature? |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|