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

Go to the source code of this file.

Functions

void Button_configureButton (entity me, string txt, float sz, string gfx)
 
void Button_draw (entity me)
 
float Button_keyDown (entity me, float key, float ascii, float shift)
 
float Button_mouseDrag (entity me, vector pos)
 
float Button_mouseRelease (entity me, vector pos)
 
void Button_playClickSound (entity me)
 
void Button_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
void Button_showNotify (entity me)
 
void Dialog_Close (entity button, entity me)
 

Function Documentation

◆ Button_configureButton()

void Button_configureButton ( entity  me,
string  txt,
float  sz,
string  gfx 
)

Definition at line 12 of file button.qc.

References SUPER.

13  {
14  SUPER(Button).configureLabel(me, txt, sz, me.srcMulti ? 0.5 : 0);
15  me.src = gfx;
16  }
Definition: button.qh:6
#define SUPER(cname)
Definition: oo.qh:219

◆ Button_draw()

void Button_draw ( entity  me)

Definition at line 69 of file button.qc.

References Dialog_Close(), draw_alpha, draw_ButtonPicture(), draw_Picture(), entity(), eX, eY, frametime, strcat(), SUPER, and vector().

70  {
71  vector bOrigin, bSize;
72  float save;
73 
74  me.focusable = !me.disabled;
75 
76  save = draw_alpha;
77  if (me.disabled) draw_alpha *= me.disabledAlpha;
78 
79  if (me.src)
80  {
81  if (me.srcMulti)
82  {
83  bOrigin = '0 0 0';
84  bSize = '1 1 0';
85  if (me.disabled) draw_ButtonPicture(bOrigin, strcat(me.src, "_d", me.srcSuffix), bSize, me.colorD, 1);
86  else if (me.forcePressed || me.pressed || me.clickTime > 0) draw_ButtonPicture(bOrigin, strcat(me.src, "_c", me.srcSuffix), bSize, me.colorC, 1);
87  else if (me.focused) draw_ButtonPicture(bOrigin, strcat(me.src, "_f", me.srcSuffix), bSize, me.colorF, 1);
88  else draw_ButtonPicture(bOrigin, strcat(me.src, "_n", me.srcSuffix), bSize, me.color, 1);
89  }
90  else
91  {
92  if (me.realFontSize_y == 0)
93  {
94  bOrigin = '0 0 0';
95  bSize = '1 1 0';
96  }
97  else
98  {
99  bOrigin = eY * (0.5 * (1 - me.realFontSize.y)) + eX * (0.5 * (me.keepspaceLeft - me.realFontSize.x));
100  bSize = me.realFontSize;
101  }
102  if (me.disabled) draw_Picture(bOrigin, strcat(me.src, "_d", me.srcSuffix), bSize, me.colorD, 1);
103  else if (me.forcePressed || me.pressed || me.clickTime > 0) draw_Picture(bOrigin, strcat(me.src, "_c", me.srcSuffix), bSize, me.colorC, 1);
104  else if (me.focused) draw_Picture(bOrigin, strcat(me.src, "_f", me.srcSuffix), bSize, me.colorF, 1);
105  else draw_Picture(bOrigin, strcat(me.src, "_n", me.srcSuffix), bSize, me.color, 1);
106  }
107  }
108  if (me.src2)
109  {
110  bOrigin = me.keepspaceLeft * eX;
111  bSize = eY + eX * (1 - me.keepspaceLeft);
112 
113  bOrigin += bSize * (0.5 - 0.5 * me.src2scale);
114  bSize = bSize * me.src2scale;
115 
116  draw_Picture(bOrigin, me.src2, bSize, me.color2, me.alpha2);
117  }
118 
119  draw_alpha = save;
120 
121  if (me.clickTime > 0 && me.clickTime <= frametime)
122  {
123  // keyboard click timer expired? Fire the event then.
124  if (!me.disabled && me.onClick)
125  {
126  if(me.applyButton)
127  me.applyButton.disabled = false;
128  me.onClick(me, me.onClickEntity);
129  if(me.disableOnClick)
130  me.disabled = true;
131  }
132  }
133  me.clickTime -= frametime;
134 
135  SUPER(Button).draw(me);
136  }
const vector eY
Definition: vector.qh:45
Definition: button.qh:6
#define SUPER(cname)
Definition: oo.qh:219
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"))
float frametime
Definition: csprogsdefs.qc:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
+ Here is the call graph for this function:

