UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cl_sequence.cpp File Reference

Non-interactive sequence rendering and AVI recording. More...

Go to the source code of this file.

Data Structures

struct  seqCmd_s
 
struct  sequence_s
 
struct  seqCamera_s
 
struct  seqEnt_s
 
struct  seq2D_s
 Represents a text object or image object. More...
 
struct  sequenceContext_s
 

Macros

#define MAX_DATA_LENGTH   512
 
#define MAX_SEQCMDS   768
 
#define MAX_SEQUENCES   32
 
#define MAX_SEQENTS   128
 
#define MAX_SEQ2DS   128
 
#define SEQ_NUMCMDS   lengthof(seqCmdName)
 

Typedefs

typedef int(* sequenceHandler_t )(struct sequenceContext_s *context, const char *name, const char *data)
 execution function of a command More...
 
typedef struct seqCmd_s seqCmd_t
 
typedef struct sequence_s sequence_t
 
typedef struct seqCamera_s seqCamera_t
 
typedef struct seqEnt_s seqEnt_t
 
typedef struct seq2D_s seq2D_t
 Represents a text object or image object. More...
 
typedef struct sequenceContext_s sequenceContext_t
 

Functions

static void SEQ_SetCamera (sequenceContext_t *context)
 Set the camera values for a sequence. More...
 
static seqEnt_tSEQ_FindEnt (sequenceContext_t *context, const char *name)
 Finds a given entity in all sequence entities. More...
 
static seq2D_tSEQ_Find2D (sequenceContext_t *context, const char *name)
 Finds a given 2d object in the current sequence data. More...
 
static void SEQ_Render3D (sequenceContext_t *context)
 
static void SEQ_Render2D (sequenceContext_t *context, bool backgroundObjects)
 Renders text and images. More...
 
void SEQ_SendClickEvent (sequenceContext_t *context)
 Unlock a click event for the current sequence or ends the current sequence if not locked. More...
 
void SEQ_SetView (sequenceContext_t *context, vec2_t pos, vec2_t size)
 Define the position of the viewport on the screen. More...
 
bool SEQ_InitContext (sequenceContext_t *context, const char *name)
 Initialize a sequence context from data of a named script sequence. More...
 
static void SEQ_StopSequence (sequenceContext_t *context)
 
static bool SEQ_Execute (sequenceContext_t *context)
 Move the sequence to the right position according to the current time. More...
 
bool SEQ_Render (sequenceContext_t *context)
 Execute and render a sequence. More...
 
sequenceContext_tSEQ_AllocContext (void)
 Allocate a sequence context. More...
 
void SEQ_FreeContext (sequenceContext_t *context)
 Free a sequence context. More...
 
static int SEQ_ExecuteClick (sequenceContext_t *context, const char *name, const char *data)
 Wait until someone clicks with the mouse. More...
 
static int SEQ_ExecuteWait (sequenceContext_t *context, const char *name, const char *data)
 Increase the sequence time. More...
 
static int SEQ_ExecuteAnimSpeed (sequenceContext_t *context, const char *name, const char *data)
 Set the animation speed, default value is 1000. More...
 
static int SEQ_ExecutePrecache (sequenceContext_t *context, const char *name, const char *data)
 Precaches the models and images for a sequence. More...
 
static int SEQ_ExecuteCamera (sequenceContext_t *context, const char *name, const char *data)
 Parse the values for the camera like given in seqCamera. More...
 
static int SEQ_ExecuteModel (sequenceContext_t *context, const char *name, const char *data)
 Parse values for a sequence model. More...
 
static int SEQ_ExecuteMusic (sequenceContext_t *context, const char *name, const char *data)
 Changes the music in the sequence. More...
 
static int SEQ_ExecuteSound (sequenceContext_t *context, const char *name, const char *data)
 Plays a sound in a sequence. More...
 
