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

Go to the source code of this file.

Functions

void centerprint_Add (int new_id, string strMessage, float duration, int countdown_num)
 
void centerprint_AddStandard (string strMessage)
 
void centerprint_Kill (int id)
 
void centerprint_KillAll ()
 

Variables

bool autocvar_hud_panel_centerprint
 
float autocvar_hud_panel_centerprint_align
 
bool autocvar_hud_panel_centerprint_dynamichud = true
 
float autocvar_hud_panel_centerprint_fade_in = 0.15
 
float autocvar_hud_panel_centerprint_fade_in_short = 0
 
float autocvar_hud_panel_centerprint_fade_minfontsize = 0
 
float autocvar_hud_panel_centerprint_fade_out = 0.15
 
float autocvar_hud_panel_centerprint_fade_subsequent = 1
 
float autocvar_hud_panel_centerprint_fade_subsequent_minfontsize = 0.75
 
float autocvar_hud_panel_centerprint_fade_subsequent_passone = 3
 
float autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha = 0.5
 
float autocvar_hud_panel_centerprint_fade_subsequent_passtwo = 10
 
float autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha = 0.5
 
bool autocvar_hud_panel_centerprint_flip
 
float autocvar_hud_panel_centerprint_fontscale
 
float autocvar_hud_panel_centerprint_fontscale_bold = 1.4
 
float autocvar_hud_panel_centerprint_time
 

Function Documentation

◆ centerprint_Add()

void centerprint_Add ( int  new_id,
string  strMessage,
float  duration,
int  countdown_num 
)

Definition at line 46 of file centerprint.qc.

References autocvar_hud_panel_centerprint_fade_out, autocvar_hud_panel_centerprint_time, BOLD_OPERATOR, centerprint_bold, centerprint_countdown_num, centerprint_expire_time, CENTERPRINT_MAX_MSGS, centerprint_messages, centerprint_msgID, centerprint_showing, centerprint_time, cpm_index, max(), min(), strcpy, strlen(), substring(), and TC.

Referenced by centerprint_AddStandard(), centerprint_Kill(), HUD_CenterPrint(), and Local_Notification_sprintf().