◆ Button_keyDown()

float Button_keyDown ( entity  me,
float  key,
float  ascii,
float  shift 
)

Definition at line 17 of file button.qc.

References K_ENTER, K_KP_ENTER, and K_SPACE.

18  {
19  if (key == K_ENTER || key == K_SPACE || key == K_KP_ENTER)
20  {
21  if(!me.disabled)
22  {
23  me.playClickSound(me);
24  me.clickTime = 0.1; // delayed for effect
25  }
26  return 1;
27  }
28  return 0;
29  }
float K_SPACE
Definition: keycodes.qc:10
float K_KP_ENTER
Definition: keycodes.qc:74
float K_ENTER
Definition: keycodes.qc:8

◆ Button_mouseDrag()

float Button_mouseDrag ( entity  me,
vector  pos 
)

Definition at line 30 of file button.qc.

References METHOD, and vector().

31  {
32  me.pressed = 1;
33  if (pos.x < 0) me.pressed = 0;
34  if (pos.y < 0) me.pressed = 0;
35  if (pos.x >= 1) me.pressed = 0;
36  if (pos.y >= 1) me.pressed = 0;
37  return 1;
38  }
+ Here is the call graph for this function:

◆ Button_mouseRelease()

float Button_mouseRelease ( entity  me,
vector  pos 
)

Definition at line 44 of file button.qc.

45  {
46  me.mouseDrag(me, pos); // verify coordinates
47  if (me.pressed)
48  {
49  if (!me.disabled)
50  {
51  me.playClickSound(me);
52  if (me.onClick)
53  {
54  if(me.applyButton)
55  me.applyButton.disabled = false;
56  me.onClick(me, me.onClickEntity);
57  if(me.disableOnClick)
58  me.disabled = true;
59  }
60  }
61  me.pressed = 0;
62  }
63  return 1;
64  }

◆ Button_playClickSound()

void Button_playClickSound ( entity  me)

Definition at line 138 of file button.qc.

References Dialog_Close(), DialogOpenButton_Click(), m_play_click_sound(), MENU_SOUND_CLOSE, MENU_SOUND_EXECUTE, and MENU_SOUND_OPEN.

139  {
141  else if (me.onClick == Dialog_Close) m_play_click_sound(MENU_SOUND_CLOSE);
143  }
void DialogOpenButton_Click(entity button, entity tab)
+ Here is the call graph for this function:

◆ Button_resizeNotify()

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

Definition at line 3 of file button.qc.

References min(), and SUPER.

4  {
5  if (me.srcMulti) me.keepspaceLeft = 0;
6  else me.keepspaceLeft = min(0.8, absSize.x == 0 ? 0 : (absSize.y / absSize.x));
7  SUPER(Button).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
8 
9  if(me.disableOnClick)
10  me.disabled = true; // initially disabled
11  }
Definition: button.qh:6
#define SUPER(cname)
Definition: oo.qh:219
+ Here is the call graph for this function:

◆ Button_showNotify()

void Button_showNotify ( entity  me)

Definition at line 65 of file button.qc.

66  {
67  me.focusable = !me.disabled;
68  }

◆ Dialog_Close()

void Dialog_Close ( entity  button,
entity  me 
)

Definition at line 7 of file dialog.qc.

Referenced by Button_draw(), Button_playClickSound(), Close_Clicked(), Disconnect_Click(), MapList_LoadMap(), and XonoticUserbindEditDialog_Save().

8  {
9  me.close(me);
10  }
+ Here is the caller graph for this function: