Skip to content

Commit

Permalink
Completed seperation of the Finale script interpreter from the rest o…
Browse files Browse the repository at this point in the history
…f the InFine object model/system.

* Encapsulated code in new object: FinaleInterpreter which resides in finaleinterpreter.c/h under /engine/portable.
* Removed fixed limit STACK_SIZE (was 16) - maximum InFine stack depth.
  • Loading branch information
danij-deng committed Jul 22, 2010
1 parent b02d054 commit 59b9b03
Show file tree
Hide file tree
Showing 8 changed files with 2,435 additions and 1,956 deletions.
2 changes: 2 additions & 0 deletions doomsday/build/codeblocks/doomsday.cbp
Expand Up @@ -240,6 +240,7 @@
<Unit filename="..\..\engine\portable\include\edit_bias.h" />
<Unit filename="..\..\engine\portable\include\edit_map.h" />
<Unit filename="..\..\engine\portable\include\fi_main.h" />
<Unit filename="..\..\engine\portable\include\finaleinterpreter.h" />
<Unit filename="..\..\engine\portable\include\gl_defer.h" />
<Unit filename="..\..\engine\portable\include\gl_draw.h" />
<Unit filename="..\..\engine\portable\include\gl_font.h" />
Expand Down Expand Up @@ -501,6 +502,7 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\engine\portable\src\fi_main.c" />
<Unit filename="..\..\engine\portable\src\finaleinterpreter.c" />
<Unit filename="..\..\engine\portable\src\gl_defer.c">
<Option compilerVar="CC" />
</Unit>
Expand Down
1 change: 1 addition & 0 deletions doomsday/build/win32/doomsday_cl.rsp
Expand Up @@ -30,6 +30,7 @@
.\..\..\engine\portable\src\s_environ.c
.\..\..\engine\portable\src\s_cache.c
.\..\..\engine\portable\src\fi_main.c
.\..\..\engine\portable\src\finaleinterpreter.c
.\..\..\engine\portable\src\gl_defer.c
.\..\..\engine\portable\src\gl_texmanager.c
.\..\..\engine\portable\src\gl_tga.c
Expand Down
8 changes: 8 additions & 0 deletions doomsday/build/win32/vs8/doomsday.vcproj
Expand Up @@ -1076,6 +1076,10 @@
RelativePath="..\..\..\engine\portable\src\fi_main.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\finaleinterpreter.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\gl_defer.c"
>
Expand Down Expand Up @@ -2833,6 +2837,10 @@
RelativePath="..\..\..\engine\portable\include\fi_main.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\finaleinterpreter.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\gl_defer.h"
>
Expand Down
3 changes: 3 additions & 0 deletions doomsday/engine/api/dd_infine.h
Expand Up @@ -67,6 +67,8 @@ struct fi_object_s;
animator_t angle; \
animatorvector3_t scale;

struct fi_object_s* FI_Object(fi_objectid_t id);