static int SEQ_ExecuteObj2D (sequenceContext_t *context, const char *name, const char *data)
 Parse 2D objects like text and images. More...
 
static int SEQ_ExecuteDelete (sequenceContext_t *context, const char *name, const char *data)
 Removed a sequence entity from the current sequence. More...
 
static int SEQ_ExecuteCommand (sequenceContext_t *context, const char *name, const char *data)
 Executes a sequence command. More...
 
 CASSERT (lengthof(seqCmdFunc)==lengthof(seqCmdName))
 
static int CL_FindSequenceCommand (const char *commandName)
 
void CL_ParseSequence (const char *name, const char **text)
 Reads the sequence values from given text-pointer. More...
 
void SEQ_Shutdown (void)
 

Variables

static sequence_t sequences [MAX_SEQUENCES]
 
static int numSequences
 
static seqCmd_tseqCmds
 
static int numSeqCmds
 
static const value_t seqCamera_vals []
 valid id names for camera More...
 
static const value_t seqEnt_vals []
 valid entity names for a sequence More...
 
static const value_t seq2D_vals []
 valid id names for 2d entity More...
 
static char const *const seqCmdName []
 
static sequenceHandler_t seqCmdFunc []
 Function to exeute all available commands. More...
 

Detailed Description

Non-interactive sequence rendering and AVI recording.

Note
Sequences are rendered inside the UI code with the sequence node. The default window sequence is used as facility with seq_start and seq_stop commands

Definition in file cl_sequence.cpp.

Macro Definition Documentation

#define MAX_DATA_LENGTH   512

Definition at line 41 of file cl_sequence.cpp.

Referenced by CL_ParseSequence().

#define MAX_SEQ2DS   128

Definition at line 120 of file cl_sequence.cpp.

Referenced by SEQ_ExecuteObj2D().

#define MAX_SEQCMDS   768

Definition at line 117 of file cl_sequence.cpp.

Referenced by CL_ParseSequence().

#define MAX_SEQENTS   128

Definition at line 119 of file cl_sequence.cpp.

Referenced by SEQ_ExecuteModel().

#define MAX_SEQUENCES   32

Definition at line 118 of file cl_sequence.cpp.

Referenced by CL_ParseSequence().

#define SEQ_NUMCMDS   lengthof(seqCmdName)

Definition at line 838 of file cl_sequence.cpp.

Referenced by CL_FindSequenceCommand().

Typedef Documentation

typedef struct seq2D_s seq2D_t

Represents a text object or image object.

typedef struct seqCamera_s seqCamera_t
typedef struct seqCmd_s seqCmd_t
typedef struct seqEnt_s seqEnt_t

Render entities that represents an (animated) model

typedef struct sequence_s sequence_t

Sequence context

typedef int(* sequenceHandler_t)(struct sequenceContext_s *context, const char *name, const char *data)

execution function of a command

Returns
0 if the same command should be executed again - or 1 to execute the next event

Definition at line 49 of file cl_sequence.cpp.

Function Documentation

static int CL_FindSequenceCommand ( const char *  commandName)
static

Find a sequence command by name

Returns
The sequence command id, else -1 if not found

Definition at line 864 of file cl_sequence.cpp.

References i, Q_streq, SEQ_NUMCMDS, and seqCmdName.

Referenced by CL_ParseSequence().

sequenceContext_t* SEQ_AllocContext ( void  )

Allocate a sequence context.

Returns
Context

Definition at line 545 of file cl_sequence.cpp.

References Mem_AllocType.

Referenced by uiSequenceNode::onWindowOpened().

static bool SEQ_Execute ( sequenceContext_t context)
static

Move the sequence to the right position according to the current time.

Parameters
context
Returns
True is the sequence is alive, false if it is the end of the sequence

Definition at line 486 of file cl_sequence.cpp.

