Patches #485

Merge in xonotic/xonotic-data.pk3dir.git: terencehill/essential_weapons_panel

Added by git-manager 12 months ago. Updated 8 months ago.

Status:Resolved Start:05/29/2011
Priority:High Due date:
Assigned to:Samual % Done:

100%

Category:-
Target version:Xonotic - 0.6
Milestones:
Votes: 0

Description

Purpose of the branch:

hud_panel_weapons_onlyowned to display only owned weapons; panel gets dynamically reduced and recentered

Repository: xonotic/xonotic-data.pk3dir.git
Commit: feaaa909b5f810059dae450bdfb45207c13f3a3a
Branch: terencehill/essential_weapons_panel

Merge commands:

cd data/xonotic-data.pk3dir
git checkout master
git reset --hard origin/master
git pull && git diff 'feaaa909b5f810059dae450bdfb45207c13f3a3a'..'origin/terencehill/essential_weapons_panel'

# please check that the diff you just saw did not contain anything complex that
# needs a new merge request, and review these changes

git merge --no-ff 'origin/terencehill/essential_weapons_panel'

# please make sure this merge worked, and if not, fix merge conflicts and git
# commit BEFORE the next command
#
# also, THIS is the point to do final pre-merge testing
#
# use git reset --hard origin/master to bail out

git push && git push --delete origin 'terencehill/essential_weapons_panel'

Diffstat:

 defaultXonotic.cfg        |    1 +
 qcsrc/client/autocvars.qh |    1 +
 qcsrc/client/hud.qc       |  113 +++++++++++++++++++++++++++++----------------
 3 files changed, 75 insertions(+), 40 deletions(-)

Revision log:

commit feaaa909b5f810059dae450bdfb45207c13f3a3a
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Add to the owned weapons list the "Unavailable/Don't have" weapon in order to make visible the warning message in the hud itself

commit 350604abf517116ae5530876369b9cdc0cb8942b
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix weapons panel not appearing at all because weapon sorting code could never be executed

commit 27cc6105adce4ef04600f1dbd7d6c5de1d6c9e45
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    hud_panel_weapons_onlyowned: if player doesn't have any weapon completely hide the weapons panel

commit 9533251c17521a8446265c8924ec3e68f1232690
Merge: 0750442 1ed620d
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Merge branch 'master' into terencehill/essential_weapons_panel

commit 07504423903fd6c6ec9d47bfd0ff2eb34a042a8c
Merge: 7766418 c96303a
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Merge branch 'master' into terencehill/essential_weapons_panel

commit 7766418aefbf1e7c90bb5bcfebf40891123c3b85
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Declare weapon_cnt just where it's used to avoid possible confusion with weapon_count

commit c76d7da18a920a442ae79b3a18196eb0f1b90901
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    hud_panel_weapons_onlyowned to display only owned weapons; panel gets dynamically reduced and recentered

User agreed to the GPLv2+.

Diff:

  1 
diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg
2
index 0781bfd..35c2edf 100644
3
--- a/defaultXonotic.cfg
4
+++ b/defaultXonotic.cfg
5
@@ -1427,6 +1427,7 @@ seta hud_panel_weapons_ammo_full_nails 200 "show 100% of the status bar at this
6 seta hud_panel_weapons_ammo_full_cells 80 "show 100% of the status bar at this ammo count" 7 seta hud_panel_weapons_ammo_full_rockets 80 "show 100% of the status bar at this ammo count" 8 seta hud_panel_weapons_ammo_full_fuel 100 "show 100% of the status bar at this ammo count" 9
+seta hud_panel_weapons_onlyowned 0 "show only owned weapons"
10 11 seta hud_panel_ammo_maxammo "40" "when you have this much ammo, the ammo status bar is full" 12 13
diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh
14
index b2a1602..fd1357c 100644
15
--- a/qcsrc/client/autocvars.qh
16
+++ b/qcsrc/client/autocvars.qh
17
@@ -273,6 +273,7 @@ float autocvar_hud_panel_weapons_complainbubble_padding;
18 float autocvar_hud_panel_weapons_complainbubble_time; 19 var float autocvar_hud_panel_weapons_fade = 1; 20 float autocvar_hud_panel_weapons_label; 21
+float autocvar_hud_panel_weapons_onlyowned;
22 float autocvar_hud_panel_weapons_timeout; 23 float autocvar_hud_panel_weapons_timeout_effect; 24 float autocvar_hud_progressbar_alpha; 25
diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc
26
index 65fe92c..3d90567 100644
27
--- a/qcsrc/client/hud.qc
28
+++ b/qcsrc/client/hud.qc
29
@@ -612,7 +612,7 @@ float GetAmmoTypeForWep(float i)
30 31 void HUD_Weapons(void) 32 { 33
- float f, screen_ar;
34
+ float i, f, screen_ar;
35 float center_x, center_y; 36 37 if(!autocvar__hud_configure) 38
@@ -644,6 +644,70 @@ void HUD_Weapons(void)
39 40 HUD_Panel_UpdateCvars(weapons); 41 42
+ // TODO make this configurable
43
+ if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
44
+ {
45
+ float weapon_cnt;
46
+ if(weaponorder_bypriority)
47
+ strunzone(weaponorder_bypriority);
48
+ if(weaponorder_byimpulse)
49
+ strunzone(weaponorder_byimpulse);
50
+
51
+ weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
52
+ weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
53
+ weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
54
+
55
+ weapon_cnt = 0;
56
+ for(i = WEP_FIRST; i <= WEP_LAST; ++i)
57
+ {
58
+ self = get_weaponinfo(i);
59
+ if(self.impulse >= 0)
60
+ {
61
+ weaponorder[weapon_cnt] = self;
62
+ ++weapon_cnt;
63
+ }
64
+ }
65
+ for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
66
+ weaponorder[i] = NULL;
67
+ heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
68
+
69
+ weaponorder_cmp_str = string_null;
70
+ }
71
+
72
+ float when, fadetime;
73
+ when = autocvar_hud_panel_weapons_complainbubble_time;
74
+ fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
75
+ float weapons_st = getstati(STAT_WEAPONS);
76
+ float weapon_count;
77
+ if (!autocvar__hud_configure && autocvar_hud_panel_weapons_onlyowned)
78
+ {
79
+ vector old_panel_size;
80
+ for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
81
+ {
82
+ if(weapons_st & weaponorder[i].weapons)
83
+ ++weapon_count;
84
+ }
85
+ if(autocvar_hud_panel_weapons_complainbubble && time - complain_weapon_time < when + fadetime)// && complain_weapon >= 0
86
+ ++weapon_count;
87
+ if (weapon_count == 0)
88
+ return;
89
+ // reduce size of the panel
90
+ if (panel_size_y > panel_size_x)
91
+ {
92
+ old_panel_size_y = panel_size_y;
93
+ panel_size_y *= weapon_count / WEP_COUNT;
94
+ panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
95
+ }
96
+ else
97
+ {
98
+ old_panel_size_x = panel_size_x;
99
+ panel_size_x *= weapon_count / WEP_COUNT;
100
+ panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
101
+ }
102
+ }
103
+ else
104
+ weapon_count = WEP_COUNT;
105
+
106 if (timeout && time >= weapontime + timeout && !autocvar__hud_configure) 107 { 108 f = (time - (weapontime + timeout)) / timeout_effect_length; 109
@@ -707,37 +771,6 @@ void HUD_Weapons(void)
110 } 111 } 112 113
- float i, weapid, wpnalpha, weapon_cnt;
114
-
115
- // TODO make this configurable
116
- if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
117
- {
118
- if(weaponorder_bypriority)
119
- strunzone(weaponorder_bypriority);
120
- if(weaponorder_byimpulse)
121
- strunzone(weaponorder_byimpulse);
122
-
123
- weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
124
- weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
125
- weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
126
-
127
- weapon_cnt = 0;
128
- for(i = WEP_FIRST; i <= WEP_LAST; ++i)
129
- {
130
- self = get_weaponinfo(i);
131
- if(self.impulse >= 0)
132
- {
133
- weaponorder[weapon_cnt] = self;
134
- ++weapon_cnt;
135
- }
136
- }
137
- for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
138
- weaponorder[i] = NULL;
139
- heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
140
-
141
- weaponorder_cmp_str = string_null;
142
- }
143
-
144 HUD_Panel_DrawBg(1); 145 if(panel_bg_padding) 146 { 147
@@ -745,6 +778,8 @@ void HUD_Weapons(void)
148 panel_size -= '2 2 0' * panel_bg_padding; 149 } 150 151
+ float weapid, wpnalpha;
152
+
153 if(autocvar_hud_panel_weapons_fade) 154 { 155 wpnalpha = 3.2 - 2 * (time - weapontime); 156
@@ -756,16 +791,12 @@ void HUD_Weapons(void)
157 float rows, columns; 158 float aspect = autocvar_hud_panel_weapons_aspect; 159 rows = panel_size_y/panel_size_x; 160
- rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
161
+ rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
162 163
- columns = ceil(WEP_COUNT/rows);
164
+ columns = ceil(weapon_count/rows);
165 float row, column; 166 167 float a, type, fullammo; 168
- float when;
169
- when = autocvar_hud_panel_weapons_complainbubble_time;
170
- float fadetime;
171
- fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
172 173 vector color; 174 vector wpnpos; 175
@@ -805,13 +836,15 @@ void HUD_Weapons(void)
176 acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i)))); 177 } 178 179
- float weapons_st = getstati(STAT_WEAPONS);
180
-
181 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i) 182 { 183 self = weaponorder[i]; 184 if (!self || self.impulse < 0) 185 continue; 186
+ if (autocvar_hud_panel_weapons_onlyowned)
187
+ if (!((weapons_st & self.weapons) || (self.weapon == complain_weapon && time - complain_weapon_time < when + fadetime && autocvar_hud_panel_weapons_complainbubble)))
188
+ if (!autocvar__hud_configure)
189
+ continue;
190 wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y; 191 192 weapid = self.impulse;

History

Updated by divVerent 12 months ago

  • Assigned to set to FruitieX

Updated by Samual 11 months ago

  • Status changed from New to Feedback
  • Assigned to changed from FruitieX to Samual

Reviewed by me-- this should be perfectly fine to merge (though I did a commit which enables it by default, if that's fine with you divVerent)

I asked around a bit and people seem to like this a bit more especially since there were many useless weapons before, though they would MOST prefer a way where you could only see the weapons which are available on the map.

Anyway, should be merged I think

Updated by terencehill 10 months ago

You allowed the panel to be shown reduced in hud config mode, just what I carefully avoided to do. I left the panel always shown in hud config mode as if onlyowned is never active because when you arrange a HUD layout you must consider the whole panel, that is the panel with all the weapons.

A compromise would be to show in hud config mode only the weapons owned but with the borders drawn around the full panel..
Also borders could be reduced to include only the owned weapons only when the menu dialog is opened: this way at least you can see how the panel really is when you check/uncheck that checkbox.

Updated by Samual 10 months ago

I thought it was a bug with showing only owned weapons while still showing full panel size

If you want to do anything, I would do this compromise -- showing the hud_configure border around it but still showing the panel as it would be in game.

Basically you could change it to draw another box entirely which goes around the entire panel, as I think it should still look exactly like it would in game.

I am very much so against how you had it previously, as it looks broken and doesn't properly show the user what their change does to the panel.

Updated by terencehill 10 months ago

Ok, I've implemented your suggestion.

Updated by divVerent 10 months ago

  • Status changed from Feedback to In Progress
  • Priority changed from Normal to High

Updated by divVerent 9 months ago

  • Assigned to changed from Samual to tZork

We still need a code review for this. FruitieX already has another and bigger code review task, so assigning this one to tZork.

Updated by Samual 9 months ago

  • Assigned to changed from tZork to Samual
  • Target version set to 0.5
  • % Done changed from 0 to 100

One last issue... if you are spectating and enter hud setup, you don't see any weapons which the onlyowned feature is on-- but you still see the background of the panel

Perhaps randomly pick weapons to display here or something? Either way, this should still be merged before code freeze -- it is (and has been for a while) basically ready and a very useful feature.

If divVerent requests and terencehill isn't around at the moment, i'll code the randomly selected weapons feature myself.

Updated by terencehill 9 months ago

Yeah, I think it's needed, I can try to code it.

Updated by Samual 9 months ago

  • Assigned to changed from Samual to terencehill

Please finish asap, if not tomorrow i'll code it myself

Updated by divVerent 9 months ago

Have you coded it now? ;)

Updated by Samual 9 months ago

No, he did already, need to review it

Updated by divVerent 9 months ago

Review status?

Updated by divVerent 9 months ago

  • Target version deleted (0.5)

Unassigned from 0.5 due to lack of review.

Updated by Samual 8 months ago

  • Status changed from In Progress to Resolved
  • Assigned to changed from terencehill to Samual
  • Target version set to 0.6

Merged

Also available in: Atom PDF