void CGUIBitmap::processRender(const GsRect<float> &RectDispCoordFloat) { if(!mScaledBitmapPtr) { return; } if(mScaledBitmapPtr->empty()) { return; } // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); GsRect<Uint16> lRect = displayRect.SDLRect(); if( mScaledBitmapPtr->width() != lRect.w || mScaledBitmapPtr->height() != lRect.h ) { // copy the bitmap mScaledBitmapPtr.reset(new GsBitmap); *mScaledBitmapPtr = *mpBitmap; lRect.x = 0; lRect.y = 0; mScaledBitmapPtr->scaleTo(lRect); } else { mScaledBitmapPtr->draw( lRect.x, lRect.y ); } }
void CGUIInputText::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); if(!mEnabled) return; SDL_Surface *blitsfc = gVideoDriver.getBlitSurface(); if( mReleased ) { drawRect( blitsfc, &lRect, 1, 0x00BBBBBB, 0x00CFCFCF ); } else if( mPressed ) { drawRect( blitsfc, &lRect, 1, 0x00BBBBBB, 0x00DFDFDF ); } else if( mHovered ) { drawRect( blitsfc, &lRect, 1, 0x00BBBBBB, 0x00EFEFEF ); } else { drawRect( blitsfc, &lRect, 1, 0x00BBBBBB, 0x00FFFFFF ); } // Now lets draw the text of the list control GsFont &Font = gGraphics.getFont(mFontID); Font.drawFontCentered( blitsfc, getInputString(), lRect.x, lRect.w, lRect.y, lRect.h,false ); }
void CGUINumberControl::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); GsRect<Uint16> lRect(displayRect); GsWeakSurface blitsfc(gVideoDriver.getBlitSurface()); if( mReleased ) { blitsfc.drawRect( lRect, 1, 0x00BBBBBB, 0x00CFCFCF ); } else if( mPressed ) { blitsfc.drawRect( lRect, 1, 0x00BBBBBB, 0x00DFDFDF ); } else if( mHovered ) { blitsfc.drawRect( lRect, 1, 0x00BBBBBB, 0x00EFEFEF ); } else { blitsfc.drawRect( lRect, 1, 0x00BBBBBB, 0x00FFFFFF ); } // Now lets draw the text of the list control GsFont &Font = gGraphics.getFont(mFontID); Font.drawFontCentered( blitsfc, mText, lRect, false ); }
void NumberControl::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); GsWeakSurface blitsfc(gVideoDriver.getBlitSurface()); if(!mEnabled) { mTextDisabledSfc.blitTo(blitsfc, lRect); } else { if(mHovered) { if(mDecSel) mTextLightSfcL.blitTo(blitsfc, lRect); else if(mIncSel) mTextLightSfcR.blitTo(blitsfc, lRect); else mTextLightSfc.blitTo(blitsfc, lRect); } else // Button is not hovered { mTextDarkSfc.blitTo(blitsfc, lRect); } } drawBlinker(lRect); }
void NumberControl::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); GsWeakSurface blitsfc(gVideoDriver.getBlitSurface()); // Now lets draw the text of the list control GsFont &Font = gGraphics.getFont(mFontID); Font.drawFont( blitsfc, mText, lRect.x+24, lRect.y, false ); Font.drawFont( blitsfc, ":", lRect.x+24+mText.size()*8, lRect.y, false ); if(mSlider) { gGraphics.getFont(2).drawFont( blitsfc, sliderStr(), lRect.x+16+(mText.size()+2)*8, lRect.y, false ); } else { std::string text = (mDecSel) ? "\025" : " "; text += itoa(mValue); if(mIncSel) text += static_cast<char>(17); else text += " "; Font.drawFont( blitsfc, text, lRect.x+24+(mText.size()+2)*8, lRect.y, false ); } drawTwirl(lRect); }
void GsScrollbar::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); drawScrollBar(lRect); }
void CGUIControl::processPointingState(const GsRect<float> &rect) { GsPointingState &pointingState = gPointDevice.mPointingState; const bool hasPoint = rect.HasPoint(pointingState.mPos); const bool bDown = (pointingState.mActionButton>0); mReleased = false; if(!bDown && mPressed) { mPressed = false; if(hasPoint) { mReleased = true; } } if(!bDown || mPressed) { mHovered = hasPoint; } if(mHovered && bDown) { mPressed = true; } }
void CGUISwitch::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); /* SDL_Rect lRect = displayRect.SDLRect(); if(gpBehaviorEngine->getEngine() == ENGINE_VORTICON) { drawVorticonStyle(lRect); } else { (this->*drawButton)(lRect); } */ }
void InputText::processRender(const GsRect<float> &RectDispCoordFloat) { if(!mEnabled) return; // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); SDL_Surface *blitsfc = gVideoDriver.getBlitSurface(); // Now lets draw the text of the list control GsFont &Font = gGraphics.getFont(mFontID); Font.drawFont( blitsfc, getInputString(), lRect.x+24, lRect.y, false ); drawTwirl(lRect); }
void CPassiveGalaxy::renderIntro() { GsRect<Uint16> gameRes = gVideoDriver.getGameResolution(); SDL_Rect gameResSDL = gameRes.SDLRect(); const int logoPosX = (gameRes.w-mCurrentLogoBmp.getWidth())/2; SDL_Surface *blitSfc = gVideoDriver.getBlitSurface(); SDL_FillRect( blitSfc, &gameResSDL, SDL_MapRGB(blitSfc->format, 0, 0, 0) ); mCommanderTextSfc.draw(mCommanderTextPos.x, mCommanderTextPos.y); mKeenTextSfc.draw(mKeenTextPos.x, mKeenTextPos.y); if(mTerminatorLogoNum < 4) { mCurrentLogoBmp.draw(logoPosX, mLogoPosY); } }
void GalaxyButton::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); GsWeakSurface blitsfc( gVideoDriver.getBlitSurface() ); if(!mEnabled) { mTextDisabledSfc.blitTo(blitsfc, lRect); } else { drawEnabledButton(blitsfc, lRect, mHovered); } drawBlinker(lRect); }
void BorderedButton::processRender(const GsRect<float> &RectDispCoordFloat) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); GsWeakSurface blitsfc( gVideoDriver.getBlitSurface() ); Uint32 newcolor; if(!mEnabled) newcolor = blitsfc.mapRGB(123, 150, 123); else if(mHovered || mPressed) newcolor = blitsfc.mapRGB(84, 234, 84); else newcolor = blitsfc.mapRGB(38, 134, 38); blitsfc.drawFrameRect( lRect, 1, newcolor); lRect.y +=2; lRect.x +=2; if(!mEnabled) { mTextDisabledSfc.blitTo(blitsfc, lRect); } else { if(mHovered) { drawEnabledButton(blitsfc, lRect, true); } else { drawEnabledButton(blitsfc, lRect, false); } } }
void CGUIBitmap::processRender(const GsRect<float> &RectDispCoordFloat) { if(mScaledBitmap.empty()) return; // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); GsRect<Uint16> lRect = displayRect.SDLRect(); if( mScaledBitmap.getWidth() != lRect.w || mScaledBitmap.getHeight() != lRect.h ) { mScaledBitmap = GsBitmap( *mpBitmap.get() ); lRect.x = 0; lRect.y = 0; mScaledBitmap.scaleTo(lRect); } else { mScaledBitmap.draw( lRect.x, lRect.y ); } }
bool GsBitmap::scaleTo(const GsRect<Uint16> &destRes) { SDL_Rect newRect = destRes.SDLRect(); // Need to do that, otherwise it won't work. optimizeSurface(); if(newRect.w == mpBitmapSurface->w && newRect.h == mpBitmapSurface->h) return true; std::shared_ptr<SDL_Surface> newSfc; auto bmpSfc = mpBitmapSurface.get(); auto bmpFormat = bmpSfc->format; newSfc.reset( SDL_CreateRGBSurface(bmpSfc->flags, newRect.w, newRect.h, bmpFormat->BitsPerPixel, bmpFormat->Rmask, bmpFormat->Gmask, bmpFormat->Bmask, bmpFormat->Amask ), &SDL_FreeSurface ); if(!newSfc) return false; #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_BlendMode blendMode; SDL_GetSurfaceBlendMode(bmpSfc, &blendMode); SDL_SetSurfaceBlendMode(newSfc.get(), blendMode); #endif CVidConfig &vidConf = gVideoDriver.getVidConfig(); blitScaled(bmpSfc, bmpSfc->clip_rect, newSfc.get(), newRect, vidConf.m_ScaleXFilter); mpBitmapSurface = newSfc; return true; }
void CPassiveGalaxy::renderIntroZoom() { SDL_Rect dstRect, srGsRect; srGsRect.x = srGsRect.y = 0; if(mZoomSfcPos.x < 16) { srGsRect.x -= mZoomSfcPos.x; } if(mZoomSfcPos.y > 8) { srGsRect.y -= mZoomSfcPos.y; } SDL_Surface *zoomSfc = mpZoomSurface.get(); // Here we define the Rects to zoom srGsRect.w = zoomSfc->w; srGsRect.h = zoomSfc->h; dstRect.x = mZoomSfcPos.x; dstRect.y = mZoomSfcPos.y; dstRect.w = mZoomSfcZoom.x; dstRect.h = mZoomSfcZoom.y; GsRect<Uint16> gameRes = gVideoDriver.getGameResolution(); SDL_Rect gameResSDL = gameRes.SDLRect(); SDL_Surface *blitSfc = gVideoDriver.getBlitSurface(); SDL_FillRect( blitSfc, &gameResSDL, SDL_MapRGB(blitSfc->format, 0, 0, 0) ); CVidConfig &vidConf = gVideoDriver.getVidConfig(); blitScaled( zoomSfc, srGsRect, blitSfc, dstRect, vidConf.m_ScaleXFilter ); }
bool GsSurface::scaleTo(const GsRect<Uint16> &scaledRect, const filterOptionType filter) { SDL_Rect newRect = scaledRect.SDLRect(); if(newRect.w == mpSurface->w && newRect.h == mpSurface->h) return true; // Need to do that, otherwise it won't work ??? //optimizeSurface(); auto sfcFormat = mpSurface->format; SDL_Surface *newSfc = SDL_CreateRGBSurface(mpSurface->flags, newRect.w, newRect.h, sfcFormat->BitsPerPixel, sfcFormat->Rmask, sfcFormat->Gmask, sfcFormat->Bmask, sfcFormat->Amask ); if(!newSfc) return false; #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_BlendMode blendMode; SDL_GetSurfaceBlendMode(mpSurface, &blendMode); SDL_SetSurfaceBlendMode(newSfc, blendMode); #endif blitScaled(mpSurface, mpSurface->clip_rect, newSfc, newRect, filter); // Tear down old surface! SDL_FreeSurface(mpSurface); // And set the newly created and scaled one mpSurface = newSfc; return true; }
bool checkSandwichMenuClicked(GsRect<float> &rRect) { GsPointingState &pointingState = gPointDevice.mPointingState; const bool hasPoint = rRect.HasPoint(pointingState.mPos); const bool bDown = (pointingState.mActionButton > 0); if(bDown && hasPoint) { return true; } else { return false; } }
void Switch::processRender(const GsRect<float> &RectDispCoordFloat) { if(mStyle == Style::GALAXY) { ComboSelection::processRender(RectDispCoordFloat); } else if(mStyle == Style::VORTICON) { // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); drawVorticonStyle(lRect); } else { GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); drawNoStyle(lRect); } }
void CGUITextSelectionList::processRender(const GsRect<float> &RectDispCoordFloat) { // Blit the List surface SDL_Surface *Blitsurface = gVideoDriver.getBlitSurface(); // Transform to the display coordinates GsRect<float> displayRect = mRect; displayRect.transform(RectDispCoordFloat); SDL_Rect lRect = displayRect.SDLRect(); SDL_FillRect(Blitsurface, &lRect, 0xFFFFFFFF); // Now lets draw the text of the list control GsFont &Font = gGraphics.getFont(mFontID); // Move 16 Pixel so we have space for the cursor/twirl to show the selection const int sepHeight = Font.getPixelTextHeight()+2; const int xpos = lRect.x+16+1; const int ypos = lRect.y+10; unsigned int textlimitWidth = (lRect.w-16)/8; mScrollbar.mLastToShow = (lRect.h/sepHeight)-1; lRect.h = 10; lRect.x += 12; lRect.w -= 12; std::string trimmedText; std::list<std::string> :: iterator it = mItemList.begin(); for(int i=0 ; i<mScrollbar.scrollPos() ; it++, i++); for ( int line = 0; it != mItemList.end() && line<mScrollbar.mLastToShow ; it++, line++ ) { if(mPressedSelection == int(line) + mScrollbar.scrollPos() ) { lRect.y = ypos+(line*10)-1; SDL_FillRect(Blitsurface, &lRect, 0xFFA5A5F1); } else if(mReleasedSelection == int(line) + mScrollbar.scrollPos() ) { lRect.y = ypos+(line*10)-1; if(mSelected) SDL_FillRect(Blitsurface, &lRect, 0xFFB5B5F1); else SDL_FillRect(Blitsurface, &lRect, 0xFFC5C5C5); } else if(mHoverSelection == int(line) + mScrollbar.scrollPos() ) { lRect.y = ypos+(line*sepHeight)-1; SDL_FillRect(Blitsurface, &lRect, 0xFFE5E5F1); } trimmedText = *it; if(trimmedText.size() > textlimitWidth) trimmedText = trimmedText.substr(0, textlimitWidth); Font.drawFont(Blitsurface, trimmedText, xpos, ypos+(line*10), false); } mScrollbar.mMaxScrollAmt = mItemList.size()-mScrollbar.lastToShow(); // Do we need a scrollbar? if(mScrollbar.mMaxScrollAmt>0) { mScrollbar.processRender(displayRect); //drawScrollBar(displayRect.SDLRect()); } }