123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- /*
- ===========================================================================
- Doom 3 BFG Edition GPL Source Code
- Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
- This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
- 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() {
- startTime = 0;
- forceBreak = false;
- }
- idStr phrase;
- int startTime;
- bool forceBreak;
- };
- class idSWFTextInstance {
- 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 );
- idStr GetRandomText( int time );
- void StartParagraphText( int time );
- idStr GetParagraphText( int time );
- bool NeedsGenerateRandomText() { return triggerGenerate; }
- bool NeedsSoundPlayed();
- void ClearPlaySound() { needsSoundUpdate = false; }
- idStr GetSoundClip() { return soundClip; }
- void SetIgnoreColor( bool ignore ) { ignoreColor = ignore; }
- void SetStrokeInfo( bool use, float strength = 0.75f, float weight = 1.75f );
- int CalcMaxScroll( int numLines = -1 );
- int CalcNumLines();
- // subtitle functions
- void SwitchSubtitleText( int time );
- bool UpdateSubtitle( int time );
- bool IsSubtitle() { return isSubtitle; }
- bool IsUpdatingSubtitle() { return subUpdating; }
- void SetSubEndIndex( int endChar, int time );
- int GetLastWordIndex() { return subLastWordIndex; }
- int GetPrevLastWordIndex() { return subPrevLastWordIndex; }
- void LastWordChanged( int wordCount, int time );
- void SetSubStartIndex( int value ) { subCharStartIndex = value; }
- int GetSubEndIndex() { return subCharEndIndex; }
- int GetSubStartIndex() { return subCharStartIndex; }
- void SetSubNextStartIndex( int value );
- int GetApporoximateSubtitleBreak( int time );
- bool SubNeedsSwitch() { return subNeedsSwitch; }
- idStr GetPreviousText() { return subtitleText.c_str(); }
- void SubtitleComplete();
- int GetSubAlignment() { return subAlign; }
- idStr GetSpeaker() { return subSpeaker.c_str(); }
- 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; }
- // 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;
- // this text instance's script object
- idSWFScriptObject scriptObject;
- idStr text;
- idStr randomtext;
- idStr variable;
- swfColorRGBA_t color;
- bool visible;
- bool tooltip;
- int selectionStart;
- int selectionEnd;
- bool ignoreColor;
- int scroll;
- int scrollTime;
- int maxscroll;
- int maxLines;
- float glyphScale;
- swfRect_t bounds;
- float linespacing;
- bool shiftHeld;
- int lastInputTime;
- bool useDropShadow;
- bool useStroke;
- float strokeStrength;
- float strokeWeight;
- int textLength;
- bool lengthCalculated;
- 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;
- // 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;
- // 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 {
- public:
- idSWFScriptObject_TextInstancePrototype();
- //----------------------------------
- // 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;
- SWF_TEXT_FUNCTION_DECLARE( onKey );
- SWF_TEXT_FUNCTION_DECLARE( onChar );
- SWF_TEXT_FUNCTION_DECLARE( generateRnd );
- SWF_TEXT_FUNCTION_DECLARE( calcNumLines );
- 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 );
- 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__
|