panel.current_panel_bg,
mySize + '1 1 0' * 2 * panel_bg_border,
panel_bg_color, panel_bg_alpha,
- '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));
+ '1 1 0' * BORDER_MULTIPLIER * panel_bg_border);
drawpic(pos, board_texture, mySize, '1 1 1', panel_bg_alpha, DRAWFLAG_NORMAL);
}
void minigame_autoclean_entity(entity e)
{
- LOG_DEBUG("CL Auto-cleaned: ",ftos(etof(e)), " (",e.classname,")\n");
- remove(e);
+ LOG_DEBUG("CL Auto-cleaned: ",ftos(etof(e)), " (",e.classname,")");
+ delete(e);
}
void HUD_MinigameMenu_CurrentButton();
if ( !minigame.descriptor || minigame.classname != "minigame" )
{
- LOG_TRACE("Trying to activate unregistered minigame ",minigame.netname," in client\n");
+ LOG_TRACE("Trying to activate unregistered minigame ",minigame.netname," in client");
return;
}
this.owner = find(this.owner,netname,owner_name);
while ( this.owner && this.owner.classname != "minigame" );
if ( !this.owner )
- LOG_TRACE("Got a minigame entity without a minigame!\n");
+ LOG_TRACE("Got a minigame entity without a minigame!");
}
NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew)
{
this.entremove = minigame_entremove;
this.descriptor = minigame_get_descriptor(ReadString_Raw());
if ( !this.descriptor )
- LOG_TRACE("Got a minigame without a client-side descriptor!\n");
+ LOG_TRACE("Got a minigame without a client-side descriptor!");
else
this.minigame_event = this.descriptor.minigame_event;
}
minigame_read_owner(this);
float ent = ReadLong();
this.minigame_playerslot = ent;
- LOG_DEBUG("Player: ",entcs_GetName(ent-1),"\n");
+ LOG_DEBUG("Player: ",entcs_GetName(ent-1));
activate = (ent == player_localnum+1 && this.owner && this.owner != active_minigame);
{
minigame_self = this;
activate_minigame(this.owner);
+ minigame_self = this; // set it again (needed before, but may also be reset)
}
}
MINIGAME_SIMPLELINKED_ENTITIES
{
LOG_DEBUG("CL Reading entity: ",ftos(etof(this)),
" classname:",this.classname," enttype:",ftos(this.enttype) );
- LOG_DEBUG(" sf:",ftos(sf)," netname:",this.netname,"\n\n");
+ LOG_DEBUG(" sf:",ftos(sf)," netname:",this.netname);
}
return true;
}
#undef FIELD
#undef MSLE
-string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
+void minigame_show_allspecs(vector boardpos, vector boardsize)
{
- int last_word;
- string s;
- int take_until;
- int skip = 0;
+ string allspecs = "";
+ float allspecs_width = 0;
+ float max_allspecs_width = boardsize.x;
+ float max_current_spec_width = hud_fontsize.x * 5;
+ int allspecs_lines = 2;
+
+ entity e;
+ FOREACH_MINIGAME_ENTITY(e)
+ {
+ if (allspecs_width >= 0 && e.classname == "minigame_player" && e.team == C4_SPECTATOR_TEAM)
+ {
+ string current_spec = ColorTranslateRGB(entcs_GetName(e.minigame_playerslot - 1));
+ current_spec = textShortenToWidth(current_spec, max_current_spec_width, hud_fontsize, stringwidth_colors);
+ if (allspecs != "")
+ current_spec = strcat(", ", current_spec);
+ else
+ current_spec = current_spec;
+
+ allspecs_width = stringwidth(allspecs, true, hud_fontsize);
+
+ float max_width = max_allspecs_width * allspecs_lines - max_current_spec_width;
+ if (allspecs_width + stringwidth(current_spec, true, hud_fontsize) < max_width)
+ allspecs = strcat(allspecs, current_spec);
+ else
+ {
+ // current_spec doesn't fit in the list
+ allspecs = strcat(allspecs, ", ...");
+ allspecs_width = -1; // skip remaining spectators
+ }
+ }
+ }
+
+ if (allspecs != "")
+ {
+ vector pos = boardpos;
+ pos.y -= panel_bg_border + hud_fontsize.y * (1.25 + allspecs_lines + 0.5);
+ minigame_drawstring_wrapped(max_allspecs_width, pos, _("Spectators:"), hud_fontsize * 1.25, '0.85 0.47 0.42', panel_fg_alpha, DRAWFLAG_NORMAL, 0);
+
+ pos.y += hud_fontsize.y * 1.25;
+ minigame_drawcolorcodedstring_wrapped(max_allspecs_width, pos, allspecs, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL, 0);
+ }
+}
- s = getWrappedLine_remaining;
+string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
+{
+ string s = getWrappedLine_remaining;
if(w <= 0)
{
return s; // the line has no size ANYWAY, nothing would be displayed.
}
- take_until = textLengthUpToWidth(s, w, theFontSize, tw);
+ int take_until = textLengthUpToWidth(s, w, theFontSize, tw);
if ( take_until > strlen(s) )
take_until = strlen(s);
- for ( int i = 0; i < take_until; i++ )
+ int skip = 0;
+ for ( int i = 0; i < take_until; ++i )
if ( substring(s,i,1) == "\n" )
{
take_until = i;
{
if ( skip == 0 && take_until < strlen(s) )
{
- last_word = take_until;
+ int last_word = take_until;
while(last_word > 0 && substring(s, last_word, 1) != " ")
--last_word;
string cmd;
cmd = "cmd minigame ";
float i;
- for ( i = 0; i < cmdargc; i++ )
+ for ( i = 0; i < cmdargc; ++i )
cmd = strcat(cmd,...(i,string));
localcmd(strcat(cmd,"\n"));
}
if(argv(1) == "minigame")
{
+ if (isdemo())
+ return true; // minigames can't function properly in demo mode
if (HUD_MinigameMenu_IsOpened())
HUD_MinigameMenu_Close(NULL, NULL, NULL);
else