00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pent_include.h"
00020 #include "MovieGump.h"
00021
00022 #include "RawArchive.h"
00023 #include "SKFPlayer.h"
00024 #include "GUIApp.h"
00025 #include "DesktopGump.h"
00026 #include "GumpNotifyProcess.h"
00027
00028 #include "FileSystem.h"
00029
00030 #include "IDataSource.h"
00031 #include "ODataSource.h"
00032
00033 DEFINE_RUNTIME_CLASSTYPE_CODE(MovieGump,ModalGump);
00034
00035 MovieGump::MovieGump()
00036 : ModalGump(), player(0)
00037 {
00038
00039 }
00040
00041 MovieGump::MovieGump(int width, int height, RawArchive* movie,
00042 bool introMusicHack, uint32 _Flags, sint32 layer)
00043 : ModalGump(50, 50, width, height, 0, _Flags, layer)
00044 {
00045 player = new SKFPlayer(movie, width, height, introMusicHack);
00046 }
00047
00048 MovieGump::~MovieGump()
00049 {
00050 delete player;
00051 }
00052
00053 void MovieGump::InitGump(Gump* newparent, bool take_focus)
00054 {
00055 ModalGump::InitGump(newparent, take_focus);
00056 player->start();
00057
00058 GUIApp::get_instance()->pushMouseCursor();
00059 GUIApp::get_instance()->setMouseCursor(GUIApp::MOUSE_NONE);
00060 }
00061
00062 void MovieGump::Close(bool no_del)
00063 {
00064 GUIApp::get_instance()->popMouseCursor();
00065
00066 ModalGump::Close(no_del);
00067 }
00068
00069 bool MovieGump::Run(const uint32 framenum)
00070 {
00071 ModalGump::Run(framenum);
00072
00073 player->run();
00074 if (!player->isPlaying()) {
00075 Close();
00076 }
00077
00078 return true;
00079 }
00080
00081 void MovieGump::PaintThis(RenderSurface* surf, sint32 lerp_factor, bool scaled)
00082 {
00083 player->paint(surf, lerp_factor);
00084 }
00085
00086 bool MovieGump::OnKeyDown(int key, int mod)
00087 {
00088 switch(key)
00089 {
00090 case SDLK_ESCAPE:
00091 {
00092 Close();
00093 } break;
00094 default:
00095 break;
00096 }
00097
00098 return true;
00099 }
00100
00101
00102 ProcId MovieGump::U8MovieViewer(RawArchive* movie, bool introMusicHack)
00103 {
00104 Gump* gump = new MovieGump(320, 200, movie, introMusicHack);
00105 gump->InitGump(0);
00106 gump->setRelativePosition(CENTER);
00107 gump->CreateNotifier();
00108 return gump->GetNotifyProcess()->getPid();
00109 }
00110
00111
00112 void MovieGump::ConCmd_play(const Console::ArgvType &argv)
00113 {
00114 if (argv.size() != 2) {
00115 pout << "play usage: play <moviename>" << std::endl;
00116 return;
00117 }
00118
00119 std::string filename = "@game/static/" + argv[1] + ".skf";
00120 FileSystem* filesys = FileSystem::get_instance();
00121 IDataSource* skf = filesys->ReadFile(filename);
00122 if (!skf) {
00123 pout << "movie not found." << std::endl;
00124 return;
00125 }
00126
00127 RawArchive* flex = new RawArchive(skf);
00128 U8MovieViewer(flex);
00129 }
00130
00131
00132 bool MovieGump::loadData(IDataSource* ids)
00133 {
00134 return false;
00135 }
00136
00137 void MovieGump::saveData(ODataSource* ods)
00138 {
00139
00140 }