void pfGUIMenuItem::IUpdate( void ) { if( fDynTextMap == nil ) return; if( fSkin != nil ) { IUpdateSkinBuffers(); if( !fSkinBuffersUpdated ) return; // Copy now from our skin buffer, plus set our text color uint16_t y = fDynTextMap->GetVisibleHeight(); if( IsInteresting() ) { fDynTextMap->DrawClippedImage( 0, 0, fDynTextMap, 0, y << 1, fDynTextMap->GetVisibleWidth(), y, plDynamicTextMap::kImgSprite ); fDynTextMap->SetTextColor( GetColorScheme()->fSelForeColor ); } else { fDynTextMap->DrawClippedImage( 0, 0, fDynTextMap, 0, y, fDynTextMap->GetVisibleWidth(), y, plDynamicTextMap::kImgSprite ); fDynTextMap->SetTextColor( GetColorScheme()->fForeColor ); } } else { if( IsInteresting() ) { fDynTextMap->ClearToColor( GetColorScheme()->fSelBackColor ); fDynTextMap->SetTextColor( GetColorScheme()->fSelForeColor ); } else { fDynTextMap->ClearToColor( GetColorScheme()->fBackColor ); fDynTextMap->SetTextColor( GetColorScheme()->fForeColor ); } } fDynTextMap->SetJustify( plDynamicTextMap::kLeftJustify ); if( fName != nil ) { uint16_t ht; fDynTextMap->CalcStringWidth( fName, &ht ); int16_t x = 0, y = ( fDynTextMap->GetVisibleHeight() - ht ) >> 1; if( fHowToSkin == kTop && fSkin != nil ) y += fSkin->GetElement( pfGUISkin::kTopSpan ).fHeight >> 1; else if( fHowToSkin == kBottom && fSkin != nil )
bool pfGUIControlMod::ISetUpDynTextMap( plPipeline *pipe ) { if( fDynTextMap == nil ) { hsAssert( false, "Trying to set up a nil dynamicTextMap in a GUI control" ); return true; } if( fDynTextLayer == nil || fInitialBounds.GetType() == kBoundsUninitialized )//|| fDialog == nil ) return false; uint32_t scrnWidth, scrnHeight; if( !HasFlag( kScaleTextWithResolution ) ) { // Scale so that there is a 1:1 pixel:textel ratio scrnWidth = pipe->Width(); scrnHeight = pipe->Height(); } else { // Scale with the resolution so that we take up the same % of screen space no matter what resolution // Assume a base "resolution" of 1024xX, where X is such that the ratio "1024/X = scrnWidth/scrnHt" holds const int kBaseScaleRes = 1024; const int kBaseScaleHeightRes = 768; scrnWidth = kBaseScaleRes; scrnHeight = kBaseScaleHeightRes; // we are going to just force things to be in 4 by 3 ratio... // ...cause it seems to work better. /////// scrnHeight = ( pipe->Height() * kBaseScaleRes ) / pipe->Width(); } const hsBounds3 &bounds = fInitialBounds;//GetBounds(); uint16_t width = (uint16_t)(( bounds.GetMaxs().fX - bounds.GetMins().fX ) * scrnWidth); uint16_t height = (uint16_t)(( bounds.GetMaxs().fY - bounds.GetMins().fY ) * scrnHeight); // Allow derived controls to allocate some extra scratch space if desired // (Do it this way so we can pass in our current calculated dimensions for them to play with) uint16_t extraW = width, extraH = height; IGrowDTMDimsToDesiredSize( extraW, extraH ); extraW -= width; extraH -= height; fDynTextMap->Reset(); fDynTextMap->Create( width, height, HasFlag( kXparentBgnd ), extraW, extraH, true ); fDynTextMap->SetFont( GetColorScheme()->fFontFace, GetColorScheme()->fFontSize, GetColorScheme()->fFontFlags, HasFlag( kXparentBgnd ) ? false : true ); fDynTextMap->SetTextColor( GetColorScheme()->fForeColor, ( HasFlag( kXparentBgnd ) && GetColorScheme()->fBackColor.a == 0.f ) ? true : false ); // Now we gotta set the texture transform on the layer so our texture comes // out with 1:1 mapping from textel to pixel plLayer *layer = (plLayer *)fDynTextLayer; layer->SetTransform( fDynTextMap->GetLayerTransform() ); layer->SetBlendFlags( layer->GetBlendFlags() | hsGMatState::kBlendAlphaPremultiplied ); // Let the derived classes do their things IPostSetUpDynTextMap(); // Do our first update IUpdate(); return true; }