2013-07-01 17:13:02 -05:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
*
* 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 Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
*/
# include "common/scummsys.h"
2013-07-06 12:30:54 -05:00
# include "zvision/actions.h"
2013-10-01 20:08:41 -05:00
2013-07-03 18:21:25 -05:00
# include "zvision/zvision.h"
2013-07-11 00:18:23 -05:00
# include "zvision/script_manager.h"
2013-08-03 15:00:58 -05:00
# include "zvision/render_manager.h"
2013-08-05 00:14:20 -05:00
# include "zvision/zork_raw.h"
2013-08-10 17:18:29 -05:00
# include "zvision/zork_avi_decoder.h"
2013-08-31 23:42:56 -05:00
# include "zvision/timer_node.h"
2013-11-01 17:00:20 +07:00
# include "zvision/music_node.h"
2013-11-15 18:46:57 +00:00
# include "zvision/animation_node.h"
2013-07-01 17:13:02 -05:00
2013-10-01 20:08:41 -05:00
# include "common/file.h"
# include "audio/decoders/wave.h"
2013-07-01 17:13:02 -05:00
namespace ZVision {
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
2013-07-03 17:21:21 -05:00
// ActionAdd
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionAdd : : ActionAdd ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %u,%d " , & _key , & _value ) ;
2013-07-01 17:13:02 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionAdd : : execute ( ) {
2013-11-01 16:23:08 +07:00
_engine - > getScriptManager ( ) - > setStateValue ( _key , _engine - > getScriptManager ( ) - > getStateValue ( _key ) + _value ) ;
2013-07-01 17:13:02 -05:00
return true ;
}
2013-07-03 17:21:21 -05:00
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
2013-07-03 17:21:21 -05:00
// ActionAssign
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionAssign : : ActionAssign ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-11-07 16:46:54 +07:00
char buf [ 64 ] ;
memset ( buf , 0 , 64 ) ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %u, %s " , & _key , buf ) ;
2013-11-07 16:46:54 +07:00
_value = new ValueSlot ( _engine - > getScriptManager ( ) , buf ) ;
}
ActionAssign : : ~ ActionAssign ( ) {
if ( _value )
delete _value ;
2013-07-03 17:21:21 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionAssign : : execute ( ) {
2013-11-07 16:46:54 +07:00
_engine - > getScriptManager ( ) - > setStateValue ( _key , _value - > getValue ( ) ) ;
2013-07-03 17:21:21 -05:00
return true ;
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionAttenuate
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionAttenuate : : ActionAttenuate ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %u, %d " , & _key , & _attenuation ) ;
2013-07-06 00:29:15 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionAttenuate : : execute ( ) {
2013-07-06 00:29:15 -05:00
// TODO: Implement
return true ;
}
//////////////////////////////////////////////////////////////////////////////
// ActionChangeLocation
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionChangeLocation : : ActionChangeLocation ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %c, %c, %c%c, %u " , & _world , & _room , & _node , & _view , & _offset ) ;
2013-07-06 00:29:15 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionChangeLocation : : execute ( ) {
2013-08-10 17:32:57 -05:00
// We can't directly call ScriptManager::ChangeLocationIntern() because doing so clears all the Puzzles, and thus would corrupt the current puzzle checking
2013-10-29 18:33:37 +00:00
_engine - > getScriptManager ( ) - > changeLocation ( _world , _room , _node , _view , _offset ) ;
2013-08-10 17:32:57 -05:00
// Tell the puzzle system to stop checking any more puzzles
return false ;
2013-07-06 00:29:15 -05:00
}
//////////////////////////////////////////////////////////////////////////////
// ActionCrossfade
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionCrossfade : : ActionCrossfade ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-07-30 14:33:53 -05:00
sscanf ( line . c_str ( ) ,
2013-11-25 13:30:29 +00:00
" %u %u %u %u %u %u %u " ,
2013-10-20 18:39:06 +00:00
& _keyOne , & _keyTwo , & _oneStartVolume , & _twoStartVolume , & _oneEndVolume , & _twoEndVolume , & _timeInMillis ) ;
2013-07-06 00:29:15 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionCrossfade : : execute ( ) {
2013-07-06 00:29:15 -05:00
// TODO: Implement
return true ;
}
2013-08-18 15:29:23 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionDisableControl
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionDisableControl : : ActionDisableControl ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %u " , & _key ) ;
2013-08-18 15:29:23 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionDisableControl : : execute ( ) {
2013-11-13 22:38:57 +00:00
_engine - > getScriptManager ( ) - > setStateFlag ( _key , Puzzle : : DISABLED ) ;
2013-08-18 15:29:23 -05:00
return true ;
}
//////////////////////////////////////////////////////////////////////////////
// ActionEnableControl
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionEnableControl : : ActionEnableControl ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %u " , & _key ) ;
2013-08-18 15:29:23 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionEnableControl : : execute ( ) {
2013-11-13 22:38:57 +00:00
_engine - > getScriptManager ( ) - > unsetStateFlag ( _key , Puzzle : : DISABLED ) ;
2013-08-18 15:29:23 -05:00
return true ;
}
2013-11-20 11:44:43 +00:00
//////////////////////////////////////////////////////////////////////////////
// ActionInventory
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionInventory : : ActionInventory ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-11-20 11:44:43 +00:00
char buf [ 25 ] ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %25s %d " , buf , & _key ) ;
2013-11-20 11:44:43 +00:00
if ( strcmp ( buf , " add " ) = = 0 ) {
_type = 0 ;
} else if ( strcmp ( buf , " addi " ) = = 0 ) {
_type = 1 ;
} else if ( strcmp ( buf , " drop " ) = = 0 ) {
_type = 2 ;
} else if ( strcmp ( buf , " dropi " ) = = 0 ) {
_type = 3 ;
} else if ( strcmp ( buf , " cycle " ) = = 0 ) {
_type = 4 ;
}
}
bool ActionInventory : : execute ( ) {
switch ( _type ) {
case 0 : // add
_engine - > getScriptManager ( ) - > invertory_add ( _key ) ;
break ;
case 1 : // addi
_engine - > getScriptManager ( ) - > invertory_add ( _engine - > getScriptManager ( ) - > getStateValue ( _key ) ) ;
break ;
case 2 : // drop
if ( _key > = 0 )
_engine - > getScriptManager ( ) - > invertory_drop ( _key ) ;
else
_engine - > getScriptManager ( ) - > invertory_drop ( _engine - > getScriptManager ( ) - > getStateValue ( StateKey_InventoryItem ) ) ;
break ;
case 3 : // dropi
_engine - > getScriptManager ( ) - > invertory_drop ( _engine - > getScriptManager ( ) - > getStateValue ( _key ) ) ;
break ;
case 4 : // cycle
_engine - > getScriptManager ( ) - > invertory_cycle ( ) ;
break ;
default :
break ;
}
return true ;
}
2013-08-18 15:29:23 -05:00
2013-11-01 16:53:46 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionKill
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionKill : : ActionKill ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-11-01 16:53:46 +07:00
_key = 0 ;
_type = 0 ;
char keytype [ 25 ] ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %25s " , keytype ) ;
2013-11-01 16:53:46 +07:00
if ( keytype [ 0 ] = = ' " ' ) {
if ( ! scumm_stricmp ( keytype , " \" ANIM \" " ) )
_type = SideFX : : SIDEFX_ANIM ;
else if ( ! scumm_stricmp ( keytype , " \" AUDIO \" " ) )
_type = SideFX : : SIDEFX_AUDIO ;
else if ( ! scumm_stricmp ( keytype , " \" DISTORT \" " ) )
_type = SideFX : : SIDEFX_DISTORT ;
else if ( ! scumm_stricmp ( keytype , " \" PANTRACK \" " ) )
_type = SideFX : : SIDEFX_PANTRACK ;
else if ( ! scumm_stricmp ( keytype , " \" REGION \" " ) )
_type = SideFX : : SIDEFX_REGION ;
else if ( ! scumm_stricmp ( keytype , " \" TIMER \" " ) )
_type = SideFX : : SIDEFX_TIMER ;
else if ( ! scumm_stricmp ( keytype , " \" TTYTEXT \" " ) )
_type = SideFX : : SIDEFX_TTYTXT ;
else if ( ! scumm_stricmp ( keytype , " \" ALL \" " ) )
_type = SideFX : : SIDEFX_ALL ;
} else
_key = atoi ( keytype ) ;
}
bool ActionKill : : execute ( ) {
if ( _type )
_engine - > getScriptManager ( ) - > killSideFxType ( ( SideFX : : SideFXType ) _type ) ;
else
_engine - > getScriptManager ( ) - > killSideFx ( _key ) ;
return true ;
}
2013-08-05 00:14:20 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionMusic : : ActionMusic ( ZVision * engine , int32 slotkey , const Common : : String & line , bool global ) :
ResultAction ( engine , slotkey ) ,
2013-11-01 17:00:20 +07:00
_volume ( 255 ) ,
_universe ( global ) {
2013-08-05 00:14:20 -05:00
uint type ;
char fileNameBuffer [ 25 ] ;
uint loop ;
uint volume = 255 ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %u %25s %u %u " , & type , fileNameBuffer , & loop , & volume ) ;
2013-08-05 00:14:20 -05:00
// type 4 are midi sound effect files
if ( type = = 4 ) {
_soundType = Audio : : Mixer : : kSFXSoundType ;
_fileName = Common : : String : : format ( " midi/%s/%u.wav " , fileNameBuffer , loop ) ;
_loop = false ;
} else {
// TODO: See what the other types are so we can specify the correct Mixer::SoundType. In the meantime use kPlainSoundType
_soundType = Audio : : Mixer : : kPlainSoundType ;
_fileName = Common : : String ( fileNameBuffer ) ;
_loop = loop = = 1 ? true : false ;
}
// Volume is optional. If it doesn't appear, assume full volume
if ( volume ! = 255 ) {
// Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255]
_volume = volume * 255 / 100 ;
}
}
2013-11-01 17:00:20 +07:00
ActionMusic : : ~ ActionMusic ( ) {
if ( ! _universe )
2013-11-25 13:30:29 +00:00
_engine - > getScriptManager ( ) - > killSideFx ( _slotkey ) ;
2013-11-01 17:00:20 +07:00
}
2013-08-05 00:14:20 -05:00
2013-11-01 17:00:20 +07:00
bool ActionMusic : : execute ( ) {
2013-11-25 13:30:29 +00:00
if ( _engine - > getScriptManager ( ) - > getSideFX ( _slotkey ) )
2013-11-01 17:00:20 +07:00
return true ;
Common : : File * file = new Common : : File ( ) ;
if ( ! file - > exists ( _fileName ) & & _fileName . size ( ) > = 12 ) {
_fileName . setChar ( ' r ' , 9 ) ;
_fileName . setChar ( ' a ' , 10 ) ;
_fileName . setChar ( ' w ' , 11 ) ;
if ( ! file - > exists ( _fileName ) ) {
_fileName . setChar ( ' i ' , 9 ) ;
_fileName . setChar ( ' f ' , 10 ) ;
_fileName . setChar ( ' p ' , 11 ) ;
if ( ! file - > exists ( _fileName ) ) {
_fileName . setChar ( ' s ' , 9 ) ;
_fileName . setChar ( ' r ' , 10 ) ;
_fileName . setChar ( ' c ' , 11 ) ;
if ( ! file - > exists ( _fileName ) )
return true ;
}
2013-08-05 00:14:20 -05:00
}
}
2013-11-01 17:00:20 +07:00
if ( file - > exists ( _fileName ) )
2013-11-25 13:30:29 +00:00
_engine - > getScriptManager ( ) - > addSideFX ( new MusicNode ( _engine , _slotkey , _fileName , _loop , _volume ) ) ;
2013-11-01 17:00:20 +07:00
delete file ;
2013-08-05 00:14:20 -05:00
return true ;
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionPreloadAnimation : : ActionPreloadAnimation ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-08-03 13:43:46 -05:00
char fileName [ 25 ] ;
2013-07-30 14:33:53 -05:00
// The two %*u are always 0 and dont seem to have a use
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %25s %*u %*u %d %d " , fileName , & _mask , & _framerate ) ;
2013-11-15 18:34:11 +00:00
if ( _mask > 0 ) {
byte r , g , b ;
Graphics : : PixelFormat ( 2 , 5 , 5 , 5 , 0 , 10 , 5 , 0 , 0 ) . colorToRGB ( _mask , r , g , b ) ;
_mask = _engine - > _pixelFormat . RGBToColor ( r , g , b ) ;
}
2013-07-06 00:29:15 -05:00
2013-08-03 13:43:46 -05:00
_fileName = Common : : String ( fileName ) ;
2013-07-29 21:42:07 -05:00
}
2013-11-15 18:34:11 +00:00
ActionPreloadAnimation : : ~ ActionPreloadAnimation ( ) {
2013-11-25 13:30:29 +00:00
_engine - > getScriptManager ( ) - > deleteSideFx ( _slotkey ) ;
2013-11-15 18:34:11 +00:00
}
2013-09-07 18:08:20 -05:00
2013-11-15 18:34:11 +00:00
bool ActionPreloadAnimation : : execute ( ) {
2013-11-25 13:30:29 +00:00
AnimationNode * nod = ( AnimationNode * ) _engine - > getScriptManager ( ) - > getSideFX ( _slotkey ) ;
2013-09-07 18:08:20 -05:00
2013-11-15 18:34:11 +00:00
if ( ! nod ) {
2013-11-25 13:30:29 +00:00
nod = new AnimationNode ( _engine , _slotkey , _fileName , _mask , _framerate , false ) ;
2013-11-15 18:34:11 +00:00
_engine - > getScriptManager ( ) - > addSideFX ( nod ) ;
} else
nod - > stop ( ) ;
2013-07-06 00:29:15 -05:00
return true ;
}
//////////////////////////////////////////////////////////////////////////////
// ActionPlayAnimation
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionPlayAnimation : : ActionPlayAnimation ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-08-02 09:59:20 -05:00
char fileName [ 25 ] ;
2013-07-30 14:33:53 -05:00
// The two %*u are always 0 and dont seem to have a use
sscanf ( line . c_str ( ) ,
2013-11-25 13:30:29 +00:00
" %25s %u %u %u %u %u %u %d %*u %*u %d %d " ,
fileName , & _x , & _y , & _x2 , & _y2 , & _start , & _end , & _loopCount , & _mask , & _framerate ) ;
2013-08-02 09:59:20 -05:00
2013-11-15 18:34:11 +00:00
if ( _mask > 0 ) {
byte r , g , b ;
Graphics : : PixelFormat ( 2 , 5 , 5 , 5 , 0 , 10 , 5 , 0 , 0 ) . colorToRGB ( _mask , r , g , b ) ;
_mask = _engine - > _pixelFormat . RGBToColor ( r , g , b ) ;
}
2013-08-02 09:59:20 -05:00
_fileName = Common : : String ( fileName ) ;
2013-07-06 00:29:15 -05:00
}
2013-11-15 18:34:11 +00:00
ActionPlayAnimation : : ~ ActionPlayAnimation ( ) {
2013-11-25 13:30:29 +00:00
_engine - > getScriptManager ( ) - > deleteSideFx ( _slotkey ) ;
2013-11-15 18:34:11 +00:00
}
2013-10-29 18:33:37 +00:00
bool ActionPlayAnimation : : execute ( ) {
2013-11-25 13:30:29 +00:00
AnimationNode * nod = ( AnimationNode * ) _engine - > getScriptManager ( ) - > getSideFX ( _slotkey ) ;
2013-11-15 18:34:11 +00:00
if ( ! nod ) {
2013-11-25 13:30:29 +00:00
nod = new AnimationNode ( _engine , _slotkey , _fileName , _mask , _framerate ) ;
2013-11-15 18:34:11 +00:00
_engine - > getScriptManager ( ) - > addSideFX ( nod ) ;
} else
nod - > stop ( ) ;
if ( nod )
2013-11-25 13:30:29 +00:00
nod - > addPlayNode ( _slotkey , _x , _y , _x2 , _y2 , _start , _end , _loopCount ) ;
2013-11-15 18:34:11 +00:00
2013-07-06 00:29:15 -05:00
return true ;
}
2013-09-07 18:08:49 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionPlayPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionPlayPreloadAnimation : : ActionPlayPreloadAnimation ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-09-07 18:08:49 -05:00
sscanf ( line . c_str ( ) ,
2013-11-25 13:30:29 +00:00
" %u %u %u %u %u %u %u %u " ,
& _controlKey , & _x1 , & _y1 , & _x2 , & _y2 , & _startFrame , & _endFrame , & _loopCount ) ;
2013-09-07 18:08:49 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionPlayPreloadAnimation : : execute ( ) {
2013-11-25 13:30:29 +00:00
AnimationNode * nod = ( AnimationNode * ) _engine - > getScriptManager ( ) - > getSideFX ( _controlKey ) ;
2013-11-15 18:34:11 +00:00
if ( nod )
2013-11-25 13:30:29 +00:00
nod - > addPlayNode ( _slotkey , _x1 , _y1 , _x2 , _y2 , _startFrame , _endFrame , _loopCount ) ;
2013-09-07 18:08:49 -05:00
return true ;
}
2013-08-10 17:12:23 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionQuit
//////////////////////////////////////////////////////////////////////////////
2013-10-29 18:33:37 +00:00
bool ActionQuit : : execute ( ) {
_engine - > quitGame ( ) ;
2013-08-10 17:12:23 -05:00
return true ;
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
2013-07-03 17:21:21 -05:00
// ActionRandom
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionRandom : : ActionRandom ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-10-31 09:53:17 +07:00
char max_buf [ 64 ] ;
memset ( max_buf , 0 , 64 ) ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %s " , max_buf ) ;
2013-10-31 09:53:17 +07:00
_max = new ValueSlot ( _engine - > getScriptManager ( ) , max_buf ) ;
}
ActionRandom : : ~ ActionRandom ( ) {
if ( _max )
delete _max ;
2013-07-03 17:21:21 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionRandom : : execute ( ) {
2013-10-31 09:53:17 +07:00
uint randNumber = _engine - > getRandomSource ( ) - > getRandomNumber ( _max - > getValue ( ) ) ;
2013-11-25 13:30:29 +00:00
_engine - > getScriptManager ( ) - > setStateValue ( _slotkey , randNumber ) ;
2013-07-03 17:21:21 -05:00
return true ;
}
2013-07-06 00:29:15 -05:00
2013-08-19 23:43:02 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionSetPartialScreen
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionSetPartialScreen : : ActionSetPartialScreen ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-08-19 23:43:02 -05:00
char fileName [ 25 ] ;
2013-10-29 19:41:38 +00:00
int color ;
2013-08-19 23:43:02 -05:00
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %u %u %25s %*u %d " , & _x , & _y , fileName , & color ) ;
2013-08-19 23:43:02 -05:00
_fileName = Common : : String ( fileName ) ;
2013-10-29 19:41:38 +00:00
if ( color > = 0 ) {
byte r , g , b ;
Graphics : : PixelFormat ( 2 , 5 , 5 , 5 , 0 , 10 , 5 , 0 , 0 ) . colorToRGB ( color , r , g , b ) ;
_backgroundColor = _engine - > _pixelFormat . RGBToColor ( r , g , b ) ;
} else {
_backgroundColor = color ;
}
if ( color > 65535 ) {
2013-08-19 23:43:02 -05:00
warning ( " Background color for ActionSetPartialScreen is bigger than a uint16 " ) ;
}
}
2013-10-29 18:33:37 +00:00
bool ActionSetPartialScreen : : execute ( ) {
RenderManager * renderManager = _engine - > getRenderManager ( ) ;
2013-10-20 20:07:31 +00:00
if ( _backgroundColor > = 0 )
renderManager - > renderImageToBackground ( _fileName , _x , _y , _backgroundColor ) ;
else
renderManager - > renderImageToBackground ( _fileName , _x , _y ) ;
2013-08-19 23:43:02 -05:00
return true ;
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
2013-08-03 15:00:58 -05:00
// ActionSetScreen
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionSetScreen : : ActionSetScreen ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-08-03 15:00:58 -05:00
char fileName [ 25 ] ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %25s " , fileName ) ;
2013-08-03 15:00:58 -05:00
_fileName = Common : : String ( fileName ) ;
2013-07-06 00:29:15 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionSetScreen : : execute ( ) {
_engine - > getRenderManager ( ) - > setBackgroundImage ( _fileName ) ;
2013-08-03 15:00:58 -05:00
return true ;
}
2013-11-01 16:55:19 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionStop
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionStop : : ActionStop ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-11-01 16:55:19 +07:00
_key = 0 ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %u " , & _key ) ;
2013-11-01 16:55:19 +07:00
}
bool ActionStop : : execute ( ) {
_engine - > getScriptManager ( ) - > stopSideFx ( _key ) ;
return true ;
}
2013-08-03 15:00:58 -05:00
2013-08-10 17:18:29 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionStreamVideo
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionStreamVideo : : ActionStreamVideo ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-08-10 17:18:29 -05:00
char fileName [ 25 ] ;
2013-10-17 21:24:50 +00:00
uint skipline ; //skipline - render video with skip every second line, not skippable.
2013-08-10 17:18:29 -05:00
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %25s %u %u %u %u %u %u " , fileName , & _x1 , & _y1 , & _x2 , & _y2 , & _flags , & skipline ) ;
2013-08-10 17:18:29 -05:00
_fileName = Common : : String ( fileName ) ;
2013-10-17 21:24:50 +00:00
_skippable = true ;
2013-08-10 17:18:29 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionStreamVideo : : execute ( ) {
2013-08-10 17:18:29 -05:00
ZorkAVIDecoder decoder ;
if ( ! decoder . loadFile ( _fileName ) ) {
return true ;
}
Common : : Rect destRect ;
2013-10-01 17:01:56 -05:00
if ( ( _flags & DIFFERENT_DIMENSIONS ) = = DIFFERENT_DIMENSIONS ) {
2013-08-11 13:39:52 -05:00
destRect = Common : : Rect ( _x1 , _y1 , _x2 , _y2 ) ;
2013-08-10 17:18:29 -05:00
}
2013-10-29 18:33:37 +00:00
_engine - > playVideo ( decoder , destRect , _skippable ) ;
2013-08-10 17:18:29 -05:00
return true ;
}
2013-08-03 15:00:58 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionTimer
//////////////////////////////////////////////////////////////////////////////
2013-11-25 13:30:29 +00:00
ActionTimer : : ActionTimer ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2013-10-30 16:21:38 +07:00
char time_buf [ 64 ] ;
memset ( time_buf , 0 , 64 ) ;
2013-11-25 13:30:29 +00:00
sscanf ( line . c_str ( ) , " %s " , time_buf ) ;
2013-10-30 16:21:38 +07:00
_time = new ValueSlot ( _engine - > getScriptManager ( ) , time_buf ) ;
}
ActionTimer : : ~ ActionTimer ( ) {
if ( _time )
delete _time ;
2013-11-25 13:30:29 +00:00
_engine - > getScriptManager ( ) - > killSideFx ( _slotkey ) ;
2013-07-29 21:42:07 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionTimer : : execute ( ) {
2013-11-25 13:30:29 +00:00
_engine - > getScriptManager ( ) - > addSideFX ( new TimerNode ( _engine , _slotkey , _time - > getValue ( ) ) ) ;
2013-07-06 00:29:15 -05:00
return true ;
}
2013-07-01 17:13:02 -05:00
} // End of namespace ZVision