References cl, sequenceContext_s::currentCmd, seqCmd_s::data, sequenceContext_s::endClickLoop, sequenceContext_s::endCmd, seqCmd_s::handler, seqCmd_s::name, SEQ_StopSequence(), clientBattleScape_s::time, and sequenceContext_s::time.

Referenced by SEQ_Render().

static int SEQ_ExecuteAnimSpeed ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Set the animation speed, default value is 1000.

Returns
1 - increase the command position of the sequence by one

Definition at line 594 of file cl_sequence.cpp.

References sequenceContext_s::animspeed.

static int SEQ_ExecuteCamera ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Parse the values for the camera like given in seqCamera.

Definition at line 628 of file cl_sequence.cpp.

References sequenceContext_s::camera, Com_EParseValue(), Com_Printf(), value_s::ofs, Q_streq, value_s::size, value_s::string, and value_s::type.

static int SEQ_ExecuteClick ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Wait until someone clicks with the mouse.

Returns
0 if you wait for the click
1 if the click occurred

Definition at line 567 of file cl_sequence.cpp.

References sequenceContext_s::endClickLoop, and sequenceContext_s::time.

static int SEQ_ExecuteCommand ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Executes a sequence command.

Returns
1 - increase the command position of the sequence by one
See also
Cbuf_AddText

Definition at line 813 of file cl_sequence.cpp.

References Cbuf_AddText().

static int SEQ_ExecuteDelete ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Removed a sequence entity from the current sequence.

Returns
1 - increase the command position of the sequence by one
See also
CL_SequenceFind2D
CL_SequenceFindEnt

Definition at line 789 of file cl_sequence.cpp.

References Com_Printf(), seqEnt_s::inuse, seq2D_s::inuse, Mem_Free, SEQ_Find2D(), SEQ_FindEnt(), and seq2D_s::text.

static int SEQ_ExecuteModel ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static
static int SEQ_ExecuteMusic ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Changes the music in the sequence.

Returns
1 - increase the command position of the sequence by one

Definition at line 710 of file cl_sequence.cpp.

References Com_DPrintf(), Cvar_Set(), and DEBUG_CLIENT.

static int SEQ_ExecuteObj2D ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static
static int SEQ_ExecutePrecache ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Precaches the models and images for a sequence.

Returns
1 - increase the command position of the sequence by one
See also
R_RegisterModelShort
R_RegisterImage

Definition at line 606 of file cl_sequence.cpp.

References Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, Q_streq, R_FindModel(), and R_FindPics().

static int SEQ_ExecuteSound ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Plays a sound in a sequence.

Returns
1 - increase the command position of the sequence by one

Definition at line 721 of file cl_sequence.cpp.

References S_StartLocalSample(), and SND_VOLUME_DEFAULT.

static int SEQ_ExecuteWait ( sequenceContext_t context,
const char *  name,
const char *  data 
)
static

Increase the sequence time.

Returns
1 - increase the command position of the sequence by one

Definition at line 584 of file cl_sequence.cpp.

References sequenceContext_s::time.

static seq2D_t* SEQ_Find2D ( sequenceContext_t context,
const char *  name 
)
static

Finds a given 2d object in the current sequence data.

See also
CL_SequenceFindEnt

Definition at line 266 of file cl_sequence.cpp.

References i, seq2D_s::inuse, seq2D_s::name, sequenceContext_s::obj2Ds, and Q_streq.

Referenced by SEQ_ExecuteDelete(), and SEQ_ExecuteObj2D().

static seqEnt_t* SEQ_FindEnt ( sequenceContext_t context,
const char *  name 
)
static

Finds a given entity in all sequence entities.

See also
CL_SequenceFind2D

Definition at line 248 of file cl_sequence.cpp.

References sequenceContext_s::ents, i, seqEnt_s::inuse, seqEnt_s::name, and Q_streq.

Referenced by SEQ_ExecuteDelete(), SEQ_ExecuteModel(), and SEQ_Render3D().

void SEQ_FreeContext ( sequenceContext_t context)

Free a sequence context.

Returns
Context

Definition at line 555 of file cl_sequence.cpp.

References Mem_Free.

Referenced by uiSequenceNode::onWindowClosed().

bool SEQ_InitContext ( sequenceContext_t context,
const char *  name 
)

Initialize a sequence context from data of a named script sequence.

Parameters
context
name
Returns
True if the sequence is initialized.

Definition at line 451 of file cl_sequence.cpp.

References sequenceContext_s::animspeed, cl, Com_Printf(), sequenceContext_s::currentCmd, sequenceContext_s::endCmd, i, sequence_s::length, sequence_s::name, sequenceContext_s::numEnts, sequenceContext_s::numObj2Ds, numSequences, OBJZERO, Q_streq, sequence_s::start, clientBattleScape_s::time, and sequenceContext_s::time.

Referenced by uiSequenceNode::onWindowOpened().

bool SEQ_Render ( sequenceContext_t context)

Execute and render a sequence.

Parameters
contextSequence context
Returns
True if the sequence is alive.

Definition at line 518 of file cl_sequence.cpp.

References sequenceContext_s::pos, SEQ_Execute(), SEQ_Render2D(), SEQ_Render3D(), sequenceContext_s::size, UI_Transform(), VID_NORM_HEIGHT, and VID_NORM_WIDTH.

Referenced by uiSequenceNode::draw().

static void SEQ_Render2D ( sequenceContext_t context,
bool  backgroundObjects 
)
static

Renders text and images.

See also
SEQ_InitStartup
Parameters
[in]contextSequence context
[in]backgroundObjectsif true, draw background objects, else display foreground objects
Todo:
We need this check - but this does not work
Todo:
use this for some nice line spacing

Definition at line 356 of file cl_sequence.cpp.

References seq2D_s::align, seq2D_s::bgcolor, seq2D_s::border, seq2D_s::bordercolor, CL_Translate(), cls, seq2D_s::color, seq2D_s::enlarge, seq2D_s::fade, seq2D_s::font, client_static_s::frametime, i, seq2D_s::image, seq2D_s::inBackground, int(), seq2D_s::inuse, it_pic, sequenceContext_s::numObj2Ds, sequenceContext_s::obj2Ds, seq2D_s::pos, R_Color(), R_DrawFill(), R_DrawImage(), R_DrawRect(), R_FindImage(), seq2D_s::relativePos, seq2D_s::size, seq2D_s::speed, seq2D_s::text, UI_DrawString(), and VID_NORM_WIDTH.

Referenced by SEQ_Render().

void SEQ_SendClickEvent ( sequenceContext_t context)

Unlock a click event for the current sequence or ends the current sequence if not locked.

Note
Script binding for seq_click
See also
menu sequence in menu_main.ufo

Definition at line 426 of file cl_sequence.cpp.

References sequenceContext_s::endClickLoop.

Referenced by uiSequenceNode::onLeftClick().

void SEQ_SetView ( sequenceContext_t context,
vec2_t  pos,
vec2_t  size 
)

Define the position of the viewport on the screen.

Parameters
contextContext
posPosition of the context screen
sizeSize of the context screen

Definition at line 437 of file cl_sequence.cpp.

References sequenceContext_s::pos, and sequenceContext_s::size.

Referenced by uiSequenceNode::draw().

void SEQ_Shutdown ( void  )

Definition at line 998 of file cl_sequence.cpp.

References numSeqCmds, numSequences, and OBJZERO.

Referenced by CL_Shutdown().

static void SEQ_StopSequence ( sequenceContext_t context)
static

Definition at line 476 of file cl_sequence.cpp.

References sequenceContext_s::endClickLoop.

Referenced by SEQ_Execute().

Variable Documentation

int numSeqCmds
static

Definition at line 131 of file cl_sequence.cpp.

