Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centerprint text should also go into the console #98

Closed
hemebond opened this issue Sep 23, 2023 · 1 comment · Fixed by #159
Closed

centerprint text should also go into the console #98

hemebond opened this issue Sep 23, 2023 · 1 comment · Fixed by #159

Comments

@hemebond
Copy link
Contributor

Sometimes centerprint text can be missed. It is useful to be able to open the console to re-read what was shown.

@Baker7
Copy link

Baker7 commented Apr 2, 2024

If you are wanting to do this:

con_logcenterprint is the cvar in FitzQuake/Quakespasm engines including Ironwail ...

cvar_t con_logcenterprint = {CF_CLIENT | CF_ARCHIVE, "con_logcenterprint","1", "centerprint messages will be logged to the console in singleplayer. If 2, they will also be logged in deathmatch"}; // Baker r1421: centerprint logging to console

void Con_LogCenterPrint (const char *str)
{
	if (String_Does_Match(str, cl.lastcenterstring))
		return; //ignore duplicates

	if (cl.gametype == GAME_DEATHMATCH && con_logcenterprint.value < 2) // default 1
		return; //don't log in deathmatch

	strlcpy (cl.lastcenterstring, str, sizeof(cl.lastcenterstring));

	if (con_logcenterprint.value) {
		Con_HidenotifyPrintLinef ("\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37");
		Con_HidenotifyPrintLinef ("%s", str);
		Con_HidenotifyPrintLinef ("\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37");
	}

}

client_t struct needs:

`char		lastcenterstring[1024];`

This function is needed

// Baker r1421: centerprint logging to console
void Con_HidenotifyPrintLinef(const char *fmt, ...)
{
	va_list argptr;
	char msg[MAX_INPUTLINE_16384];

	va_start(argptr,fmt);
	dpvsnprintf(msg,sizeof(msg),fmt,argptr);
	va_end(argptr);

	int s_len = (int)strlen(msg);
	if (s_len >= MAX_INPUTLINE_16384 - 1) {
		msg[s_len - 1] = 10; // trunc
	} else {
		msg[s_len] = 10; // was 0
		msg[s_len+1] = 0; // extra
	}
	Con_MaskPrint (CON_MASK_HIDENOTIFY, msg);
}

Modified:

void SCR_CenterPrint(const char *str)
{
	Con_LogCenterPrint (str); // Baker r1421: centerprint logging to console
	c_strlcpy (scr_centerstring, str);
	scr_centertime_off = scr_centertime.value;
	scr_centertime_start = cl.time;

// count the number of lines for centering
	scr_center_lines = 1;
	while (*str)
	{
		if (*str == '\n')
			scr_center_lines++;
		str++;
	}
}

bones-was-here added a commit that referenced this issue May 28, 2024
Add new function `Con_CenterPrint` which can be used to print messages
to the console, without showing onscreen, and with a "horizontal rule"
above and below. Use `Con_CenterPrint` to log centerprint messages to
the console.


![image](https://github.com/DarkPlacesEngine/darkplaces/assets/424218/8ef0bdc4-7481-4f11-b0a3-d46e4d451c74)

Fixes #98

---------

Signed-off-by: bones_was_here <[email protected]>
Co-authored-by: bones_was_here <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants