Finished first version of ui_msd

UI displays status of all systems connected to it's parent target-shiphealth
There is also a slide for relative health
It does not auto update.

Up next I'll try the HUD-Element.

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2012-11-23 22:56:39 +01:00
parent 8e9348d463
commit 5500407c65
6 changed files with 169 additions and 48 deletions

View File

@ -881,7 +881,7 @@ static void CG_ServerCommand( void ) {
}
if(!strcmp(cmd, "ui_msd")) {
static char ui_msd1[MAX_STRING_CHARS], ui_msd2[MAX_STRING_CHARS], ui_msd3[MAX_STRING_CHARS], ui_msd4[MAX_STRING_CHARS], ui_msd5[MAX_STRING_CHARS], ui_msd6[MAX_STRING_CHARS], ui_msd7[MAX_STRING_CHARS], ui_msd8[MAX_STRING_CHARS], ui_msd9[MAX_STRING_CHARS];
static char ui_msd1[MAX_STRING_CHARS], ui_msd2[MAX_STRING_CHARS], ui_msd3[MAX_STRING_CHARS], ui_msd4[MAX_STRING_CHARS], ui_msd5[MAX_STRING_CHARS], ui_msd6[MAX_STRING_CHARS], ui_msd7[MAX_STRING_CHARS], ui_msd8[MAX_STRING_CHARS], ui_msd9[MAX_STRING_CHARS], ui_msd10[MAX_STRING_CHARS];
trap_Argv( 1, ui_msd1, sizeof( ui_msd1 ) );
trap_Argv( 2, ui_msd2, sizeof( ui_msd2 ) );
trap_Argv( 3, ui_msd3, sizeof( ui_msd3 ) );
@ -891,7 +891,8 @@ static void CG_ServerCommand( void ) {
trap_Argv( 7, ui_msd7, sizeof( ui_msd7 ) );
trap_Argv( 8, ui_msd8, sizeof( ui_msd8 ) );
trap_Argv( 9, ui_msd9, sizeof( ui_msd9 ) );
trap_SendConsoleCommand(va("ui_msd %s %s %s %s %s %s %s %s %s", ui_msd1, ui_msd2, ui_msd3, ui_msd4, ui_msd5, ui_msd6, ui_msd7, ui_msd8, ui_msd9));
trap_Argv( 10, ui_msd10, sizeof( ui_msd10 ) );
trap_SendConsoleCommand(va("ui_msd %s %s %s %s %s %s %s %s %s %s", ui_msd1, ui_msd2, ui_msd3, ui_msd4, ui_msd5, ui_msd6, ui_msd7, ui_msd8, ui_msd9, ui_msd10));
return;
}

View File

@ -2936,10 +2936,12 @@ falsename: falsename/redname for target_alert
"model" - path to a shader with a MSD-Display (ship) to show. Default will be the Daedalus Class
We're sponsoring a varayity, which were created by Alexander Richardson.
The shaders for these are stowed in scripts/msd.shader in the pakX.pk3
The shaders for these are stowed in scripts/msd.shader in the pakX.pk3.
It contains two versions: One for Texturing in Level design (like a display) and opne for the UI.
To retrieve such an image simply look for the MSD-Folder in your radiants texture browser
For personalized MSD's see segment below.
Ship-Classname || Online Source || Shader-Name
Ship-Classname || Online Source || Shader-Name (for <type> insert gfx for UI-Shader and textures for texture shader)
Constellation Class || http://lcarsgfx.wordpress.com/2012/09/12/constellation-sisyphus/ ||
Danube Runabout || http://lcarsgfx.wordpress.com/2012/06/30/the-blue-danube/ ||
Nova Class || http://lcarsgfx.wordpress.com/2012/06/13/can-you-tell-what-it-is-yet-2/ ||
@ -2980,14 +2982,32 @@ After that create a scripts/msd_shipname_registry.shader file (registry is optio
however it is useful in avoiding collitions with ships of similar names)
In that file add the following short script:
menu/msd/shipname_registry //this will be the path to your shader to add in the radiant
gfx/msd/akira //this will be the path to the image for the UI
{
{
map gfx/msd/shipname_registry.jpg //this will be the image you will use
map textures/msd/akira.jpg //this will be the image you will use
blendFunc add //this will remove the black background. I might find a better solution...
}
}
textures/msd/akira //this will be the image you will use for texturing
{
surfaceparm nolightmap
surfaceparm nomarks
{
map textures/msd/akira.jpg //this will be the image you will use
}
{
map textures/engineering/glass1.tga //this segment creates the glass effect to make it look like a display
blendfunc gl_one gl_one_minus_src_color
rgbGen identity
tcMod scale 3 3
tcGen environment
}
}
For distribution put both files (including their relative paths) in a *.pk3 file.
*/
static int target_shiphealth_get_unsafe_players(gentity_t *ents[MAX_GENTITIES]) {
@ -3251,6 +3271,10 @@ void SP_target_shiphealth(gentity_t *ent) {
else
ent->splashDamage = 1;
//let's make sure we have something to return as model
if(!ent->model)
ent->model = "gfx/msd/daedalus";
ent->think = target_shiphealth_think;
ent->use = target_shiphealth_use;
ent->nextthink = level.time + 60000;

View File

@ -135,6 +135,7 @@ Opens a Master Systems Display. It will display data grabbed from a target_shiph
void ui_msd_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
gentity_t *target, *temp = NULL;
int maxhull, currhull, maxshield, currshield, shieldstate, warpstate= -2, turbostate= -2, transstate= -2, alertstate= -2;
const char *model;
if(!Q_stricmp(ent->swapname, activator->target)) {
ent->flags ^= FL_LOCKED;
@ -194,7 +195,8 @@ void ui_msd_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
temp = NULL;
}
}
trap_SendServerCommand(activator-g_entities, va("ui_msd %i %i %i %i %i %i %i %i %i", maxhull, currhull, maxshield, currshield, shieldstate, warpstate, turbostate, transstate, alertstate));
model = target->model;
trap_SendServerCommand(activator-g_entities, va("ui_msd %i %i %i %i %i %i %i %i %i %s", maxhull, currhull, maxshield, currshield, shieldstate, warpstate, turbostate, transstate, alertstate, model));
//Debugging G_Printf(S_COLOR_YELLOW "ui_msd G %i %i %i %i %i %i %i %i %i\n", maxhull, currhull, maxshield, currshield, shieldstate, warpstate, turbostate, transstate, alertstate);
}
}

