Update menu interface, add credits

This commit is contained in:
a1batross 2015-12-22 23:48:53 +03:00
parent 8263fbafd3
commit e555173b7d
7 changed files with 122 additions and 93 deletions

View File

@ -275,6 +275,9 @@ void UI_DrawString( int x, int y, int w, int h, const char *string, const int co
if( ch == 0xB8 ) ch = (byte)'<EFBFBD>';
if( ch == 0xA8 ) ch = (byte)'<EFBFBD>';
#endif
ch = UtfProcessChar( (unsigned char) ch );
if(!ch)
continue;
if( ch != ' ' )
{
if( shadow ) TextMessageDrawChar( xx + ofsX, yy + ofsY, charW, charH, ch, shadowModulate, uiStatic.hFont );
@ -510,7 +513,7 @@ void UI_CursorMoved( menuFramework_s *menu )
if( callback ) callback( (void *)curItem, QM_LOSTFOCUS );
// Disable text editing
if( curItem->type == QMTYPE_FIELD ) g_engfuncs.pfnEnableTextInput( false );
if( curItem->type == QMTYPE_FIELD ) EnableTextInput( false );
}
if( menu->cursor >= 0 && menu->cursor < menu->numItems )
@ -521,7 +524,7 @@ void UI_CursorMoved( menuFramework_s *menu )
if( callback ) callback( (void *)curItem, QM_GOTFOCUS );
// Enable text editing. It will open keyboard on Android.
if( curItem->type == QMTYPE_FIELD ) g_engfuncs.pfnEnableTextInput( true );
if( curItem->type == QMTYPE_FIELD ) EnableTextInput( true );
}
}

View File

