UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_sequence.cpp File Reference

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

Include dependency graph for cl_sequence.cpp:

Go to the source code of this file.

Data Structures

struct  seqCmd_t
struct  sequence_t
struct  seqCamera_t
struct  seqEnt_t
struct  seq2D_t
 Represents a text object or image object. More...
struct  sequenceContext_t

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

Functions

static void SEQ_SetCamera (sequenceContext_t *context)
 Set the camera values for a sequence.
static seqEnt_tSEQ_FindEnt (sequenceContext_t *context, const char *name)
 Finds a given entity in all sequence entities.
static seq2D_tSEQ_Find2D (sequenceContext_t *context, const char *name)
 Finds a given 2d object in the current sequence data.
static void SEQ_Render3D (sequenceContext_t *context)
static void SEQ_Render2D (sequenceContext_t *context, bool backgroundObjects)
 Renders text and images.
void SEQ_SendClickEvent (sequenceContext_t *context)
 Unlock a click event for the current sequence or ends the current sequence if not locked.
void SEQ_SetView (sequenceContext_t *context, vec2_t pos, vec2_t size)
 Define the position of the viewport on the screen.
bool SEQ_InitContext (sequenceContext_t *context, const char *name)
 Initialize a sequence context from data of a named script sequence.
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.
bool SEQ_Render (sequenceContext_t *context)
 Execute and render a sequence.
sequenceContext_tSEQ_AllocContext (void)
 Allocate a sequence context.
void SEQ_FreeContext (sequenceContext_t *context)
 Free a sequence context.
static int SEQ_ExecuteClick (sequenceContext_t *context, const char *name, const char *data)
 Wait until someone clicks with the mouse.
static int SEQ_ExecuteWait (sequenceContext_t *context, const char *name, const char *data)
 Increase the sequence time.
static int SEQ_ExecuteAnimSpeed (sequenceContext_t *context, const char *name, const char *data)
 Set the animation speed, default value is 1000.
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_ExecuteModel (sequenceContext_t *context, const char *name, const char *data)
 Parse values for a sequence model.
static int SEQ_ExecuteMusic (sequenceContext_t *context, const char *name, const char *data)
 Changes the music in the sequence.
static int SEQ_ExecuteSound (sequenceContext_t *context, const char *name, const char *data)
 Plays a sound in a sequence.
static int SEQ_ExecuteObj2D (sequenceContext_t *context, const char *name, const char *data)
 Parse 2D objects like text and images.
static int SEQ_ExecuteDelete (sequenceContext_t *context, const char *name, const char *data)
 Removed a sequence entity from the current sequence.
static int SEQ_ExecuteCommand (sequenceContext_t *context, const char *name, const char *data)
 Executes a sequence command.
 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.
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
static const value_t seqEnt_vals []
 valid entity names for a sequence
static const value_t seq2D_vals []
 valid id names for 2d entity
static char const *const seqCmdName []
static sequenceHandler_t seqCmdFunc []
 Function to exeute all available commands.

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

◆ MAX_DATA_LENGTH

#define MAX_DATA_LENGTH   512

Definition at line 41 of file cl_sequence.cpp.

Referenced by CL_ParseSequence().

◆ MAX_SEQ2DS

#define MAX_SEQ2DS   128

Definition at line 120 of file cl_sequence.cpp.

Referenced by SEQ_ExecuteObj2D().

◆ MAX_SEQCMDS

#define MAX_SEQCMDS   768

Definition at line 117 of file cl_sequence.cpp.

Referenced by CL_ParseSequence().

◆ MAX_SEQENTS

#define MAX_SEQENTS   128

Definition at line 119 of file cl_sequence.cpp.

Referenced by SEQ_ExecuteModel().

◆ MAX_SEQUENCES

#define MAX_SEQUENCES   32

Definition at line 118 of file cl_sequence.cpp.

Referenced by CL_ParseSequence().

◆ SEQ_NUMCMDS

#define SEQ_NUMCMDS   lengthof(seqCmdName)