View File

@ -1299,7 +1299,7 @@ qboolean UI_ConsoleCommand( void ) {
}
if ( Q_stricmp( cmd, "ui_msd" ) == 0 ) {
static char ui_msd1[MAX_STRING_CHARS], ui_msd2[MAX_STRING_CHARS], ui_msd3[MAX_STRING_CHARS], ui_msd4[MAX_STRING_CHARS], ui_msd5[MAX_STRING_CHARS], ui_msd6[MAX_STRING_CHARS], ui_msd7[MAX_STRING_CHARS], ui_msd8[MAX_STRING_CHARS], ui_msd9[MAX_STRING_CHARS];
static char ui_msd1[MAX_STRING_CHARS], ui_msd2[MAX_STRING_CHARS], ui_msd3[MAX_STRING_CHARS], ui_msd4[MAX_STRING_CHARS], ui_msd5[MAX_STRING_CHARS], ui_msd6[MAX_STRING_CHARS], ui_msd7[MAX_STRING_CHARS], ui_msd8[MAX_STRING_CHARS], ui_msd9[MAX_STRING_CHARS], ui_msd10[MAX_STRING_CHARS];
trap_Argv( 1, ui_msd1, sizeof( ui_msd1 ) );
trap_Argv( 2, ui_msd2, sizeof( ui_msd2 ) );
trap_Argv( 3, ui_msd3, sizeof( ui_msd3 ) );
@ -1309,7 +1309,8 @@ qboolean UI_ConsoleCommand( void ) {
trap_Argv( 7, ui_msd7, sizeof( ui_msd7 ) );
trap_Argv( 8, ui_msd8, sizeof( ui_msd8 ) );
trap_Argv( 9, ui_msd9, sizeof( ui_msd9 ) );
UI_msdMenu( atoi(ui_msd1), atoi(ui_msd2), atoi(ui_msd3), atoi(ui_msd4), atoi(ui_msd5), atoi(ui_msd6), atoi(ui_msd7), atoi(ui_msd8), atoi(ui_msd9));
trap_Argv( 10, ui_msd10, sizeof( ui_msd10 ) );
UI_msdMenu( atoi(ui_msd1), atoi(ui_msd2), atoi(ui_msd3), atoi(ui_msd4), atoi(ui_msd5), atoi(ui_msd6), atoi(ui_msd7), atoi(ui_msd8), atoi(ui_msd9), ui_msd10);
return qtrue;
}

View File

@ -1853,7 +1853,7 @@ extern void UI_AdminMenu_Cache( void );
//
// ui_msd.c
//
extern void UI_msdMenu(int maxhull, int currhull, int maxshield, int currshield, int shieldstate, int warpstate, int turbostate, int transstate, int alertstate);
extern void UI_msdMenu(int maxhull, int currhull, int maxshield, int currshield, int shieldstate, int warpstate, int turbostate, int transstate, int alertstate, char *model);
//
// ui_transporter.c

View File

@ -19,6 +19,7 @@ typedef struct //static
int turbostate;
int transstate;
int alertstate;
const char *model;
} msd_t;
msd_t s_msd;
@ -72,6 +73,7 @@ qhandle_t loading5;
qhandle_t redalert;
qhandle_t yellowalert;
qhandle_t bluealert;
qhandle_t model;
/*
=================
@ -93,7 +95,7 @@ static void M_msdMenu_Graphics (void)
*/
//menubitmap_s *holdDeck;
//int i;
int length,xTurboStart;
int length,xTurboStart, lengthshield, lengthhull;
//int numColor, roundColor;
// Draw the basic screen frame
@ -152,29 +154,130 @@ static void M_msdMenu_Graphics (void)
"MASTER SYSTEMS DISPLAY", UI_BIGFONT | UI_RIGHT, colorTable[CT_WHITE]);
trap_R_SetColor( colorTable[CT_DKPURPLE1]); //DKGOLD1
UI_DrawHandlePic( 607, 24,-16, 32, leftRound);
UI_DrawHandlePic( 607, 24, -16, 32, leftRound);
trap_R_SetColor( colorTable[CT_LTBLUE1] );
UI_DrawHandlePic( 366, 208, 243, 212, loading2 );
trap_R_SetColor( colorTable[CT_LTGOLD1] );
UI_DrawHandlePic( 366, 208, 243, 212, loading3 );
UI_DrawHandlePic( 366, 208, 243, 212, loading1 );
trap_R_SetColor( colorTable[CT_DKBLUE1] );
UI_DrawHandlePic( 366, 208, 243, 212, loading4 );
trap_R_SetColor( colorTable[CT_DKORANGE] );
UI_DrawHandlePic( 366, 208, 243, 212, loading5 );
// MSD Model
UI_DrawHandlePic( 100, 60, 500, 250, model);
UI_DrawProportionalString(487, 297, "1", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(508, 297, "2", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(487, 322, "3", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(508, 322, "4", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(395, 405, "22", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(370, 327, "45", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(399, 236, "7", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(487, 215, "35", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(502, 215, "2", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(596, 318, "67", UI_TINYFONT, colorTable[CT_BLACK]);
UI_DrawProportionalString(502, 405, "27", UI_TINYFONT, colorTable[CT_BLACK]);
// health Bars
lengthshield = (int)(498 * s_msd.currshield / s_msd.maxshield);
lengthhull = (int)(498 * s_msd.currhull / s_msd.maxhull);
trap_R_SetColor( colorTable[CT_WHITE] );
UI_DrawHandlePic( 100, 320, 500, 49, uis.whiteShader); //background
trap_R_SetColor( colorTable[CT_BLACK] );
//trap_R_SetColor( colorTable[CT_VDKPURPLE2] );
UI_DrawHandlePic( 101, 321, 498, 23, uis.whiteShader); //Shield Bar BG
trap_R_SetColor( colorTable[CT_BLACK] );
//trap_R_SetColor( colorTable[CT_VDKORANGE] );
UI_DrawHandlePic( 101, 345, 498, 23, uis.whiteShader); //Health Bar BG
//Shield Bar
if(s_msd.shieldstate == 1){
trap_R_SetColor( colorTable[CT_BLUE] );
UI_DrawHandlePic( 101, 321, lengthshield, 23, uis.whiteShader);
UI_DrawProportionalString(103, 323, va("Shields at %.1f Percent", (lengthshield / 4.98)), UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.shieldstate == 0){
UI_DrawProportionalString(103, 323, "Shields are on standby", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.shieldstate == -2){
UI_DrawProportionalString(103, 323, "Shields are offline", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.shieldstate == -1){
UI_DrawProportionalString(103, 323, "Shields are inoperable", UI_TINYFONT, colorTable[CT_MDGREY]);
}
trap_R_SetColor( colorTable[CT_YELLOW] );
UI_DrawHandlePic( 101, 345, lengthhull, 23, uis.whiteShader); //Health Bar
UI_DrawProportionalString(103, 347, va("Structual Integity at %.1f Percent", (lengthhull / 4.98)), UI_TINYFONT, colorTable[CT_MDGREY]);
//Sub System indicators
//Shields
trap_R_SetColor( colorTable[CT_WHITE] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 100, 380, 90, 45, uis.whiteShader);
if(s_msd.shieldstate == 1){
trap_R_SetColor( colorTable[CT_GREEN] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 101, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(101, 382, "Shields are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(101, 397, "online", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.shieldstate == 0){
trap_R_SetColor( colorTable[CT_YELLOW] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 101, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(101, 382, "Shields are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(101, 397, "on standby", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.shieldstate == -2){
trap_R_SetColor( colorTable[CT_RED] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 101, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(101, 382, "Shields are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(101, 397, "offline", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.shieldstate == -1){
trap_R_SetColor( colorTable[CT_RED] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 101, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(101, 382, "Shields are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(101, 397, "inoperable", UI_TINYFONT, colorTable[CT_MDGREY]);
}
//Warp Drive
trap_R_SetColor( colorTable[CT_WHITE] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 195, 380, 90, 45, uis.whiteShader);
if(s_msd.warpstate == 1){
trap_R_SetColor( colorTable[CT_GREEN] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 196, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(197, 382, "Warp Drive is", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(197, 397, "online", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.warpstate == 0){
trap_R_SetColor( colorTable[CT_RED] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 196, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(197, 382, "Warp Drive is", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(197, 397, "offline", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.warpstate == -1){
trap_R_SetColor( colorTable[CT_RED] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 196, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(197, 382, "Warp Core is", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(197, 397, "ejected", UI_TINYFONT, colorTable[CT_MDGREY]);
} else {//-2, no info available
trap_R_SetColor( colorTable[CT_YELLOW] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 196, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(197, 382, "Warp-Core-ODN-", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(197, 397, "Update required", UI_TINYFONT, colorTable[CT_MDGREY]);
}
//Turbolift
trap_R_SetColor( colorTable[CT_WHITE] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 290, 380, 90, 45, uis.whiteShader);
if(s_msd.warpstate == 1){
trap_R_SetColor( colorTable[CT_GREEN] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 291, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(292, 382, "Turbolifts are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(292, 397, "online", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.warpstate == 0){
trap_R_SetColor( colorTable[CT_RED] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 291, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(292, 382, "Turbolifts are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(292, 397, "offline", UI_TINYFONT, colorTable[CT_MDGREY]);
} else {//-2, no info available
trap_R_SetColor( colorTable[CT_YELLOW] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 291, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(292, 382, "Turbolift-ODN-", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(292, 397, "Update required", UI_TINYFONT, colorTable[CT_MDGREY]);
}
//Transporter
trap_R_SetColor( colorTable[CT_WHITE] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 385, 380, 90, 45, uis.whiteShader);
if(s_msd.warpstate == 1){
trap_R_SetColor( colorTable[CT_GREEN] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 386, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(387, 382, "Transporters are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(387, 397, "online", UI_TINYFONT, colorTable[CT_MDGREY]);
} else if(s_msd.warpstate == 0){
trap_R_SetColor( colorTable[CT_RED] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 386, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(387, 382, "Transporters are", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(387, 397, "offline", UI_TINYFONT, colorTable[CT_MDGREY]);
} else {//-2, no info available
trap_R_SetColor( colorTable[CT_YELLOW] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 386, 381, 88, 43, uis.whiteShader);
UI_DrawProportionalString(386, 382, "Transporter-ODN-", UI_TINYFONT, colorTable[CT_MDGREY]);
UI_DrawProportionalString(387, 397, "Update required", UI_TINYFONT, colorTable[CT_MDGREY]);
}
}
@ -209,6 +312,7 @@ void UI_msdMenu_Cache (void)
redalert = trap_R_RegisterShaderNoMip("menu/alert/red");
yellowalert = trap_R_RegisterShaderNoMip("menu/alert/yellow");
bluealert = trap_R_RegisterShaderNoMip("menu/alert/blue");
model = trap_R_RegisterShaderNoMip(s_msd.model);
}
/*
@ -218,10 +322,6 @@ msdMenu_Init
*/
void msdMenu_Init(void)
{
int y,pad,x;
//int i;
int width;
s_msd.menu.nitems = 0;
s_msd.menu.draw = msdMenu_Draw;
s_msd.menu.key = msdMenu_Key;
@ -231,19 +331,14 @@ void msdMenu_Init(void)
s_msd.menu.titleX = MENU_TITLE_X;
s_msd.menu.titleY = MENU_TITLE_Y;
pad = PROP_BIG_HEIGHT + 10;
width = MENU_BUTTON_MED_WIDTH-20;
y = 72;
x = 208;
s_msd.quitmenu.generic.type = MTYPE_BITMAP;
s_msd.quitmenu.generic.flags = QMF_HIGHLIGHT_IF_FOCUS;
s_msd.quitmenu.generic.x = x;
s_msd.quitmenu.generic.y = y;
s_msd.quitmenu.generic.x = 490;
s_msd.quitmenu.generic.y = 380;
s_msd.quitmenu.generic.name = GRAPHIC_BUTTONLEFT;
s_msd.quitmenu.generic.id = ID_QUIT;
s_msd.quitmenu.generic.callback = M_msd_Event;
s_msd.quitmenu.width = width;
s_msd.quitmenu.width = MENU_BUTTON_MED_WIDTH-20;
s_msd.quitmenu.height = PROP_BIG_HEIGHT;
s_msd.quitmenu.color = CT_DKPURPLE1;
s_msd.quitmenu.color2 = CT_LTPURPLE1;
@ -254,9 +349,6 @@ void msdMenu_Init(void)
s_msd.quitmenu.textcolor2 = CT_WHITE;
s_msd.quitmenu.textStyle = UI_TINYFONT;
y -= (2*pad);
x += width + 8;
Menu_AddItem( &s_msd.menu, &s_msd.quitmenu );
}
@ -265,7 +357,7 @@ void msdMenu_Init(void)
UI_msdMenu
===============
*/
void UI_msdMenu(int maxhull, int currhull, int maxshield, int currshield, int shieldstate, int warpstate, int turbostate, int transstate, int alertstate)
void UI_msdMenu(int maxhull, int currhull, int maxshield, int currshield, int shieldstate, int warpstate, int turbostate, int transstate, int alertstate, char *model)
{
memset( &s_msd, 0, sizeof( s_msd ) );
@ -278,6 +370,7 @@ void UI_msdMenu(int maxhull, int currhull, int maxshield, int currshield, int sh
s_msd.turbostate = turbostate;
s_msd.transstate = transstate;
s_msd.alertstate = alertstate;
s_msd.model = model;
uis.menusp = 0;