@ -98,7 +98,6 @@ inline HIMAGE PIC_Load( const char *szPicName, const byte *ucRawImage, long ulRa
#define CHECK_MAP_LIST (*g_engfuncs.pfnCreateMapsList)
#define HOST_ENDGAME (*g_engfuncs.pfnHostEndGame)
#define GET_CLIPBOARD (*g_engfuncs.pfnGetClipboardData)
#define SDL_FREE( x ) (*g_engfuncs.pfnSDL_free)( x )
#define FS_SEARCH (*g_engfuncs.pfnGetFilesList)
#define MAP_IS_VALID (*g_engfuncs.pfnIsMapValid)
@ -182,4 +181,33 @@ inline void TextMessageSetColor( int r, int g, int b, int alpha = 255 )
#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime)
//#define UtfProcessChar (*g_textfuncs.pfnUtfProcessChar)
//#define UtfMoveLeft (*g_textfuncs.pfnUtfMoveLeft)
//#define UtfMoveRight (*g_textfuncs.pfnUtfMoveRight)
//#define EnableTextInput (*g_textfuncs.pfnEnableTextInput)
inline void EnableTextInput( int enable )
{
if( g_textfuncs.pfnEnableTextInput )
g_textfuncs.pfnEnableTextInput( enable );
}
inline int UtfMoveRight( char *str, int pos, int length )
{
if( g_textfuncs.pfnUtfMoveRight )
return g_textfuncs.pfnUtfMoveRight( str, pos, length );
return pos + 1;
}
inline int UtfMoveLeft( char *str, int pos )
{
if( g_textfuncs.pfnUtfMoveLeft )
return g_textfuncs.pfnUtfMoveLeft( str, pos );
return pos - 1;
}
inline int UtfProcessChar( int in )
{
if( g_textfuncs.pfnUtfProcessChar )
return g_textfuncs.pfnUtfProcessChar( in );
return in;
}
#endif//ENGINECALLBACKS_H

View File

@ -27,8 +27,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static const char *uiCreditsDefault[] =
{
"Developers: ",
"a1batross and mittorn",
"",
"Beta-testers:",
"ahsim, SergioPoverony, 1.kirill, Messi",
"GFOXSH, Romka_ZVO, cerg2010cerg2010, MakcuM56",
"akhmamir, valera0141, konnor512, Pho[en]ix",
"bayan47, mars873, art-sorokin, lewa_j",
"ANIME_lover, yaruhkincssv34, kakashka99, THE_Swank",
"namotrasnik, artslay, Se Android 2.2, Smoke-Bomb",
"",
"Copyright XashXT Group 2014 (C)",
"Big thanks to Valve Corporation for Counter-Strike",
"Uncle Mike for this powerful engine",
"and Nagist for cs16nd",
"",
"Copyright SDLash3D Team 2015 (C)",
"SDLash3D is not affiliated with Valve or any of their partners.",
"All copyrights reserved to their respective owners.",
0
};
@ -41,8 +57,6 @@ typedef struct
int numLines;
int active;
int finalCredits;
char *index[UI_CREDITS_MAXLINES];
char *buffer;
menuFramework_s menu;
} uiCredits_t;
@ -61,12 +75,12 @@ static void UI_Credits_DrawFunc( void )
float speed = 40.0f;
int w = UI_MED_CHAR_WIDTH;
int h = UI_MED_CHAR_HEIGHT;
int color = 0;
int color = 0x00FFA000;
// draw the background first
if( !uiCredits.finalCredits && !CVAR_GET_FLOAT( "cl_background" ))
/*if( !uiCredits.finalCredits && !CVAR_GET_FLOAT( "cl_background" ))
UI_DrawPic( 0, 0, 1024 * uiStatic.scaleX, 768 * uiStatic.scaleY, uiColorWhite, ART_BACKGROUND );
else speed = 45.0f; // syncronize with final background track :-)
else speed = 45.0f; // syncronize with final background track :-)*/
// otherwise running on cutscene
speed = 32.0f * (768.0f / ScreenHeight);
@ -130,56 +144,9 @@ static void UI_Credits_Init( void )
uiCredits.menu.drawFunc = UI_Credits_DrawFunc;
uiCredits.menu.keyFunc = UI_Credits_KeyFunc;
if( !uiCredits.buffer )
{
int count;
char *p;
// load credits if needed
uiCredits.buffer = (char *)LOAD_FILE( UI_CREDITS_PATH, &count );
if( count )
{
if( uiCredits.buffer[count - 1] != '\n' && uiCredits.buffer[count - 1] != '\r' )
{
char *tmp = (char *)MALLOC( count + 2 );
memcpy( tmp, uiCredits.buffer, count );
FREE_FILE( uiCredits.buffer );
uiCredits.buffer = tmp;
strncpy( uiCredits.buffer + count, "\r", 1 ); // add terminator
count += 2; // added "\r\0"
}
p = uiCredits.buffer;
// convert customs credits to 'ideal' strings array
for ( uiCredits.numLines = 0; uiCredits.numLines < UI_CREDITS_MAXLINES; uiCredits.numLines++ )
{
uiCredits.index[uiCredits.numLines] = p;
while ( *p != '\r' && *p != '\n' )
{
p++;
if ( --count == 0 )
break;
}
if ( *p == '\r' )
{
*p++ = 0;
if( --count == 0 ) break;
}
*p++ = 0;
if( --count == 0 ) break;
}
uiCredits.index[++uiCredits.numLines] = 0;
uiCredits.credits = (const char **)uiCredits.index;
}
else
{
// use built-in credits
uiCredits.credits = uiCreditsDefault;
uiCredits.numLines = ( sizeof( uiCreditsDefault ) / sizeof( uiCreditsDefault[0] )) - 1; // skip term
}
}
// use built-in credits
uiCredits.credits = uiCreditsDefault;
uiCredits.numLines = ( sizeof( uiCreditsDefault ) / sizeof( uiCreditsDefault[0] )) - 1; // skip term
// run credits
uiCredits.startTime = (gpGlobals->time * 1000) + 500; // make half-seconds delay

View File

