Xonotic
playermodel.qc File Reference
#include "playermodel.qh"
+ Include dependency graph for playermodel.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XONVOTE186   1
 

Functions

entity makeXonoticPlayerModelSelector ()
 
void PlayerModelSelector_Next_Click (entity btn, entity me)
 
void PlayerModelSelector_Prev_Click (entity btn, entity me)
 
void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector (entity me)
 
void XonoticPlayerModelSelector_destroy (entity me)
 
void XonoticPlayerModelSelector_draw (entity me)
 
void XonoticPlayerModelSelector_go (entity me, float d)
 
void XonoticPlayerModelSelector_loadCvars (entity me)
 
void XonoticPlayerModelSelector_loadModels (entity me)
 
void XonoticPlayerModelSelector_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
void XonoticPlayerModelSelector_saveCvars (entity me)
 
void XonoticPlayerModelSelector_showNotify (entity me)
 

Variables

const float BUFMODELS_COUNT = 5
 
const float BUFMODELS_DESC = 4
 
const float BUFMODELS_IMAGE = 1
 
const float BUFMODELS_MODEL = 2
 
const float BUFMODELS_SKIN = 3
 
const float BUFMODELS_TITLE = 0
 

Macro Definition Documentation

◆ XONVOTE186

#define XONVOTE186   1

Definition at line 18 of file playermodel.qc.

Function Documentation

◆ makeXonoticPlayerModelSelector()

entity makeXonoticPlayerModelSelector ( )

Definition at line 3 of file playermodel.qc.

References entity(), and NEW.

4 {
5  entity me;
7  me.configureXonoticPlayerModelSelector(me);
8  return me;
9 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:

◆ PlayerModelSelector_Next_Click()

void PlayerModelSelector_Next_Click ( entity  btn,
entity  me 
)

Definition at line 131 of file playermodel.qc.

132 {
133  if (me.numModels <= 0)
134  return;
135  me.go(me, +1);
136  me.saveCvars(me);
137 }

◆ PlayerModelSelector_Prev_Click()

void PlayerModelSelector_Prev_Click ( entity  btn,
entity  me 
)

Definition at line 139 of file playermodel.qc.

140 {
141  if (me.numModels <= 0)
142  return;
143  me.go(me, -1);
144  me.saveCvars(me);
145 }

◆ XonoticPlayerModelSelector_configureXonoticPlayerModelSelector()

void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector ( entity  me)

Definition at line 20 of file playermodel.qc.

References string_null.

21 {
22  me.configureXonoticImage(me, string_null, -1);
23 }
string string_null
Definition: nil.qh:9

◆ XonoticPlayerModelSelector_destroy()

void XonoticPlayerModelSelector_destroy ( entity  me)

Definition at line 84 of file playermodel.qc.

85 {
86  if(me.bufModels >= 0)
87  {
88  buf_del(me.bufModels);
89  me.bufModels = -1;
90  }
91 }

◆ XonoticPlayerModelSelector_draw()

void XonoticPlayerModelSelector_draw ( entity  me)

Definition at line 154 of file playermodel.qc.

References draw_CenterText(), and vector().

155 {
156  float i, n;
157  vector o;
158 
159  if (me.numModels <= 0)
160  {
161  draw_CenterText('0.5 0.5 0', _("<no model found>"), me.realFontSize, SKINCOLOR_TEXT, 0.6, false);
162  return;
163  }
164 
166  // draw text on the image, handle \n in the description
167 
169 
170 #if XONVOTE186 // (nyov) lower name display looks better when there is no description text
171  draw_CenterText('0.5 0.8 0', me.currentModelTitle, me.realFontSize * (me.titleFontSize / me.fontSize), SKINCOLOR_MODELTITLE, SKINALPHA_MODELTITLE, false);
172 #else
173  draw_CenterText('0.5 0 0', me.currentModelTitle, me.realFontSize * (me.titleFontSize / me.fontSize), SKINCOLOR_MODELTITLE, SKINALPHA_MODELTITLE, false);
174 #endif
175 
177 
178  o = '0.5 1 0' - eY * me.realFontSize.y * ((n = tokenizebyseparator(me.currentModelDescription, "\n")) + 0.5);
179  for(i = 0; i < n; ++i)
180  {
181  draw_CenterText(o, argv(i), me.realFontSize, SKINCOLOR_TEXT, 1, false);
182  o += eY * me.realFontSize.y;
183  }
184 }
#define draw_endBoldFont()
Definition: draw.qh:5
const vector eY
Definition: vector.qh:45
#define draw_beginBoldFont()
Definition: draw.qh:4
#define SUPER(cname)
Definition: oo.qh:219
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define tokenizebyseparator
Definition: dpextensions.qh:21
+ Here is the call graph for this function:

◆ XonoticPlayerModelSelector_go()

void XonoticPlayerModelSelector_go ( entity  me,
float  d 
)

Definition at line 112 of file playermodel.qc.

References BUFMODELS_COUNT, BUFMODELS_DESC, BUFMODELS_IMAGE, BUFMODELS_MODEL, BUFMODELS_SKIN, BUFMODELS_TITLE, draw_PictureSize(), mod(), stof(), and strcpy.

113 {
114  me.idxModels = mod(me.idxModels + d + me.numModels, me.numModels);
115 
116  // select model #i!
117  strcpy(me.currentModelTitle, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_TITLE));
118  strcpy(me.currentModelImage, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_IMAGE));
119  me.currentSkin = stof(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_SKIN));
120  strcpy(me.currentModel, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_MODEL));
121  strcpy(me.currentModelDescription, bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_DESC));
122 
123  // fix the image
124  if(draw_PictureSize(me.currentModelImage) == '0 0 0')
125  me.src = "nopreview_player";
126  else
127  me.src = me.currentModelImage;
128  me.updateAspect(me);
129 }
const float BUFMODELS_SKIN
Definition: playermodel.qc:14
const float BUFMODELS_DESC
Definition: playermodel.qc:15
#define strcpy(this, s)
Definition: string.qh:49
const float BUFMODELS_IMAGE
Definition: playermodel.qc:12
const float BUFMODELS_TITLE
Definition: playermodel.qc:11
const float BUFMODELS_COUNT
Definition: playermodel.qc:16
const float BUFMODELS_MODEL
Definition: playermodel.qc:13
+ Here is the call graph for this function:

◆ XonoticPlayerModelSelector_loadCvars()

void XonoticPlayerModelSelector_loadCvars ( entity  me)

Definition at line 93 of file playermodel.qc.

References BUFMODELS_COUNT, BUFMODELS_MODEL, BUFMODELS_SKIN, cvar_string(), and skin.

94 {
95  string skin, modelname;
96  float i;
97 
98  skin = cvar_string("_cl_playerskin");
99  modelname = cvar_string("_cl_playermodel");
100 
101  for(i = 0; i < me.numModels; ++i)
102  {
103  if(bufstr_get(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_MODEL) == modelname)
104  if(bufstr_get(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_SKIN) == skin)
105  break;
106  }
107  if(i >= me.numModels) // fail
108  i = 0;
109  me.idxModels = i;
110 }
const float BUFMODELS_SKIN
Definition: playermodel.qc:14
skin
Definition: ent_cs.qc:143
const float BUFMODELS_COUNT
Definition: playermodel.qc:16
const float BUFMODELS_MODEL
Definition: playermodel.qc:13
+ Here is the call graph for this function:

◆ XonoticPlayerModelSelector_loadModels()

void XonoticPlayerModelSelector_loadModels ( entity  me)

Definition at line 25 of file playermodel.qc.

References buf_create, BUFMODELS_COUNT, BUFMODELS_DESC, BUFMODELS_IMAGE, BUFMODELS_MODEL, BUFMODELS_SKIN, BUFMODELS_TITLE, error(), ftos(), get_model_datafilename(), get_model_parameters(), get_model_parameters_age, get_model_parameters_desc, get_model_parameters_description, get_model_parameters_hidden, get_model_parameters_modelname, get_model_parameters_modelskin, get_model_parameters_name, get_model_parameters_sex, get_model_parameters_weight, search_begin(), search_end(), search_getfilename(), search_getsize(), strcat(), string_null, and substring().

