Started to work on a full Master Systems Display UI

For Head Start I ripped the Transporter UI and associated entities

I have already started to work on it's first display function, the Alert Condition,
however it seems that I am losing my int's somewhere on the path,
probably on handover between cgame and ui sections (ui_atoms.c)

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2012-11-20 22:26:46 +01:00
parent e416f650ea
commit 63e3ed0928
8 changed files with 465 additions and 2 deletions

View file

@ -2367,6 +2367,7 @@ Q3UIOBJ_ = \
$(B)/$(BASEGAME)/ui/ui_turbolift.o \
$(B)/$(BASEGAME)/ui/ui_transporter.o \
$(B)/$(BASEGAME)/ui/ui_motd.o \
$(B)/$(BASEGAME)/ui/ui_msd.o \
$(B)/$(BASEGAME)/ui/ui_admin.o \
$(B)/$(BASEGAME)/ui/ui_fonts.o \
$(B)/$(BASEGAME)/ui/ui_emotes.o \

View file

@ -880,6 +880,11 @@ static void CG_ServerCommand( void ) {
return;
}
if(!strcmp(cmd, "ui_msd")) {
trap_SendConsoleCommand(va("ui_msd %s %s %s %s %s %s %s %s %s", CG_Argv(1), CG_Argv(2), CG_Argv(3), CG_Argv(4), CG_Argv(5), CG_Argv(6), CG_Argv(7), CG_Argv(8), CG_Argv(9)));
return;
}
if(!strcmp(cmd, "ui_transporter")) {
trap_SendConsoleCommand(va("ui_transporter %s", CG_Argv(1)));
return;

View file

@ -244,6 +244,7 @@ void SP_path_point(gentity_t *ent);
// ui entities
void SP_ui_transporter(gentity_t *ent);
void SP_ui_msd(gentity_t *ent);
void SP_ui_holodeck(gentity_t *ent);
// cinematic entities
@ -427,6 +428,7 @@ spawn_t spawns[] = {
// ui entities
{"ui_transporter", SP_ui_transporter},
{"ui_msd", SP_ui_msd},
{"ui_holodeck", SP_ui_holodeck},
{"ref_tag", SP_info_notnull},

View file

@ -109,6 +109,146 @@ void SP_ui_transporter(gentity_t *ent) {
trap_LinkEntity(ent);
}
/*QUAKED ui_msd (.5 .5 .5) ? DISABLED
-----DESCRIPTION-----
Opens a Master Systems Display. It will display data grabbed from a target_shiphealth.
-----SPAWNFLAGS-----
1: DISABLED - Entity is disabled at spawn
-----KEYS-----
"swapname" - enables/disables entity(NO_ACTIVATOR/SELF flag must be checked for any entity using this)
"target" - target_shiphealth to draw info from
*/
/**
* \brief Use function for ui_msd entity.
*
* Either either (de)activates entity or opens up the MSD.
*
* \param ent the ui_msd entity
* \param activator the entity that has used the ui_msd entity
* \param other other entity
*
* \author Ubergames - Harry Young
*/
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;
if(!Q_stricmp(ent->swapname, activator->target)) {
ent->flags ^= FL_LOCKED;
} else {
if(ent->flags & FL_LOCKED) return;
target = ent->target_ent;
maxhull = target->health;
currhull = target->count;
maxshield = target->splashRadius;
currshield = target->n00bCount;
shieldstate = target->splashDamage;
if(target->falsetarget){
while((temp = G_Find(temp, FOFS(targetname), target->falsetarget)) != NULL){
if(!Q_stricmp(temp->classname, "target_warp")) break;
}
if(temp){
if(temp->sound1to2)//warp active
warpstate = 1;
else if(temp->sound2to1)//warp ejected
warpstate = -1;
else//not online && not ejected -->offline
warpstate = 0;
temp = NULL;
}
}
if(target->bluename){
while((temp = G_Find(temp, FOFS(targetname), target->bluename)) != NULL){
if(!Q_stricmp(temp->classname, "target_turbolift")) break;
}
if(temp){
if (temp->flags & FL_LOCKED)
turbostate = 0;
else
turbostate = 1;
temp = NULL;
}
}
if(target->bluesound){
while((temp = G_Find(temp, FOFS(targetname), target->bluesound)) != NULL){
if(!Q_stricmp(temp->classname, "ui_transporter")) break;
}
if(temp){
if (temp->flags & FL_LOCKED)
transstate = 0;
else
transstate = 1;
temp = NULL;
}
}
if(target->falsename){
while((temp = G_Find(temp, FOFS(targetname), target->falsename)) != NULL){
if(!Q_stricmp(temp->classname, "target_alert")) break;
}
if(temp){
alertstate = temp->damage;
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));
}
}
/**
* \brief Continues setupt of ui_msd entity after all other entites had time to spawn.
*
* \param ent the ui_msd entity
*
* \author Ubergames - GSIO01
*/
void ui_msd_setup(gentity_t *ent) {
gentity_t *target = NULL;
while((target = G_Find(target, FOFS(targetname), ent->target)) != NULL){
if(!Q_stricmp(target->classname, "target_shiphealth")) break;
}
if(!target) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] ui_msd without target_shiphealth as target at %s! Removing Entity.\n", vtos(ent->s.origin)););
G_FreeEntity(ent);
return;
}
ent->target_ent = target;
ent->target_ent->target_ent = ent;
ent->nextthink = -1;
ent->think = 0;
}
/**
* \brief Spawn function of ui_msd entity.
*
* \param ent the ui_msd entity
*
* \author GSIO01
*/
void SP_ui_msd(gentity_t *ent) {
if(!ent->target) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] ui_msd without target at %s! Removing Entity.\n", vtos(ent->s.origin)););
G_FreeEntity(ent);
return;
}
if(ent->spawnflags & 1)
ent->flags ^= FL_LOCKED;
ent->use = ui_msd_use;
ent->think = ui_msd_setup;
ent->nextthink = level.time + 500;
ent->count = 0;
trap_LinkEntity(ent);
}
/*QUAKED ui_holodeck (.5 .5 .5) ? DISABLED
-----Description-----
Will open the holodeck UI once this is implemented. For now this will not spawn.

View file

@ -152,6 +152,7 @@ ui_credits.o : ui_credits.c; $(DO_CC)
ui_admin.o : ui_admin.c; $(DO_CC)
ui_emotes.o : ui_emotes.c; $(DO_CC)
ui_motd.o : ui_motd.c; $(DO_CC)
ui_msd.o : ui_msd.c; $(DO_CC)
ui_transporter.o : ui_transporter.c; $(DO_CC)
ui_turbolift.o : ui_turbolift.c; $(DO_CC)

View file

@ -1298,8 +1298,8 @@ qboolean UI_ConsoleCommand( void ) {
return qtrue;
}
if ( Q_stricmp( cmd, "ui_transporter" ) == 0 ) {
UI_TransporterMenu( atoi(UI_Argv( 1 )) );
if ( Q_stricmp( cmd, "ui_msd" ) == 0 ) {
UI_msdMenu( atoi(UI_Argv( 1 )), atoi(UI_Argv( 2 )), atoi(UI_Argv( 3 )), atoi(UI_Argv( 4 )), atoi(UI_Argv( 5 )), atoi(UI_Argv( 6 )), atoi(UI_Argv( 7 )), atoi(UI_Argv( 8 )), atoi(UI_Argv( 9 )) );
return qtrue;
}

View file

@ -1850,6 +1850,11 @@ extern void HoloDataReceived(const char *data);
extern void UI_AdminMenu( qboolean fromConsole );
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);
//
// ui_transporter.c
//

309
code/ui/ui_msd.c Normal file
View file

@ -0,0 +1,309 @@
/**********************************************************************
UI_TRANSPORTER.C
User interface trigger from within game
**********************************************************************/
#include "ui_local.h"
typedef struct //static
{
menuframework_s menu;
menubitmap_s quitmenu;
int maxhull;
int currhull;
int maxshield;
int currshield;
int shieldstate;
int warpstate;
int turbostate;
int transstate;
int alertstate;
} msd_t;
msd_t s_msd;
//s_msd.maxhull
#define ID_QUIT 10
void UI_msdMenu_Cache (void);
/*
=================
M_msd_Event
=================
*/
static void M_msd_Event (void* ptr, int notification)
{
int id;
//menubitmap_s *holdLocation;
//menubitmap_s *holdServer;
id = ((menucommon_s*)ptr)->id;
/*if ( notification != QM_ACTIVATED )
{
return;
}*/
if ((id == ID_QUIT) && (notification == QM_ACTIVATED))
UI_PopMenu();
}
/*
=================
msdMenu_Key
=================
*/
sfxHandle_t msdMenu_Key (int key)
{
return ( Menu_DefaultKey( &s_msd.menu, key ) );
}
extern qhandle_t leftRound;
extern qhandle_t corner_ul_24_60;
extern qhandle_t corner_ll_12_60;
qhandle_t loading1;
qhandle_t loading2;
qhandle_t loading3;
qhandle_t loading4;
qhandle_t loading5;
/*
=================
M_msdMenu_Graphics
=================
*/
static void M_msdMenu_Graphics (void)
{
/*Notes:
Color-Types in Frame:
trap_R_SetColor( colorTable[CT_DKPURPLE3]);
Blue Alert:
trap_R_SetColor( colorTable[CT_BLUE] );
Yellow Alert:
trap_R_SetColor( colorTable[CT_YELLOW] );
Red Alert:
trap_R_SetColor( colorTable[CT_RED] );
*/
//menubitmap_s *holdDeck;
//int i;
int length,xTurboStart;
//int numColor, roundColor;
// Draw the basic screen frame
// Upper corners
trap_R_SetColor( colorTable[CT_DKPURPLE1]);
UI_DrawHandlePic( 20, 24, 64, 32, corner_ul_24_60); // Upper corner
// Lower corners
if(s_msd.alertstate == 2)
trap_R_SetColor( colorTable[CT_RED]);
else if(s_msd.alertstate == 1)
trap_R_SetColor( colorTable[CT_YELLOW]);
else if(s_msd.alertstate == 3)
trap_R_SetColor( colorTable[CT_BLUE] );
else
trap_R_SetColor( colorTable[CT_DKPURPLE3]); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 20, 440, 64, 16, corner_ll_12_60); //
xTurboStart = 604;
length = UI_ProportionalStringWidth( menu_normal_text[MNT_TRANSPORTER],UI_BIGFONT);
length += 4;
// Upper half
trap_R_SetColor( colorTable[CT_DKPURPLE1]); //DKGOLD1
UI_DrawHandlePic( 79, 24, xTurboStart - (79 + length), PROP_BIG_HEIGHT, uis.whiteShader); // Top left line
UI_DrawHandlePic( 20, 60, 60, 40, uis.whiteShader); //
if(s_msd.alertstate == 2)
trap_R_SetColor( colorTable[CT_RED]);
else if(s_msd.alertstate == 1)
trap_R_SetColor( colorTable[CT_YELLOW]);
else if(s_msd.alertstate == 3)
trap_R_SetColor( colorTable[CT_BLUE] );
else
trap_R_SetColor( colorTable[CT_DKPURPLE3]);
UI_DrawHandlePic( 20, 106, 60, 11, uis.whiteShader); //
trap_R_SetColor( colorTable[CT_DKPURPLE1]); //DKGOLD1
UI_DrawHandlePic( 20, 123, 60, 250, uis.whiteShader); // Left hand column
// Lower half
if(s_msd.alertstate == 2)
trap_R_SetColor( colorTable[CT_RED] );
else if(s_msd.alertstate == 1)
trap_R_SetColor( colorTable[CT_YELLOW] );
else if(s_msd.alertstate == 3)
trap_R_SetColor( colorTable[CT_BLUE] );
else
trap_R_SetColor( colorTable[CT_DKPURPLE3] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 20, 380, 60, 70, uis.whiteShader); // Left Column
// Bottom line
if(s_msd.alertstate == 2)
trap_R_SetColor( colorTable[CT_RED] );
else if(s_msd.alertstate == 1)
trap_R_SetColor( colorTable[CT_YELLOW] );
else if(s_msd.alertstate == 3)
trap_R_SetColor( colorTable[CT_BLUE] );
else
trap_R_SetColor( colorTable[CT_DKPURPLE3] ); //colorTable[CT_VDKPURPLE2]
UI_DrawHandlePic( 69, 443, 287, 12, uis.whiteShader); //
trap_R_SetColor( colorTable[CT_DKPURPLE1]); //colorTable[CT_DKGOLD1]
UI_DrawHandlePic(364, 443, 260, 12, uis.whiteShader); // Bottom line
if(s_msd.alertstate == 2)
UI_DrawProportionalString( xTurboStart, 24,
"MASTER SYSTEMS DISPLAY", UI_BIGFONT | UI_RIGHT, colorTable[CT_RED]);
else if(s_msd.alertstate == 1)
UI_DrawProportionalString( xTurboStart, 24,
"MASTER SYSTEMS DISPLAY", UI_BIGFONT | UI_RIGHT, colorTable[CT_YELLOW]);
else if(s_msd.alertstate == 3)
UI_DrawProportionalString( xTurboStart, 24,
"MASTER SYSTEMS DISPLAY", UI_BIGFONT | UI_RIGHT, colorTable[CT_BLUE]);
else
UI_DrawProportionalString( xTurboStart, 24,
"MASTER SYSTEMS DISPLAY", UI_BIGFONT | UI_RIGHT, colorTable[CT_WHITE]);
trap_R_SetColor( colorTable[CT_DKPURPLE1]); //DKGOLD1
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 );
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]);
}
/*
===============
msdMenu_Draw
===============
*/
static void msdMenu_Draw(void)
{
// Draw graphics particular to Main Menu
M_msdMenu_Graphics();
Menu_Draw( &s_msd.menu );
}
/*
===============
UI_msdMenu_Cache
===============
*/
void UI_msdMenu_Cache (void)
{
leftRound = trap_R_RegisterShaderNoMip("menu/common/halfroundl_24.tga");
corner_ul_24_60 = trap_R_RegisterShaderNoMip("menu/common/corner_ul_24_60.tga");
corner_ll_12_60 = trap_R_RegisterShaderNoMip("menu/common/corner_ll_12_60.tga");
loading1 = trap_R_RegisterShaderNoMip("menu/new/nav_y.tga");
loading2 = trap_R_RegisterShaderNoMip("menu/new/nav_mb.tga");
loading3 = trap_R_RegisterShaderNoMip("menu/new/nav_lb.tga");
loading4 = trap_R_RegisterShaderNoMip("menu/new/nav_db.tga");
loading5 = trap_R_RegisterShaderNoMip("menu/new/nab_o.tga");
}
/*
===============
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;
s_msd.menu.wrapAround = qtrue;
s_msd.menu.descX = MENU_DESC_X;
s_msd.menu.descY = MENU_DESC_Y;
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.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.height = PROP_BIG_HEIGHT;
s_msd.quitmenu.color = CT_DKPURPLE1;
s_msd.quitmenu.color2 = CT_LTPURPLE1;
s_msd.quitmenu.textX = MENU_BUTTON_TEXT_X;
s_msd.quitmenu.textY = 12;
s_msd.quitmenu.textEnum = MBT_RETURNMENU;
s_msd.quitmenu.textcolor = CT_BLACK;
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 );
}
/*
===============
UI_msdMenu
===============
*/
void UI_msdMenu(int maxhull, int currhull, int maxshield, int currshield, int shieldstate, int warpstate, int turbostate, int transstate, int alertstate)
{
memset( &s_msd, 0, sizeof( s_msd ) );
s_msd.maxhull = maxhull;
s_msd.currhull = currhull;
s_msd.maxshield = maxshield;
s_msd.currshield = currshield;
s_msd.shieldstate = shieldstate;
s_msd.warpstate = warpstate;
s_msd.turbostate = turbostate;
s_msd.transstate = transstate;
s_msd.alertstate = alertstate;
uis.menusp = 0;
ingameFlag = qtrue; // true when in game menu is in use
Mouse_Show();
UI_msdMenu_Cache();
msdMenu_Init();
UI_PushMenu( &s_msd.menu );
Menu_AdjustCursor( &s_msd.menu, 1 );
}