ui_node_video.c

Go to the documentation of this file.
00001 
00011 /*
00012 Copyright (C) 2002-2010 UFO: Alien Invasion.
00013 
00014 This program is free software; you can redistribute it and/or
00015 modify it under the terms of the GNU General Public License
00016 as published by the Free Software Foundation; either version 2
00017 of the License, or (at your option) any later version.
00018 
00019 This program is distributed in the hope that it will be useful,
00020 but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 
00023 See the GNU General Public License for more details.
00024 
00025 You should have received a copy of the GNU General Public License
00026 along with this program; if not, write to the Free Software
00027 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00028 
00029 */
00030 
00031 #include "../ui_nodes.h"
00032 #include "../ui_parse.h"
00033 #include "../ui_draw.h"
00034 #include "ui_node_video.h"
00035 #include "ui_node_abstractnode.h"
00036 
00037 #include "../../client.h"
00038 #include "../../cinematic/cl_cinematic.h"
00039 
00040 #define EXTRADATA_TYPE videoExtraData_t
00041 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
00042 #define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
00043 
00044 static void UI_VideoNodeDrawOverWindow (uiNode_t *node)
00045 {
00046     if (EXTRADATA(node).cin.status == CIN_STATUS_NONE) {
00047         vec2_t pos;
00048         qboolean nosound = UI_VIDEOEXTRADATACONST(node).nosound;
00049 
00050         CIN_PlayCinematic(&(EXTRADATA(node).cin), va("videos/%s", (const char *)node->image));
00051 
00052         UI_GetNodeAbsPos(node, pos);
00053         CIN_SetParameters(&(EXTRADATA(node).cin), pos[0], pos[1], node->size[0], node->size[1], CIN_STATUS_PLAYING, nosound);
00054     }
00055 
00056     if (EXTRADATA(node).cin.status) {
00057         /* only set replay to true if video was found and is running */
00058         CIN_RunCinematic(&(EXTRADATA(node).cin));
00059     }
00060 }
00061 
00062 static void UI_VideoNodeDraw (uiNode_t *node)
00063 {
00064     if (!node->image)
00065         return;
00066 
00067     if (EXTRADATA(node).cin.fullScreen) {
00068         UI_CaptureDrawOver(node);
00069         return;
00070     }
00071 
00072     UI_VideoNodeDrawOverWindow(node);
00073 }
00074 
00075 static void UI_VideoNodeInit (uiNode_t *node)
00076 {
00077     CIN_InitCinematic(&(EXTRADATA(node).cin));
00078 }
00079 
00080 static void UI_VideoNodeClose (uiNode_t *node)
00081 {
00082     /* If playing a cinematic, stop it */
00083     CIN_StopCinematic(&(EXTRADATA(node).cin));
00084 }
00085 
00086 static const value_t properties[] = {
00088     {"src", V_CVAR_OR_STRING, offsetof(uiNode_t, image), 0},
00089     {"nosound", V_BOOL, UI_EXTRADATA_OFFSETOF(EXTRADATA_TYPE, nosound), MEMBER_SIZEOF(EXTRADATA_TYPE, nosound)},
00090     {NULL, V_NULL, 0, 0}
00091 };
00092 
00093 void UI_RegisterVideoNode (uiBehaviour_t* behaviour)
00094 {
00095     behaviour->name = "video";
00096     behaviour->draw = UI_VideoNodeDraw;
00097     behaviour->properties = properties;
00098     behaviour->init = UI_VideoNodeInit;
00099     behaviour->close = UI_VideoNodeClose;
00100     behaviour->drawOverWindow = UI_VideoNodeDrawOverWindow;
00101     behaviour->extraDataSize = sizeof(EXTRADATA_TYPE);
00102 }

Generated by  doxygen 1.6.2