/**
* Rectangle/Image sequence.
*/
Expand Down Expand Up @@ -111,6 +113,7 @@ typedef struct fidata_pic_s {

void FIData_PicThink(fidata_pic_t* pic);
void FIData_PicDraw(fidata_pic_t* pic, const float offset[3]);
uint FIData_PicAppendFrame(fidata_pic_t* pic, int type, int tics, void* texRef, short sound, boolean flagFlipH);
void FIData_PicClearAnimation(fidata_pic_t* pic);

/**
Expand Down
70 changes: 62 additions & 8 deletions doomsday/engine/portable/include/fi_main.h
Expand Up @@ -25,11 +25,35 @@
#ifndef LIBDENG_INFINE_MAIN_H
#define LIBDENG_INFINE_MAIN_H

#include "finaleinterpreter.h"

// We'll use the base template directly as our object.
typedef struct fi_object_s {
FIOBJECT_BASE_ELEMENTS()
} fi_object_t;

typedef struct fi_namespace_s {
uint num;
fi_object_t** vector;
} fi_namespace_t;

typedef enum {
FVT_INT,
FVT_FLOAT,
FVT_SCRIPT_STRING, // ptr points to a char*, which points to the string.
FVT_OBJECT
} fi_operand_type_t;

typedef struct {
fi_operand_type_t type;
union {
int integer;
float flt;
const char* cstring;
fi_object_t* obj;
} data;
} fi_operand_t;

/**
* @defgroup playsimServerFinaleFlags Play-simulation Server-side Finale Flags.
*
Expand All @@ -48,16 +72,46 @@ typedef struct fi_object_s {

extern float fiDefaultTextRGB[];

void FI_Register(void);
void FI_Register(void);

void FI_Init(void);
void FI_Shutdown(void);
int FI_Responder(ddevent_t* ev);
void FI_Drawer(void);

void FI_Ticker(timespan_t time);

int FI_SkipRequest(void);
boolean FI_CmdExecuted(void);

fidata_text_t* P_CreateText(fi_objectid_t id, const char* name);
void P_DestroyText(fidata_text_t* text);

fidata_pic_t* P_CreatePic(fi_objectid_t id, const char* name);
void P_DestroyPic(fidata_pic_t* pic);

fi_namespace_t* FI_ScriptNamespace(void);
finaleinterpreter_t* FI_ScriptInterpreter(void);

void* FI_ScriptExtraData(void);

fi_objectid_t FI_FindObjectIdForName(fi_namespace_t* names, const char* name, fi_obtype_e type);
boolean FI_ObjectInNamespace(fi_namespace_t* names, fi_object_t* obj);
fi_object_t* FI_AddObjectInNamespace(fi_namespace_t* names, fi_object_t* obj);
fi_object_t* FI_RemoveObjectInNamespace(fi_namespace_t* names, fi_object_t* obj);

fi_object_t* FI_NewObject(fi_obtype_e type, const char* name);
void FI_DeleteObject(fi_object_t* obj);

void FI_SetBackground(struct material_s* mat);
void FI_SetBackgroundColor(float red, float green, float blue, int steps);
void FI_SetBackgroundColorAndAlpha(float red, float green, float blue, float alpha, int steps);

void FI_Init(void);
void FI_Shutdown(void);
int FI_Responder(ddevent_t* ev);
void FI_Drawer(void);
void FI_SetImageOffsetX(float x, int steps);
void FI_SetImageOffsetY(float y, int steps);

void FI_Ticker(timespan_t time);
void FI_SetFilterColorAndAlpha(float red, float green, float blue, float alpha, int steps);

int FI_SkipRequest(void);
boolean FI_CmdExecuted(void);
void FI_SetPredefinedColor(uint idx, float red, float green, float blue, int steps);

#endif /* LIBDENG_INFINE_MAIN_H */
71 changes: 71 additions & 0 deletions doomsday/engine/portable/include/finaleinterpreter.h
@@ -0,0 +1,71 @@
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2010 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#ifndef LIBDENG_FINALEINTERPRETER_H
#define LIBDENG_FINALEINTERPRETER_H

/// \todo Should be private.
typedef struct fi_handler_s {
ddevent_t ev; // Template.
fi_objectname_t marker;
} fi_handler_t;

typedef struct finaleinterpreter_t {
struct finaleinterpreter_flags_s {
char can_skip:1;
char suspended:1;
char paused:1;
char eat_events:1; // Script will eat all input events.
char show_menu:1;
} flags;
char* script; // A copy of the script.
const char* cp; // The command cursor.
int doLevel; // Level of DO-skipping.
boolean cmdExecuted; // Set to true after first command is executed.
boolean skipping, lastSkipped, gotoSkip, gotoEnd, skipNext;
fi_objectname_t gotoTarget;
int wait;
int inTime;
struct fi_object_s* waitingText;
struct fi_object_s* waitingPic;

uint numEventHandlers;
fi_handler_t* eventHandlers;
} finaleinterpreter_t;

void FinaleInterpreter_LoadScript(finaleinterpreter_t* fi, const char* script);
void FinaleInterpreter_ReleaseScript(finaleinterpreter_t* fi);
boolean FinaleInterpreter_IsMenuTrigger(finaleinterpreter_t* fi);
boolean FinaleInterpreter_Suspended(finaleinterpreter_t* fi);
boolean FinaleInterpreter_CommandExecuted(finaleinterpreter_t* fi);
boolean FinaleInterpreter_CanSkip(finaleinterpreter_t* fi);
void FinaleInterpreter_AllowSkip(finaleinterpreter_t* fi, boolean yes);

boolean FinaleInterpreter_RunCommands(finaleinterpreter_t* fi);
boolean FinaleInterpreter_SkipToMarker(finaleinterpreter_t* fi, const char* marker);
boolean FinaleInterpreter_Skip(finaleinterpreter_t* fi);

int FinaleInterpreter_Responder(finaleinterpreter_t* fi, ddevent_t* ev);

#endif /* LIBDENG_FINALEINTERPRETER_H */

0 comments on commit 59b9b03

Please sign in to comment.