Browse Source

Review changes cf. Adam: change name of local vars to not start

with 'f' prefix (used for fields in objects).
Also removed trailing space from lines that irritate Git difference listings.
working_subtitles
rarified 3 years ago
parent
commit
b9f8e3d1bd
  1. 116
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

116
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -125,7 +125,7 @@ class pfEsHTMLChunk
hsScalar fCurrOpacity; // For SFX images
hsScalar fSFXTime; // For SFX images
hsScalar fMinOpacity, fMaxOpacity;
hsScalar fMinOpacity, fMaxOpacity;
hsColorRGBA fCurrColor;
hsColorRGBA fOffColor, fOnColor;
@ -156,7 +156,7 @@ class pfEsHTMLChunk
kCanLink = 0x00000008,
kFloating = 0x00000010,
kGlowing = 0x00000020,
kActAsCB = 0x00000040, // Cause the image to act in a checkbox-like fashion.
kActAsCB = 0x00000040, // Cause the image to act in a checkbox-like fashion.
// Min opacity turns into "off opacity" and max opacity
// is "on opacity"
kChecked = 0x00000080, // Only for kActAsCB, set if it's currently "checked"
@ -469,7 +469,7 @@ pfBookData::pfBookData(const char *guiName /* = nil */)
fTurnFrontEditCtrl = fTurnBackEditCtrl = nil;
fEditable = false;
fAdjustCursorTo = -1;
if (guiName)
fGUIName = guiName;
else
@ -542,7 +542,7 @@ hsBool pfBookData::MsgReceive(plMessage *pMsg)
else if( fCurrentlyTurning )
{
if( callback->fUser & 0x04 )
IFillUncoveringPage( (hsBool)( callback->fUser & 0x01 ) ? true : false );
IFillUncoveringPage( (hsBool)( callback->fUser & 0x01 ) ? true : false );
else if( callback->fUser & 0x02 )
StartTriggeredFlip( (hsBool)( callback->fUser & 0x01 ) ? true : false );
else
@ -564,7 +564,7 @@ hsBool pfBookData::MsgReceive(plMessage *pMsg)
if( time != nil && fCurrSFXPages != kNoSides && !fCurrentlyTurning && fCurrentlyOpen )
{
IHandleSFX( (hsScalar)time->DSeconds() );
return true;
return true;
}
plTimerCallbackMsg* timerMsg = plTimerCallbackMsg::ConvertNoRef(pMsg);
@ -590,13 +590,13 @@ void pfBookData::IInitTemplate(pfGUIDialogMod *templateDlg)
hsAssert(templateDlg != nil, "Nil template in pfBookData::IInitTemplate()!");
// Init and ref our fDialog pointer
hsgResMgr::ResMgr()->SendRef(templateDlg->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefDialog), plRefFlags::kPassiveRef);
hsgResMgr::ResMgr()->SendRef(templateDlg->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefDialog), plRefFlags::kPassiveRef);
// Hijack the dialog proc with our own
templateDlg->SetHandlerForAll(TRACKED_NEW pfJournalDlgProc(this));
// Find our animation keys
// And other interesting pointers
fCoverButton = pfGUICheckBoxCtrl::ConvertNoRef(templateDlg->GetControlFromTag(pfJournalDlgProc::kTagBookCover));
fTurnPageButton = pfGUICheckBoxCtrl::ConvertNoRef(templateDlg->GetControlFromTag(pfJournalDlgProc::kTagTurnPageCtrl));
@ -621,7 +621,7 @@ void pfBookData::IInitTemplate(pfGUIDialogMod *templateDlg)
// Grab and ref the default cover mipmap
plLayer *lay = plLayer::ConvertNoRef(fCoverLayer);
if((lay != nil)&&(lay->GetTexture() != nil))
hsgResMgr::ResMgr()->AddViaNotify(lay->GetTexture()->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefDefaultCover), plRefFlags::kPassiveRef);
hsgResMgr::ResMgr()->AddViaNotify(lay->GetTexture()->GetKey(), TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefDefaultCover), plRefFlags::kPassiveRef);
fLeftPageMap->SetFlag(pfGUIClickMapCtrl::kReportHovering);
fRightPageMap->SetFlag(pfGUIClickMapCtrl::kReportHovering);
@ -663,7 +663,7 @@ void pfBookData::IInitTemplate(pfGUIDialogMod *templateDlg)
}
//// IGetDTMap ///////////////////////////////////////////////////////////////
// Just a quick helper
// Just a quick helper
plDynamicTextMap *pfBookData::GetDTMap(UInt32 which)
{
@ -691,7 +691,7 @@ pfGUIMultiLineEditCtrl *pfBookData::GetEditCtrl(UInt32 which)
}
//// IRegisterForSFX /////////////////////////////////////////////////////////
// Registers (or unregisters) for time messages so we can process special FX
// Registers (or unregisters) for time messages so we can process special FX
// if we need to
void pfBookData::RegisterForSFX(WhichSide whichPages)
@ -705,7 +705,7 @@ void pfBookData::RegisterForSFX(WhichSide whichPages)
}
else
plgDispatch::Dispatch()->UnRegisterForExactType(plTimeMsg::Index(), GetKey());
fCurrSFXPages = whichPages;
}
@ -747,7 +747,7 @@ void pfBookData::IHandleSFX(hsScalar currTime, WhichSide whichSide /*= kNoSides*
for(idx = fCurrBook->fPageStarts[fCurrBook->fCurrentPage + inc]; idx < fCurrBook->fPageStarts[fCurrBook->fCurrentPage + inc + 1]; idx++)
{
pfEsHTMLChunk *chunk = fCurrBook->fHTMLSource[idx];
if(chunk->fFlags & pfEsHTMLChunk::kGlowing)
{
// Glow SFX: animate opacity based on time offset
@ -843,7 +843,7 @@ void pfBookData::IFillUncoveringPage(hsBool rightSide)
// The right edit ctrl doesn't update until the page flip animation is done
id = 98;
}
// create a timer so we can hide the old left or right turn page right before the animation finishes to prevent flicker
plTimerCallbackMsg* pTimerMsg = TRACKED_NEW plTimerCallbackMsg(GetKey(),id);
plgTimerCallbackMgr::NewTimer( .5, pTimerMsg ); // .5 found by trial and error
@ -882,7 +882,7 @@ void pfBookData::ITriggerPageFlip(hsBool flipBackwards, hsBool immediate)
}
msg->SetAnimName(flipBackwards ? "backward" : "forward");
msg->AddReceivers(keys);
// Here's the whole reason why we're not just checking the checkbox: so we can attach a callback
// so we know when the animation completes. Pretty sad, huh? Poor checkbox.
plEventCallbackMsg *eventMsg = TRACKED_NEW plEventCallbackMsg;
@ -920,7 +920,7 @@ void pfBookData::ITriggerPageFlip(hsBool flipBackwards, hsBool immediate)
}
//// StartTriggeredFlip /////////////////////////////////////////////////////
// Finishes the start of the triggered page flip (once we're sure the
// Finishes the start of the triggered page flip (once we're sure the
// animation is at the new frame)
void pfBookData::StartTriggeredFlip(hsBool flipBackwards)
@ -1206,7 +1206,7 @@ void pfJournalBook::UnloadAllGUIs()
// the name of the mipmap to use as the cover of the book. The callback
// key is the keyed object to send event messages to (see <img> tag).
pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/,
pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/,
const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const char *guiName /* = nil */ )
{
if (guiName && (strcmp(guiName,"") != 0))
@ -1219,7 +1219,7 @@ pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plK
hsgResMgr::ResMgr()->NewKey(fCurBookGUI.c_str(),fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation());
fBookGUIs[fCurBookGUI]->LoadGUI();
}
fCurrentPage = 0;
fLastPage = -1;
fCoverMipKey = coverImageKey;
@ -1242,7 +1242,7 @@ pfJournalBook::pfJournalBook( const char *esHTMLSource, plKey coverImageKey, plK
delete [] wESHTMLSource;
}
pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/,
pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey, plKey callbackKey /*= nil*/,
const plLocation &hintLoc /* = plLocation::kGlobalFixedLoc */, const char *guiName /* = nil */ )
{
if (guiName && (strcmp(guiName,"") != 0))
@ -1255,7 +1255,7 @@ pfJournalBook::pfJournalBook( const wchar_t *esHTMLSource, plKey coverImageKey,
hsgResMgr::ResMgr()->NewKey(fCurBookGUI.c_str(),fBookGUIs[fCurBookGUI],pfGameGUIMgr::GetInstance()->GetKey()->GetUoid().GetLocation());
fBookGUIs[fCurBookGUI]->LoadGUI();
}
fCurrentPage = 0;
fLastPage = -1;
fCoverMipKey = coverImageKey;
@ -1498,7 +1498,7 @@ void pfJournalBook::ITriggerCloseWithNotify( hsBool closeNotOpen, hsBool immedia
}
msg->SetAnimName( animName );
msg->AddReceivers( keys );
plEventCallbackMsg *eventMsg = TRACKED_NEW plEventCallbackMsg;
eventMsg->AddReceiver( fBookGUIs[fCurBookGUI]->GetKey() );
eventMsg->fRepeats = 0;
@ -1548,7 +1548,7 @@ void pfJournalBook::NextPage( void )
fVisibleLinks.Reset();
// Swap the right DT map into the turn page front DTMap, then render
// the new current page into turn page back and currPage+1 into
// the new current page into turn page back and currPage+1 into
// the right DTMap
plDynamicTextMap *turnFront = fBookGUIs[fCurBookGUI]->GetDTMap( pfJournalDlgProc::kTagTurnFrontDTMap );
plDynamicTextMap *right = fBookGUIs[fCurBookGUI]->GetDTMap( pfJournalDlgProc::kTagRightDTMap );
@ -1588,7 +1588,7 @@ void pfJournalBook::PreviousPage( void )
{
if (fCurrentPage >= 2) // this variable can get out of whack if we open the book to a page in the middle
fCurrentPage -= 2; // just making sure that this doesn't go below zero (and therefore wrap around)
pfGUIMultiLineEditCtrl *right = fBookGUIs[fCurBookGUI]->GetEditCtrl(pfJournalDlgProc::kTagRightEditCtrl);
pfGUIMultiLineEditCtrl *left = fBookGUIs[fCurBookGUI]->GetEditCtrl(pfJournalDlgProc::kTagLeftEditCtrl);
pfGUIMultiLineEditCtrl *turnFront = fBookGUIs[fCurBookGUI]->GetEditCtrl(pfJournalDlgProc::kTagTurnFrontEditCtrl);
@ -1602,7 +1602,7 @@ void pfJournalBook::PreviousPage( void )
// At this point, only the left and right pages are visible, we don't want to actually update anything until the animation
// starts so that nothing flashes or overdraws.
fBookGUIs[fCurBookGUI]->StartTriggeredFlip( true );
fBookGUIs[fCurBookGUI]->TurnPageButton()->PlaySound( pfGUICheckBoxCtrl::kMouseUp );
ISendNotify(kNotifyPreviousPage);
@ -1618,7 +1618,7 @@ void pfJournalBook::PreviousPage( void )
fVisibleLinks.Reset();
// Swap the left DT map into the turn page back DTMap, then render
// the new current page into the left and currPage+1 into
// the new current page into the left and currPage+1 into
// the turn page front DTMap
plDynamicTextMap *turnBack = fBookGUIs[fCurBookGUI]->GetDTMap( pfJournalDlgProc::kTagTurnBackDTMap );
plDynamicTextMap *left = fBookGUIs[fCurBookGUI]->GetDTMap( pfJournalDlgProc::kTagLeftDTMap );
@ -1844,7 +1844,7 @@ hsBool pfJournalBook::ICompileSource( const wchar_t *source, const plLocation &h
UInt8 type = IGetTagType( c );
if( type != pfEsHTMLChunk::kEmpty )
{
// First, end the current paragraph chunk, which is a special case 'cause its
// First, end the current paragraph chunk, which is a special case 'cause its
// text is defined outside the tag
if( start == c )
{
@ -1855,7 +1855,7 @@ hsBool pfJournalBook::ICompileSource( const wchar_t *source, const plLocation &h
else if( lastParChunk != nil )
{
UInt32 count = ((UInt32)c - (UInt32)start)/2; // wchar_t is 2 bytes
wchar_t *temp = TRACKED_NEW wchar_t[ count + 1 ];
wcsncpy( temp, start, count );
temp[count] = L'\0';
@ -2010,7 +2010,7 @@ hsBool pfJournalBook::ICompileSource( const wchar_t *source, const plLocation &h
break;
case pfEsHTMLChunk::kCover:
// Don't create an actual chunk for this one, just use the "src" and
// Don't create an actual chunk for this one, just use the "src" and
// grab the mipmap key for our cover
c += 6;
while( IGetNextOption( c, name, option ) )
@ -2181,7 +2181,7 @@ hsBool pfJournalBook::ICompileSource( const wchar_t *source, const plLocation &h
}
fHeightScale = 1.f - bookHeight;
fWidthScale = 1.f - bookWidth;
// Still gotta create a new par chunk
lastParChunk = TRACKED_NEW pfEsHTMLChunk( nil );
lastParChunk->fFlags = IFindLastAlignment();
@ -2316,7 +2316,7 @@ hsBool pfJournalBook::ICompileSource( const wchar_t *source, const plLocation &h
lastParChunk = TRACKED_NEW pfEsHTMLChunk( nil );
lastParChunk->fFlags = IFindLastAlignment();
break;
case pfEsHTMLChunk::kEditable:
c += 9;
SetEditable(true);
@ -2350,12 +2350,12 @@ hsBool pfJournalBook::ICompileSource( const wchar_t *source, const plLocation &h
else if( lastParChunk != nil )
{
UInt32 count = (UInt32)c - (UInt32)start;
wchar_t *temp = TRACKED_NEW wchar_t[ count + 1 ];
wcsncpy( temp, start, count + 1 );
lastParChunk->fText = temp;
delete [] temp;
// Special case to remove any last trailing carriage return
// if( count > 1 && lastParChunk->fText[ count - 1 ] == '\n' )
// lastParChunk->fText[ count - 1 ] = 0;
@ -2370,7 +2370,7 @@ hsBool pfJournalBook::ICompileSource( const wchar_t *source, const plLocation &h
fLastPage = 0;
else
fLastPage = -1;
return true;
}
@ -2394,7 +2394,7 @@ UInt8 pfJournalBook::IGetTagType( const wchar_t *string )
{ L"movie", pfEsHTMLChunk::kMovie },
{ L"editable", pfEsHTMLChunk::kEditable },
{ nil, pfEsHTMLChunk::kEmpty } };
UInt32 i;
for( i = 0; tags[ i ].fTag != nil; i++ )
@ -2458,7 +2458,7 @@ hsBool pfJournalBook::IGetNextOption( const wchar_t *&string, wchar_t *name, wch
len = ((UInt32)string - (UInt32)c)/2; // divide length by 2 because each character is two bytes
wcsncpy( option, c, len );
option[len] = L'\0';
if( *string == L'\"' )
string++;
@ -2473,14 +2473,14 @@ hsBool pfJournalBook::IGetNextOption( const wchar_t *&string, wchar_t *name, wch
len = ((UInt32)string - (UInt32)c)/2; // divide length by 2 because each character is two bytes
wcsncpy( option, c, len );
option[len] = L'\0';
return true;
}
void pfJournalBook::IFreeSource( void )
{
UInt32 i;
for( i = 0; i < fHTMLSource.GetCount(); i++ )
delete fHTMLSource[ i ];
fHTMLSource.Reset();
@ -2573,7 +2573,7 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
{
if (fAreEditing)
return; // we don't render if we are editing the book
// Grab the DTMap via the GUI system
plDynamicTextMap *dtMap = fBookGUIs[fCurBookGUI]->GetDTMap( whichDTMap );
hsAssert( dtMap != nil, "Invalid DT map in IRenderPage()" );
@ -2619,12 +2619,12 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
#endif // USE_BINK_SDK
hsAssert(page < fPageStarts.GetCount() || page > fLastPage, "UnInitialized page start!");
if( page <= fLastPage
if( page <= fLastPage
&& page < fPageStarts.GetCount()) // Added this as a crash-prevention bandaid - MT
{
UInt32 idx;
UInt16 width, height, y, x, ascent, lastX, lastY;
UInt8 fontFlags, fontSize;
const wchar_t *fontFace;
hsColorRGBA fontColor;
@ -2668,14 +2668,14 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
width = (UInt16)(512 - fPageLMargin - fPageRMargin);
height = (UInt16)(512 - fPageBMargin - y);
UInt32 lastChar;
const wchar_t *fTextStr; // initialize later to avoid compile errors inside case block
int fTextStrLen;
fTextStr = chunk->fText.c_str();
fTextStrLen = chunk->fText.length();
dtMap->CalcWrappedStringSize( fTextStr, &width, &height, &lastChar, &ascent, &lastX, &lastY );
const wchar_t *chunkTextStr; // initialize later to avoid compile errors inside case block
int chunkTextStrLen;
chunkTextStr = chunk->fText.c_str();
chunkTextStrLen = chunk->fText.length();
dtMap->CalcWrappedStringSize( chunkTextStr, &width, &height, &lastChar, &ascent, &lastX, &lastY );
width = (UInt16)(512 - fPageLMargin - fPageRMargin);
if( !suppressRendering )
dtMap->DrawWrappedString( (UInt16)fPageLMargin, y, fTextStr, width, (UInt16)(512 - fPageBMargin - y), &lastX, &lastY );
dtMap->DrawWrappedString( (UInt16)fPageLMargin, y, chunkTextStr, width, (UInt16)(512 - fPageBMargin - y), &lastX, &lastY );
if( lastChar == 0 )
{
@ -2686,16 +2686,16 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
idx--;
break;
}
if( fTextStr[ lastChar ] != L'\0' )
if( chunkTextStr[ lastChar ] != L'\0' )
{
// Didn't get to render the whole paragraph in this go, so we're going to cheat
// and split the paragraph up into two so that we can handle it properly. Note:
// this changes the chunk array beyond this point, so we need to invalidate the
// cache, but that's ok 'cause if we're doing this, it's probably invalid (or empty)
// anyway
wchar_t *s = TRACKED_NEW wchar_t[fTextStrLen+1];
wcscpy(s,fTextStr);
s[fTextStrLen] = L'\0';
wchar_t *s = TRACKED_NEW wchar_t[chunkTextStrLen+1];
wcscpy(s,chunkTextStr);
s[chunkTextStrLen] = L'\0';
// Note: Makes a copy of the string
pfEsHTMLChunk *c2 = TRACKED_NEW pfEsHTMLChunk( &s[ lastChar ] );
@ -2714,7 +2714,7 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
y += 512;
break;
}
x = lastX;
y = (UInt16)(lastY - dtMap->GetCurrFont()->GetAscent()); // Since our text is top-justified
@ -2753,13 +2753,13 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
{
// Mipmap overlaps the bottom of this page, so forcibly break so we'll
// end up marking the page break here (note that, unlike paragraphs, we
// can't really break the mipmap into two...well, OK, we could, but it
// can't really break the mipmap into two...well, OK, we could, but it
// wouldn't make much sense :)
y += (UInt16)(mip->GetHeight());
// Wonderful, the break breaks us from the switch(), which means the for()
// loops runs once more and increments idx. So this is to counter that.
// (We better check tho, just to make sure nobody feeds us an extra-large
// (We better check tho, just to make sure nobody feeds us an extra-large
// image and sends us on an infinite loop)
if( idx > fPageStarts[ page ] )
idx--;
@ -2799,7 +2799,7 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
x = (UInt16)fPageLMargin;
break;
case pfEsHTMLChunk::kFontChange:
case pfEsHTMLChunk::kFontChange:
IFindFontProps( idx, fontFace, fontSize, fontFlags, fontColor, fontSpacing );
dtMap->SetFont( fontFace, fontSize, fontFlags, false );
dtMap->SetTextColor( fontColor, true );
@ -2827,7 +2827,7 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
// Wonderful, the break breaks us from the switch(), which means the for()
// loops runs once more and increments idx. So this is to counter that.
// (We better check tho, just to make sure nobody feeds us an extra-large
// (We better check tho, just to make sure nobody feeds us an extra-large
// image and sends us on an infinite loop)
if( idx > fPageStarts[ page ] )
idx--;
@ -2966,7 +2966,7 @@ void pfJournalBook::IDrawMipmap( pfEsHTMLChunk *chunk, UInt16 x, UInt16 y, plMip
else
x -= xShift;
}
copy->SetCurrLevel(0); // resize the image so it will look unchanged when rendered on the altered book
copy->ResizeNicely((UInt16)width,(UInt16)height,plMipmap::kDefaultFilter);
}
@ -2981,7 +2981,7 @@ void pfJournalBook::IDrawMipmap( pfEsHTMLChunk *chunk, UInt16 x, UInt16 y, plMip
opts.fBlueTint = chunk->fCurrColor.b;
opts.fOpacity = (UInt8)(chunk->fCurrColor.a * 255.f);
}
else
else
{
if( chunk->fFlags & pfEsHTMLChunk::kGlowing )
opts.fFlags = ( chunk->fFlags & pfEsHTMLChunk::kBlendAlpha ) ? 0 : plMipmap::kMaskSrcAlpha;
@ -3177,7 +3177,7 @@ plLayerBink *pfJournalBook::IMakeMovieLayer(pfEsHTMLChunk *chunk, UInt16 x, UInt
else
flipMat = hsMatrix44::IdentityMatrix();
}
hsMatrix44 xfm;
xfm = translateMat * scaleMat * flipMat;
@ -3550,7 +3550,7 @@ void pfJournalBook::ILoadAllImages( hsBool unload )
fBookGUIs[fCurBookGUI]->GetKey()->Release( fHTMLSource[ i ]->fImageKey );
else
{
plGenRefMsg *ref = TRACKED_NEW plGenRefMsg( fBookGUIs[fCurBookGUI]->GetKey(), plRefMsg::kOnCreate, -1, kRefImage );
plGenRefMsg *ref = TRACKED_NEW plGenRefMsg( fBookGUIs[fCurBookGUI]->GetKey(), plRefMsg::kOnCreate, -1, kRefImage );
hsgResMgr::ResMgr()->AddViaNotify( fHTMLSource[ i ]->fImageKey, ref, plRefFlags::kActiveRef );
}
}

Loading…
Cancel
Save