This is an automated email from the git hooks/post-receive script. smcv pushed a commit to branch debian/master in repository openjk.
commit 59548a41db45518b5f6cc95e5c6ed6bb66769e24 Author: Ensiform <[email protected]> Date: Sat Mar 11 17:06:22 2017 -0600 SP: Merge ui_screenshotType additions from MP --- code/ui/ui_main.cpp | 130 +++++++++++++++++++++++++++++++++++++------------- code/ui/ui_shared.cpp | 18 ++++++- code/ui/ui_shared.h | 8 ++++ 3 files changed, 122 insertions(+), 34 deletions(-) diff --git a/code/ui/ui_main.cpp b/code/ui/ui_main.cpp index 2fd0aae..d229261 100644 --- a/code/ui/ui_main.cpp +++ b/code/ui/ui_main.cpp @@ -354,15 +354,39 @@ uiInfo_t uiInfo; static void UI_RegisterCvars( void ); void UI_Load(void); +static int UI_GetScreenshotFormatForString( const char *str ) { + if ( !Q_stricmp(str, "jpg") || !Q_stricmp(str, "jpeg") ) + return SSF_JPEG; + else if ( !Q_stricmp(str, "tga") ) + return SSF_TGA; + else if ( !Q_stricmp(str, "png") ) + return SSF_PNG; + else + return -1; +} -typedef struct { +static const char *UI_GetScreenshotFormatString( int format ) +{ + switch ( format ) + { + default: + case SSF_JPEG: + return "jpg"; + case SSF_TGA: + return "tga"; + case SSF_PNG: + return "png"; + } +} + +typedef struct cvarTable_s { vmCvar_t *vmCvar; const char *cvarName; const char *defaultString; - int cvarFlags; + void (*update)( void ); + uint32_t cvarFlags; } cvarTable_t; - vmCvar_t ui_menuFiles; vmCvar_t ui_hudFiles; @@ -380,40 +404,76 @@ vmCvar_t ui_char_color_red; vmCvar_t ui_char_color_green; vmCvar_t ui_char_color_blue; vmCvar_t ui_PrecacheModels; +vmCvar_t ui_screenshotType; + +static void UI_UpdateScreenshot( void ) +{ + qboolean changed = qfalse; + // check some things + if ( ui_screenshotType.string[0] && isalpha( ui_screenshotType.string[0] ) ) + { + int ssf = UI_GetScreenshotFormatForString( ui_screenshotType.string ); + if ( ssf == -1 ) + { + ui.Printf( "UI Screenshot Format Type '%s' unrecognised, defaulting to JPEG\n", ui_screenshotType.string ); + uiInfo.uiDC.screenshotFormat = SSF_JPEG; + changed = qtrue; + } + else + uiInfo.uiDC.screenshotFormat = ssf; + } + else if ( ui_screenshotType.integer < SSF_JPEG || ui_screenshotType.integer > SSF_PNG ) + { + ui.Printf( "ui_screenshotType %i is out of range, defaulting to 0 (JPEG)\n", ui_screenshotType.integer ); + uiInfo.uiDC.screenshotFormat = SSF_JPEG; + changed = qtrue; + } + else { + uiInfo.uiDC.screenshotFormat = atoi( ui_screenshotType.string ); + changed = qtrue; + } + + if ( changed ) { + Cvar_Set( "ui_screenshotType", UI_GetScreenshotFormatString( uiInfo.uiDC.screenshotFormat ) ); + Cvar_Update( &ui_screenshotType ); + } +} static cvarTable_t cvarTable[] = { - { &ui_menuFiles, "ui_menuFiles", "ui/menus.txt", CVAR_ARCHIVE }, + { &ui_menuFiles, "ui_menuFiles", "ui/menus.txt", NULL, CVAR_ARCHIVE }, #ifdef JK2_MODE - { &ui_hudFiles, "cg_hudFiles", "ui/jk2hud.txt",CVAR_ARCHIVE}, + { &ui_hudFiles, "cg_hudFiles", "ui/jk2hud.txt", NULL, CVAR_ARCHIVE}, #else - { &ui_hudFiles, "cg_hudFiles", "ui/jahud.txt",CVAR_ARCHIVE}, + { &ui_hudFiles, "cg_hudFiles", "ui/jahud.txt", NULL, CVAR_ARCHIVE}, #endif - { &ui_char_anim, "ui_char_anim", "BOTH_WALK1",0}, + { &ui_char_anim, "ui_char_anim", "BOTH_WALK1", NULL, 0}, - { &ui_char_model, "ui_char_model", "",0}, //these are filled in by the "g_*" versions on load - { &ui_char_skin_head, "ui_char_skin_head", "",0}, //the "g_*" versions are initialized in UI_Init, ui_atoms.cpp - { &ui_char_skin_torso, "ui_char_skin_torso", "",0}, - { &ui_char_skin_legs, "ui_char_skin_legs", "",0}, + { &ui_char_model, "ui_char_model", "", NULL, 0}, //these are filled in by the "g_*" versions on load + { &ui_char_skin_head, "ui_char_skin_head", "", NULL, 0}, //the "g_*" versions are initialized in UI_Init, ui_atoms.cpp + { &ui_char_skin_torso, "ui_char_skin_torso", "", NULL, 0}, + { &ui_char_skin_legs, "ui_char_skin_legs", "", NULL, 0}, - { &ui_saber_type, "ui_saber_type", "",0}, - { &ui_saber, "ui_saber", "",0}, - { &ui_saber2, "ui_saber2", "",0}, - { &ui_saber_color, "ui_saber_color", "",0}, - { &ui_saber2_color, "ui_saber2_color", "",0}, + { &ui_saber_type, "ui_saber_type", "", NULL, 0}, + { &ui_saber, "ui_saber", "", NULL, 0}, + { &ui_saber2, "ui_saber2", "", NULL, 0}, + { &ui_saber_color, "ui_saber_color", "", NULL, 0}, + { &ui_saber2_color, "ui_saber2_color", "", NULL, 0}, - { &ui_char_color_red, "ui_char_color_red", "", 0}, - { &ui_char_color_green, "ui_char_color_green", "", 0}, - { &ui_char_color_blue, "ui_char_color_blue", "", 0}, + { &ui_char_color_red, "ui_char_color_red", "", NULL, 0}, + { &ui_char_color_green, "ui_char_color_green", "", NULL, 0}, + { &ui_char_color_blue, "ui_char_color_blue", "", NULL, 0}, - { &ui_PrecacheModels, "ui_PrecacheModels", "1", CVAR_ARCHIVE}, + { &ui_PrecacheModels, "ui_PrecacheModels", "1", NULL, CVAR_ARCHIVE}, + + { &ui_screenshotType, "ui_screenshotType", "jpg", UI_UpdateScreenshot, CVAR_ARCHIVE } }; #define FP_UPDATED_NONE -1 #define NOWEAPON -1 -static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]); +static const size_t cvarTableSize = ARRAY_LEN( cvarTable ); void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, int iMaxPixelWidth, int style, int iFontIndex); int Key_GetCatcher( void ); @@ -461,8 +521,6 @@ void _UI_Refresh( int realtime ) uiInfo.uiDC.FPS = 1000 * UI_FPS_FRAMES / total; } - - UI_UpdateCvars(); if (Menu_Count() > 0) @@ -2719,7 +2777,6 @@ void _UI_Init( qboolean inGameLoad ) } - /* ================= UI_RegisterCvars @@ -2727,12 +2784,13 @@ UI_RegisterCvars */ static void UI_RegisterCvars( void ) { - int i; - cvarTable_t *cv; + size_t i = 0; + const cvarTable_t *cv = NULL; - for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) - { + for ( i=0, cv=cvarTable; i<cvarTableSize; i++, cv++ ) { Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags ); + if ( cv->update ) + cv->update(); } } @@ -3600,12 +3658,18 @@ UI_UpdateCvars */ void UI_UpdateCvars( void ) { - int i; - cvarTable_t *cv; + size_t i = 0; + const cvarTable_t *cv = NULL; - for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) - { - Cvar_Update( cv->vmCvar ); + for ( i=0, cv=cvarTable; i<cvarTableSize; i++, cv++ ) { + if ( cv->vmCvar ) { + int modCount = cv->vmCvar->modificationCount; + Cvar_Update( cv->vmCvar ); + if ( cv->vmCvar->modificationCount != modCount ) { + if ( cv->update ) + cv->update(); + } + } } } diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 2ab8b1a..379e677 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -11283,7 +11283,23 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) case A_F12: if (DC->getCVarValue("developer")) { - DC->executeText(EXEC_APPEND, "screenshot\n"); + switch ( DC->screenshotFormat ) + { + case SSF_JPEG: + DC->executeText(EXEC_APPEND, "screenshot\n"); + break; + case SSF_TGA: + DC->executeText(EXEC_APPEND, "screenshot_tga\n"); + break; + case SSF_PNG: + DC->executeText(EXEC_APPEND, "screenshot_png\n"); + break; + default: + if (DC->Print) { + DC->Print(S_COLOR_YELLOW "Menu_HandleKey[F12]: Unknown screenshot format assigned! This should not happen.\n"); + } + break; + } } break; case A_KP_8: diff --git a/code/ui/ui_shared.h b/code/ui/ui_shared.h index a661370..1eb849e 100644 --- a/code/ui/ui_shared.h +++ b/code/ui/ui_shared.h @@ -24,6 +24,12 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. #ifndef __UI_SHARED_H #define __UI_SHARED_H +enum { + SSF_JPEG = 0, + SSF_TGA, + SSF_PNG +}; + #define MAX_TOKENLENGTH 1024 #define MAX_OPEN_MENUS 16 #define MAX_TEXTSCROLL_LINES 256 @@ -239,6 +245,8 @@ typedef struct { qhandle_t gradientImage; float FPS; + int screenshotFormat; + } displayContextDef_t; void UI_InitMemory( void ); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