@ -58,6 +58,7 @@ typedef struct
menuPicButton_s console;
menuPicButton_s resumeGame;
menuPicButton_s configuration;
menuPicButton_s credits;
menuPicButton_s multiPlayer;
menuPicButton_s quit;
@ -193,7 +194,7 @@ static void UI_Main_ActivateFunc( void )
if( gpGlobals->developer )
{
uiMain.console.generic.y = CL_IsActive() ? 430 : 480;
uiMain.console.generic.y = CL_IsActive() ? 480 : 430;
UI_ScaleCoords( NULL, &uiMain.console.generic.y, NULL, NULL );
}
}
@ -261,7 +262,7 @@ static void UI_Main_Callback( void *self, int event )
UI_Options_Menu();
break;
case ID_PREVIEWS:
SHELL_EXECUTE( MenuStrings[HINT_PREVIEWS_CMD], NULL, false );
UI_Credits_Menu( );
break;
case ID_QUIT:
case ID_QUIT_BUTTON:
@ -320,7 +321,7 @@ static void UI_Main_Init( void )
uiMain.console.generic.name = "Console";
uiMain.console.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW;
uiMain.console.generic.x = 72;
uiMain.console.generic.y = CL_IsActive() ? 430 : 480;
uiMain.console.generic.y = CL_IsActive() ? 330 : 380;
uiMain.console.generic.callback = UI_Main_Callback;
UI_UtilSetupPicButton( &uiMain.console, PC_CONSOLE );
@ -331,7 +332,7 @@ static void UI_Main_Init( void )
uiMain.resumeGame.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_NOTIFY;
uiMain.resumeGame.generic.statusText = MenuStrings[HINT_RESUME_GAME];
uiMain.resumeGame.generic.x = 72;
uiMain.resumeGame.generic.y = 480;
uiMain.resumeGame.generic.y = 430;
uiMain.resumeGame.generic.callback = UI_Main_Callback;
UI_UtilSetupPicButton( &uiMain.resumeGame, PC_RESUME_GAME );
@ -347,7 +348,7 @@ static void UI_Main_Init( void )
uiMain.multiPlayer.generic.name = "Multiplayer";
uiMain.multiPlayer.generic.statusText = MenuStrings[HINT_MULTIPLAYER];
uiMain.multiPlayer.generic.x = 72;
uiMain.multiPlayer.generic.y = 530 ;
uiMain.multiPlayer.generic.y = 480 ;
uiMain.multiPlayer.generic.callback = UI_Main_Callback;
UI_UtilSetupPicButton( &uiMain.multiPlayer, PC_MULTIPLAYER );
@ -358,10 +359,21 @@ static void UI_Main_Init( void )
uiMain.configuration.generic.name = "Configuration";
uiMain.configuration.generic.statusText = MenuStrings[HINT_CONFIGURATION];
uiMain.configuration.generic.x = 72;
uiMain.configuration.generic.y = 580;
uiMain.configuration.generic.y = 530;
uiMain.configuration.generic.callback = UI_Main_Callback;
UI_UtilSetupPicButton( &uiMain.configuration, PC_CONFIG );
uiMain.credits.generic.id = ID_PREVIEWS;
uiMain.credits.generic.type = QMTYPE_BM_BUTTON;
uiMain.credits.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_NOTIFY;
uiMain.credits.generic.name = "Credits";
uiMain.credits.generic.statusText = "Developer credits";
uiMain.credits.generic.x = 72;
uiMain.credits.generic.y = 580;
uiMain.credits.generic.callback = UI_Main_Callback;
UI_UtilSetupPicButton( &uiMain.credits, PC_VIEW_README );
if ( gMenu.m_gameinfo.gamemode == GAME_SINGLEPLAYER_ONLY )
uiMain.multiPlayer.generic.flags |= QMF_GRAYED;
@ -455,6 +467,7 @@ static void UI_Main_Init( void )
UI_AddItem( &uiMain.menu, (void *)&uiMain.configuration );
UI_AddItem( &uiMain.menu, (void *)&uiMain.multiPlayer );
UI_AddItem( &uiMain.menu, (void *)&uiMain.credits );
UI_AddItem( &uiMain.menu, (void *)&uiMain.quit );
UI_AddItem( &uiMain.menu, (void *)&uiMain.minimizeBtn );

View File

@ -18,6 +18,7 @@ GNU General Public License for more details.
#include "utils.h"
ui_enginefuncs_t g_engfuncs;
ui_textfuncs_t g_textfuncs;
ui_globalvars_t *gpGlobals;
CMenu gMenu;
@ -60,8 +61,22 @@ extern "C" EXPORT int GetMenuAPI(UI_FUNCTIONS *pFunctionTable, ui_enginefuncs_t*
// copy HUD_FUNCTIONS table to engine, copy engfuncs table from engine
memcpy( pFunctionTable, &gFunctionTable, sizeof( UI_FUNCTIONS ));
memcpy( &g_engfuncs, pEngfuncsFromEngine, sizeof( ui_enginefuncs_t ));
memset( &g_textfuncs, 0, sizeof( ui_textfuncs_t ));
gpGlobals = pGlobals;
return TRUE;
}
extern "C" EXPORT int GiveTextAPI( ui_enginefuncs_t* pTextfuncsFromEngine )
{
if( !pTextfuncsFromEngine )
{
return FALSE;
}
// copy HUD_FUNCTIONS table to engine, copy engfuncs table from engine
memcpy( &g_textfuncs, pTextfuncsFromEngine, sizeof( ui_textfuncs_t ));
return TRUE;
}

