HUD showing teammates alive.

Something else for Armagetron? Goody!
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

HUD showing teammates alive.

Post by wrtlprnft »

Wow. My first change to the source, and it works. yay.

Anyways, for fortress the "Enemies Alive:" display is infinitely helpful if you defend, but I wanted it to display the teammates as well, so i made a small change so it now displays "Players Alive: Enemies/Teammates" (screenshot).

If anone likes it, here is the patch:

Code: Select all

--- src/tron/gHud.cpp.old       2006-02-03 15:43:41.000000000 -0600
+++ src/tron/gHud.cpp   2006-02-03 15:39:03.000000000 -0600
@@ -125,7 +125,7 @@

 }

-static int alivepeople, thetopscore, hudfpscount;
+static int alivepeople, alivemates, thetopscore, hudfpscount;

 static void tank_display_hud( ePlayerNetID* me ){
     static int fps       = 60;
@@ -166,11 +166,16 @@
         //Calculation, enemies (people not on me's team) alive
         if (dohudcrap) {
             alivepeople=0;
+            alivemates=0;
             if (me){
                 for(unsigned short int i=0;i<max;i++){
                     ePlayerNetID *p=se_PlayerNetIDs(i);
-                    if (p->Object() && p->Object()->Alive() && (p->CurrentTeam() != me->CurrentTeam())){
-                        alivepeople++;
+                    if (p->Object() && p->Object()->Alive()){
+                       if (p->CurrentTeam() != me->CurrentTeam()){
+                           alivepeople++;
+                       }else{
+                           alivemates++;
+                       }
                     }
                 }
             }
@@ -376,7 +381,7 @@

                         if(subby_ShowAliveEnemies){
                             tString message;
-                            message << "Enemies Alive: " << alivepeople ;
+                            message << "Players Alive: " << alivepeople << "/" << alivemates;
                             int length = message.Len();
                             float size = subby_AliveEnemiesSize;
                             rTextField enemies_alive(subby_AliveEnemiesLocX-((.15*size*(length-1.5))/2.0),subby_AliveEnemiesLocY,.15*size,.3*size);
A bit quirky, alivepeople could use some renaming to aliveenemies, but it was the wrong name already before I even touched the file ;)
Last edited by wrtlprnft on Wed Feb 08, 2006 5:13 am, edited 1 time in total.
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

Addition: Why is that "Enemies Alive" in the source? I thought those things go into the language files...
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Heh, it should be in the language file.

I committed this patch, thanks! Modified it somewhat, and moved the stuff in the hud to the left a tad to make room for the map. I'd like to replace the rubber gauge with the hud, and remove the rubber gauge. I don't object to bringing it back in a different, less space-consuming form. Any objections to me replacing the rubber gauge with the brake gauge?
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

I find the rubber gauge more useful than the speed gauge, but I wouldn't mind making all gauges together a tad smaller.

I'm just looking at the code, I'll try to make a patch that makes the gauges way less space- consuming. Like not having a line, but a colored box that grows full or empty according to the value. Doesn't seem to be too hard.
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Heh, I'm finding all the gauges useless. I actually look at my brake gauge sometimes, but other than that, I don't look at them. I'm more interested in enemies alive and the map. Occasionally I look at the score. ;) (I usually tab to see that, though) I don't know why I still have all of the hud on, anyway.

So, when you update to a version that has your patch, go through your user.cfg and delete all the *_LOCX varibles to reposition the elements. (Heh, I forgot those were configurable) That'll make it run the new defaults I just put in. They still need to slide left a bit, though. A triple-digit ping still overlaps the hud map.

/me goes off to learn a new place to look for enemies alive information. :)

(In testing I already used the new information, I was defending and I needed to know if I should attack. I saw that there were 2 enemies and 4 teammates alive and decided to advance, although not attack. Then the round ended)
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Oops. Anyway, I decided this met all of z-man's qualifications for what can be put in b0_2_8_0 and it's requested enough that I stuck it in there. So it'll be in the release.

The oops is because I also accidentally commited a sky.png that I had intended not to accidentally commit. No biggee, we're changing it in the release anyway (and the one I committed might get picked, heh), but I'll be more careful.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

Screenshot

A new variation of gauges ;) They consume way less vertical space so you could stack them on top of each other if you want space for the map. Additionally, they are more visual. Now if you run into a wall you get a square turning from green to read instead of just some line with an attached number moving which should reduce brain lag ;)