Definition at line 838 of file cl_sequence.cpp.

Referenced by CL_FindSequenceCommand().

Typedef Documentation

◆ sequenceHandler_t

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

◆ CASSERT()

References seqCmdFunc, and seqCmdName.

◆ CL_FindSequenceCommand()

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().

◆ CL_ParseSequence()

◆ SEQ_AllocContext()

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().

◆ SEQ_Execute()

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_t::currentCmd, seqCmd_t::data, sequenceContext_t::endClickLoop, sequenceContext_t::endCmd, seqCmd_t::handler, seqCmd_t::name, SEQ_StopSequence(), seqCmds, and sequenceContext_t::time.

Referenced by SEQ_Render().

◆ SEQ_ExecuteAnimSpeed()

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_t::animspeed, data, and name.

◆ SEQ_ExecuteCamera()

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_t::camera, Com_EParseValue(), Com_Printf(), data, name, value_t::ofs, Q_streq, seqCamera_vals, value_t::size, value_t::string, and value_t::type.

◆ SEQ_ExecuteClick()

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 data, sequenceContext_t::endClickLoop, name, and sequenceContext_t::time.

◆ SEQ_ExecuteCommand()

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(), data, and name.

◆ SEQ_ExecuteDelete()

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(), data, seq2D_t::inuse, seqEnt_t::inuse, Mem_Free, name, SEQ_Find2D(), SEQ_FindEnt(), and seq2D_t::text.

◆ SEQ_ExecuteModel()

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

◆ SEQ_ExecuteMusic()

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(), data, DEBUG_CLIENT, and name.

◆ SEQ_ExecuteObj2D()

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

◆ SEQ_ExecutePrecache()

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(), data, DEBUG_CLIENT, name, Q_streq, R_FindModel(), and R_FindPics().

◆ SEQ_ExecuteSound()

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 data, name, S_StartLocalSample(), and SND_VOLUME_DEFAULT.

◆ SEQ_ExecuteWait()

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 data, name, and sequenceContext_t::time.

◆ SEQ_Find2D()

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_t::inuse, name, seq2D_t::name, sequenceContext_t::obj2Ds, and Q_streq.

Referenced by SEQ_ExecuteDelete(), and SEQ_ExecuteObj2D().

◆ SEQ_FindEnt()

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_t::ents, i, seqEnt_t::inuse, name, seqEnt_t::name, and Q_streq.

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

◆ SEQ_FreeContext()

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().

◆ SEQ_InitContext()

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_t::animspeed, cl, Com_Printf(), sequenceContext_t::currentCmd, sequenceContext_t::endCmd, i, sequence_t::length, name, sequence_t::name, sequenceContext_t::numEnts, sequenceContext_t::numObj2Ds, numSequences, OBJZERO, Q_streq, sequences, sequence_t::start, and sequenceContext_t::time.

Referenced by uiSequenceNode::onWindowOpened().

◆ SEQ_Render()

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_t::pos, SEQ_Execute(), SEQ_Render2D(), SEQ_Render3D(), sequenceContext_t::size, UI_Transform(), VID_NORM_HEIGHT, and VID_NORM_WIDTH.

Referenced by uiSequenceNode::draw().

◆ SEQ_Render2D()

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_t::align, seq2D_t::bgcolor, seq2D_t::border, seq2D_t::bordercolor, CL_Translate(), cls, seq2D_t::color, seq2D_t::enlarge, seq2D_t::fade, seq2D_t::font, i, seq2D_t::image, seq2D_t::inBackground, int(), seq2D_t::inuse, it_pic, sequenceContext_t::numObj2Ds, sequenceContext_t::obj2Ds, seq2D_t::pos, R_Color(), R_DrawFill(), R_DrawImage(), R_DrawRect(), R_FindImage(), seq2D_t::relativePos, seq2D_t::size, seq2D_t::speed, seq2D_t::text, UI_DrawString(), and VID_NORM_WIDTH.

Referenced by SEQ_Render().