View File

@ -51,7 +51,7 @@ int ColorStrlen( const char *str )
int len = 0;
p = str;
UtfProcessChar( 0 );
while( *p )
{
if( IsColorString( p ))
@ -61,8 +61,10 @@ int ColorStrlen( const char *str )
}
p++;
len++;
if( UtfProcessChar( (unsigned char) *p ) )
len++;
}
len++;
return len;
}
@ -178,45 +180,44 @@ key and returns the associated value, or an empty string.
*/
char *Info_ValueForKey( const char *s, const char *key )
{
static char value[MAX_INFO_STRING];
char pkey[MAX_INFO_STRING];
static char value[2][MAX_INFO_STRING]; // use two buffers so compares work without stomping on each other
static int valueindex;
char *o;
valueindex ^= 1;
if( *s == '\\' ) s++;
printf("I_VFK '%s' '%s'\n", s, key );
if ( *s == '\\' )
s++;
while ( 1 )
while( 1 )
{
char *o = pkey;
while ( *s != '\\' && *s != '\n' )
o = pkey;
while( *s != '\\' && *s != '\n' )
{
if ( !*s )
return "";
if( !*s ) return "";
*o++ = *s++;
}
*o = 0;
s++;
o = value;
o = value[valueindex];
while ( *s != '\\' && *s != '\n' && *s )
while( *s != '\\' && *s != '\n' && *s )
{
if ( !*s )
return "";
if( !*s ) return "";
*o++ = *s++;
}
*o = 0;
if ( !strcmp( key, pkey ))
return value;
if ( !*s )
return "";
if( !strcmp( key, pkey ))
return value[valueindex];
if( !*s ) return "";
s++;
}
}
/*
===================
Key_GetKey
@ -1412,7 +1413,7 @@ void UI_Field_Paste( void )
pasteLen = strlen( str );
for( i = 0; i < pasteLen; i++ )
UI_CharEvent( str[i] );
SDL_FREE( str );
FREE( str );
}
/*
@ -1458,7 +1459,7 @@ const char *UI_Field_Key( menuField_s *f, int key, int down )
// previous character
if( key == K_LEFTARROW )
{
if( f->cursor > 0 ) f->cursor--;
if( f->cursor > 0 ) f->cursor = UtfMoveLeft( f->buffer, f->cursor );
if( f->cursor < f->scroll ) f->scroll--;
return uiSoundNull;
}
@ -1466,7 +1467,7 @@ const char *UI_Field_Key( menuField_s *f, int key, int down )
// next character
if( key == K_RIGHTARROW )
{
if( f->cursor < len ) f->cursor++;
if( f->cursor < len ) f->cursor = UtfMoveRight( f->buffer, f->cursor, len );
if( f->cursor >= f->scroll + f->widthInChars && f->cursor <= len )
f->scroll++;
return uiSoundNull;
@ -1490,8 +1491,9 @@ const char *UI_Field_Key( menuField_s *f, int key, int down )
{
if( f->cursor > 0 )
{
memmove( f->buffer + f->cursor - 1, f->buffer + f->cursor, len - f->cursor + 1 );
f->cursor--;
int pos = UtfMoveLeft( f->buffer, f->cursor );
memmove( f->buffer + pos, f->buffer + f->cursor, len - f->cursor + 1 );
f->cursor = pos;
if( f->scroll ) f->scroll--;
}
}
@ -1548,7 +1550,7 @@ void UI_Field_Char( menuField_s *f, int key )
}
// ignore any other non printable chars
if( key < 32 ) return;
//if( key < 32 ) return;
if( key == '^' && !( f->generic.flags & QMF_ALLOW_COLORSTRINGS ))
{
@ -2237,4 +2239,4 @@ void UI_PicButton_Draw( menuPicButton_s *item )
if( item->generic.flags & QMF_FOCUSBEHIND )
UI_DrawString( item->generic.x, item->generic.y, item->generic.width, item->generic.height, item->generic.name, item->generic.color, false, item->generic.charWidth, item->generic.charHeight, justify, shadow );
}
}
}

View File

@ -17,6 +17,7 @@ GNU General Public License for more details.
#define UTILS_H
extern ui_enginefuncs_t g_engfuncs;
extern ui_textfuncs_t g_textfuncs;
#include "enginecallback.h"
#include "gameinfo.h"