Is there a way to predict exactly how tall a font will be? There is some weird code for the title, I just copied this for the value, but it's far from exact.

I think the best would be to re- add the old gauges and make them configurable via something like RUBBER_GAUGE_TYPE.

Here's the patch (to the file in the release):

Code: Select all

--- src/tron/gHud.cpp.old       2006-02-03 15:43:41.000000000 -0600
+++ src/tron/gHud.cpp   2006-02-03 17:46:38.000000000 -0600
@@ -62,7 +62,7 @@

 #ifndef DEDICATED

-void GLmeter_subby(float value,float max, float locx, float locy, float size, const char * t,bool displayvalue = true, bool reverse = false, REAL r=.5, REAL g=.5, REAL b=1)
+void GLmeter_subby(float value,float max, float locx, float locy, float size, const char * t,bool displayvalue = true, bool reverse = false, REAL r=.5, REAL g=.5, REAL b=1, bool highbetter = false)
 {
     tString title( t );

@@ -72,9 +72,8 @@
     char string[50];
     value>max?value=max:1;
     value<0?value=0:1;
-    x= (reverse?-1:1) * cos(M_PI*value/max);
-    y= sin(M_PI*value/max);
-    if(y<size*.24) displayvalue = false; // dont display text when at minimum
+    int factor=(reverse?-1:1);
+    x= factor * (value/max*2. - 1.);

     /* Draws an ugly background on the gauge
        BeginQuads();
@@ -92,10 +91,30 @@

        RenderEnd();*/

+    //render the box
+    BeginQuads();
+    Color(r,g, b,0.3);
+    Vertex(-size+locx, size*0.3+locy,0);
+    Vertex(-size+locx,locy,0);
+    Vertex( size+locx,locy,0);
+    Vertex( size+locx, size*0.3+locy,0);
+    RenderEnd();
+    //fill
+    BeginQuads();
+    if(highbetter)
+       Color((x>0?1.-x:1.),(x<0.?x+1.:1.),0.,.5);
+    else
+       Color((x<0.?x+1.:1.),(x>0?1.-x:1.),0.,.5);
+    Vertex(-size+locx, size*0.3+locy,0);
+    Vertex(-size+locx, locy,0);
+    Vertex(size*x+locx,locy,0);
+    Vertex(size*x+locx,size*0.3+locy,0);
+    RenderEnd();
+    //render the line
     BeginLines();
     Color(r,g, b);
-    Vertex(-.1*x*size+locx,.1*y*size+locy,0);
-    Vertex(-x*size+locx,y*size+locy,0);
+    Vertex(size*x+locx,locy,0);
+    Vertex(size*x+locx, size*0.3+locy,0);
     RenderEnd();


@@ -105,8 +124,8 @@
     max_t << "0xcccccc" << (reverse?0:max);

     if(displayvalue){
-        rTextField speed_t(-x*1.45*size+locx,y*1.35*size+locy,.1*size,.2*size);
-        sprintf(string,"%.1f",value);
+        int length = sprintf(string,"%.1f",value);
+        rTextField speed_t(locx-((.15*size*(length-1.5))/2.0),locy+size*.28,.12*size,.24*size);
         speed_t << "0xccffff" << (string);
     }
     int length = title.Len();
@@ -125,7 +144,7 @@

 }