47 {
48  TC(int, new_id); TC(int, countdown_num);
49  //LOG_INFOF("centerprint_Add: ^2id: %d ^3dur: %d ^5countdown: %d\n'%s'", new_id, duration, countdown_num, strreplace("\n", "^7\\n^7", strMessage));
50  int i, j;
51 
52  if(strMessage == "" && new_id == 0)
53  return;
54 
55  // strip BOLD_OPERATOR
56  bool is_bold = (substring(strMessage, 0, 5) == BOLD_OPERATOR);
57  if (is_bold)
58  strMessage = substring(strMessage, 5, -1);
59 
60  // strip trailing newlines
61  j = strlen(strMessage) - 1;
62  while(substring(strMessage, j, 1) == "\n" && j >= 0)
63  --j;
64  if (j < strlen(strMessage) - 1)
65  strMessage = substring(strMessage, 0, j + 1);
66 
67  if(strMessage == "" && new_id == 0)
68  return;
69 
70  // strip leading newlines
71  j = 0;
72  while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
73  ++j;
74  if (j > 0)
75  strMessage = substring(strMessage, j, strlen(strMessage) - j);
76 
77  if(strMessage == "" && new_id == 0)
78  return;
79 
81  centerprint_showing = true;
82 
83  for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
84  {
85  if (j == CENTERPRINT_MAX_MSGS)
86  j = 0;
87  if (new_id && new_id == centerprint_msgID[j])
88  {
89  if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
90  {
91  // fade out the current msg (duration and countdown_num are ignored)
93  centerprint_expire_time[j] = -1; // don't use the variable time here!
94  return;
95  }
96  break; // found a msg with the same id, at position j
97  }
98  }
99 
100  if (i == CENTERPRINT_MAX_MSGS)
101  {
102  // a msg with the same id was not found, add the msg at the next position
103  --cpm_index;
104  if (cpm_index == -1)
105  cpm_index = CENTERPRINT_MAX_MSGS - 1;
106  j = cpm_index;
107  }
108  strcpy(centerprint_messages[j], strMessage);
109  centerprint_bold[j] = is_bold;
110  centerprint_msgID[j] = new_id;
111  if (duration < 0)
112  {
113  centerprint_time[j] = -1;
114  centerprint_expire_time[j] = -1; // don't use the variable time here!
115  }
116  else
117  {
118  if(duration == 0)
120  centerprint_time[j] = duration;
121  centerprint_expire_time[j] = -1; // don't use the variable time here!
122  }
123  centerprint_countdown_num[j] = countdown_num;
124 }
int cpm_index
Definition: centerprint.qc:37
#define BOLD_OPERATOR
Definition: all.qh:12
#define strcpy(this, s)
Definition: string.qh:49
bool centerprint_showing
Definition: centerprint.qc:44
const int CENTERPRINT_MAX_MSGS
Definition: centerprint.qc:34
int centerprint_countdown_num[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:43
#define TC(T, sym)
Definition: _all.inc:82
float autocvar_hud_panel_centerprint_time
Definition: centerprint.qh:20
float autocvar_hud_panel_centerprint_fade_out
Definition: centerprint.qh:8
float centerprint_time[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:41
int centerprint_msgID[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:39
bool centerprint_bold[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:40
float centerprint_expire_time[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:42
string centerprint_messages[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ centerprint_AddStandard()

void centerprint_AddStandard ( string  strMessage)

Definition at line 132 of file centerprint.qc.

References autocvar_hud_panel_centerprint_time, and centerprint_Add().

Referenced by CSQC_Parse_CenterPrint(), and LocalCommand_localprint().

133 {
135 }
float autocvar_hud_panel_centerprint_time
Definition: centerprint.qh:20
void centerprint_Add(int new_id, string strMessage, float duration, int countdown_num)
Definition: centerprint.qc:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ centerprint_Kill()

void centerprint_Kill ( int  id)

Definition at line 126 of file centerprint.qc.

References centerprint_Add(), and TC.

Referenced by Announcer_Gamestart(), and Local_Notification_WOVA().

127 {
128  TC(int, id);
129  centerprint_Add(id, "", 0, 0);
130 }
#define TC(T, sym)
Definition: _all.inc:82
void centerprint_Add(int new_id, string strMessage, float duration, int countdown_num)
Definition: centerprint.qc:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ centerprint_KillAll()

void centerprint_KillAll ( )

Definition at line 137 of file centerprint.qc.

References centerprint_bold, centerprint_expire_time, CENTERPRINT_MAX_MSGS, centerprint_messages, centerprint_msgID, centerprint_time, and strfree.

Referenced by Destroy_All_Notifications(), HUD_CenterPrint(), and Local_Notification_WOVA().

138 {
139  for (int i=0; i<CENTERPRINT_MAX_MSGS; ++i)
140  {
142  centerprint_time[i] = 1;
143  centerprint_msgID[i] = 0;
144  centerprint_bold[i] = false;
146  }
147 }
const int CENTERPRINT_MAX_MSGS
Definition: centerprint.qc:34
float centerprint_time[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:41
#define strfree(this)
Definition: string.qh:56
int centerprint_msgID[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:39
bool centerprint_bold[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:40
float centerprint_expire_time[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:42
string centerprint_messages[CENTERPRINT_MAX_MSGS]
Definition: centerprint.qc:38
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_hud_panel_centerprint

bool autocvar_hud_panel_centerprint

Definition at line 4 of file centerprint.qh.

Referenced by HUD_CenterPrint().

◆ autocvar_hud_panel_centerprint_align

float autocvar_hud_panel_centerprint_align

Definition at line 5 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_dynamichud

bool autocvar_hud_panel_centerprint_dynamichud = true

Definition at line 19 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_in

float autocvar_hud_panel_centerprint_fade_in = 0.15

Definition at line 6 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_in_short

float autocvar_hud_panel_centerprint_fade_in_short = 0

Definition at line 7 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_minfontsize

float autocvar_hud_panel_centerprint_fade_minfontsize = 0

Definition at line 15 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_out

float autocvar_hud_panel_centerprint_fade_out = 0.15

Definition at line 8 of file centerprint.qh.

Referenced by centerprint_Add().

◆ autocvar_hud_panel_centerprint_fade_subsequent

float autocvar_hud_panel_centerprint_fade_subsequent = 1

Definition at line 9 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_subsequent_minfontsize

float autocvar_hud_panel_centerprint_fade_subsequent_minfontsize = 0.75

Definition at line 14 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_subsequent_passone

float autocvar_hud_panel_centerprint_fade_subsequent_passone = 3

Definition at line 10 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha

float autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha = 0.5

Definition at line 11 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_subsequent_passtwo

float autocvar_hud_panel_centerprint_fade_subsequent_passtwo = 10

Definition at line 12 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha

float autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha = 0.5

Definition at line 13 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_flip

bool autocvar_hud_panel_centerprint_flip

Definition at line 16 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fontscale

float autocvar_hud_panel_centerprint_fontscale

Definition at line 17 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_fontscale_bold

float autocvar_hud_panel_centerprint_fontscale_bold = 1.4

Definition at line 18 of file centerprint.qh.

◆ autocvar_hud_panel_centerprint_time

float autocvar_hud_panel_centerprint_time

Definition at line 20 of file centerprint.qh.

Referenced by centerprint_Add(), and centerprint_AddStandard().