コード例 #1
0
ファイル: cl_console.c プロジェクト: chrisnew/quetoo
/*
 * @brief Initializes the client console.
 */
void Cl_InitConsole(void) {

	memset(&cl_console, 0, sizeof(cl_console));

	cl_console.Append = Cl_Print;

	Con_AddConsole(&cl_console);

	file_t *file = Fs_OpenRead("history");
	if (file) {
		Con_ReadHistory(&cl_console, file);
		Fs_Close(file);
	} else {
		Com_Debug("Couldn't read history");
	}

	memset(&cl_chat_console, 0, sizeof(cl_chat_console));
	cl_chat_console.level = PRINT_CHAT | PRINT_TEAM_CHAT;
	
	cl_draw_chat = Cvar_Get("cl_draw_chat", "1", 0, "Draw recent chat messages");
	cl_draw_notify = Cvar_Get("cl_draw_notify", "1", 0, "Draw recent console activity");

	cl_notify_lines = Cvar_Get("cl_console_notify_lines", "3", CVAR_ARCHIVE, NULL);
	cl_notify_time = Cvar_Get("cl_notify_time", "3.0", CVAR_ARCHIVE, NULL);

	cl_chat_lines = Cvar_Get("cl_chat_lines", "3", CVAR_ARCHIVE, NULL);
	cl_chat_time = Cvar_Get("cl_chat_time", "10.0", CVAR_ARCHIVE, NULL);

	Cmd_Add("cl_toggle_console", Cl_ToggleConsole_f, CMD_SYSTEM | CMD_CLIENT, "Toggle the console");
	Cmd_Add("cl_message_mode", Cl_MessageMode_f, CMD_CLIENT, "Activate chat");
	Cmd_Add("cl_message_mode_2", Cl_MessageMode2_f, CMD_CLIENT, "Activate team chat");

	Com_Print("Client console initialized\n");
}
コード例 #2
0
ファイル: sv_console.c プロジェクト: jdolan/quetoo
/**
 * @brief
 */
void Sv_InitConsole(void) {

	if (!dedicated->value) {
		return;
	}

#if defined(_WIN32)
	if (AllocConsole()) {
		freopen("CONIN$", "r", stdin);
		freopen("CONOUT$", "w", stdout);
		freopen("CONERR$", "w", stderr);
	} else {
		Com_Warn("Failed to allocate console: %u\n", (uint32_t) GetLastError());
	}
#endif

	memset(&sv_console_state, 0, sizeof(sv_console_state));

	sv_console_state.window = initscr();
	sv_console_state.dirty = true;

	cbreak();
	noecho();
	keypad(sv_console_state.window, TRUE);
	nodelay(sv_console_state.window, TRUE);
	curs_set(1);

	if (has_colors() == TRUE) {
		start_color();
		use_default_colors();
		init_pair(CON_COLOR_RED, COLOR_RED, -1);
		init_pair(CON_COLOR_GREEN, COLOR_GREEN, -1);
		init_pair(CON_COLOR_YELLOW, COLOR_YELLOW, -1);
		init_pair(CON_COLOR_BLUE, COLOR_BLUE, -1);
		init_pair(CON_COLOR_CYAN, COLOR_CYAN, -1);
		init_pair(CON_COLOR_MAGENTA, COLOR_MAGENTA, -1);
		init_pair(CON_COLOR_WHITE, COLOR_WHITE, -1);
	}

#ifdef SIGWINCH
	signal(SIGWINCH, Sv_ResizeConsole);
#endif

	memset(&sv_console, 0, sizeof(sv_console));

	sv_console.Append = Sv_Print;

	Con_AddConsole(&sv_console);

	if (dedicated->value) {
		file_t *file = Fs_OpenRead("history");
		if (file) {
			Con_ReadHistory(&sv_console, file);
			Fs_Close(file);
		} else {
			Com_Debug(DEBUG_SERVER, "Couldn't read history");
		}
	}

	Com_Print("Server console initialized\n");
}