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 .
2016-09-03 12:46:38 +02:00
*
2013-07-01 17:13:02 -05:00
* 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 .
2016-09-03 12:46:38 +02:00
*
2013-07-01 17:13:02 -05:00
* 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"
2015-01-07 11:29:28 +02:00
# include "video/video_decoder.h"
2013-07-01 17:13:02 -05:00
2015-01-10 22:03:15 +02:00
# include "zvision/scripting/actions.h"
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"
2014-12-26 04:03:20 +02:00
# include "zvision/file/save_manager.h"
2014-12-26 13:14:24 +02:00
# include "zvision/scripting/menu.h"
2014-12-30 01:10:36 -06:00
# include "zvision/scripting/effects/timer_effect.h"
# include "zvision/scripting/effects/music_effect.h"
# include "zvision/scripting/effects/syncsound_effect.h"
# include "zvision/scripting/effects/animation_effect.h"
# include "zvision/scripting/effects/distort_effect.h"
# include "zvision/scripting/effects/ttytext_effect.h"
# include "zvision/scripting/effects/region_effect.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"
2014-12-30 01:10:36 -06:00
# include "zvision/graphics/graphics_effect.h"
2014-10-10 16:40:46 +07:00
# include "zvision/graphics/effects/fog.h"
# include "zvision/graphics/effects/light.h"
# include "zvision/graphics/effects/wave.h"
2014-12-16 01:00:50 +02:00
# include "zvision/graphics/cursors/cursor_manager.h"
2013-07-01 17:13:02 -05:00
namespace ZVision {
2015-06-10 16:56:04 +01:00
ResultAction : : ResultAction ( ZVision * engine , int32 slotKey ) :
_engine ( engine ) ,
_slotKey ( slotKey ) ,
_scriptManager ( engine - > getScriptManager ( ) ) {
2015-02-14 15:07:15 +02:00
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
2013-07-03 17:21:21 -05:00
// ActionAdd
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionAdd : : ActionAdd ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:32:27 +06:00
_key = 0 ;
_value = 0 ;
2013-11-25 13:30:29 +00:00
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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > setStateValue ( _key , _scriptManager - > 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionAssign : : ActionAssign ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 15:42:19 +06:00
_key = 0 ;
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 ) ;
2015-02-14 15:07:15 +02:00
_value = new ValueSlot ( _scriptManager , buf ) ;
2013-11-07 16:46:54 +07:00
}
ActionAssign : : ~ ActionAssign ( ) {
2015-01-26 22:14:26 +01:00
delete _value ;
2013-07-03 17:21:21 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionAssign : : execute ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > setStateValue ( _key , _value - > getValue ( ) ) ;
2013-07-03 17:21:21 -05:00
return true ;
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionAttenuate
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionAttenuate : : ActionAttenuate ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:22:57 +06:00
_key = 0 ;
_attenuation = 0 ;
2013-11-25 13:30:29 +00:00
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 ( ) {
2015-02-14 15:07:15 +02:00
ScriptingEffect * fx = _scriptManager - > getSideFX ( _key ) ;
2014-12-30 01:10:36 -06:00
if ( fx & & fx - > getType ( ) = = ScriptingEffect : : SCRIPTING_EFFECT_AUDIO ) {
2015-01-23 16:31:10 +06:00
MusicNodeBASE * mus = ( MusicNodeBASE * ) fx ;
2015-01-23 16:26:17 +06:00
mus - > setVolume ( 255 * ( 10000 - abs ( _attenuation ) ) / 10000 ) ;
2014-01-17 11:07:58 +07:00
}
2013-07-06 00:29:15 -05:00
return true ;
}
//////////////////////////////////////////////////////////////////////////////
// ActionChangeLocation
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionChangeLocation : : ActionChangeLocation ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:35:15 +06:00
_world = ' g ' ;
_room = ' a ' ;
_node = ' r ' ;
_view = ' y ' ;
_offset = 0 ;
2013-11-25 13:30:29 +00:00
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
2015-02-14 15:07:15 +02:00
_scriptManager - > 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionCrossfade : : ActionCrossfade ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:31:33 +06:00
_keyOne = 0 ;
_keyTwo = 0 ;
_oneStartVolume = 0 ;
_twoStartVolume = 0 ;
_oneEndVolume = 0 ;
_twoEndVolume = 0 ;
_timeInMillis = 0 ;
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 ) {
2015-02-14 15:07:15 +02:00
ScriptingEffect * fx = _scriptManager - > getSideFX ( _keyOne ) ;
2014-12-30 01:10:36 -06:00
if ( fx & & fx - > getType ( ) = = ScriptingEffect : : SCRIPTING_EFFECT_AUDIO ) {
2015-01-23 16:31:10 +06:00
MusicNodeBASE * mus = ( MusicNodeBASE * ) fx ;
2014-01-17 11:10:17 +07:00
if ( _oneStartVolume > = 0 )
mus - > setVolume ( ( _oneStartVolume * 255 ) / 100 ) ;
mus - > setFade ( _timeInMillis , ( _oneEndVolume * 255 ) / 100 ) ;
}
}
if ( _keyTwo ) {
2015-02-14 15:07:15 +02:00
ScriptingEffect * fx = _scriptManager - > getSideFX ( _keyTwo ) ;
2014-12-30 01:10:36 -06:00
if ( fx & & fx - > getType ( ) = = ScriptingEffect : : SCRIPTING_EFFECT_AUDIO ) {
2015-01-23 16:31:10 +06:00
MusicNodeBASE * mus = ( MusicNodeBASE * ) fx ;
2014-01-17 11:10:17 +07:00
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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionCursor : : ActionCursor ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-11-12 14:31:48 +06:00
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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionDelayRender : : ActionDelayRender ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:39:21 +06:00
_framesToDelay = 0 ;
2014-11-08 12:26:04 +06:00
sscanf ( line . c_str ( ) , " %u " , & _framesToDelay ) ;
2015-02-14 15:27:01 +02:00
// Limit to 10 frames maximum. This fixes the script bug in ZGI scene px10
// (outside Frobozz Electric building), where this is set to 100 (bug #6791).
_framesToDelay = MIN < uint32 > ( _framesToDelay , 10 ) ;
2014-11-08 12:26:04 +06:00
}
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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionDisableControl : : ActionDisableControl ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 17:04:26 +06:00
_key = 0 ;
2013-11-25 13:30:29 +00:00
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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > setStateFlag ( _key , Puzzle : : DISABLED ) ;
2013-08-18 15:29:23 -05:00
return true ;
}
2014-09-10 16:20:50 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionDisplayMessage
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionDisplayMessage : : ActionDisplayMessage ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 15:44:41 +06:00
_control = 0 ;
_msgid = 0 ;
2014-09-10 16:20:50 +07:00
sscanf ( line . c_str ( ) , " %hd %hd " , & _control , & _msgid ) ;
}
bool ActionDisplayMessage : : execute ( ) {
2015-02-14 15:07:15 +02:00
Control * ctrl = _scriptManager - > getControl ( _control ) ;
2014-09-10 16:20:50 +07:00
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
//////////////////////////////////////////////////////////////////////////////
2014-12-26 12:04:21 +02:00
// ActionDistort - only used by Zork: Nemesis for the "treatment" puzzle in the Sanitarium (aj30)
2014-10-23 17:09:58 +07:00
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionDistort : : ActionDistort ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:44:18 +06:00
_distSlot = 0 ;
_speed = 0 ;
_startAngle = 60.0 ;
_endAngle = 60.0 ;
_startLineScale = 1.0 ;
_endLineScale = 1.0 ;
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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFx ( _distSlot ) ;
2014-10-23 17:09:58 +07:00
}
bool ActionDistort : : execute ( ) {
2015-02-14 15:07:15 +02:00
if ( _scriptManager - > getSideFX ( _distSlot ) )
2014-10-23 17:09:58 +07:00
return true ;
2015-02-14 15:07:15 +02:00
_scriptManager - > 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionEnableControl : : ActionEnableControl ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:38:34 +06:00
_key = 0 ;
2013-11-25 13:30:29 +00:00
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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > unsetStateFlag ( _key , Puzzle : : DISABLED ) ;
2013-08-18 15:29:23 -05:00
return true ;
}
2014-11-08 12:59:58 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionFlushMouseEvents
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionFlushMouseEvents : : ActionFlushMouseEvents ( ZVision * engine , int32 slotKey ) :
ResultAction ( engine , slotKey ) {
2014-11-08 12:59:58 +06:00
}
bool ActionFlushMouseEvents : : execute ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > flushEvent ( Common : : EVENT_LBUTTONUP ) ;
_scriptManager - > flushEvent ( Common : : EVENT_LBUTTONDOWN ) ;
2014-11-08 12:59:58 +06:00
return true ;
}
2013-11-20 11:44:43 +00:00
//////////////////////////////////////////////////////////////////////////////
// ActionInventory
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionInventory : : ActionInventory ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 17:05:03 +06:00
_type = - 1 ;
_key = 0 ;
2013-11-20 11:44:43 +00:00
char buf [ 25 ] ;
2014-12-23 02:20:17 +02:00
sscanf ( line . c_str ( ) , " %24s %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
2015-02-14 15:07:15 +02:00
_scriptManager - > inventoryAdd ( _key ) ;
2013-11-20 11:44:43 +00:00
break ;
case 1 : // addi
2015-02-14 15:07:15 +02:00
_scriptManager - > inventoryAdd ( _scriptManager - > getStateValue ( _key ) ) ;
2013-11-20 11:44:43 +00:00
break ;
case 2 : // drop
if ( _key > = 0 )
2015-02-14 15:07:15 +02:00
_scriptManager - > inventoryDrop ( _key ) ;
2013-11-20 11:44:43 +00:00
else
2015-02-14 15:07:15 +02:00
_scriptManager - > inventoryDrop ( _scriptManager - > getStateValue ( StateKey_InventoryItem ) ) ;
2013-11-20 11:44:43 +00:00
break ;
case 3 : // dropi
2015-02-14 15:07:15 +02:00
_scriptManager - > inventoryDrop ( _scriptManager - > getStateValue ( _key ) ) ;
2013-11-20 11:44:43 +00:00
break ;
case 4 : // cycle
2015-02-14 15:07:15 +02:00
_scriptManager - > inventoryCycle ( ) ;
2013-11-20 11:44:43 +00:00
break ;
default :
break ;
}
return true ;
}
2013-11-01 16:53:46 +07:00
//////////////////////////////////////////////////////////////////////////////
2014-12-26 12:04:21 +02:00
// ActionKill - only used by ZGI
2013-11-01 16:53:46 +07:00
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01: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 ] ;
2014-12-23 02:20:17 +02:00
sscanf ( line . c_str ( ) , " %24s " , keytype ) ;
2013-11-01 16:53:46 +07:00
if ( keytype [ 0 ] = = ' " ' ) {
if ( ! scumm_stricmp ( keytype , " \" ANIM \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_ANIM ;
2013-11-01 16:53:46 +07:00
else if ( ! scumm_stricmp ( keytype , " \" AUDIO \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_AUDIO ;
2013-11-01 16:53:46 +07:00
else if ( ! scumm_stricmp ( keytype , " \" DISTORT \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_DISTORT ;
2013-11-01 16:53:46 +07:00
else if ( ! scumm_stricmp ( keytype , " \" PANTRACK \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_PANTRACK ;
2013-11-01 16:53:46 +07:00
else if ( ! scumm_stricmp ( keytype , " \" REGION \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_REGION ;
2013-11-01 16:53:46 +07:00
else if ( ! scumm_stricmp ( keytype , " \" TIMER \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_TIMER ;
2013-11-01 16:53:46 +07:00
else if ( ! scumm_stricmp ( keytype , " \" TTYTEXT \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_TTYTXT ;
2013-11-01 16:53:46 +07:00
else if ( ! scumm_stricmp ( keytype , " \" ALL \" " ) )
2014-12-30 01:10:36 -06:00
_type = ScriptingEffect : : SCRIPTING_EFFECT_ALL ;
2013-11-01 16:53:46 +07:00
} else
_key = atoi ( keytype ) ;
}
bool ActionKill : : execute ( ) {
if ( _type )
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFxType ( ( ScriptingEffect : : ScriptingEffectType ) _type ) ;
2013-11-01 16:53:46 +07:00
else
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFx ( _key ) ;
2013-11-01 16:53:46 +07:00
return true ;
}
2014-11-08 13:02:48 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionMenuBarEnable
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionMenuBarEnable : : ActionMenuBarEnable ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 17:05:31 +06:00
_menus = 0xFFFF ;
2014-11-08 13:02:48 +06:00
sscanf ( line . c_str ( ) , " %hu " , & _menus ) ;
}
bool ActionMenuBarEnable : : execute ( ) {
2014-12-26 13:14:24 +02:00
_engine - > getMenuHandler ( ) - > setEnable ( _menus ) ;
2014-11-08 13:02:48 +06:00
return true ;
}
2013-11-01 16:53:46 +07:00
2013-08-05 00:14:20 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionMusic
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionMusic : : ActionMusic ( ZVision * engine , int32 slotKey , const Common : : String & line , bool global ) :
ResultAction ( engine , slotKey ) ,
2014-12-19 16:29:51 +06:00
_note ( 0 ) ,
_prog ( 0 ) ,
2013-11-01 17:00:20 +07:00
_universe ( global ) {
2015-01-26 22:07:47 +01:00
uint type = 0 ;
char fileNameBuffer [ 25 ] ;
uint loop = 0 ;
char volumeBuffer [ 15 ] ;
2013-08-05 00:14:20 -05:00
2015-01-26 22:07:47 +01:00
// Volume is optional. If it doesn't appear, assume full volume
strcpy ( volumeBuffer , " 100 " ) ;
2013-08-05 00:14:20 -05:00
2015-01-26 22:07:47 +01:00
sscanf ( line . c_str ( ) , " %u %24s %u %14s " , & type , fileNameBuffer , & loop , volumeBuffer ) ;
// Type 4 actions are MIDI commands, not files. These are only used by
// Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well
// as vr)
2013-08-05 00:14:20 -05:00
if ( type = = 4 ) {
2014-10-22 11:49:24 +07:00
_midi = true ;
2015-01-26 22:07:47 +01:00
int note ;
int prog ;
sscanf ( line . c_str ( ) , " %u %d %d %14s " , & type , & prog , & note , volumeBuffer ) ;
2015-02-14 15:07:15 +02:00
_volume = new ValueSlot ( _scriptManager , volumeBuffer ) ;
2015-01-26 22:07:47 +01:00
_note = note ;
_prog = prog ;
2013-08-05 00:14:20 -05:00
} else {
2014-10-22 11:49:24 +07:00
_midi = false ;
2015-01-26 22:07:47 +01:00
_fileName = Common : : String ( fileNameBuffer ) ;
_loop = loop = = 1 ? true : false ;
if ( volumeBuffer [ 0 ] ! = ' [ ' & & atoi ( volumeBuffer ) > 100 ) {
// I thought I saw a case like this in Zork Nemesis, so
// let's guard against it.
warning ( " ActionMusic: Adjusting volume for %s from %s to 100 " , _fileName . c_str ( ) , volumeBuffer ) ;
strcpy ( volumeBuffer , " 100 " ) ;
2014-10-22 11:49:24 +07:00
}
2015-02-14 15:07:15 +02:00
_volume = new ValueSlot ( _scriptManager , volumeBuffer ) ;
2013-08-05 00:14:20 -05:00
}
2015-02-14 14:55:09 +02:00
// WORKAROUND for a script bug in Zork Nemesis, rooms mq70/mq80.
// Fixes an edge case where the player goes to the dark room with the grue
// without holding a torch, and then quickly runs away before the grue's
// sound effect finishes. Fixes script bug #6794.
2015-02-14 15:07:15 +02:00
if ( engine - > getGameId ( ) = = GID_NEMESIS & & _slotKey = = 14822 & & _scriptManager - > getStateValue ( _slotKey ) = = 2 )
_scriptManager - > setStateValue ( _slotKey , 0 ) ;
2015-02-14 14:55:09 +02:00
2013-08-05 00:14:20 -05:00
}
2013-11-01 17:00:20 +07:00
ActionMusic : : ~ ActionMusic ( ) {
if ( ! _universe )
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFx ( _slotKey ) ;
2015-01-26 22:07:47 +01:00
delete _volume ;
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 ( ) {
2015-02-14 15:07:15 +02:00
if ( _scriptManager - > getSideFX ( _slotKey ) ) {
_scriptManager - > killSideFx ( _slotKey ) ;
_scriptManager - > setStateValue ( _slotKey , 2 ) ;
2015-01-16 14:08:15 +02:00
}
2015-01-26 22:07:47 +01:00
uint volume = _volume - > getValue ( ) ;
2015-01-26 19:34:21 +01:00
2014-10-22 11:49:24 +07:00
if ( _midi ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > 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
2015-01-26 19:34:21 +01:00
// Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255]
2015-02-14 15:07:15 +02:00
_scriptManager - > addSideFX ( new MusicNode ( _engine , _slotKey , _fileName , _loop , volume * 255 / 100 ) ) ;
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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionPanTrack : : ActionPanTrack ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) ,
2014-01-17 10:57:29 +07:00
_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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFx ( _slotKey ) ;
2014-01-17 10:57:29 +07:00
}
bool ActionPanTrack : : execute ( ) {
2015-02-14 15:07:15 +02:00
if ( _scriptManager - > getSideFX ( _slotKey ) )
2014-01-17 10:57:29 +07:00
return true ;
2015-02-14 15:07:15 +02:00
_scriptManager - > 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionPreferences : : ActionPreferences ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-11-08 13:04:27 +06:00
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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionPreloadAnimation : : ActionPreloadAnimation ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:51:01 +06:00
_mask = 0 ;
_framerate = 0 ;
2013-08-03 13:43:46 -05:00
char fileName [ 25 ] ;
2014-12-23 00:02:30 +02:00
// The two %*u are usually 0 and dont seem to have a use
2014-12-23 02:20:17 +02:00
sscanf ( line . c_str ( ) , " %24s %*u %*u %d %d " , fileName , & _mask , & _framerate ) ;
2013-11-15 18:34:11 +00:00
2014-12-26 22:30:32 +02:00
// Mask 0 means "no transparency" in this case. Since we use a common blitting
// code for images and animations, we set it to -1 to avoid confusion with
// color 0, which is used as a mask in some images
if ( _mask = = 0 )
_mask = - 1 ;
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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > 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 ( ) {
2015-02-14 15:07:15 +02:00
AnimationEffect * nod = ( AnimationEffect * ) _scriptManager - > getSideFX ( _slotKey ) ;
2013-09-07 18:08:20 -05:00
2013-11-15 18:34:11 +00:00
if ( ! nod ) {
2014-12-30 01:10:36 -06:00
nod = new AnimationEffect ( _engine , _slotKey , _fileName , _mask , _framerate , false ) ;
2015-02-14 15:07:15 +02:00
_scriptManager - > addSideFX ( nod ) ;
2013-11-15 18:34:11 +00:00
} else
nod - > stop ( ) ;
2015-02-14 15:07:15 +02:00
_scriptManager - > setStateValue ( _slotKey , 2 ) ;
2013-07-06 00:29:15 -05:00
return true ;
}
2014-11-08 12:21:38 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionUnloadAnimation
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionUnloadAnimation : : ActionUnloadAnimation ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:41:51 +06:00
_key = 0 ;
2014-11-08 12:21:38 +06:00
sscanf ( line . c_str ( ) , " %u " , & _key ) ;
}
bool ActionUnloadAnimation : : execute ( ) {
2015-02-14 15:07:15 +02:00
AnimationEffect * nod = ( AnimationEffect * ) _scriptManager - > getSideFX ( _key ) ;
2014-11-08 12:21:38 +06:00
2014-12-30 01:10:36 -06:00
if ( nod & & nod - > getType ( ) = = ScriptingEffect : : SCRIPTING_EFFECT_ANIM )
2015-02-14 15:07:15 +02:00
_scriptManager - > deleteSideFx ( _key ) ;
2014-11-08 12:21:38 +06:00
return true ;
}
2013-07-06 00:29:15 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionPlayAnimation
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionPlayAnimation : : ActionPlayAnimation ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:33:26 +06:00
_x = 0 ;
_y = 0 ;
_x2 = 0 ;
_y2 = 0 ;
_start = 0 ;
_end = 0 ;
_loopCount = 0 ;
_mask = 0 ;
_framerate = 0 ;
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 ( ) ,
2014-12-23 02:20:17 +02:00
" %24s %u %u %u %u %u %u %d %*u %*u %d %d " ,
2013-11-25 13:30:29 +00:00
fileName , & _x , & _y , & _x2 , & _y2 , & _start , & _end , & _loopCount , & _mask , & _framerate ) ;
2013-08-02 09:59:20 -05:00
2014-12-26 22:30:32 +02:00
// Mask 0 means "no transparency" in this case. Since we use a common blitting
// code for images and animations, we set it to -1 to avoid confusion with
// color 0, which is used as a mask in some images
if ( _mask = = 0 )
_mask = - 1 ;
2013-08-02 09:59:20 -05:00
_fileName = Common : : String ( fileName ) ;
2015-01-17 23:37:59 +02:00
// WORKAROUND for bug #6769, location me1g.scr (the "Alchemical debacle"
// video in ZGI). We only scale up by 2x, in AnimationEffect::process(),
// but the dimensions of the target frame are off by 2 pixels. We fix that
// here, so that the video can be scaled.
if ( _fileName = = " me1ga011.avi " & & _y2 = = 213 )
_y2 = 215 ;
2013-07-06 00:29:15 -05:00
}
2013-11-15 18:34:11 +00:00
ActionPlayAnimation : : ~ ActionPlayAnimation ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > deleteSideFx ( _slotKey ) ;
2013-11-15 18:34:11 +00:00
}
2013-10-29 18:33:37 +00:00
bool ActionPlayAnimation : : execute ( ) {
2015-02-14 15:07:15 +02:00
AnimationEffect * nod = ( AnimationEffect * ) _scriptManager - > getSideFX ( _slotKey ) ;
2013-11-15 18:34:11 +00:00
if ( ! nod ) {
2014-12-30 01:10:36 -06:00
nod = new AnimationEffect ( _engine , _slotKey , _fileName , _mask , _framerate ) ;
2015-02-14 15:07:15 +02:00
_scriptManager - > addSideFX ( nod ) ;
2013-11-15 18:34:11 +00:00
} 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionPlayPreloadAnimation : : ActionPlayPreloadAnimation ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 17:03:39 +06:00
_controlKey = 0 ;
_x1 = 0 ;
_y1 = 0 ;
_x2 = 0 ;
_y2 = 0 ;
_startFrame = 0 ;
_endFrame = 0 ;
_loopCount = 0 ;
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 ( ) {
2015-02-14 15:07:15 +02:00
AnimationEffect * nod = ( AnimationEffect * ) _scriptManager - > 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
//////////////////////////////////////////////////////////////////////////////
2014-12-25 15:00:49 +02:00
// ActionRegion - only used by Zork: Nemesis
2014-10-10 16:40:46 +07:00
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionRegion : : ActionRegion ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 15:43:46 +06:00
_delay = 0 ;
_type = 0 ;
_unk1 = 0 ;
_unk2 = 0 ;
2014-10-10 16:40:46 +07:00
char art [ 64 ] ;
char custom [ 64 ] ;
2014-12-19 15:43:46 +06:00
int32 x1 = 0 , x2 = 0 , y1 = 0 , y2 = 0 ;
2014-10-10 16:40:46 +07:00
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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFx ( _slotKey ) ;
2014-10-10 16:40:46 +07:00
}
bool ActionRegion : : execute ( ) {
2015-02-14 15:07:15 +02:00
if ( _scriptManager - > getSideFX ( _slotKey ) )
2014-10-10 16:40:46 +07:00
return true ;
2014-12-30 01:10:36 -06:00
GraphicsEffect * effect = NULL ;
2014-10-10 16:40:46 +07:00
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 ) ;
2014-12-26 12:04:21 +02:00
effect = 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-12-26 12:04:21 +02:00
effect = 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-12-26 12:04:21 +02:00
effect = new FogFx ( _engine , _slotKey , _rect , _unk1 , _map , Common : : String ( buf ) ) ;
2014-10-10 16:40:46 +07:00
}
break ;
default :
break ;
}
2014-12-26 12:04:21 +02:00
if ( effect ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > addSideFX ( new RegionNode ( _engine , _slotKey , effect , _delay ) ) ;
2014-12-26 12:04:21 +02:00
_engine - > getRenderManager ( ) - > addEffect ( effect ) ;
2014-10-10 16:40:46 +07:00
}
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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01: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 ) ;
2015-02-14 15:07:15 +02:00
_max = new ValueSlot ( _scriptManager , maxBuffer ) ;
2013-10-31 09:53:17 +07:00
}
ActionRandom : : ~ ActionRandom ( ) {
2015-01-26 22:14:26 +01:00
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 ( ) ) ;
2015-02-14 15:07:15 +02:00
_scriptManager - > setStateValue ( _slotKey , randNumber ) ;
2013-07-03 17:21:21 -05:00
return true ;
}
2015-01-10 22:03:15 +02:00
//////////////////////////////////////////////////////////////////////////////
// ActionRestoreGame
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionRestoreGame : : ActionRestoreGame ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2015-01-10 22:03:15 +02:00
char buf [ 128 ] ;
sscanf ( line . c_str ( ) , " %s " , buf ) ;
_fileName = Common : : String ( buf ) ;
}
bool ActionRestoreGame : : execute ( ) {
_engine - > getSaveManager ( ) - > loadGame ( - 1 ) ;
return false ;
}
2014-11-07 10:25:11 +06:00
//////////////////////////////////////////////////////////////////////////////
// ActionRotateTo
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionRotateTo : : ActionRotateTo ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 17:04:04 +06:00
_time = 0 ;
_toPos = 0 ;
2014-11-07 10:25:11 +06:00
sscanf ( line . c_str ( ) , " %d, %d " , & _toPos , & _time ) ;
}
bool ActionRotateTo : : execute ( ) {
2014-12-26 13:14:24 +02:00
_engine - > getRenderManager ( ) - > rotateTo ( _toPos , _time ) ;
2014-11-07 10:25:11 +06:00
return true ;
}
2013-08-19 23:43:02 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionSetPartialScreen
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01: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 ] ;
2014-12-24 22:40:54 +02:00
sscanf ( line . c_str ( ) , " %u %u %24s %*u %d " , & _x , & _y , fileName , & _backgroundColor ) ;
2013-08-19 23:43:02 -05:00
_fileName = Common : : String ( fileName ) ;
2014-12-24 22:40:54 +02:00
if ( _backgroundColor > 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01: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 ] ;
2014-12-23 02:20:17 +02:00
sscanf ( line . c_str ( ) , " %24s " , 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01: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 ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > stopSideFx ( _key ) ;
2013-11-01 16:55:19 +07:00
return true ;
}
2013-08-10 17:18:29 -05:00
//////////////////////////////////////////////////////////////////////////////
// ActionStreamVideo
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionStreamVideo : : ActionStreamVideo ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 17:02:22 +06:00
_x1 = 0 ;
_x2 = 0 ;
_y1 = 0 ;
_y2 = 0 ;
_flags = 0 ;
2013-08-10 17:18:29 -05:00
char fileName [ 25 ] ;
2014-12-19 17:02:22 +06:00
uint skipline = 0 ; //skipline - render video with skip every second line, not skippable.
2013-08-10 17:18:29 -05:00
2014-12-23 02:20:17 +02:00
sscanf ( line . c_str ( ) , " %24s %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 ( ) {
2015-01-07 11:29:28 +02:00
Video : : VideoDecoder * decoder ;
Common : : Rect destRect = Common : : Rect ( _x1 , _y1 , _x2 + 1 , _y2 + 1 ) ;
2015-01-10 21:32:15 +02:00
Common : : String subname = _fileName ;
subname . setChar ( ' s ' , subname . size ( ) - 3 ) ;
subname . setChar ( ' u ' , subname . size ( ) - 2 ) ;
subname . setChar ( ' b ' , subname . size ( ) - 1 ) ;
bool subtitleExists = _engine - > getSearchManager ( ) - > hasFile ( subname ) ;
bool switchToHires = false ;
2014-02-04 08:32:02 +07:00
2018-10-31 21:37:56 +00:00
// NOTE: We only show the hires MPEG2 videos when libmpeg2 and liba52 are compiled in,
2015-01-10 21:32:15 +02:00
// otherwise we fall back to the lowres ones
2018-10-31 21:37:56 +00:00
# if defined(USE_MPEG2) && defined(USE_A52)
2015-01-07 11:39:02 +02:00
Common : : String hiresFileName = _fileName ;
hiresFileName . setChar ( ' d ' , hiresFileName . size ( ) - 8 ) ;
hiresFileName . setChar ( ' v ' , hiresFileName . size ( ) - 3 ) ;
hiresFileName . setChar ( ' o ' , hiresFileName . size ( ) - 2 ) ;
hiresFileName . setChar ( ' b ' , hiresFileName . size ( ) - 1 ) ;
2015-02-14 15:07:15 +02:00
if ( _scriptManager - > getStateValue ( StateKey_MPEGMovies ) = = 1 & & _engine - > getSearchManager ( ) - > hasFile ( hiresFileName ) ) {
2015-08-01 20:15:30 +02:00
_fileName = hiresFileName ;
switchToHires = true ;
2015-01-10 21:32:15 +02:00
} else if ( ! _engine - > getSearchManager ( ) - > hasFile ( _fileName ) )
return true ;
# else
2015-01-07 11:29:28 +02:00
if ( ! _engine - > getSearchManager ( ) - > hasFile ( _fileName ) )
return true ;
2015-01-10 21:32:15 +02:00
# endif
2014-11-12 14:34:01 +06:00
2015-01-07 11:29:28 +02:00
decoder = _engine - > loadAnimation ( _fileName ) ;
2015-01-10 21:32:15 +02:00
Subtitle * sub = ( subtitleExists ) ? new Subtitle ( _engine , subname , switchToHires ) : NULL ;
2014-03-02 00:03:25 +07:00
2015-01-07 11:29:28 +02:00
_engine - > getCursorManager ( ) - > showMouse ( false ) ;
2014-03-02 00:03:25 +07:00
2015-01-10 21:32:15 +02:00
if ( switchToHires ) {
_engine - > initHiresScreen ( ) ;
destRect = Common : : Rect ( 40 , - 40 , 760 , 440 ) ;
Common : : Rect workingWindow = _engine - > _workingWindow ;
workingWindow . translate ( 0 , - 40 ) ;
_engine - > getRenderManager ( ) - > initSubArea ( HIRES_WINDOW_WIDTH , HIRES_WINDOW_HEIGHT , workingWindow ) ;
}
2014-03-02 00:03:25 +07:00
2015-01-07 11:29:28 +02:00
_engine - > playVideo ( * decoder , destRect , _skippable , sub ) ;
2015-01-10 21:32:15 +02:00
if ( switchToHires ) {
_engine - > initScreen ( ) ;
_engine - > getRenderManager ( ) - > initSubArea ( WINDOW_WIDTH , WINDOW_HEIGHT , _engine - > _workingWindow ) ;
}
2013-08-10 17:18:29 -05:00
2015-01-07 11:29:28 +02:00
_engine - > getCursorManager ( ) - > showMouse ( true ) ;
2014-11-12 14:34:01 +06:00
2015-01-10 21:32:15 +02:00
delete decoder ;
delete sub ;
2013-08-10 17:18:29 -05:00
return true ;
}
2014-03-01 20:41:13 +07:00
//////////////////////////////////////////////////////////////////////////////
// ActionSyncSound
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionSyncSound : : ActionSyncSound ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 16:36:54 +06:00
_syncto = 0 ;
2014-03-01 20:41:13 +07:00
char fileName [ 25 ] ;
2014-12-19 16:36:54 +06:00
int notUsed = 0 ;
2014-03-01 20:41:13 +07:00
2014-12-23 02:20:17 +02:00
sscanf ( line . c_str ( ) , " %d %d %24s " , & _syncto , & notUsed , fileName ) ;
2014-03-01 20:41:13 +07:00
_fileName = Common : : String ( fileName ) ;
}
bool ActionSyncSound : : execute ( ) {
2015-02-14 15:07:15 +02:00
ScriptingEffect * fx = _scriptManager - > getSideFX ( _syncto ) ;
2014-03-01 20:41:13 +07:00
if ( ! fx )
return true ;
2014-12-30 01:10:36 -06:00
if ( ! ( fx - > getType ( ) & ScriptingEffect : : SCRIPTING_EFFECT_ANIM ) )
2014-03-01 20:41:13 +07:00
return true ;
2015-02-14 15:07:15 +02:00
_scriptManager - > 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01: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 ) ;
2015-02-14 15:07:15 +02:00
_time = new ValueSlot ( _scriptManager , timeBuffer ) ;
2013-10-30 16:21:38 +07:00
}
ActionTimer : : ~ ActionTimer ( ) {
2015-01-26 22:14:26 +01:00
delete _time ;
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFx ( _slotKey ) ;
2013-07-29 21:42:07 -05:00
}
2013-10-29 18:33:37 +00:00
bool ActionTimer : : execute ( ) {
2015-02-14 15:07:15 +02:00
if ( _scriptManager - > getSideFX ( _slotKey ) )
2014-02-24 20:40:20 +07:00
return true ;
2015-02-14 15:07:15 +02:00
_scriptManager - > 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
//////////////////////////////////////////////////////////////////////////////
2015-06-10 16:56:04 +01:00
ActionTtyText : : ActionTtyText ( ZVision * engine , int32 slotKey , const Common : : String & line ) :
ResultAction ( engine , slotKey ) {
2014-12-19 17:03:07 +06:00
_delay = 0 ;
2014-03-09 23:20:27 +07:00
char filename [ 64 ] ;
2014-12-19 17:03:07 +06:00
int32 x1 = 0 , y1 = 0 , x2 = 0 , y2 = 0 ;
2015-03-22 08:14:18 +01:00
sscanf ( line . c_str ( ) , " %d %d %d %d %63s %u " , & x1 , & y1 , & x2 , & y2 , filename , & _delay ) ;
2014-03-09 23:20:27 +07:00
_r = Common : : Rect ( x1 , y1 , x2 , y2 ) ;
_filename = Common : : String ( filename ) ;
}
ActionTtyText : : ~ ActionTtyText ( ) {
2015-02-14 15:07:15 +02:00
_scriptManager - > killSideFx ( _slotKey ) ;
2014-03-09 23:20:27 +07:00
}
bool ActionTtyText : : execute ( ) {
2015-02-14 15:07:15 +02:00
if ( _scriptManager - > getSideFX ( _slotKey ) )
2014-03-09 23:20:27 +07:00
return true ;
2015-02-14 15:07:15 +02:00
_scriptManager - > 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