Referenced by CL_ParseSequence(), and SEQ_Shutdown().

int numSequences
static

Definition at line 127 of file cl_sequence.cpp.

Referenced by CL_ParseSequence(), SEQ_InitContext(), and SEQ_Shutdown().

const value_t seq2D_vals[]
static
Initial value:
= {
{"name", V_STRING, offsetof(seq2D_t, name), 0},
{"text", V_TRANSLATION_STRING, offsetof(seq2D_t, text), 0},
{"font", V_STRING, offsetof(seq2D_t, font), 0},
{"image", V_STRING, offsetof(seq2D_t, image), 0},
{"pos", V_POS, offsetof(seq2D_t, pos), MEMBER_SIZEOF(seq2D_t, pos)},
{"speed", V_POS, offsetof(seq2D_t, speed), MEMBER_SIZEOF(seq2D_t, speed)},
{"size", V_POS, offsetof(seq2D_t, size), MEMBER_SIZEOF(seq2D_t, size)},
{"enlarge", V_POS, offsetof(seq2D_t, enlarge), MEMBER_SIZEOF(seq2D_t, enlarge)},
{"bgcolor", V_COLOR, offsetof(seq2D_t, bgcolor), MEMBER_SIZEOF(seq2D_t, bgcolor)},
{"color", V_COLOR, offsetof(seq2D_t, color), MEMBER_SIZEOF(seq2D_t, color)},
{"fade", V_COLOR, offsetof(seq2D_t, fade), MEMBER_SIZEOF(seq2D_t, fade)},
{"align", V_ALIGN, offsetof(seq2D_t, align), MEMBER_SIZEOF(seq2D_t, align)},
{"bordercolor", V_COLOR, offsetof(seq2D_t, bordercolor), MEMBER_SIZEOF(seq2D_t, bordercolor)},
{"border", V_INT, offsetof(seq2D_t, border), MEMBER_SIZEOF(seq2D_t, border)},
{"inbackground", V_BOOL, offsetof(seq2D_t, inBackground), MEMBER_SIZEOF(seq2D_t, inBackground)},
{"relative", V_BOOL, offsetof(seq2D_t, relativePos), MEMBER_SIZEOF(seq2D_t, relativePos)},
{nullptr, V_NULL, 0, 0}
}
GLsizei size
Definition: r_gl.h:152
Definition: scripts.h:49
Definition: scripts.h:50
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition: scripts.h:34
Definition: scripts.h:52
Definition: scripts.h:55
Represents a text object or image object.
Definition: cl_sequence.cpp:97

valid id names for 2d entity

Definition at line 195 of file cl_sequence.cpp.

const value_t seqCamera_vals[]
static
Initial value:
= {
{"speed", V_VECTOR, offsetof(seqCamera_t, speed), MEMBER_SIZEOF(seqCamera_t, speed)},
{"angles", V_VECTOR, offsetof(seqCamera_t, angles), MEMBER_SIZEOF(seqCamera_t, angles)},
{"omega", V_VECTOR, offsetof(seqCamera_t, omega), MEMBER_SIZEOF(seqCamera_t, omega)},
{"dist", V_FLOAT, offsetof(seqCamera_t, dist), MEMBER_SIZEOF(seqCamera_t, dist)},
{"ddist", V_FLOAT, offsetof(seqCamera_t, ddist), MEMBER_SIZEOF(seqCamera_t, ddist)},
{"zoom", V_FLOAT, offsetof(seqCamera_t, zoom), MEMBER_SIZEOF(seqCamera_t, zoom)},
{"dzoom", V_FLOAT, offsetof(seqCamera_t, dzoom), MEMBER_SIZEOF(seqCamera_t, dzoom)},
{nullptr, V_NULL, 0, 0}
}
voidpf uLong int origin
Definition: ioapi.h:45
Definition: scripts.h:49
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition: scripts.h:34

valid id names for camera

