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

Go to the source code of this file.

Functions

entity makeXonoticSkinList ()
 
void SetSkin_Click (entity btn, entity me)
 
void XonoticSkinList_configureXonoticSkinList (entity me)
 
void XonoticSkinList_destroy (entity me)
 
void XonoticSkinList_doubleClickListBoxItem (entity me, float i, vector where)
 
void XonoticSkinList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
 
void XonoticSkinList_getSkins (entity me)
 
float XonoticSkinList_keyDown (entity me, float scan, float ascii, float shift)
 
void XonoticSkinList_loadCvars (entity me)
 
void XonoticSkinList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
void XonoticSkinList_saveCvars (entity me)
 
void XonoticSkinList_setSkin (entity me)
 
string XonoticSkinList_skinParameter (entity me, float i, float key)
 

Variables

const float SKINPARM_AUTHOR = 2
 
const float SKINPARM_COUNT = 4
 
const float SKINPARM_NAME = 0
 
const float SKINPARM_PREVIEW = 3
 
const float SKINPARM_TITLE = 1
 

Function Documentation

◆ makeXonoticSkinList()

entity makeXonoticSkinList ( )

Definition at line 9 of file skinlist.qc.

References entity(), and NEW.

10 {
11  entity me;
12  me = NEW(XonoticSkinList);
13  me.configureXonoticSkinList(me);
14  return me;
15 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:

◆ SetSkin_Click()

void SetSkin_Click ( entity  btn,
entity  me 
)

Definition at line 157 of file skinlist.qc.

158 {
159  me.setSkin(me);
160 }

◆ XonoticSkinList_configureXonoticSkinList()

void XonoticSkinList_configureXonoticSkinList ( entity  me)

Definition at line 17 of file skinlist.qc.

18 {
19  me.configureXonoticListBox(me);
20  me.getSkins(me);
21  me.loadCvars(me);
22 }

◆ XonoticSkinList_destroy()

void XonoticSkinList_destroy ( entity  me)

Definition at line 104 of file skinlist.qc.

105 {
106  buf_del(me.skinlist);
107 }

◆ XonoticSkinList_doubleClickListBoxItem()

void XonoticSkinList_doubleClickListBoxItem ( entity  me,
float  i,
vector  where 
)

Definition at line 162 of file skinlist.qc.

References m_play_click_sound(), and MENU_SOUND_EXECUTE.

163 {
165  me.setSkin(me);
166 }
+ Here is the call graph for this function:

◆ XonoticSkinList_drawListBoxItem()

void XonoticSkinList_drawListBoxItem ( entity  me,
int  i,
vector  absSize,
bool  isSelected,
bool  isFocused 
)

Definition at line 127 of file skinlist.qc.

References draw_Fill(), draw_Picture(), draw_Text(), draw_TextShortenToWidth(), draw_TextWidth(), eX, eY, getFadedAlpha(), SKINPARM_AUTHOR, SKINPARM_PREVIEW, and SKINPARM_TITLE.

128 {
129  string s;
130 
131  if(isSelected)
132  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
133  else if(isFocused)
134  {
135  me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
136  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
137  }
138 
139  s = me.skinParameter(me, i, SKINPARM_PREVIEW);
140  draw_Picture(me.columnPreviewOrigin * eX, s, me.columnPreviewSize * eX + eY, '1 1 1', 1);
141 
142  s = me.skinParameter(me, i, SKINPARM_TITLE);
143  s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
144  draw_Text(me.realUpperMargin1 * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_SKINLIST_TITLE, SKINALPHA_TEXT, 0);
145 
146  s = me.skinParameter(me, i, SKINPARM_AUTHOR);
147  s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
148  draw_Text(me.realUpperMargin2 * eY + (me.columnNameOrigin + 1.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_SKINLIST_AUTHOR, SKINALPHA_TEXT, 0);
149 }
const vector eY
Definition: vector.qh:45
const float SKINPARM_TITLE
Definition: skinlist.qc:4
const float SKINPARM_PREVIEW
Definition: skinlist.qc:6
const vector eX
Definition: vector.qh:44
const float SKINPARM_AUTHOR
Definition: skinlist.qc:5
+ Here is the call graph for this function:

◆ XonoticSkinList_getSkins()

void XonoticSkinList_getSkins ( entity  me)

Definition at line 50 of file skinlist.qc.

References buf_create, name, search_begin(), search_getfilename(), search_getsize(), SKINPARM_COUNT, SKINPARM_NAME, SKINPARM_TITLE, strlen(), and substring().

51 {
52  float glob, buf, i, n, fh;
53  string s, name;
54 
55  buf = buf_create();
56  glob = search_begin("gfx/menu/*/skinvalues.txt", true, true);
57  if(glob < 0)
58  {
59  me.skinlist = buf;
60  me.nItems = 0;
61  return;
62  }
63 
64  n = search_getsize(glob);
65  for(i = 0; i < n; ++i)
66  {
67  s = search_getfilename(glob, i);
68  name = substring(s, 9, strlen(s) - 24); // the * part
69  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_NAME, name);
70  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, _("<TITLE>"));
71  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, _("<AUTHOR>"));
72  if(draw_PictureSize(strcat("/gfx/menu/", substring(s, 9, strlen(s) - 24), "/skinpreview")) == '0 0 0')
73  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_PREVIEW, "nopreview_menuskin");
74  else
75  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_PREVIEW, strcat("/gfx/menu/", substring(s, 9, strlen(s) - 24), "/skinpreview"));
76  fh = fopen(s, FILE_READ);
77  if(fh < 0)
78  {
79  LOG_INFO("Warning: can't open skinvalues.txt file");
80  continue;
81  }
82  while((s = fgets(fh)))
83  {
84  // these two are handled by skinlist.qc
85  if(substring(s, 0, 6) == "title ")
86  {
87  if (name == cvar_defstring("menu_skin"))
88  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, strcat(substring(s, 6, strlen(s) - 6), " (", _("Default"), ")"));
89  else
90  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, substring(s, 6, strlen(s) - 6));
91  }
92  else if(substring(s, 0, 7) == "author ")
93  bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, substring(s, 7, strlen(s) - 7));
94  }
95  fclose(fh);
96  }
97 
98  search_end(glob);
99 
100  me.skinlist = buf;
101  me.nItems = n;
102 }
const float FILE_READ
Definition: csprogsdefs.qc:231
#define buf_create
Definition: dpextensions.qh:63
const float SKINPARM_TITLE
Definition: skinlist.qc:4
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 SKINPARM_COUNT
Definition: skinlist.qc:7
#define LOG_INFO(...)
Definition: log.qh:70
const float SKINPARM_PREVIEW
Definition: skinlist.qc:6
const float SKINPARM_NAME
Definition: skinlist.qc:3
const float SKINPARM_AUTHOR
Definition: skinlist.qc:5
+ Here is the call graph for this function:

