doom3-bfg/neo/swf/SWF_TextInstance.h

332 lines
8.2 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.
===========================================================================
*/
#ifndef __SWF_TEXTINSTANCE_H__
#define __SWF_TEXTINSTANCE_H__
struct subTimingWordData_t
{
subTimingWordData_t()
{
2012-11-26 18:58:24 +00:00
startTime = 0;
forceBreak = false;
}
2012-11-26 18:58:24 +00:00
idStr phrase;
int startTime;
bool forceBreak;
};
class idSWFTextInstance
{
2012-11-26 18:58:24 +00:00
public:
idSWFTextInstance();
~idSWFTextInstance();
void Init( idSWFEditText* editText, idSWF* _swf );
idSWFScriptObject* GetScriptObject()
{
return &scriptObject;
}
bool GetHasDropShadow()
{
return useDropShadow;
}
bool HasStroke()
{
return useStroke;
}
float GetStrokeStrength()
{
return strokeStrength;
}
float GetStrokeWeight()
{
return strokeWeight;
}
// used for when text has random render mode set
bool IsGeneratingRandomText()
{
return generatingText;
}
void StartRandomText( int time );
2012-11-26 18:58:24 +00:00
idStr GetRandomText( int time );
void StartParagraphText( int time );
idStr GetParagraphText( int time );
bool NeedsGenerateRandomText()
{
return triggerGenerate;
}
2012-11-26 18:58:24 +00:00
bool NeedsSoundPlayed();
void ClearPlaySound()
{
needsSoundUpdate = false;
}
idStr GetSoundClip()
{
return soundClip;
}
void SetIgnoreColor( bool ignore )
{
ignoreColor = ignore;
}
2012-11-26 18:58:24 +00:00
void SetStrokeInfo( bool use, float strength = 0.75f, float weight = 1.75f );
int CalcMaxScroll( int numLines = -1 );
int CalcNumLines();
2012-11-26 18:58:24 +00:00
// subtitle functions
void SwitchSubtitleText( int time );
bool UpdateSubtitle( int time );
bool IsSubtitle()
{
return isSubtitle;
}
bool IsUpdatingSubtitle()
{
return subUpdating;
}
2012-11-26 18:58:24 +00:00
void SetSubEndIndex( int endChar, int time );
int GetLastWordIndex()
{
return subLastWordIndex;
}
int GetPrevLastWordIndex()
{
return subPrevLastWordIndex;
}
2012-11-26 18:58:24 +00:00
void LastWordChanged( int wordCount, int time );
void SetSubStartIndex( int value )
{
subCharStartIndex = value;
}
int GetSubEndIndex()
{
return subCharEndIndex;
}
int GetSubStartIndex()
{
return subCharStartIndex;
}
2012-11-26 18:58:24 +00:00
void SetSubNextStartIndex( int value );
int GetApporoximateSubtitleBreak( int time );
bool SubNeedsSwitch()
{
return subNeedsSwitch;
}
idStr GetPreviousText()
{
return subtitleText.c_str();
}
2012-11-26 18:58:24 +00:00
void SubtitleComplete();
int GetSubAlignment()
{
return subAlign;
}
idStr GetSpeaker()
{
return subSpeaker.c_str();
}
2012-11-26 18:58:24 +00:00
void SubtitleCleanup();
float GetTextLength();
int GetInputStartChar( )
{
return inputTextStartChar;
}
void SetInputStartCharacter( int c )
{
inputTextStartChar = c;
}
const idSWFEditText* GetEditText() const
{
return editText;
}
void SetText( idStr val )
{
text = val;
lengthCalculated = false;
}
2012-11-26 18:58:24 +00:00
// Removing the private access control statement due to cl 214702
// Apparently MS's C++ compiler supports the newer C++ standard, and GCC supports C++03
// In the new C++ standard, nested members of a friend class have access to private/protected members of the class granting friendship
// In C++03, nested members defined in a friend class do NOT have access to private/protected members of the class granting friendship
idSWFEditText* editText;
idSWF* swf;
2012-11-26 18:58:24 +00:00
// this text instance's script object
idSWFScriptObject scriptObject;
2012-11-26 18:58:24 +00:00
idStr text;
idStr randomtext;
idStr variable;
swfColorRGBA_t color;
2012-11-26 18:58:24 +00:00
bool visible;
bool tooltip;
2012-11-26 18:58:24 +00:00
int selectionStart;
int selectionEnd;
bool ignoreColor;
2012-11-26 18:58:24 +00:00
int scroll;
int scrollTime;
int maxscroll;
int maxLines;
float glyphScale;
swfRect_t bounds;
float linespacing;
2012-11-26 18:58:24 +00:00
bool shiftHeld;
int lastInputTime;
2012-11-26 18:58:24 +00:00
bool useDropShadow;
bool useStroke;
2012-11-26 18:58:24 +00:00
float strokeStrength;
float strokeWeight;
2012-11-26 18:58:24 +00:00
int textLength;
bool lengthCalculated;
2012-11-26 18:58:24 +00:00
swfTextRenderMode_t renderMode;
bool generatingText;
int rndSpotsVisible;
int rndSpacesVisible;
int charMultiplier;
int textSpotsVisible;
int rndTime;
int startRndTime;
int prevReplaceIndex;
bool triggerGenerate;
int renderDelay;
bool scrollUpdate;
idStr soundClip;
bool needsSoundUpdate;
idList<int, TAG_SWF> indexArray;
idRandom2 rnd;
2012-11-26 18:58:24 +00:00
// used for subtitles
bool isSubtitle;
int subLength;
int subCharDisplayTime;
int subAlign;
bool subUpdating;
int subCharStartIndex;
int subNextStartIndex;
int subCharEndIndex;
int subDisplayTime;
int subStartTime;
int subSourceID;
idStr subtitleText;
bool subNeedsSwitch;
bool subForceKillQueued;
bool subForceKill;
int subKillTimeDelay;
int subSwitchTime;
int subLastWordIndex;
int subPrevLastWordIndex;
idStr subSpeaker;
bool subWaitClear;
bool subInitialLine;
2012-11-26 18:58:24 +00:00
// input text
int inputTextStartChar;
idList< subTimingWordData_t, TAG_SWF > subtitleTimingInfo;
};
/*
================================================
This is the prototype object that all the text instance script objects reference
================================================
*/
class idSWFScriptObject_TextInstancePrototype : public idSWFScriptObject
{
2012-11-26 18:58:24 +00:00
public:
idSWFScriptObject_TextInstancePrototype();
2012-11-26 18:58:24 +00:00
//----------------------------------
// Native Script Functions
//----------------------------------
#define SWF_TEXT_FUNCTION_DECLARE( x ) \
class idSWFScriptFunction_##x : public idSWFScriptFunction_RefCounted { \
public: \
void AddRef() {} \
void Release() {} \
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ); \
} scriptFunction_##x;
2012-11-26 18:58:24 +00:00
SWF_TEXT_FUNCTION_DECLARE( onKey );
SWF_TEXT_FUNCTION_DECLARE( onChar );
SWF_TEXT_FUNCTION_DECLARE( generateRnd );
SWF_TEXT_FUNCTION_DECLARE( calcNumLines );
2012-11-26 18:58:24 +00:00
SWF_NATIVE_VAR_DECLARE( text );
SWF_NATIVE_VAR_DECLARE( autoSize );
SWF_NATIVE_VAR_DECLARE( dropShadow );
SWF_NATIVE_VAR_DECLARE( _stroke );
SWF_NATIVE_VAR_DECLARE( _strokeStrength );
SWF_NATIVE_VAR_DECLARE( _strokeWeight );
SWF_NATIVE_VAR_DECLARE( variable );
SWF_NATIVE_VAR_DECLARE( _alpha );
SWF_NATIVE_VAR_DECLARE( textColor );
SWF_NATIVE_VAR_DECLARE( _visible );
SWF_NATIVE_VAR_DECLARE( scroll );
SWF_NATIVE_VAR_DECLARE( maxscroll );
SWF_NATIVE_VAR_DECLARE( selectionStart );
SWF_NATIVE_VAR_DECLARE( selectionEnd );
SWF_NATIVE_VAR_DECLARE( isTooltip );
SWF_NATIVE_VAR_DECLARE( mode );
SWF_NATIVE_VAR_DECLARE( delay );
SWF_NATIVE_VAR_DECLARE( renderSound );
SWF_NATIVE_VAR_DECLARE( updateScroll );
SWF_NATIVE_VAR_DECLARE( subtitle );
SWF_NATIVE_VAR_DECLARE( subtitleAlign );
SWF_NATIVE_VAR_DECLARE( subtitleSourceID );
SWF_NATIVE_VAR_DECLARE( subtitleSpeaker );
SWF_NATIVE_VAR_DECLARE_READONLY( _textLength );
2012-11-26 18:58:24 +00:00
SWF_TEXT_FUNCTION_DECLARE( subtitleSourceCheck );
SWF_TEXT_FUNCTION_DECLARE( subtitleStart );
SWF_TEXT_FUNCTION_DECLARE( subtitleLength );
SWF_TEXT_FUNCTION_DECLARE( killSubtitle );
SWF_TEXT_FUNCTION_DECLARE( forceKillSubtitle );
SWF_TEXT_FUNCTION_DECLARE( subLastLine );
SWF_TEXT_FUNCTION_DECLARE( addSubtitleInfo );
SWF_TEXT_FUNCTION_DECLARE( terminateSubtitle );
SWF_TEXT_FUNCTION_DECLARE( clearTimingInfo );
};
#endif // !__SWF_TEXTINSTANCE_H__