◆ SEQ_Render3D()

◆ SEQ_SendClickEvent()

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_t::endClickLoop.

Referenced by uiSequenceNode::onLeftClick().

◆ SEQ_SetCamera()

◆ SEQ_SetView()

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_t::pos, and sequenceContext_t::size.

Referenced by uiSequenceNode::draw().

◆ SEQ_Shutdown()

void SEQ_Shutdown ( void )

Definition at line 998 of file cl_sequence.cpp.

References numSeqCmds, numSequences, OBJZERO, seqCmds, and sequences.

Referenced by CL_Shutdown().

◆ SEQ_StopSequence()

void SEQ_StopSequence ( sequenceContext_t * context)
static

Definition at line 476 of file cl_sequence.cpp.

References sequenceContext_t::endClickLoop.

Referenced by SEQ_Execute().

Variable Documentation

◆ numSeqCmds

int numSeqCmds
static

Definition at line 131 of file cl_sequence.cpp.

Referenced by CL_ParseSequence(), and SEQ_Shutdown().

◆ numSequences

int numSequences
static

Definition at line 127 of file cl_sequence.cpp.

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

◆ seq2D_vals

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}
}
voidpf void uLong size
Definition ioapi.h:42
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
@ V_BOOL
Definition scripts.h:50
@ V_TRANSLATION_STRING
Definition scripts.h:59
@ V_NULL
Definition scripts.h:49
@ V_STRING
Definition scripts.h:58
@ V_ALIGN
Definition scripts.h:61
@ V_INT
Definition scripts.h:52
@ V_COLOR
Definition scripts.h:57
@ V_POS
Definition scripts.h:55
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition scripts.h:34
Represents a text object or image object.

valid id names for 2d entity

Definition at line 195 of file cl_sequence.cpp.

Referenced by SEQ_ExecuteObj2D().

◆ seqCamera_vals

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
@ V_FLOAT
Definition scripts.h:54
@ V_VECTOR
Definition scripts.h:56

valid id names for camera

Definition at line 167 of file cl_sequence.cpp.

Referenced by SEQ_ExecuteCamera().

◆ seqCmdFunc

sequenceHandler_t seqCmdFunc[]
static
Initial value:
= {
nullptr,
}
static int SEQ_ExecuteObj2D(sequenceContext_t *context, const char *name, const char *data)
Parse 2D objects like text and images.
static int SEQ_ExecuteDelete(sequenceContext_t *context, const char *name, const char *data)
Removed a sequence entity from the current sequence.
static int SEQ_ExecuteMusic(sequenceContext_t *context, const char *name, const char *data)
Changes the music in the sequence.
static int SEQ_ExecuteAnimSpeed(sequenceContext_t *context, const char *name, const char *data)
Set the animation speed, default value is 1000.
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_ExecuteCamera(sequenceContext_t *context, const char *name, const char *data)
Parse the values for the camera like given in seqCamera.
static int SEQ_ExecuteSound(sequenceContext_t *context, const char *name, const char *data)
Plays a sound in a sequence.
static int SEQ_ExecuteModel(sequenceContext_t *context, const char *name, const char *data)
Parse values for a sequence model.
static int SEQ_ExecuteCommand(sequenceContext_t *context, const char *name, const char *data)
Executes a sequence command.
static int SEQ_ExecutePrecache(sequenceContext_t *context, const char *name, const char *data)
Precaches the models and images for a sequence.

Function to exeute all available commands.

Definition at line 843 of file cl_sequence.cpp.

Referenced by CASSERT(), and CL_ParseSequence().

◆ seqCmdName

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 CASSERT(), and CL_FindSequenceCommand().

◆ seqCmds

seqCmd_t* seqCmds
static

Store all sequence commands

Definition at line 130 of file cl_sequence.cpp.

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

◆ seqEnt_vals

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}
}

valid entity names for a sequence

Definition at line 180 of file cl_sequence.cpp.

Referenced by SEQ_ExecuteModel().

◆ sequences

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.

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