Definition at line 167 of file cl_sequence.cpp.

sequenceHandler_t seqCmdFunc[]
static
Initial value:
= {
nullptr,
}
static int SEQ_ExecuteModel(sequenceContext_t *context, const char *name, const char *data)
Parse values for a sequence model.
static int SEQ_ExecuteWait(sequenceContext_t *context, const char *name, const char *data)
Increase the sequence time.
static int SEQ_ExecuteClick(sequenceContext_t *context, const char *name, const char *data)
Wait until someone clicks with the mouse.
static int SEQ_ExecuteSound(sequenceContext_t *context, const char *name, const char *data)
Plays a sound in a sequence.
static int SEQ_ExecuteDelete(sequenceContext_t *context, const char *name, const char *data)
Removed a sequence entity from the current sequence.
static int SEQ_ExecutePrecache(sequenceContext_t *context, const char *name, const char *data)
Precaches the models and images for a sequence.
static int SEQ_ExecuteCamera(sequenceContext_t *context, const char *name, const char *data)
Parse the values for the camera like given in seqCamera.
static int SEQ_ExecuteObj2D(sequenceContext_t *context, const char *name, const char *data)
Parse 2D objects like text and images.
static int SEQ_ExecuteAnimSpeed(sequenceContext_t *context, const char *name, const char *data)
Set the animation speed, default value is 1000.
static int SEQ_ExecuteCommand(sequenceContext_t *context, const char *name, const char *data)
Executes a sequence command.
static int SEQ_ExecuteMusic(sequenceContext_t *context, const char *name, const char *data)
Changes the music in the sequence.

Function to exeute all available commands.

Definition at line 843 of file cl_sequence.cpp.

Referenced by CL_ParseSequence().

char const* const seqCmdName[]
static
Initial value:
= {
"end",
"wait",
"click",
"precache",
"camera",
"model",
"obj2d",
"music",
"sound",
"rem",
"delete",
"animspeed",
"cmd"
}

Definition at line 822 of file cl_sequence.cpp.

Referenced by CL_FindSequenceCommand().

seqCmd_t* seqCmds
static

Store all sequence commands

Definition at line 130 of file cl_sequence.cpp.

const value_t seqEnt_vals[]
static
Initial value:
= {
{"name", V_STRING, offsetof(seqEnt_t, name), 0},
{"skin", V_INT, offsetof(seqEnt_t, skin), MEMBER_SIZEOF(seqEnt_t, skin)},
{"alpha", V_FLOAT, offsetof(seqEnt_t, alpha), MEMBER_SIZEOF(seqEnt_t, alpha)},
{"origin", V_VECTOR, offsetof(seqEnt_t, origin), MEMBER_SIZEOF(seqEnt_t, origin)},
{"speed", V_VECTOR, offsetof(seqEnt_t, speed), MEMBER_SIZEOF(seqEnt_t, speed)},
{"angles", V_VECTOR, offsetof(seqEnt_t, angles), MEMBER_SIZEOF(seqEnt_t, angles)},
{"omega", V_VECTOR, offsetof(seqEnt_t, omega), MEMBER_SIZEOF(seqEnt_t, omega)},
{"color", V_VECTOR, offsetof(seqEnt_t, color), MEMBER_SIZEOF(seqEnt_t, color)},
{"parent", V_STRING, offsetof(seqEnt_t, parent), 0},
{"tag", V_STRING, offsetof(seqEnt_t, tag), 0},
{nullptr, V_NULL, 0, 0}
}
voidpf uLong int origin
Definition: ioapi.h:45
Definition: scripts.h:49
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition: scripts.h:34
Definition: scripts.h:52

valid entity names for a sequence

Definition at line 180 of file cl_sequence.cpp.

sequence_t sequences[MAX_SEQUENCES]
static

Global content

Todo:
move it to cls?

Store main sequence entries

Definition at line 126 of file cl_sequence.cpp.