-static int alivepeople, thetopscore, hudfpscount;
+static int alivepeople, alivemates, thetopscore, hudfpscount;

 static void tank_display_hud( ePlayerNetID* me ){
     static int fps       = 60;
@@ -166,11 +185,16 @@
         //Calculation, enemies (people not on me's team) alive
         if (dohudcrap) {
             alivepeople=0;
+            alivemates=0;
             if (me){
                 for(unsigned short int i=0;i<max;i++){
                     ePlayerNetID *p=se_PlayerNetIDs(i);
-                    if (p->Object() && p->Object()->Alive() && (p->CurrentTeam() != me->CurrentTeam())){
-                        alivepeople++;
+                    if (p->Object() && p->Object()->Alive()){
+                       if (p->CurrentTeam() != me->CurrentTeam()){
+                           alivepeople++;
+                       }else{
+                           alivemates++;
+                       }
                     }
                 }
             }
@@ -327,12 +351,12 @@
                             GLmeter_subby(h->Speed(),maxmeterspeed,subby_SpeedGaugeLocX,subby_SpeedGaugeLocY,subby_SpeedGaugeSize,"Speed");  // easy to use configurable meters
                         if(subby_ShowRubberMeter)
                         {
-                            GLmeter_subby(h->GetRubber(),sg_rubberCycle,subby_RubberGaugeLocX,subby_RubberGaugeLocY,subby_RubberGaugeSize," Rubber Used");
+                            GLmeter_subby(h->GetRubber(),sg_rubberCycle,subby_RubberGaugeLocX,subby_RubberGaugeLocY,subby_RubberGaugeSize," Rubber", true, true, .5, .5, 1., true);
                             if ( gCycle::RubberMalusActive() )
                                 GLmeter_subby(100/(1+h->GetRubberMalus()),100,subby_RubberGaugeLocX,subby_RubberGaugeLocY,subby_RubberGaugeSize,"",true, false, 1,.5,.5);
                         }
                         if(subby_ShowBrakeMeter)
-                            GLmeter_subby(h->GetBrakingReservoir(), 1.0,subby_BrakeGaugeLocX,subby_BrakeGaugeLocY,subby_BrakeGaugeSize, " Brakes");
+                            GLmeter_subby(h->GetBrakingReservoir(), 1.0,subby_BrakeGaugeLocX,subby_BrakeGaugeLocY,subby_BrakeGaugeSize, " Brakes", true, false, .5, .5, 1., true);

                         //  bool displayfastest = true;// put into global, set via menusytem... subby to do.make sr_DISPLAYFASTESTout

@@ -376,7 +400,7 @@

                         if(subby_ShowAliveEnemies){
                             tString message;
-                            message << "Enemies Alive: " << alivepeople ;
+                            message << "Players Alive: " << alivepeople << "/" << alivemates;
                             int length = message.Len();
                             float size = subby_AliveEnemiesSize;
                             rTextField enemies_alive(subby_AliveEnemiesLocX-((.15*size*(length-1.5))/2.0),subby_AliveEnemiesLocY,.15*size,.3*size);
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

At the very top of gHud, you have these lines:

Code: Select all

REAL subby_PingLocX = 0.40, subby_PingLocY = -0.95, subby_PingSize = 0.13;
There's one for every thing that's on the hud. Here, subby_PingSize is the font size for the ping readout. Each one (except for size, maybe) is tied to a config item in user.cfg, so if you change it in your console, it persists. That's kinda neat.

So, here's what I'd like to see, probably another 5 minutes of your time, if you don't mind. :) I'd like to see a gauge scaling factor, where the size of each gauge is determined by a gauge scaling factor for each gauge. So you must multiply all your sizes by this factor, and default it to 1.

I'll be happy to tie it into the config system for you, of course. Also, if you want to make it selectable which gauge to use, then do that. But follow the model I quoted here, where you make the global variables at the top. That way I can hook it into the config system easily for you. :)

Anything else you'd like to add, of coruse, will be welcome. You might want to add bar colors, the option to make them vertical bars rather than horizontal, that sort of thing. Up to you, of course. ;)

gHud is a mess and is kinda scheduled for a big refactoring, but don't sweat it. Improvements now tell us which direction to go in teh refactoring, and all code that's there now will exist after the refactoring. :) So don't worry if it offends your sensibilities to make these global variables, we'll get it straightened out eventually.

Of course, it's theoretically straightforward to make it selectable for the old gauge type and what you've got here. I'd kinda like to have that, at least, before putting it into cvs.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

Currently working on it, longer post will follow. 2 things:
1. That's not what I mean. rTextField has two arguments for the font size, and I have no idea what scale it is... I poked around for this constructor and the values get multiplied by some weird ratios and constants...
I just wanna center a piece of text, but what's currently used for those red titles is everything but accurate.
2. WTH does stubby mean? I see that it is related to the config system and it is its variables, but what does it stand for?
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Ahhh.

1. I don't know. :) I just know that .13 is the size of the text at the bottom.

2. subby is the guy who wrote this stuff in the first place, with what looks like a lot of help from tank.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

Ok, here we go:

The scaling factor existed all the time, so it should work.

I added some variables and stuff, can you send me the changed files so I don't have to wait for CVS to sync? It is also possible to mix the meters now. See the Screenshot.

The colors would definitely get messy and add a total of 18 config variables, but I can do that if you want. I'm thinking about vertical bars, but what would I do with the labels? They would use lots of horizontal space, and i don't think vertical text is possible...

Attached the patch this time.
Attachments
diff.patch.gz
(2.1 KiB) Downloaded 419 times
User avatar
Phytotron
Formerly Oscilloscope
Posts: 5042
Joined: Thu Jun 09, 2005 10:06 pm
Location: A site or situation, especially considered in regard to its surroundings.
Contact:

Post by Phytotron »

Hmm, I do believe I prefer the look of those bars over the current guages. After all, wouldn't a lightcycle more likely have digital guages similar to that? I like Lucifer's suggestions as well.

The only guage I personally have on is the rubber meter, and that's just for general and occasional reference (I do recommend to players not to rely on it). But for aesthetic purposes, yeah, I like this here.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Lucifer wrote:Modified it somewhat, and moved the stuff in the hud to the left a tad to make room for the map.
Note that the map can also be easily moved.
Oscilloscope wrote:After all, wouldn't a lightcycle more likely have digital guages similar to that?
Digital basically means quantized. What does that have to do with these visual representations?
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

@Jonathan: yeah, the map can be moved, but I like it where it is. :) I just want some more room for it is all..

@wrtl: attached is a tarball, there are new config items to support the gauge bar flags. It's from the trunk, but should work fine in the release candidate, I don't think there's any hud changes from the trunk to the rc.
Attachments
files.tar.gz
(14.81 KiB) Downloaded 458 times
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Lucifer
Project Developer
Posts: 8742
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

I tweaked the positions and sizes, here's the code:

Code: Select all

REAL subby_SpeedGaugeSize=.150, subby_SpeedGaugeLocX=-0.12, subby_SpeedGaugeLocY=-0.9;
REAL subby_BrakeGaugeSize=.150, subby_BrakeGaugeLocX=0.25, subby_BrakeGaugeLocY=-0.9;
REAL subby_RubberGaugeSize=.150, subby_RubberGaugeLocX=-0.47, subby_RubberGaugeLocY=-0.9;
It would be nice to have color config items, but not a big deal. We'll eventually have them, of course, in some form or other, but there's no big hurry, since that's something that might be deeply affected by the pending factoring.

Edit: Committed, after tweaking a few things. This stuff's going in the trunk, now. Updated the screenshot.

Anyway, here's a screenshot:
Attachments
screenshot_73.png
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
Post Reply