◆ XonoticSkinList_keyDown()

float XonoticSkinList_keyDown ( entity  me,
float  scan,
float  ascii,
float  shift 
)

Definition at line 168 of file skinlist.qc.

References K_ENTER, K_KP_ENTER, m_play_click_sound(), MENU_SOUND_EXECUTE, and SUPER.

169 {
170  if(scan == K_ENTER || scan == K_KP_ENTER)
171  {
173  me.setSkin(me);
174  return 1;
175  }
176  else
177  return SUPER(XonoticSkinList).keyDown(me, scan, ascii, shift);
178 }
float K_KP_ENTER
Definition: keycodes.qc:74
#define SUPER(cname)
Definition: oo.qh:219
float K_ENTER
Definition: keycodes.qc:8
+ Here is the call graph for this function:

◆ XonoticSkinList_loadCvars()

void XonoticSkinList_loadCvars ( entity  me)

Definition at line 24 of file skinlist.qc.

References cvar_string(), and SKINPARM_NAME.

25 {
26  string s;
27  float i, n;
28  s = cvar_string("menu_skin");
29  n = me.nItems;
30  for(i = 0; i < n; ++i)
31  {
32  if(me.skinParameter(me, i, SKINPARM_NAME) == s)
33  {
34  me.setSelected(me, i);
35  break;
36  }
37  }
38 }
const float SKINPARM_NAME
Definition: skinlist.qc:3
+ Here is the call graph for this function:

◆ XonoticSkinList_resizeNotify()

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

Definition at line 109 of file skinlist.qc.

References SUPER.

110 {
111  me.itemAbsSize = '0 0 0';
112  SUPER(XonoticSkinList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
113 
114  me.itemAbsSize.y = absSize.y * me.itemHeight;
115  me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
116  me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
117  me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
118  me.realUpperMargin1 = 0.5 * (1 - 2.5 * me.realFontSize.y);
119  me.realUpperMargin2 = me.realUpperMargin1 + 1.5 * me.realFontSize.y;
120 
121  me.columnPreviewOrigin = 0;
122  me.columnPreviewSize = me.itemAbsSize.y / me.itemAbsSize.x * 4 / 3;
123  me.columnNameOrigin = me.columnPreviewOrigin + me.columnPreviewSize + me.realFontSize.x;
124  me.columnNameSize = 1 - me.columnPreviewSize - 2 * me.realFontSize.x;
125 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticSkinList_saveCvars()

void XonoticSkinList_saveCvars ( entity  me)

Definition at line 40 of file skinlist.qc.

References cvar_set(), and SKINPARM_NAME.

41 {
42  cvar_set("menu_skin", me.skinParameter(me, me.selectedItem, SKINPARM_NAME));
43 }
const float SKINPARM_NAME
Definition: skinlist.qc:3
+ Here is the call graph for this function:

◆ XonoticSkinList_setSkin()

void XonoticSkinList_setSkin ( entity  me)

Definition at line 151 of file skinlist.qc.

References localcmd.

152 {
153  me.saveCvars(me);
154  localcmd("\nmenu_restart\nmenu_cmd skinselect\n");
155 }

◆ XonoticSkinList_skinParameter()

string XonoticSkinList_skinParameter ( entity  me,
float  i,
float  key 
)

Definition at line 45 of file skinlist.qc.

References SKINPARM_COUNT.

46 {
47  return bufstr_get(me.skinlist, i * SKINPARM_COUNT + key);
48 }
const float SKINPARM_COUNT
Definition: skinlist.qc:7

Variable Documentation

◆ SKINPARM_AUTHOR

const float SKINPARM_AUTHOR = 2

Definition at line 5 of file skinlist.qc.

Referenced by XonoticSkinList_drawListBoxItem().

◆ SKINPARM_COUNT

const float SKINPARM_COUNT = 4

Definition at line 7 of file skinlist.qc.

Referenced by XonoticSkinList_getSkins(), and XonoticSkinList_skinParameter().

◆ SKINPARM_NAME

const float SKINPARM_NAME = 0

◆ SKINPARM_PREVIEW

const float SKINPARM_PREVIEW = 3

Definition at line 6 of file skinlist.qc.

Referenced by XonoticSkinList_drawListBoxItem().

◆ SKINPARM_TITLE

const float SKINPARM_TITLE = 1

Definition at line 4 of file skinlist.qc.

Referenced by XonoticSkinList_drawListBoxItem(), and XonoticSkinList_getSkins().