26 {
27  int i;
28  string fn;
29 
30  float glob = search_begin(get_model_datafilename(string_null, -1, "txt"), true, true);
31  if (glob < 0)
32  return;
33 
34  float sortbuf = buf_create();
35  for(i = 0; i < search_getsize(glob); ++i)
36  {
37  // select model #i!
38  fn = search_getfilename(glob, i);
39  if(!get_model_parameters(fn, -1))
40  continue;
42  continue;
43  bufstr_add(sortbuf, sprintf("%-128s%s", get_model_parameters_name, fn), 1);
44  }
45  search_end(glob);
46  buf_sort(sortbuf, 128, 0);
47  me.numModels = buf_getsize(sortbuf);
48  me.bufModels = buf_create();
49  for(i = 0; i < me.numModels; ++i)
50  {
51  fn = substring(bufstr_get(sortbuf, i), 128, -1);
52  if(!get_model_parameters(fn, -1))
53  error("But it JUST worked!");
55  continue;
56  bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_TITLE, get_model_parameters_name);
61 #if XONVOTE186
64 #else
73 #endif
74  while(substring(get_model_parameters_desc, -1, 1) == "\n")
76  bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_DESC, get_model_parameters_desc);
77  }
78  buf_del(sortbuf);
80  me.loadCvars(me); // this will select the initial model, depending on the current cvars
81  me.go(me, 0); // this will set the vars for the selected model
82 }
float get_model_parameters_weight
Definition: util.qh:142
string get_model_datafilename(string m, float sk, string fil)
Definition: util.qc:1245
string get_model_parameters_desc
Definition: util.qh:152
const float BUFMODELS_SKIN
Definition: playermodel.qc:14
string string_null
Definition: nil.qh:9
float get_model_parameters(string m, float sk)
Definition: util.qc:1258
string get_model_parameters_description
Definition: util.qh:145
const float BUFMODELS_DESC
Definition: playermodel.qc:15
string get_model_parameters_sex
Definition: util.qh:141
float get_model_parameters_age
Definition: util.qh:143
float get_model_parameters_modelskin
Definition: util.qh:138
#define buf_create
Definition: dpextensions.qh:63
string get_model_parameters_modelname
Definition: util.qh:137
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
const float BUFMODELS_IMAGE
Definition: playermodel.qc:12
const float BUFMODELS_TITLE
Definition: playermodel.qc:11
const float BUFMODELS_COUNT
Definition: playermodel.qc:16
bool get_model_parameters_hidden
Definition: util.qh:144
const float BUFMODELS_MODEL
Definition: playermodel.qc:13
string get_model_parameters_name
Definition: util.qh:139
+ Here is the call graph for this function:

◆ XonoticPlayerModelSelector_resizeNotify()

void XonoticPlayerModelSelector_resizeNotify ( entity  me,
vector  relOrigin,
vector  relSize,
vector  absOrigin,
vector  absSize 
)

Definition at line 186 of file playermodel.qc.

References SUPER.

187 {
188  SUPER(XonoticPlayerModelSelector).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
189  me.realFontSize_y = me.fontSize / absSize.y;
190  me.realFontSize_x = me.fontSize / absSize.x;
191 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticPlayerModelSelector_saveCvars()

void XonoticPlayerModelSelector_saveCvars ( entity  me)

Definition at line 147 of file playermodel.qc.

References cvar_set(), and ftos().

148 {
149  // we can't immediately apply here because of flood control
150  cvar_set("_cl_playermodel", me.currentModel);
151  cvar_set("_cl_playerskin", ftos(me.currentSkin));
152 }
+ Here is the call graph for this function:

◆ XonoticPlayerModelSelector_showNotify()

void XonoticPlayerModelSelector_showNotify ( entity  me)

Definition at line 193 of file playermodel.qc.

194 {
195  // Reinitialize self.
196  me.destroy(me);
197  me.loadModels(me);
198 }

Variable Documentation

◆ BUFMODELS_COUNT

◆ BUFMODELS_DESC

const float BUFMODELS_DESC = 4

◆ BUFMODELS_IMAGE

const float BUFMODELS_IMAGE = 1

◆ BUFMODELS_MODEL

◆ BUFMODELS_SKIN

◆ BUFMODELS_TITLE

const float BUFMODELS_TITLE = 0