doom3-bfg/neo/swf/SWF_Main.cpp

791 lines
21 KiB
C++
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code 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 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code 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 Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma hdrstop
#include "../idlib/precompiled.h"
#include "../renderer/Image.h"
2012-11-26 18:58:24 +00:00
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
idCVar swf_loadBinary( "swf_loadBinary", "1", CVAR_INTEGER, "used to set whether to load binary swf from generated" );
int idSWF::mouseX = -1;
int idSWF::mouseY = -1;
bool idSWF::isMouseInClientArea = false;
extern idCVar in_useJoystick;
/*
===================
idSWF::idSWF
===================
*/
idSWF::idSWF( const char* filename_, idSoundWorld* soundWorld_ )
{
2012-11-26 18:58:24 +00:00
atlasMaterial = NULL;
2012-11-26 18:58:24 +00:00
swfScale = 1.0f;
scaleToVirtual.Set( 1.0f, 1.0f );
2012-11-26 18:58:24 +00:00
random.SetSeed( Sys_Milliseconds() );
2012-11-26 18:58:24 +00:00
guiSolid = declManager->FindMaterial( "guiSolid" );
guiCursor_arrow = declManager->FindMaterial( "ui/assets/guicursor_arrow" );
guiCursor_hand = declManager->FindMaterial( "ui/assets/guicursor_hand" );
white = declManager->FindMaterial( "_white" );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY1>", "guis/assets/hud/controller/xb360/a", "guis/assets/hud/controller/ps3/cross", 37, 37, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY2>", "guis/assets/hud/controller/xb360/b", "guis/assets/hud/controller/ps3/circle", 37, 37, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY3>", "guis/assets/hud/controller/xb360/x", "guis/assets/hud/controller/ps3/square", 37, 37, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY4>", "guis/assets/hud/controller/xb360/y", "guis/assets/hud/controller/ps3/triangle", 37, 37, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY_TRIGGER2>", "guis/assets/hud/controller/xb360/rt", "guis/assets/hud/controller/ps3/r2", 64, 52, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY_TRIGGER1>", "guis/assets/hud/controller/xb360/lt", "guis/assets/hud/controller/ps3/l2", 64, 52, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY5>", "guis/assets/hud/controller/xb360/lb", "guis/assets/hud/controller/ps3/l1", 52, 32, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<JOY6>", "guis/assets/hud/controller/xb360/rb", "guis/assets/hud/controller/ps3/r1", 52, 32, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<MOUSE1>", "guis/assets/hud/controller/mouse1", "", 64, 52, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<MOUSE2>", "guis/assets/hud/controller/mouse2", "", 64, 52, 0 ) );
tooltipButtonImage.Append( keyButtonImages_t( "<MOUSE3>", "guis/assets/hud/controller/mouse3", "", 64, 52, 0 ) );
for( int index = 0; index < tooltipButtonImage.Num(); index++ )
{
if( ( tooltipButtonImage[index].xbImage != NULL ) && ( tooltipButtonImage[index].xbImage[0] != '\0' ) )
{
2012-11-26 18:58:24 +00:00
declManager->FindMaterial( tooltipButtonImage[index].xbImage );
}
if( ( tooltipButtonImage[index].psImage != NULL ) && ( tooltipButtonImage[index].psImage[0] != '\0' ) )
{
2012-11-26 18:58:24 +00:00
declManager->FindMaterial( tooltipButtonImage[index].psImage );
}
}
2012-11-26 18:58:24 +00:00
frameWidth = 0;
frameHeight = 0;
frameRate = 0;
lastRenderTime = 0;
2012-11-26 18:58:24 +00:00
isActive = false;
inhibitControl = false;
useInhibtControl = true;
2012-11-26 18:58:24 +00:00
crop = false;
blackbars = false;
paused = false;
hasHitObject = false;
2012-11-26 18:58:24 +00:00
useMouse = true;
mouseEnabled = false;
renderBorder = 0;
mouseObject = NULL;
hoverObject = NULL;
soundWorld = NULL;
forceNonPCPlatform = false;
if( idStr::Cmpn( filename_, "swf/", 4 ) != 0 )
{
2012-11-26 18:58:24 +00:00
// if it doesn't already have swf/ in front of it, add it
filename = "swf/";
filename += filename_;
}
else
{
2012-11-26 18:58:24 +00:00
filename = filename_;
}
filename.ToLower();
filename.BackSlashesToSlashes();
filename.SetFileExtension( ".swf" );
2012-11-26 18:58:24 +00:00
timestamp = fileSystem->GetTimestamp( filename );
mainsprite = new( TAG_SWF ) idSWFSprite( this );
2012-11-26 18:58:24 +00:00
mainspriteInstance = NULL;
2012-11-26 18:58:24 +00:00
idStr binaryFileName = "generated/";
binaryFileName += filename;
binaryFileName.SetFileExtension( ".bswf" );
if( swf_loadBinary.GetBool() )
{
2012-11-26 18:58:24 +00:00
ID_TIME_T sourceTime = fileSystem->GetTimestamp( filename );
if( !LoadBinary( binaryFileName, sourceTime ) )
{
if( LoadSWF( filename ) )
{
2012-11-26 18:58:24 +00:00
WriteBinary( binaryFileName );
}
}
}
else
{
2012-11-26 18:58:24 +00:00
LoadSWF( filename );
}
idStr atlasFileName = binaryFileName;
atlasFileName.SetFileExtension( ".tga" );
atlasMaterial = declManager->FindMaterial( atlasFileName );
2012-11-26 18:58:24 +00:00
globals = idSWFScriptObject::Alloc();
globals->Set( "_global", globals );
2012-11-26 18:58:24 +00:00
globals->Set( "Object", &scriptFunction_Object );
2012-11-26 18:58:24 +00:00
mainspriteInstance = spriteInstanceAllocator.Alloc();
mainspriteInstance->Init( mainsprite, NULL, 0 );
2012-11-26 18:58:24 +00:00
shortcutKeys = idSWFScriptObject::Alloc();
scriptFunction_shortcutKeys_clear.Bind( this );
scriptFunction_shortcutKeys_clear.Call( shortcutKeys, idSWFParmList() );
globals->Set( "shortcutKeys", shortcutKeys );
2012-11-26 18:58:24 +00:00
globals->Set( "deactivate", scriptFunction_deactivate.Bind( this ) );
globals->Set( "inhibitControl", scriptFunction_inhibitControl.Bind( this ) );
globals->Set( "useInhibit", scriptFunction_useInhibit.Bind( this ) );
globals->Set( "precacheSound", scriptFunction_precacheSound.Bind( this ) );
globals->Set( "playSound", scriptFunction_playSound.Bind( this ) );
globals->Set( "stopSounds", scriptFunction_stopSounds.Bind( this ) );
2012-11-26 18:58:24 +00:00
globals->Set( "getPlatform", scriptFunction_getPlatform.Bind( this ) );
globals->Set( "getTruePlatform", scriptFunction_getTruePlatform.Bind( this ) );
globals->Set( "getLocalString", scriptFunction_getLocalString.Bind( this ) );
globals->Set( "swapPS3Buttons", scriptFunction_swapPS3Buttons.Bind( this ) );
globals->Set( "_root", mainspriteInstance->scriptObject );
globals->Set( "strReplace", scriptFunction_strReplace.Bind( this ) );
globals->Set( "getCVarInteger", scriptFunction_getCVarInteger.Bind( this ) );
globals->Set( "setCVarInteger", scriptFunction_setCVarInteger.Bind( this ) );
2012-11-26 18:58:24 +00:00
globals->Set( "acos", scriptFunction_acos.Bind( this ) );
globals->Set( "cos", scriptFunction_cos.Bind( this ) );
globals->Set( "sin", scriptFunction_sin.Bind( this ) );
globals->Set( "round", scriptFunction_round.Bind( this ) );
globals->Set( "pow", scriptFunction_pow.Bind( this ) );
globals->Set( "sqrt", scriptFunction_sqrt.Bind( this ) );
globals->Set( "abs", scriptFunction_abs.Bind( this ) );
globals->Set( "rand", scriptFunction_rand.Bind( this ) );
globals->Set( "floor", scriptFunction_floor.Bind( this ) );
globals->Set( "ceil", scriptFunction_ceil.Bind( this ) );
globals->Set( "toUpper", scriptFunction_toUpper.Bind( this ) );
2012-11-26 18:58:24 +00:00
globals->SetNative( "platform", swfScriptVar_platform.Bind( &scriptFunction_getPlatform ) );
globals->SetNative( "blackbars", swfScriptVar_blackbars.Bind( this ) );
globals->SetNative( "cropToHeight", swfScriptVar_crop.Bind( this ) );
globals->SetNative( "cropToFit", swfScriptVar_crop.Bind( this ) );
globals->SetNative( "crop", swfScriptVar_crop.Bind( this ) );
2012-11-26 18:58:24 +00:00
// Do this to touch any external references (like sounds)
// But disable script warnings because many globals won't have been created yet
extern idCVar swf_debug;
int debug = swf_debug.GetInteger();
swf_debug.SetInteger( 0 );
2012-11-26 18:58:24 +00:00
mainspriteInstance->Run();
mainspriteInstance->RunActions();
mainspriteInstance->RunTo( 0 );
2012-11-26 18:58:24 +00:00
swf_debug.SetInteger( debug );
if( mouseX == -1 )
{
2012-11-26 18:58:24 +00:00
mouseX = ( frameWidth / 2 );
}
if( mouseY == -1 )
{
2012-11-26 18:58:24 +00:00
mouseY = ( frameHeight / 2 );
}
2012-11-26 18:58:24 +00:00
soundWorld = soundWorld_;
}
/*
===================
idSWF::~idSWF
===================
*/
idSWF::~idSWF()
{
2012-11-26 18:58:24 +00:00
spriteInstanceAllocator.Free( mainspriteInstance );
delete mainsprite;
for( int i = 0 ; i < dictionary.Num() ; i++ )
{
if( dictionary[i].sprite )
{
2012-11-26 18:58:24 +00:00
delete dictionary[i].sprite;
dictionary[i].sprite = NULL;
}
if( dictionary[i].shape )
{
2012-11-26 18:58:24 +00:00
delete dictionary[i].shape;
dictionary[i].shape = NULL;
}
if( dictionary[i].font )
{
2012-11-26 18:58:24 +00:00
delete dictionary[i].font;
dictionary[i].font = NULL;
}
if( dictionary[i].text )
{
2012-11-26 18:58:24 +00:00
delete dictionary[i].text;
dictionary[i].text = NULL;
}
if( dictionary[i].edittext )
{
2012-11-26 18:58:24 +00:00
delete dictionary[i].edittext;
dictionary[i].edittext = NULL;
}
}
globals->Clear();
tooltipButtonImage.Clear();
globals->Release();
2012-11-26 18:58:24 +00:00
shortcutKeys->Clear();
shortcutKeys->Release();
}
/*
===================
idSWF::Activate
when a SWF is deactivated, it rewinds the timeline back to the start
===================
*/
void idSWF::Activate( bool b )
{
if( !isActive && b )
{
2012-11-26 18:58:24 +00:00
inhibitControl = false;
lastRenderTime = Sys_Milliseconds();
2012-11-26 18:58:24 +00:00
mainspriteInstance->FreeDisplayList();
mainspriteInstance->Play();
mainspriteInstance->Run();
mainspriteInstance->RunActions();
}
isActive = b;
}
/*
===================
idSWF::InhibitControl
===================
*/
bool idSWF::InhibitControl()
{
if( !IsLoaded() || !IsActive() )
{
2012-11-26 18:58:24 +00:00
return false;
}
return ( inhibitControl && useInhibtControl );
}
/*
===================
idSWF::PlaySound
===================
*/
int idSWF::PlaySound( const char* sound, int channel, bool blocking )
{
if( !IsActive() )
{
2012-11-26 18:58:24 +00:00
return -1;
}
if( soundWorld != NULL )
{
2012-11-26 18:58:24 +00:00
return soundWorld->PlayShaderDirectly( sound, channel );
}
else
{
2012-11-26 18:58:24 +00:00
idLib::Warning( "No playing sound world on soundSystem in swf play sound!" );
return -1;
}
}
/*
===================
idSWF::PlaySound
===================
*/
void idSWF::StopSound( int channel )
{
if( soundWorld != NULL )
{
2012-11-26 18:58:24 +00:00
soundWorld->PlayShaderDirectly( NULL, channel );
}
else
{
2012-11-26 18:58:24 +00:00
idLib::Warning( "No playing sound world on soundSystem in swf play sound!" );
}
}
/*
===================
idSWF::idSWFScriptFunction_inhibitControl::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_inhibitControl::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
pThis->inhibitControl = parms[0].ToBool();
return idSWFScriptVar();
}
/*
===================
idSWF::idSWFScriptFunction_inhibitControl::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_useInhibit::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
pThis->useInhibtControl = parms[0].ToBool();
return idSWFScriptVar();
}
/*
===================
idSWF::idSWFScriptFunction_deactivate::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_deactivate::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
pThis->Activate( false );
return idSWFScriptVar();
}
/*
===================
idSWF::idSWFScriptFunction_precacheSound::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_precacheSound::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
const idSoundShader* soundShader = declManager->FindSound( parms[0].ToString(), true );
2012-11-26 18:58:24 +00:00
return soundShader->GetName();
}
/*
===================
idSWF::idSWFScriptFunction_playSound::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_playSound::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
int channel = SCHANNEL_ANY;
// specific channel passed in
if( parms.Num() > 1 )
{
2012-11-26 18:58:24 +00:00
channel = parms[1].ToInteger();
}
2012-11-26 18:58:24 +00:00
pThis->PlaySound( parms[0].ToString(), channel );
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
/*
===================
idSWF::idSWFScriptFunction_stopSounds::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_stopSounds::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
int channel = SCHANNEL_ANY;
if( parms.Num() == 1 )
{
2012-11-26 18:58:24 +00:00
channel = parms[0].ToInteger();
}
2012-11-26 18:58:24 +00:00
pThis->StopSound( channel );
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
/*
========================
idSWFScriptFunction_GetPlatform::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_getPlatform::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
return pThis->GetPlatform();
}
/*
========================
idSWFScriptFunction_GetPlatform::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_getTruePlatform::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
return 2;
}
/*
========================
idSWFScriptFunction_GetPlatform::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_strReplace::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
if( parms.Num() != 3 )
{
2012-11-26 18:58:24 +00:00
return "";
}
2012-11-26 18:58:24 +00:00
idStr str = parms[0].ToString();
idStr repString = parms[1].ToString();
idStr val = parms[2].ToString();
str.Replace( repString, val );
2012-11-26 18:58:24 +00:00
return str;
}
/*
========================
idSWFScriptFunction_GetPlatform::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_getLocalString::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
if( parms.Num() == 0 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
2012-11-26 18:58:24 +00:00
idStr val = idLocalization::GetString( parms[0].ToString() );
return val;
2012-11-26 18:58:24 +00:00
}
/*
========================
idSWF::UseCircleForAccept
========================
*/
bool idSWF::UseCircleForAccept()
{
2012-11-26 18:58:24 +00:00
return false;
}
/*
========================
idSWF::GetPlatform
========================
*/
int idSWF::GetPlatform()
{
2012-11-26 18:58:24 +00:00
if( in_useJoystick.GetBool() || forceNonPCPlatform )
{
2012-11-26 18:58:24 +00:00
forceNonPCPlatform = false;
return 0;
}
2012-11-26 18:58:24 +00:00
return 2;
}
/*
========================
idSWFScriptFunction_swapPS3Buttons::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_swapPS3Buttons::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
return pThis->UseCircleForAccept();
}
/*
========================
idSWFScriptFunction_getCVarInteger::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_getCVarInteger::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
return cvarSystem->GetCVarInteger( parms[0].ToString() );
}
/*
========================
idSWFScriptFunction_setCVarInteger::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_setCVarInteger::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
cvarSystem->SetCVarInteger( parms[0].ToString(), parms[1].ToInteger() );
return idSWFScriptVar();
}
/*
===================
idSWF::idSWFScriptFunction_acos::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_acos::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
return idMath::ACos( parms[0].ToFloat() );
}
/*
===================
idSWF::idSWFScriptFunction_cos::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_cos::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
return idMath::Cos( parms[0].ToFloat() );
}
/*
===================
idSWF::idSWFScriptFunction_sin::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_sin::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
return ( idMath::Sin( parms[0].ToFloat() ) );
}
/*
===================
idSWF::idSWFScriptFunction_round::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_round::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
int value = idMath::Ftoi( parms[0].ToFloat() + 0.5f );
return value;
}
/*
===================
idSWF::idSWFScriptFunction_pow::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_pow::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 2 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
2012-11-26 18:58:24 +00:00
float value = parms[0].ToFloat();
float power = parms[1].ToFloat();
return ( idMath::Pow( value, power ) );
}
/*
===================
idSWF::idSWFScriptFunction_pow::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_sqrt::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
2012-11-26 18:58:24 +00:00
float value = parms[0].ToFloat();
return ( idMath::Sqrt( value ) );
}
/*
===================
idSWF::idSWFScriptFunction_abs::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_abs::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 )
{
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
2012-11-26 18:58:24 +00:00
float value = idMath::Fabs( parms[0].ToFloat() );
return value;
}
/*
===================
idSWF::idSWFScriptFunction_rand::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_rand::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
float min = 0.0f;
float max = 1.0f;
switch( parms.Num() )
{
case 0:
break;
case 1:
max = parms[0].ToFloat();
break;
default:
min = parms[0].ToFloat();
max = parms[1].ToFloat();
break;
2012-11-26 18:58:24 +00:00
}
return min + pThis->GetRandom().RandomFloat() * ( max - min );
}
/*
========================
idSWFScriptFunction_floor::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_floor::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 || !parms[0].IsNumeric() )
{
2012-11-26 18:58:24 +00:00
idLib::Warning( "Invalid parameters specified for floor" );
return idSWFScriptVar();
}
2012-11-26 18:58:24 +00:00
float num = parms[0].ToFloat();
2012-11-26 18:58:24 +00:00
return idSWFScriptVar( idMath::Floor( num ) );
}
/*
========================
idSWFScriptFunction_ceil::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_ceil::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 || !parms[0].IsNumeric() )
{
2012-11-26 18:58:24 +00:00
idLib::Warning( "Invalid parameters specified for ceil" );
return idSWFScriptVar();
}
2012-11-26 18:58:24 +00:00
float num = parms[0].ToFloat();
2012-11-26 18:58:24 +00:00
return idSWFScriptVar( idMath::Ceil( num ) );
}
/*
========================
idSWFScriptFunction_toUpper::Call
========================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_toUpper::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
if( parms.Num() != 1 || !parms[0].IsString() )
{
2012-11-26 18:58:24 +00:00
idLib::Warning( "Invalid parameters specified for toUpper" );
return idSWFScriptVar();
}
2012-11-26 18:58:24 +00:00
idStr val = idLocalization::GetString( parms[0].ToString() );
val.ToUpper();
return val;
}
/*
===================
idSWF::idSWFScriptFunction_shortcutKeys_clear::Call
===================
*/
idSWFScriptVar idSWF::idSWFScriptFunction_shortcutKeys_clear::Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
idSWFScriptObject* object = pThis->shortcutKeys;
2012-11-26 18:58:24 +00:00
object->Clear();
object->Set( "clear", this );
object->Set( "JOY1", "ENTER" );
object->Set( "JOY2", "BACKSPACE" );
object->Set( "JOY3", "START" );
object->Set( "JOY5", "LB" );
object->Set( "JOY6", "RB" );
object->Set( "JOY9", "START" );
object->Set( "JOY10", "BACKSPACE" );
object->Set( "JOY_DPAD_UP", "UP" );
object->Set( "JOY_DPAD_DOWN", "DOWN" );
object->Set( "JOY_DPAD_LEFT", "LEFT" );
object->Set( "JOY_DPAD_RIGHT", "RIGHT" );
object->Set( "JOY_STICK1_UP", "STICK1_UP" );
object->Set( "JOY_STICK1_DOWN", "STICK1_DOWN" );
object->Set( "JOY_STICK1_LEFT", "STICK1_LEFT" );
object->Set( "JOY_STICK1_RIGHT", "STICK1_RIGHT" );
object->Set( "JOY_STICK2_UP", "STICK2_UP" );
object->Set( "JOY_STICK2_DOWN", "STICK2_DOWN" );
object->Set( "JOY_STICK2_LEFT", "STICK2_LEFT" );
object->Set( "JOY_STICK2_RIGHT", "STICK2_RIGHT" );
object->Set( "KP_ENTER", "ENTER" );
object->Set( "MWHEELDOWN", "MWHEEL_DOWN" );
object->Set( "MWHEELUP", "MWHEEL_UP" );
object->Set( "K_TAB", "TAB" );
2012-11-26 18:58:24 +00:00
// FIXME: I'm an RTARD and didn't realize the keys all have "ARROW" after them
object->Set( "LEFTARROW", "LEFT" );
object->Set( "RIGHTARROW", "RIGHT" );
object->Set( "UPARROW", "UP" );
object->Set( "DOWNARROW", "DOWN" );
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
idSWFScriptVar idSWF::idSWFScriptNativeVar_blackbars::Get( idSWFScriptObject* object )
{
2012-11-26 18:58:24 +00:00
return pThis->blackbars;
}
void idSWF::idSWFScriptNativeVar_blackbars::Set( idSWFScriptObject* object, const idSWFScriptVar& value )
{
2012-11-26 18:58:24 +00:00
pThis->blackbars = value.ToBool();
}
idSWFScriptVar idSWF::idSWFScriptNativeVar_crop::Get( idSWFScriptObject* object )
{
2012-11-26 18:58:24 +00:00
return pThis->crop;
}
void idSWF::idSWFScriptNativeVar_crop::Set( idSWFScriptObject* object, const idSWFScriptVar& value )
{
2012-11-26 18:58:24 +00:00
pThis->crop = value.ToBool();
}