summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2002-04-01 15:10:34 +0000
committerTim Angus <tim@ngus.net>2002-04-01 15:10:34 +0000
commit980ea0250159a10c8e14e11f580e5c97b81b6263 (patch)
treec85f8bba78f88dd730a9377cd83fb30b65541b16 /src/ui
parent944a6bd6d99e66bb0d4cc3b5d53ff7322c7e6837 (diff)
Partial infopanes implementation
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_local.h18
-rw-r--r--src/ui/ui_main.c168
2 files changed, 184 insertions, 2 deletions
diff --git a/src/ui/ui_local.h b/src/ui/ui_local.h
index 98626059..6079e867 100644
--- a/src/ui/ui_local.h
+++ b/src/ui/ui_local.h
@@ -749,10 +749,21 @@ typedef struct {
} modInfo_t;
//TA: tremulous menus
+#define MAX_INFOPANE_LINES 16
+#define MAX_INFOPANES 16
+
typedef struct
{
- const char *text;
- const char *cmd;
+ const char *name;
+ const char *lines[ MAX_INFOPANE_LINES ];
+ int numLines;
+} tremInfoPane_t;
+
+typedef struct
+{
+ const char *text;
+ const char *cmd;
+ tremInfoPane_t *infopane;
} tremMenuItem_t;
//TA: tremulous menus
@@ -815,6 +826,9 @@ typedef struct {
int movieIndex;
int previewMovie;
+ tremInfoPane_t tremInfoPanes[ MAX_INFOPANES ];
+ int tremInfoPaneCount;
+
//TA: tremulous menus
tremMenuItem_t tremTeamList[ 3 ];
int tremTeamCount;
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index 55da8aa9..abf61bf3 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -917,6 +917,133 @@ void UI_ParseMenu(const char *menuFile) {
trap_PC_FreeSource(handle);
}
+/*
+===============
+UI_FindInfoPaneByName
+===============
+*/
+tremInfoPane_t *UI_FindInfoPaneByName( const char *name )
+{
+ int i;
+
+ for( i = 0; i < uiInfo.tremInfoPaneCount; i++ )
+ {
+ if( !Q_stricmp( uiInfo.tremInfoPanes[ i ].name, name ) )
+ return &uiInfo.tremInfoPanes[ i ];
+ }
+
+ return NULL;
+}
+
+/*
+===============
+UI_LoadInfoPane
+===============
+*/
+qboolean UI_LoadInfoPane( int handle )
+{
+ pc_token_t token;
+ qboolean valid = qfalse;
+
+ while( 1 )
+ {
+ memset( &token, 0, sizeof( pc_token_t ) );
+
+ if( !trap_PC_ReadToken( handle, &token ) )
+ break;
+
+ if( !Q_stricmp( token.string, "name" ) )
+ {
+ memset( &token, 0, sizeof( pc_token_t ) );
+
+ if( !trap_PC_ReadToken( handle, &token ) )
+ break;
+
+ uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].name = String_Alloc( token.string );
+ valid = qtrue;
+ }
+ else if( !Q_stricmp( token.string, "line" ) )
+ {
+ int *line;
+
+ memset( &token, 0, sizeof( pc_token_t ) );
+
+ if( !trap_PC_ReadToken( handle, &token ) )
+ break;
+
+ line = &uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].numLines;
+
+ uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].lines[ *line ] = String_Alloc( token.string );
+
+ //increment lines
+ (*line)++;
+
+ if( *line == MAX_INFOPANE_LINES )
+ break;
+ }
+ else if( token.string[ 0 ] == '}' )
+ {
+ //reached the end, break
+ break;
+ }
+ else
+ break;
+ }
+
+ if( valid )
+ {
+ uiInfo.tremInfoPaneCount++;
+ return qtrue;
+ }
+ else
+ {
+ uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].numLines = 0;
+ return qfalse;
+ }
+}
+
+/*
+===============
+UI_LoadInfoPanes
+===============
+*/
+void UI_LoadInfoPanes( const char *file )
+{
+ pc_token_t token;
+ int handle;
+ int count;
+
+ uiInfo.tremInfoPaneCount = 0;
+
+ handle = trap_PC_LoadSource( file );
+
+ if( !handle )
+ {
+ trap_Error( va( S_COLOR_YELLOW "infopane file not found: %s\n", file ) );
+ return;
+ }
+
+ while( 1 )
+ {
+ if( !trap_PC_ReadToken( handle, &token ) )
+ break;
+
+ if( token.string[ 0 ] == 0 )
+ break;
+
+ if( token.string[ 0 ] == '{' )
+ {
+ if( UI_LoadInfoPane( handle ) )
+ count++;
+
+ if( count == MAX_INFOPANES )
+ break;
+ }
+ }
+
+ trap_PC_FreeSource( handle );
+}
+
qboolean Load_Menu(int handle) {
pc_token_t token;
@@ -1157,6 +1284,26 @@ static void UI_DrawDialogText( rectDef_t *rect, float scale, vec4_t color,
Text_Paint( rect->x, rect->y, scale, color, text, 0, 0, textStyle );
}
+static void UI_RenderInfoPane( tremInfoPane_t *pane, rectDef_t *rect, float scale, vec4_t color, int textStyle )
+{
+ int i;
+
+ for( i = 0; i < pane->numLines; i++ )
+ {
+ int height = Text_Height( pane->lines[ i ], scale, 0 );
+
+ Text_Paint( rect->x, rect->y + i * height * 1.5, scale, color, pane->lines[ i ], 0, 0, textStyle );
+ }
+}
+
+static void UI_DrawTeamInfoPane( rectDef_t *rect, float scale, vec4_t color, int textStyle )
+{
+ tremInfoPane_t *pane = NULL;
+
+ if( pane = uiInfo.tremTeamList[ uiInfo.tremTeamIndex ].infopane )
+ UI_RenderInfoPane( pane, rect, scale, color, textStyle );
+}
+
static void UI_DrawSkill(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
int i;
@@ -2011,6 +2158,10 @@ static void UI_OwnerDraw(float x, float y, float w, float h, float text_x, float
UI_DrawDialogText( &rect, scale, color, textStyle );
break;
+ case UI_TEAMINFOPANE:
+ UI_DrawTeamInfoPane( &rect, scale, color, textStyle );
+ break;
+
case UI_HANDICAP:
UI_DrawHandicap(&rect, scale, color, textStyle);
break;
@@ -2871,12 +3022,15 @@ static void UI_LoadTremTeams( )
uiInfo.tremTeamCount = 3;
uiInfo.tremTeamList[ 0 ].text = String_Alloc( "Aliens" );
uiInfo.tremTeamList[ 0 ].cmd = String_Alloc( "cmd team aliens" );
+ uiInfo.tremTeamList[ 0 ].infopane = UI_FindInfoPaneByName( "alienteam" );
uiInfo.tremTeamList[ 1 ].text = String_Alloc( "Humans" );
uiInfo.tremTeamList[ 1 ].cmd = String_Alloc( "cmd team humans" );
+ uiInfo.tremTeamList[ 1 ].infopane = UI_FindInfoPaneByName( "humanteam" );
uiInfo.tremTeamList[ 2 ].text = String_Alloc( "Spectate" );
uiInfo.tremTeamList[ 2 ].cmd = String_Alloc( "cmd team spectate" );
+ uiInfo.tremTeamList[ 2 ].infopane = UI_FindInfoPaneByName( "spectateteam" );
}
/*
@@ -5603,6 +5757,20 @@ void _UI_Init( qboolean inGameLoad ) {
UI_LoadMenus(menuSet, qtrue);
UI_LoadMenus("ui/ingame.txt", qfalse);
UI_LoadMenus("ui/tremulous.txt", qfalse);
+
+ UI_LoadInfoPanes( "ui/infopanes.def" );
+
+ {
+ int ijk, abc;
+
+ for( ijk = 0; ijk < uiInfo.tremInfoPaneCount; ijk++ )
+ {
+ Com_Printf( "name: %s\n", uiInfo.tremInfoPanes[ ijk ].name );
+
+ for( abc = 0; abc < uiInfo.tremInfoPanes[ ijk ].numLines; abc++ )
+ Com_Printf( "line %d: %s\n", abc, uiInfo.tremInfoPanes[ ijk ].lines[ abc ] );
+ }
+ }
#endif
Menus_CloseAll();