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"
2014-06-14 15:18:24 +07:00
# include "zvision/scripting/actions.h"
2013-10-01 20:08:41 -05:00
2013-07-03 18:21:25 -05:00
# include "zvision/zvision.h"
2014-06-14 15:18:24 +07:00
# include "zvision/scripting/script_manager.h"
# include "zvision/graphics/render_manager.h"
# include "zvision/sound/zork_raw.h"
# include "zvision/video/zork_avi_decoder.h"
2014-07-02 19:50:55 +00:00
# include "zvision/scripting/sidefx/timer_node.h"
# include "zvision/scripting/sidefx/music_node.h"
# include "zvision/scripting/sidefx/syncsound_node.h"
# include "zvision/scripting/sidefx/animation_node.h"
2014-10-23 17:09:58 +07:00
# include "zvision/scripting/sidefx/distort_node.h"
2014-07-02 19:50:55 +00:00
# include "zvision/scripting/sidefx/ttytext_node.h"
2014-10-10 16:40:46 +07:00
# include "zvision/scripting/sidefx/region_node.h"
2014-09-10 16:20:50 +07:00
# include "zvision/scripting/controls/titler_control.h"
2014-10-10 16:40:46 +07:00
# include "zvision/graphics/render_table.h"
# include "zvision/graphics/effect.h"
# include "zvision/graphics/effects/fog.h"
# include "zvision/graphics/effects/light.h"
# include "zvision/graphics/effects/wave.h"
2014-11-08 13:06:48 +06:00
# include "zvision/core/save_manager.h"
2014-12-16 01:00:50 +02:00
# include "zvision/graphics/cursors/cursor_manager.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-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 ( ) {
2014-01-17 11:07:58 +07:00
SideFX * fx = _engine - > getScriptManager ( ) - > getSideFX ( _key ) ;
if ( fx & & fx - > getType ( ) = = SideFX : : SIDEFX_AUDIO ) {
MusicNode * mus = ( MusicNode * ) fx ;
mus - > setVolume ( 255 - ( abs ( _attenuation ) > > 7 ) ) ;
}
2013-07-06 00:29:15 -05:00
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 ( ) ,
2014-01-17 11:10:17 +07:00
" %u %u %d %d %d %d %d " ,
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 ( ) {
2014-01-17 11:10:17 +07:00
if ( _keyOne ) {
SideFX * fx = _engine - > getScriptManager ( ) - > getSideFX ( _keyOne ) ;
if ( fx & & fx - > getType ( ) = = SideFX : : SIDEFX_AUDIO ) {
MusicNode * mus = ( MusicNode * ) fx ;
if ( _oneStartVolume > = 0 )
mus - > setVolume ( ( _oneStartVolume * 255 ) / 100 ) ;
mus - > setFade ( _timeInMillis , ( _oneEndVolume * 255 ) / 100 ) ;
}
}
if ( _keyTwo ) {
SideFX * fx = _engine - > getScriptManager ( ) - > getSideFX ( _keyTwo ) ;
if ( fx & & fx - > getType ( ) = = SideFX : : SIDEFX_AUDIO ) {
MusicNode * mus = ( MusicNode * ) fx ;
if ( _twoStartVolume > = 0 )
mus - > setVolume ( ( _twoStartVolume * 255 ) / 100 ) ;
mus - > setFade ( _timeInMillis , ( _twoEndVolume * 255 ) / 100 ) ;
}
}
2013-07-06 00:29:15 -05:00
return true ;
}
2014-11-12 14:31:48 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionCursor
//////////////////////////////////////////////////////////////////////////////
ActionCursor : : ActionCursor ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
Common : : String up = line ;
up . toUppercase ( ) ;
_action = 0 ;
if ( up [ 0 ] = = ' B ' )
_action = 2 ;
else if ( up [ 0 ] = = ' I ' )
_action = 3 ;
else if ( up [ 0 ] = = ' U ' )
_action = 0 ;
else if ( up [ 0 ] = = ' H ' )
_action = 1 ;
}
bool ActionCursor : : execute ( ) {
switch ( _action ) {
case 1 :
_engine - > getCursorManager ( ) - > showMouse ( false ) ;
break ;
default :
_engine - > getCursorManager ( ) - > showMouse ( true ) ;
break ;
}
return true ;
}
2014-11-08 12:26:04 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionDelayRender
//////////////////////////////////////////////////////////////////////////////
ActionDelayRender : : ActionDelayRender ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %u " , & _framesToDelay ) ;
}
bool ActionDelayRender : : execute ( ) {
_engine - > setRenderDelay ( _framesToDelay ) ;
return true ;
}
2013-07-06 00:29:15 -05:00
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 ;
}
2014-11-08 12:44:00 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionDisableVenus
//////////////////////////////////////////////////////////////////////////////
ActionDisableVenus : : ActionDisableVenus ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %d " , & _key ) ;
}
bool ActionDisableVenus : : execute ( ) {
_engine - > getScriptManager ( ) - > setStateValue ( _key , 0 ) ;
return true ;
}
2014-09-10 16:20:50 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionDisplayMessage
//////////////////////////////////////////////////////////////////////////////
ActionDisplayMessage : : ActionDisplayMessage ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %hd %hd " , & _control , & _msgid ) ;
}
bool ActionDisplayMessage : : execute ( ) {
Control * ctrl = _engine - > getScriptManager ( ) - > getControl ( _control ) ;
if ( ctrl & & ctrl - > getType ( ) = = Control : : CONTROL_TITLER ) {
TitlerControl * titler = ( TitlerControl * ) ctrl ;
titler - > setString ( _msgid ) ;
}
return true ;
}
2013-08-18 15:29:23 -05:00
2014-11-08 12:58:11 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionDissolve
//////////////////////////////////////////////////////////////////////////////
ActionDissolve : : ActionDissolve ( ZVision * engine ) :
ResultAction ( engine , 0 ) {
}
bool ActionDissolve : : execute ( ) {
// Cause black screen flick
// _engine->getRenderManager()->bkgFill(0, 0, 0);
return true ;
}
2014-10-23 17:09:58 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionDistort
//////////////////////////////////////////////////////////////////////////////
ActionDistort : : ActionDistort ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
2014-11-20 14:48:24 +06:00
sscanf ( line . c_str ( ) , " %hd %hd %f %f %f %f " , & _distSlot , & _speed , & _startAngle , & _endAngle , & _startLineScale , & _endLineScale ) ;
2014-10-23 17:09:58 +07:00
}
ActionDistort : : ~ ActionDistort ( ) {
_engine - > getScriptManager ( ) - > killSideFx ( _distSlot ) ;
}
bool ActionDistort : : execute ( ) {
if ( _engine - > getScriptManager ( ) - > getSideFX ( _distSlot ) )
return true ;
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new DistortNode ( _engine , _distSlot , _speed , _startAngle , _endAngle , _startLineScale , _endLineScale ) ) ;
2014-10-23 17:09:58 +07:00
return true ;
}
2013-08-18 15:29:23 -05:00
//////////////////////////////////////////////////////////////////////////////
// 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 ;
}
2014-11-08 12:59:58 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionFlushMouseEvents
//////////////////////////////////////////////////////////////////////////////
ActionFlushMouseEvents : : ActionFlushMouseEvents ( ZVision * engine , int32 slotkey ) :
ResultAction ( engine , slotkey ) {
}
bool ActionFlushMouseEvents : : execute ( ) {
_engine - > getScriptManager ( ) - > flushEvent ( Common : : EVENT_LBUTTONUP ) ;
_engine - > getScriptManager ( ) - > flushEvent ( Common : : EVENT_LBUTTONDOWN ) ;
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
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > inventoryAdd ( _key ) ;
2013-11-20 11:44:43 +00:00
break ;
case 1 : // addi
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > inventoryAdd ( _engine - > getScriptManager ( ) - > getStateValue ( _key ) ) ;
2013-11-20 11:44:43 +00:00
break ;
case 2 : // drop
if ( _key > = 0 )
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > inventoryDrop ( _key ) ;
2013-11-20 11:44:43 +00:00
else
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > inventoryDrop ( _engine - > getScriptManager ( ) - > getStateValue ( StateKey_InventoryItem ) ) ;
2013-11-20 11:44:43 +00:00
break ;
case 3 : // dropi
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > inventoryDrop ( _engine - > getScriptManager ( ) - > getStateValue ( _key ) ) ;
2013-11-20 11:44:43 +00:00
break ;
case 4 : // cycle
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > inventoryCycle ( ) ;
2013-11-20 11:44:43 +00:00
break ;
default :
break ;
}
return true ;
}
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 ;
}
2014-11-08 13:02:48 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionMenuBarEnable
//////////////////////////////////////////////////////////////////////////////
ActionMenuBarEnable : : ActionMenuBarEnable ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %hu " , & _menus ) ;
}
bool ActionMenuBarEnable : : execute ( ) {
_engine - > menuBarEnable ( _menus ) ;
return true ;
}
2013-11-01 16:53:46 +07:00
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 ) {
2014-10-22 11:49:24 +07:00
_midi = true ;
int note ;
int prog ;
sscanf ( line . c_str ( ) , " %u %d %d %u " , & type , & prog , & note , & volume ) ;
_volume = volume ;
_note = note ;
_prog = prog ;
2013-08-05 00:14:20 -05:00
} else {
2014-10-22 11:49:24 +07:00
_midi = false ;
2013-08-05 00:14:20 -05:00
_fileName = Common : : String ( fileNameBuffer ) ;
_loop = loop = = 1 ? true : false ;
2014-10-22 11:49:24 +07:00
// 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-08-05 00:14:20 -05:00
}
}
2013-11-01 17:00:20 +07:00
ActionMusic : : ~ ActionMusic ( ) {
if ( ! _universe )
2014-11-20 14:48:24 +06: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 ( ) {
2014-11-20 14:48:24 +06:00
if ( _engine - > getScriptManager ( ) - > getSideFX ( _slotKey ) )
2013-11-01 17:00:20 +07:00
return true ;
2014-02-04 08:32:02 +07:00
2014-10-22 11:49:24 +07:00
if ( _midi ) {
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new MusicMidiNode ( _engine , _slotKey , _prog , _note , _volume ) ) ;
2014-10-22 11:49:24 +07:00
} else {
if ( ! _engine - > getSearchManager ( ) - > hasFile ( _fileName ) )
return true ;
2014-02-04 08:32:02 +07:00
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new MusicNode ( _engine , _slotKey , _fileName , _loop , _volume ) ) ;
2014-10-22 11:49:24 +07:00
}
2013-08-05 00:14:20 -05:00
return true ;
}
2014-01-17 10:57:29 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionPanTrack
//////////////////////////////////////////////////////////////////////////////
ActionPanTrack : : ActionPanTrack ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) ,
_pos ( 0 ) ,
2014-11-20 14:48:24 +06:00
_musicSlot ( 0 ) {
2014-01-17 10:57:29 +07:00
2014-11-20 14:48:24 +06:00
sscanf ( line . c_str ( ) , " %u %d " , & _musicSlot , & _pos ) ;
2014-01-17 10:57:29 +07:00
}
ActionPanTrack : : ~ ActionPanTrack ( ) {
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > killSideFx ( _slotKey ) ;
2014-01-17 10:57:29 +07:00
}
bool ActionPanTrack : : execute ( ) {
2014-11-20 14:48:24 +06:00
if ( _engine - > getScriptManager ( ) - > getSideFX ( _slotKey ) )
2014-01-17 10:57:29 +07:00
return true ;
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new PanTrackNode ( _engine , _slotKey , _musicSlot , _pos ) ) ;
2014-01-17 10:57:29 +07:00
return true ;
}
2013-08-05 00:14:20 -05:00
2014-11-08 13:04:27 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionPreferences
//////////////////////////////////////////////////////////////////////////////
ActionPreferences : : ActionPreferences ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
if ( line . compareToIgnoreCase ( " save " ) = = 0 )
_save = true ;
else
_save = false ;
}
bool ActionPreferences : : execute ( ) {
if ( _save )
_engine - > saveSettings ( ) ;
else
_engine - > loadSettings ( ) ;
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 ( ) {
2014-11-20 14:48:24 +06: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 ( ) {
2014-11-20 14:48:24 +06: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 ) {
2014-11-20 14:48:24 +06: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 ( ) ;
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > setStateValue ( _slotKey , 2 ) ;
2013-07-06 00:29:15 -05:00
return true ;
}
2014-11-08 12:21:38 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionUnloadAnimation
//////////////////////////////////////////////////////////////////////////////
ActionUnloadAnimation : : ActionUnloadAnimation ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %u " , & _key ) ;
}
bool ActionUnloadAnimation : : execute ( ) {
AnimationNode * nod = ( AnimationNode * ) _engine - > getScriptManager ( ) - > getSideFX ( _key ) ;
if ( nod & & nod - > getType ( ) = = SideFX : : SIDEFX_ANIM )
_engine - > getScriptManager ( ) - > deleteSideFx ( _key ) ;
return true ;
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
// 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 ( ) {
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > deleteSideFx ( _slotKey ) ;
2013-11-15 18:34:11 +00:00
}
2013-10-29 18:33:37 +00:00
bool ActionPlayAnimation : : execute ( ) {
2014-11-20 14:48:24 +06:00
AnimationNode * nod = ( AnimationNode * ) _engine - > getScriptManager ( ) - > getSideFX ( _slotKey ) ;
2013-11-15 18:34:11 +00:00
if ( ! nod ) {
2014-11-20 14:48:24 +06: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 )
2014-11-20 14:48:24 +06: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 )
2014-11-20 14:48:24 +06: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 ;
}
2014-10-10 16:40:46 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionRegion
//////////////////////////////////////////////////////////////////////////////
ActionRegion : : ActionRegion ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
char art [ 64 ] ;
char custom [ 64 ] ;
int32 x1 , x2 , y1 , y2 ;
sscanf ( line . c_str ( ) , " %s %d %d %d %d %hu %hu %hu %hu %s " , art , & x1 , & y1 , & x2 , & y2 , & _delay , & _type , & _unk1 , & _unk2 , custom ) ;
_art = Common : : String ( art ) ;
_custom = Common : : String ( custom ) ;
_rect = Common : : Rect ( x1 , y1 , x2 + 1 , y2 + 1 ) ;
}
ActionRegion : : ~ ActionRegion ( ) {
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > killSideFx ( _slotKey ) ;
2014-10-10 16:40:46 +07:00
}
bool ActionRegion : : execute ( ) {
2014-11-20 14:48:24 +06:00
if ( _engine - > getScriptManager ( ) - > getSideFX ( _slotKey ) )
2014-10-10 16:40:46 +07:00
return true ;
Effect * effct = NULL ;
switch ( _type ) {
case 0 : {
2014-11-20 14:48:24 +06:00
uint16 centerX , centerY , frames ;
2014-10-10 16:40:46 +07:00
double amplitude , waveln , speed ;
2014-11-20 14:48:24 +06:00
sscanf ( _custom . c_str ( ) , " %hu,%hu,%hu,%lf,%lf,%lf, " , & centerX , & centerY , & frames , & amplitude , & waveln , & speed ) ;
effct = new WaveFx ( _engine , _slotKey , _rect , _unk1 , frames , centerX , centerY , amplitude , waveln , speed ) ;
2014-10-10 16:40:46 +07:00
}
break ;
case 1 : {
uint16 aX , aY , aD ;
if ( _engine - > getRenderManager ( ) - > getRenderTable ( ) - > getRenderState ( ) = = RenderTable : : PANORAMA )
sscanf ( _art . c_str ( ) , " useart[%hu,%hu,%hu] " , & aY , & aX , & aD ) ;
else
sscanf ( _art . c_str ( ) , " useart[%hu,%hu,%hu] " , & aX , & aY , & aD ) ;
int8 minD ;
int8 maxD ;
EffectMap * _map = _engine - > getRenderManager ( ) - > makeEffectMap ( Common : : Point ( aX , aY ) , aD , _rect , & minD , & maxD ) ;
2014-11-20 14:48:24 +06:00
effct = new LightFx ( _engine , _slotKey , _rect , _unk1 , _map , atoi ( _custom . c_str ( ) ) , minD , maxD ) ;
2014-10-10 16:40:46 +07:00
}
break ;
case 9 : {
int16 dum1 ;
int32 dum2 ;
char buf [ 64 ] ;
sscanf ( _custom . c_str ( ) , " %hd,%d,%s " , & dum1 , & dum2 , buf ) ;
Graphics : : Surface tempMask ;
_engine - > getRenderManager ( ) - > readImageToSurface ( _art , tempMask ) ;
if ( _rect . width ( ) ! = tempMask . w )
_rect . setWidth ( tempMask . w ) ;
if ( _rect . height ( ) ! = tempMask . h )
_rect . setHeight ( tempMask . h ) ;
EffectMap * _map = _engine - > getRenderManager ( ) - > makeEffectMap ( tempMask , 0 ) ;
2014-11-20 14:48:24 +06:00
effct = new FogFx ( _engine , _slotKey , _rect , _unk1 , _map , Common : : String ( buf ) ) ;
2014-10-10 16:40:46 +07:00
}
break ;
default :
break ;
}
if ( effct ) {
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new RegionNode ( _engine , _slotKey , effct , _delay ) ) ;
2014-10-10 16:40:46 +07:00
_engine - > getRenderManager ( ) - > addEffect ( effct ) ;
}
return true ;
}
2013-08-10 17:12:23 -05:00
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 ) {
2014-11-20 14:48:24 +06:00
char maxBuffer [ 64 ] ;
memset ( maxBuffer , 0 , 64 ) ;
sscanf ( line . c_str ( ) , " %s " , maxBuffer ) ;
_max = new ValueSlot ( _engine - > getScriptManager ( ) , maxBuffer ) ;
2013-10-31 09:53:17 +07:00
}
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 ( ) ) ;
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > setStateValue ( _slotKey , randNumber ) ;
2013-07-03 17:21:21 -05:00
return true ;
}
2014-11-08 13:06:48 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionRestoreGame
//////////////////////////////////////////////////////////////////////////////
ActionRestoreGame : : ActionRestoreGame ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
char buf [ 128 ] ;
sscanf ( line . c_str ( ) , " %s " , buf ) ;
_fileName = Common : : String ( buf ) ;
}
bool ActionRestoreGame : : execute ( ) {
_engine - > getSaveManager ( ) - > loadGame ( _fileName ) ;
return false ;
}
2014-11-07 10:25:11 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionRotateTo
//////////////////////////////////////////////////////////////////////////////
ActionRotateTo : : ActionRotateTo ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %d, %d " , & _toPos , & _time ) ;
}
bool ActionRotateTo : : execute ( ) {
_engine - > rotateTo ( _toPos , _time ) ;
return true ;
}
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 ) {
2014-12-19 15:41:39 +06:00
_x = 0 ;
_y = 0 ;
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 ( ) ;
2014-11-12 14:36:30 +06:00
if ( _engine - > getGameId ( ) = = GID_NEMESIS ) {
if ( _backgroundColor )
renderManager - > renderImageToBackground ( _fileName , _x , _y , 0 , 0 ) ;
else
renderManager - > renderImageToBackground ( _fileName , _x , _y ) ;
} else {
if ( _backgroundColor > = 0 )
renderManager - > renderImageToBackground ( _fileName , _x , _y , _backgroundColor ) ;
else if ( _backgroundColor = = - 2 )
renderManager - > renderImageToBackground ( _fileName , _x , _y , 0 , 0 ) ;
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 ;
}
2014-11-08 12:44:00 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionSetVenus
//////////////////////////////////////////////////////////////////////////////
ActionSetVenus : : ActionSetVenus ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
sscanf ( line . c_str ( ) , " %d " , & _key ) ;
}
bool ActionSetVenus : : execute ( ) {
if ( _engine - > getScriptManager ( ) - > getStateValue ( _key ) )
_engine - > getScriptManager ( ) - > setStateValue ( StateKey_Venus , _key ) ;
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-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 ;
2014-02-04 08:32:02 +07:00
Common : : File * _file = _engine - > getSearchManager ( ) - > openFile ( _fileName ) ;
if ( _file ) {
if ( ! decoder . loadStream ( _file ) ) {
return true ;
}
2014-11-12 14:34:01 +06:00
_engine - > getCursorManager ( ) - > showMouse ( false ) ;
2014-03-02 00:03:25 +07:00
Common : : Rect destRect = Common : : Rect ( _x1 , _y1 , _x2 + 1 , _y2 + 1 ) ;
Common : : String subname = _fileName ;
subname . setChar ( ' s ' , subname . size ( ) - 3 ) ;
subname . setChar ( ' u ' , subname . size ( ) - 2 ) ;
subname . setChar ( ' b ' , subname . size ( ) - 1 ) ;
Subtitle * sub = NULL ;
if ( _engine - > getSearchManager ( ) - > hasFile ( subname ) )
sub = new Subtitle ( _engine , subname ) ;
_engine - > playVideo ( decoder , destRect , _skippable , sub ) ;
2013-08-10 17:18:29 -05:00
2014-11-12 14:34:01 +06:00
_engine - > getCursorManager ( ) - > showMouse ( true ) ;
2014-03-02 00:03:25 +07:00
if ( sub )
delete sub ;
2013-08-10 17:18:29 -05:00
}
return true ;
}
2014-03-01 20:41:13 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionSyncSound
//////////////////////////////////////////////////////////////////////////////
ActionSyncSound : : ActionSyncSound ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
char fileName [ 25 ] ;
2014-11-20 14:48:24 +06:00
int notUsed ;
2014-03-01 20:41:13 +07:00
2014-11-20 14:48:24 +06:00
sscanf ( line . c_str ( ) , " %d %d %25s " , & _syncto , & notUsed , fileName ) ;
2014-03-01 20:41:13 +07:00
_fileName = Common : : String ( fileName ) ;
}
bool ActionSyncSound : : execute ( ) {
SideFX * fx = _engine - > getScriptManager ( ) - > getSideFX ( _syncto ) ;
if ( ! fx )
return true ;
if ( ! ( fx - > getType ( ) & SideFX : : SIDEFX_ANIM ) )
return true ;
AnimationNode * animnode = ( AnimationNode * ) fx ;
if ( animnode - > getFrameDelay ( ) > 200 ) // Hack for fix incorrect framedelay in some animpreload
animnode - > setNewFrameDelay ( 66 ) ; // ~15fps
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new SyncSoundNode ( _engine , _slotKey , _fileName , _syncto ) ) ;
2014-03-01 20:41:13 +07:00
return true ;
}
2013-08-10 17:18:29 -05:00
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 ) {
2014-11-20 14:48:24 +06:00
char timeBuffer [ 64 ] ;
memset ( timeBuffer , 0 , 64 ) ;
sscanf ( line . c_str ( ) , " %s " , timeBuffer ) ;
_time = new ValueSlot ( _engine - > getScriptManager ( ) , timeBuffer ) ;
2013-10-30 16:21:38 +07:00
}
ActionTimer : : ~ ActionTimer ( ) {
if ( _time )
delete _time ;
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > killSideFx ( _slotKey ) ;
2013-07-29 21:42:07 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionTimer : : execute ( ) {
2014-11-20 14:48:24 +06:00
if ( _engine - > getScriptManager ( ) - > getSideFX ( _slotKey ) )
2014-02-24 20:40:20 +07:00
return true ;
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new TimerNode ( _engine , _slotKey , _time - > getValue ( ) ) ) ;
2013-07-06 00:29:15 -05:00
return true ;
}
2014-03-09 23:20:27 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionTtyText
//////////////////////////////////////////////////////////////////////////////
ActionTtyText : : ActionTtyText ( ZVision * engine , int32 slotkey , const Common : : String & line ) :
ResultAction ( engine , slotkey ) {
char filename [ 64 ] ;
int32 x1 , y1 , x2 , y2 ;
sscanf ( line . c_str ( ) , " %d %d %d %d %s %u " , & x1 , & y1 , & x2 , & y2 , filename , & _delay ) ;
_r = Common : : Rect ( x1 , y1 , x2 , y2 ) ;
_filename = Common : : String ( filename ) ;
}
ActionTtyText : : ~ ActionTtyText ( ) {
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > killSideFx ( _slotKey ) ;
2014-03-09 23:20:27 +07:00
}
bool ActionTtyText : : execute ( ) {
2014-11-20 14:48:24 +06:00
if ( _engine - > getScriptManager ( ) - > getSideFX ( _slotKey ) )
2014-03-09 23:20:27 +07:00
return true ;
2014-11-20 14:48:24 +06:00
_engine - > getScriptManager ( ) - > addSideFX ( new ttyTextNode ( _engine , _slotKey , _filename , _r , _delay ) ) ;
2014-03-09 23:20:27 +07:00
return true ;
}
2013-07-01 17:13:02 -05:00
} // End of namespace ZVision