示例#1
0
static RectI DrawBottomRightLink(HWND hwnd, HDC hdc, const WCHAR *txt)
{
    ScopedFont fontLeftTxt(GetSimpleFont(hdc, L"MS Shell Dlg", 14));
    HPEN penLinkLine = CreatePen(PS_SOLID, 1, COL_BLUE_LINK);

    HGDIOBJ origFont = SelectObject(hdc, fontLeftTxt); /* Just to remember the orig font */

    SetTextColor(hdc, COL_BLUE_LINK);
    SetBkMode(hdc, TRANSPARENT);
    ClientRect rc(hwnd);

    SIZE txtSize;
    GetTextExtentPoint32(hdc, txt, (int)str::Len(txt), &txtSize);
    RectI rect(rc.dx - txtSize.cx - ABOUT_INNER_PADDING,
               rc.y + rc.dy - txtSize.cy - ABOUT_INNER_PADDING, txtSize.cx, txtSize.cy);
    if (IsUIRightToLeft())
        rect.x = ABOUT_INNER_PADDING;
    DrawText(hdc, txt, -1, &rect.ToRECT(), IsUIRightToLeft() ? DT_RTLREADING : DT_LEFT);

    SelectObject(hdc, penLinkLine);
    PaintLine(hdc, RectI(rect.x, rect.y + rect.dy, rect.dx, 0));

    SelectObject(hdc, origFont);
    DeleteObject(penLinkLine);

    // make the click target larger
    rect.Inflate(ABOUT_INNER_PADDING, ABOUT_INNER_PADDING);
    return rect;
}
RectI Win32WindowManager::getMonitorRect(U32 index)
{
   if(index >= mMonitors.size())
      return RectI(0, 0, 0, 0);

   return mMonitors[index].region;
}
示例#3
0
RectI
TrackMarker::getMarkerImageRoI(int time) const
{
    const unsigned int mipmapLevel = 0;
    Point center, offset;
    KnobDoublePtr centerKnob = getCenterKnob();
    KnobDoublePtr offsetKnob = getOffsetKnob();

    center.x = centerKnob->getValueAtTime(time, 0);
    center.y = centerKnob->getValueAtTime(time, 1);

    offset.x = offsetKnob->getValueAtTime(time, 0);
    offset.y = offsetKnob->getValueAtTime(time, 1);

    RectD roiCanonical;
    KnobDoublePtr swBl = getSearchWindowBottomLeftKnob();
    KnobDoublePtr swTr = getSearchWindowTopRightKnob();

    roiCanonical.x1 = swBl->getValueAtTime(time, 0) + center.x + offset.x;
    roiCanonical.y1 = swBl->getValueAtTime(time, 1) + center.y + offset.y;
    roiCanonical.x2 = swTr->getValueAtTime(time, 0) + center.x + offset.x;
    roiCanonical.y2 = swTr->getValueAtTime(time, 1) + center.y + offset.y;

    RectI roi;
    NodePtr node = getContext()->getNode();
    NodePtr input = node->getInput(0);
    if (!input) {
        return RectI();
    }
    roiCanonical.toPixelEnclosing(mipmapLevel, input ? input->getEffectInstance()->getAspectRatio(-1) : 1., &roi);

    return roi;
}
GFXLockedRect* GFXGLTextureObject::lock(U32 mipLevel, RectI *inRect)
{
   AssertFatal(mBinding != GL_TEXTURE_3D, "GFXGLTextureObject::lock - We don't support locking 3D textures yet");
   U32 width = mTextureSize.x >> mipLevel;
   U32 height = mTextureSize.y >> mipLevel;

   if(inRect)
   {
      if((inRect->point.x + inRect->extent.x > width) || (inRect->point.y + inRect->extent.y > height))
         AssertFatal(false, "GFXGLTextureObject::lock - Rectangle too big!");

      mLockedRectRect = *inRect;
   }
   else
   {
      mLockedRectRect = RectI(0, 0, width, height);
   }
   
   mLockedRect.pitch = mLockedRectRect.extent.x * mBytesPerTexel;

   // CodeReview [ags 12/19/07] This one texel boundary is necessary to keep the clipmap code from crashing.  Figure out why.
   U32 size = (mLockedRectRect.extent.x + 1) * (mLockedRectRect.extent.y + 1) * mBytesPerTexel;
   AssertFatal(!mFrameAllocatorMark && !mFrameAllocatorPtr, "");
   mFrameAllocatorMark = FrameAllocator::getWaterMark();
   mFrameAllocatorPtr = (U8*)FrameAllocator::alloc( size );
   mLockedRect.bits = mFrameAllocatorPtr;
#if TORQUE_DEBUG
   mFrameAllocatorMarkGuard = FrameAllocator::getWaterMark();
#endif
   
   if( !mLockedRect.bits )
      return NULL;

   return &mLockedRect;
}
示例#5
0
const RectI GuiContainer::getClientRect()
{
   RectI resRect = RectI( Point2I(0,0), getExtent() );

   // Inset by padding
   mSizingOptions.mInternalPadding.insetRect( resRect ); 

   return resRect;
}
// returns the dimensions the given window has to have in order to be a fullscreen window
RectI GetFullscreenRect(HWND hwnd)
{
    MONITORINFO mi = { 0 };
    mi.cbSize = sizeof(mi);
    if (GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &mi))
        return RectI::FromRECT(mi.rcMonitor);
    // fall back to the primary monitor
    return RectI(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
示例#7
0
void GuiTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
{
   if ( mList[cell.y].active )
   {
      if (selected || (mProfile->mMouseOverSelected && mouseOver))
      {
         RectI highlightRect = RectI(offset.x, offset.y, mCellSize.x, mCellSize.y);
         highlightRect.inset( 0, -1 );
         renderFilledBorder( highlightRect, mProfile->mBorderColorHL, mProfile->mFillColorHL);
         GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColorHL);
      }
      else
         GFX->getDrawUtil()->setBitmapModulation(mouseOver ? mProfile->mFontColorHL : mProfile->mFontColor);
   }
   else
      GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColorNA );

   const char *text = mList[cell.y].text;
   for(U32 index = 0; index < mColumnOffsets.size(); index++)
   {
      const char *nextCol = dStrchr(text, '\t');
      if(mColumnOffsets[index] >= 0)
      {
         dsize_t slen;
         if(nextCol)
            slen = nextCol - text;
         else
            slen = dStrlen(text);

         Point2I pos(offset.x + 4 + mColumnOffsets[index], offset.y);

         RectI saveClipRect;
         bool clipped = false;

         if(mClipColumnText && (index != (mColumnOffsets.size() - 1)))
         {
            saveClipRect = GFX->getClipRect();

            RectI clipRect(pos, Point2I(mColumnOffsets[index+1] - mColumnOffsets[index] - 4, mCellSize.y));
            if(clipRect.intersect(saveClipRect))
            {
               clipped = true;
               GFX->setClipRect( clipRect );
            }
         }

         GFX->getDrawUtil()->drawTextN(mFont, pos, text, slen, mProfile->mFontColors);

         if(clipped)
            GFX->setClipRect( saveClipRect );
      }
      if(!nextCol)
         break;
      text = nextCol+1;
   }
}
示例#8
0
void CMatCanvas::Refresh()
{
	CRect wsize;
	GetWindowRect(wsize);
	Point2I zero(0,0);
	Point2I stretch(wsize.Width(),wsize.Height());
    
    m_renderContext->lock();
    m_renderContext->getSurface()->clear(0);
    m_renderContext->getSurface()->draw3DBegin();

	if (!m_pMaterial)
		m_pSurface->drawRect2d_f(&RectI(zero,stretch),0);
	else
      switch ((m_pMaterial->fParams.fFlags & TSMaterial::MatFlags)) {
			case TSMaterial::MatNull:
				m_pSurface->drawRect2d_f(&RectI(zero,stretch),0);
				break;

			case TSMaterial::MatRGB:
			case TSMaterial::MatPalette:
				m_pSurface->drawRect2d_f(&RectI(zero,stretch),
					m_pMaterial->fParams.fIndex);
				break;

			case TSMaterial::MatTexture:
              {
				if (m_pMaterial->getTextureMap() != 0)
                {
                  if (stretchit)
                  {
                    m_renderContext->getSurface()->drawBitmap2d(m_pMaterial->getTextureMap(), &zero, &stretch);
                  } else {
                    m_renderContext->getSurface()->drawBitmap2d(m_pMaterial->getTextureMap(), &zero);
                  }
				}
				break;
			}
		}
    m_renderContext->getSurface()->update();
    m_renderContext->getSurface()->draw3DEnd();
    m_renderContext->unlock();
}
示例#9
0
static void CalcCloseButtonPos(LabelWithCloseWnd *w, int dx, int dy) {
    int btnDx = DpiScaleX(w->hwnd, CLOSE_BTN_DX);
    int btnDy = DpiScaleY(w->hwnd, CLOSE_BTN_DY);
    int x = dx - btnDx - DpiScaleX(w->hwnd, w->padX);
    int y = 0;
    if (dy > btnDy) {
        y = (dy - btnDy) / 2;
    }
    w->closeBtnPos = RectI(x, y, btnDx, btnDy);
}
示例#10
0
//--------------------------------------------------------------------------
void GuiColorPickerCtrl::setSelectorPos(const Point2I &pos)
{
   Point2I extent = getExtent();
   RectI rect;
   if (mDisplayMode != pDropperBackground) 
   {
      extent.x -= 3;
      extent.y -= 2;
      rect = RectI(Point2I(1,1), extent);
   }
   else
   {
      rect = RectI(Point2I(0,0), extent);
   }
   
   if (rect.pointInRect(pos)) 
   {
      mSelectorPos = pos;
      mPositionChanged = true;
      // We now need to update
      setUpdate();
   }

   else
   {
      if ((pos.x > rect.point.x) && (pos.x < (rect.point.x + rect.extent.x)))
         mSelectorPos.x = pos.x;
      else if (pos.x <= rect.point.x)
         mSelectorPos.x = rect.point.x;
      else if (pos.x >= (rect.point.x + rect.extent.x))
         mSelectorPos.x = rect.point.x + rect.extent.x - 1;

      if ((pos.y > rect.point.y) && (pos.y < (rect.point.y + rect.extent.y)))
         mSelectorPos.y = pos.y;
      else if (pos.y <= rect.point.y)
         mSelectorPos.y = rect.point.y;
      else if (pos.y >= (rect.point.y + rect.extent.y))
         mSelectorPos.y = rect.point.y + rect.extent.y - 1;

      mPositionChanged = true;
      setUpdate();
   }
}
示例#11
0
RectI GuiControlProfile::getBitmapArrayRect(U32 i)
{
   if(!mBitmapArrayRects.size())
      constructBitmapArray();
   
   if( i >= mBitmapArrayRects.size())
      return RectI(0,0,0,0);

   return mBitmapArrayRects[i];
}
示例#12
0
bool GuiInspectorMountingGroup::createContent()
{
   if(!Parent::createContent())
      return false;

   //give the necessary padding for the nested controls so it looks nice.
   setMargin(RectI(4,0,4,4));

   return true;
}
示例#13
0
static void CalcCloseButtonPos(LabelWithCloseWnd *w, int dx, int dy)
{
    int btnDx = win::DpiAdjust(w->hwnd, CLOSE_BTN_DX);
    int btnDy = win::DpiAdjust(w->hwnd, CLOSE_BTN_DY);
    int x = dx - btnDx - win::DpiAdjust(w->hwnd, w->padR);
    int y = 0;
    if (dy > btnDy) {
        y  = (dy - btnDy) / 2;
    }
    w->closeBtnPos = RectI(x, y, btnDx, btnDy);
}
示例#14
0
void TransformTool::dglRenderTool()
{
   if (!mActive)
      return;

   if (mBoxSelection)
   {
      Torque::Graphics.dglDrawRectFill(mMouseDownPosition, mMousePosition, ColorI(255, 255, 255, 64));
      Torque::Graphics.dglDrawRect(RectI(mMouseDownPosition, mMousePosition - mMouseDownPosition), ColorI(255, 255, 255, 255), 2.0f);
   }
}
示例#15
0
Game::Game( HWND hWnd,KeyboardServer& kServer,const MouseServer& mServer )
:	gfx( hWnd ),
	//audio( hWnd ),
	kbd( kServer ),
	mouse( mServer ),
    t(testMap, MAPWIDTH, MAPHEIGHT, TILESIZE, TILESIZE),
    controller(p,kbd),
    port(gfx,RectI(10,590,10,790)),
    cam(port, t.GetBoundaries())
{
    srand( (unsigned int)time( NULL ) );
}
bool RenderTexTargetBinManager::setTargetSize(const Point2I &newTargetSize)
{
   if( GFX->getAdapterType() != OpenGL && // Targets need to match up exactly in size on OpenGL.
       mTargetSize.x >= newTargetSize.x &&
       mTargetSize.y >= newTargetSize.y )
      return true;

   mTargetSize = newTargetSize;
   mNamedTarget.setViewport( RectI( Point2I::Zero, mTargetSize ) );

   return _updateTargets();
}
void Canvas2DBuffer::clear()
{
    HE_ASSERT(m_GlContext == GL::s_CurrentContext, "Access Violation: wrong context is bound!");

    GL::heSetViewport(RectI(0, 0, static_cast<int>(m_Size.x), static_cast<int>(m_Size.y)));
    GL::heBindFbo(m_FrameBufferId);
    GLenum buffers[1] = { GL_COLOR_ATTACHMENT0 };
    glDrawBuffers(1, buffers);
    GL::heClearColor(Color(0.0f, 0.0f, 0.0f, 0.0f));
    GL::heSetDepthWrite(false);
    glClear(GL_COLOR_BUFFER_BIT);
}
void FGIRCActiveTextFormat::onRender(GFXSurface *sfc, Point2I offset, const Box2I &)
{
   GFXFont *font;

   if (mOrgTextPtr)
   {
      if (stateOver && szAction[0] != '\0')
      {
         sfc->drawRect2d(&RectI(offset.x, offset.y + 1, 
            offset.x + extent.x - 10, offset.y + extent.y - 1), 255);
      }

      offset.x += 4;
      offset.y -= 2;
      
      // Use a local buffer
      char *localBuffer = strnew(mOrgTextPtr);

      Vector<msgFormat>::iterator i;
      for (i = msgLines.begin(); i != msgLines.end(); i++)
      {
         font = fontArray[i->fontType].font;

         AssertFatal(font, "what happened to the font?");
      
         // Find out where to draw the text;
         Point2I textOffset = offset + i->offset;
      
         // Draw the text
         char *textPtr = localBuffer + i->startChar;
         if (i->length > 0)
         {
            char temp = textPtr[i->length];
            textPtr[i->length] = '\0';
         
            sfc->drawText_p(font, &textOffset, textPtr);
         
            textPtr[i->length] = temp;
         }
      }
   
      // Delete the local buffer
      delete [] localBuffer;
   
      // Now draw all the bitmaps
      for (int j = 0; j < mBitmapCount; j++)
      {
         Point2I bmpOffset = offset + mBitmaps[j].offset;
         sfc->drawBitmap2d(mBitmaps[j].bmp, &bmpOffset);
      }
   }
}
示例#19
0
bool GuiGradientCtrl::onAdd()
{
	Parent::onAdd();

   RectI bounds = getBounds();
   S32 l = bounds.point.x + mSwatchFactor, r = bounds.point.x + bounds.extent.x - mSwatchFactor;
   S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - mSwatchFactor;
	mBlendRangeBox = RectI( Point2I(l, t), Point2I(r, b) );
	
	setupDefaultRange();
	reInitSwatches( mDisplayMode );
	return true;
}
示例#20
0
static RectI ExtractDSCPageSize(const WCHAR *fileName)
{
    char header[1024] = { 0 };
    file::ReadN(fileName, header, sizeof(header) - 1);
    if (!str::StartsWith(header, "%!PS-Adobe-"))
        return RectI();

    // PostScript creators are supposed to set the page size
    // e.g. through a setpagedevice call in PostScript code,
    // some creators however fail to do so and only indicate
    // the page size in a DSC BoundingBox comment.
    char *nl = header;
    geomutil::RectT<float> bbox;
    while ((nl = strchr(nl + 1, '\n')) != NULL && '%' == nl[1]) {
        if (str::StartsWith(nl + 1, "%%BoundingBox:") &&
            str::Parse(nl + 1, "%%%%BoundingBox: 0 0 %f %f% ", &bbox.dx, &bbox.dy)) {
            return bbox.ToInt();
        }
    }

    return RectI();
}
void ServerInfoCtrl::onRenderCell(GFXSurface *sfc, Point2I offset, Point2I cell, bool, bool)
{
   //make sure we have a server
   if (! mServer) return;
   
   char *s = &(mServer->mInfoList[cell.y].buf[0]);
   
   //find out which tab stops array to use
   int *tabStops;
   if (*s == '0') tabStops = &teamTabStops[0];
   else tabStops = &playerTabStops[0];
   s++;
   
   //find out whether we skip the count after the tab or not
   bool tabSkipOne;
   if (*s == '0') tabSkipOne = FALSE;
   else tabSkipOne = TRUE; 
   s++;
   
   int stop = 0;
   while (1)
   {
      char buft[256];
      int i = 0;
      while(*s && *s != '\t')
         buft[i++] = *s++;
      buft[i] = 0;
      if(i)
      {
         RectI cr = *sfc->getClipRect();
         sfc->setClipRect(
            &RectI(max(offset.x + tabStops[stop], cr.upperL.x),
                   max(offset.y, cr.upperL.y),
                   min(offset.x + tabStops[stop+1] - 2, cr.lowerR.x),
                   min(offset.y + 2 * hFont->getHeight(), cr.lowerR.y) ) );

         sfc->drawText_p((tabSkipOne ? hFont : hFontHL), &Point2I(offset.x + tabStops[stop] + 4, offset.y - 2), buft);
         sfc->setClipRect(&cr);
      }
      if(*s == '\t' && *(s+1) && tabSkipOne)
         s += 2;
      else if(*s == '\t')
         s++;

      if(!*s)
         break;
      stop++;
   }
}
示例#22
0
void
HistogramCPU::quitAnyComputation()
{
    if ( isRunning() ) {
        QMutexLocker l(&_imp->mustQuitMutex);
        _imp->mustQuit = true;

        ///post a fake request to wakeup the thread
        l.unlock();
        computeHistogram(0, boost::shared_ptr<Natron::Image>(), RectI(), 0,0,0,0);
        l.relock();
        while (_imp->mustQuit) {
            _imp->mustQuitCond.wait(&_imp->mustQuitMutex);
        }
    }
}
示例#23
0
void EnsureAreaVisibility(RectI& r)
{
    // adjust to the work-area of the current monitor (not necessarily the primary one)
    RectI work = GetWorkAreaRect(r);

    // make sure that the window is neither too small nor bigger than the monitor
    if (r.dx < MIN_WIN_DX || r.dx > work.dx)
        r.dx = (int)min(work.dy * DEF_PAGE_RATIO, work.dx);
    if (r.dy < MIN_WIN_DY || r.dy > work.dy)
        r.dy = work.dy;

    // check whether the lower half of the window's title bar is
    // inside a visible working area
    int captionDy = GetSystemMetrics(SM_CYCAPTION);
    RectI halfCaption(r.x, r.y + captionDy / 2, r.dx, captionDy / 2);
    if (halfCaption.Intersect(work).IsEmpty())
        r = RectI(work.TL(), r.Size());
}
示例#24
0
	void CurvePreview::Redraw()
	{
		if (!mCurve)
			return;

		TextureRef texture = mSprite->GetTexture();
		if (!texture || texture->GetSize() != layout->GetSize())
		{
			texture = TextureRef(layout->GetSize(), PixelFormat::R8G8B8A8, Texture::Usage::RenderTarget);
			mSprite->SetTexture(texture);
			mSprite->SetTextureSrcRect(RectI(Vec2I(), texture->GetSize()));
		}

		const Color4 backColor(120, 120, 120, 255);
		const Color4 curveColor(0, 255, 0, 255);

		Camera prevCamera = o2Render.GetCamera();
		Camera currCamera; currCamera.SetRect(mCurve->GetRect());
		currCamera.SetScale(currCamera.GetScale().InvertedY());

		o2Render.SetRenderTexture(texture);
		o2Render.SetCamera(currCamera);
		o2Render.Clear(backColor);

		static Vector<Vertex2> buffer;
		buffer.Clear();

		auto curveColorHex = curveColor.ARGB();

		auto& keys = mCurve->GetKeys();
		for (auto& key : keys)
		{
			buffer.Add(Vertex2(key.position, key.value, curveColorHex, 0, 0));

			auto points = key.GetApproximatedPoints();
			for (int i = 0; i < key.GetApproximatedPointsCount(); i++)
				buffer.Add(Vertex2(points[i], curveColorHex, 0, 0));

			o2Render.DrawAAPolyLine(buffer.Data(), buffer.Count(), 2);
		}

		o2Render.UnbindRenderTexture();
		o2Render.SetCamera(prevCamera);
	}
void ShapeView::onWake()
{
   float width, height;

   if (camera)
   {
      // Set up the viewport
      width  = DEFAULT_NEAR_PLANE * tan(DEFAULT_FOV);
      height = (float)extent.y / (float)extent.x * width;

      camera->setWorldViewport(
         RectF(-width, height, width, -height));
      camera->setNearDist(DEFAULT_NEAR_PLANE);
      camera->setFarDist (getFarPlane());
      camera->setScreenViewport(
         RectI(position.x, position.y, 
               position.x + extent.x, position.y + extent.y));

      // Load the shape
      loadShape(gDefaultShapeFile);

      timer.reset();
   }
}
示例#26
0
static void draw_title()
{
	// background is dk grey, not pure black
	ClearScreen(0x20, 0x20, 0x20);
	
	// top logo
	int tx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_TITLE].w / 2) - 2;
	draw_sprite(tx, 40, SPR_TITLE);
	
	// draw menu
	int cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8;
	int cy = (Graphics::SCREEN_HEIGHT / 2) - 8;
	for(int i=0;i<sprites[SPR_MENU].nframes;i++)
	{
		draw_sprite(cx, cy, SPR_MENU, i);
		if (i == title.cursel)
		{
			draw_sprite(cx - 16, cy - 1, title.sprite, title.selframe);
		}
		
        //RectI r = Sprites::get_sprite_rect(cx, cy, SPR_MENU, i);
        //Graphics::DrawRect(r.x, r.y, r.x + r.w, r.y + r.h, 255,255,255);
        
		cy += (sprites[SPR_MENU].h + 18);
	}
	
	// animate character
	if (++title.seltimer > 8)
	{
		title.seltimer = 0;
		if (++title.selframe >= sprites[title.sprite].nframes)
			title.selframe = 0;
	}
	
	// accreditation
	cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_PIXEL_FOREVER].w / 2);
	int acc_y = Graphics::SCREEN_HEIGHT - 48;
	draw_sprite(cx, acc_y, SPR_PIXEL_FOREVER);
	
	// version
	static const char *VERSION = "NXEngine v. 1.0.0.4";
	static const int SPACING = 5;
	int wd = GetFontWidth(VERSION, SPACING);
	cx = (Graphics::SCREEN_WIDTH / 2) - (wd / 2);
	font_draw(cx, acc_y + sprites[SPR_PIXEL_FOREVER].h + 4, VERSION, SPACING);
	
	// draw Nikumaru display
	if (title.besttime != 0xffffffff)
		niku_draw(title.besttime, true);
    
    // options
    {
        const char *str = "F3:Options";
        cx = (Graphics::SCREEN_WIDTH / 2) - (GetFontWidth(str, 0) / 2) - 4;
        cy = (Graphics::SCREEN_HEIGHT - 8) - GetFontHeight();
        int f3wd = font_draw(cx, cy, "F3", 0);
        font_draw(cx + f3wd, cy, ":Options", 0, &bluefont);
        
#ifdef CONFIG_USE_TAPS
        RectI r = RectI(cx, cy, GetFontWidth(str, 0), GetFontHeight());
        debug_absbox(r.x, r.y, r.x + r.w, r.y + r.h, 255, 255, 255);
        if (VJoy::ModeAware::wasTap(r))
        {
            game.pause(GP_OPTIONS);
        }
#endif
        
    }
}
示例#27
0
bool ClipMap::fillWithTextureData()
{
   PROFILE_SCOPE(ClipMap_fillWithTextureData);

   mForceClipmapPurge = false;
   // Note our interest for the cache.
   {
      // Calculate the new texel at most detailed level.
      Point2F texelCenterF = mLevels[0].mClipCenter * F32(mClipMapSize) * mLevels[0].mScale;
      Point2I texelCenter((S32)mFloor(texelCenterF.y), (S32)mFloor(texelCenterF.x));

      // Update interest region.
      mImageCache->setInterestCenter(texelCenter);
   }

   // First generate our desired rects for each level.
   FrameTemp< RectI > desiredData( mClipStackDepth );
   for(S32 i=0; i<mClipStackDepth; i++)
   {
      ClipStackEntry &cse = mLevels[i];

      // Calculate new center point for this texture.
      Point2F texelCenterF = cse.mClipCenter * F32(mClipMapSize) * cse.mScale;

      const S32 texelMin = mClipMapSize/2;
      //const S32 texelMax = S32(F32(mClipMapSize) * cse.mScale) - texelMin;

      Point2I texelTopLeft;

      //if(mTile)
      //{
         texelTopLeft.x = S32(mFloor(texelCenterF.y)) - texelMin;
         texelTopLeft.y = S32(mFloor(texelCenterF.x)) - texelMin;
      //}
      //else
      //{
      //   texelTopLeft.x = mClamp(S32(mFloor(texelCenterF.y)), texelMin, texelMax) - texelMin;
      //   texelTopLeft.y = mClamp(S32(mFloor(texelCenterF.x)), texelMin, texelMax) - texelMin;
      //}

      desiredData[i] = RectI(texelTopLeft, Point2I(mClipMapSize, mClipMapSize));

      // Make sure we have available data...
      if(!mImageCache->isDataAvailable(getMipLevel(cse.mScale), desiredData[i]))
         return false;
   }

   // Upload all the textures...
   for(S32 i=0; i<mClipStackDepth; i++)
   {
      ClipStackEntry &cse = mLevels[i];

      RectI buffer[8];
      S32   rectCount = 0;

      clipAgainstGrid(mClipMapSize, desiredData[i], &rectCount, buffer);
      AssertFatal(rectCount < 8, "ClipMap::fillWithTextureData - got too many rects back!");

      if(rectCount)
      {
         if (!mImageCache->beginRectUpdates(cse))
         {
            mForceClipmapPurge = true;
            return false;
         }

         for(S32 j=0; j<rectCount; j++)
         {
            RectI srcRegion = buffer[j];
            buffer[j].point.x = srcRegion.point.x % mClipMapSize;
            buffer[j].point.y = srcRegion.point.y % mClipMapSize;

            mImageCache->doRectUpdate(getMipLevel(cse.mScale), cse, srcRegion, buffer[j]);
         }

         mImageCache->finishRectUpdates(cse);
      }

      cse.mToroidalOffset  = desiredData[i].point;
   }
   
   GRAPHIC->disableShaders();

   // Success!
   return true;
}
const char *SimTreePlugin::consoleCallback(CMDConsole*,int id,int argc,const char *argv[])
{
   switch( id )
   {
      case SimTreeCreate:
         if ( argc==3 || argc==4 )
         {
            SimCanvas *sc = dynamic_cast<SimCanvas*>(manager->findObject(argv[2]));
            if (!sc)
            {
               console->printf("simTreeCreate: can't find parent");
               return 0;
            }
            GWWindow *parent = sc;

            SimTreeView *stv = new SimTreeView();
            if ( stv )
            {
					if ( argc==4 )
					{
   					if (!stricmp(argv[3],"server"))
   						stv->targetManager = SimGame::get()->getManager(SimGame::SERVER);
   					else
   						stv->targetManager = SimGame::get()->getManager(SimGame::CLIENT);
					}
               else
   					stv->targetManager = manager;

				   manager->addObject(stv);
					manager->assignName(stv,argv[1]);
               stv->createWin( parent, argv[1], RectI(0,0,300,400) );

               console->evaluate( avar("simTreeRegBitmaps( %s, \"Node.bmp\", \"NodeOpen.bmp\");",argv[1]), false );
               console->evaluate( avar("simTreeRegBitmaps( %s, \"FolderClosed.bmp\", \"FolderOpen.bmp\");",argv[1]), false );
               console->evaluate( avar("simTreeRegBitmaps( %s, \"SetClosed.bmp\", \"SetOpen.bmp\");",argv[1]), false );
               console->evaluate( avar("simTreeRegBitmaps( %s, \"DropPt.bmp\", \"DropPtOpen.bmp\");",argv[1]), false );
               console->evaluate( avar("simTreeRegClass( %s, SimSet,   4, 5);",argv[1]), false );
               console->evaluate( avar("simTreeRegClass( %s, SimGroup, 2, 3);",argv[1]), false );
               console->evaluate( avar("simTreeRegClass( %s, Locked,   6, 7);",argv[1]), false );
            }
         }
         else
            console->printf( "simTreeCreate: TreeName parentWindowName [Server|Client]" );
         break;

      case SimTreeAddSet:
         if ( argc>=3 )
         {
            if ( SimObject* obj = manager->findObject(argv[1]) )
            {
               SimTreeView *stv=dynamic_cast<SimTreeView*>(obj);
               SimSet *set;
               for ( int i=2; i<argc; i++ )
               {
                  if ((obj = stv->targetManager->findObject(argv[i])) != NULL)
                  {
                     set = dynamic_cast<SimSet*>(obj);
                     stv->addSet( set );
                  }
                  else if ( !strcmpi(argv[i],"manager") )
                     stv->addSet( stv->targetManager );
                  else
                  {
                     console->printf( "simTreeAddSet: can't find SimSet" );
                     return 0;
                  }
               }
            }
         }
         else
            console->printf( "simTreeAddSet: TreeName TargetSimSet [TargetSimSet...]" );
         break;

      case SimTreeRegBitmaps:
         if ( argc>2 )
         {
            if ( SimObject* obj = manager->findObject(argv[1]) )
            {
               SimTreeView *stv=dynamic_cast<SimTreeView*>(obj);
               Resource<GFXPalette> pal = SimGame::get()->getWorld(SimGame::CLIENT)->getPalette();
               for ( int i=2; i<argc; i++ )
               {
                  Resource<GFXBitmap> bitmap;
         	      bitmap = SimResource::get(manager)->load(argv[i]);
                  if ( (bool)bitmap )
                     stv->registerBitmap( bitmap, pal );
                  else
                     console->printf( avar("simTreeRegBitmaps: bitmap not found %s",argv[i]) );
               }
            }
         }
         else
            console->printf( "simTreeRegBitmaps: TreeName bitmap1.bmp [bitmapn.bmp] ..." );
         break;

      case SimTreeRegClass:
         if ( argc == 5 )
         {
            if ( SimObject* obj = manager->findObject(argv[1]) )
            {
               SimTreeView *stv=dynamic_cast<SimTreeView*>(obj);
               if ( stv )
                  stv->registerClass( argv[2], atoi(argv[3]), atoi(argv[4]) );
            }
         }
         break;

      case SimTreeRegScript:
         if ( argc > 1 )
         {
            if ( SimObject* obj = manager->findObject(argv[1]) )
            {
               SimTreeView *stv=dynamic_cast<SimTreeView*>(obj);
               stv->registerScript( argv[2], argv[3] );
            }
         }
         else
         {
            console->printf( "simTreeRegScript: TreeName menuText scriptName" );
            console->printf( "simTreeRegScript: TreeName seperator" );
         }
         break;

   }
   return 0;
}
示例#29
0
 void UpdateGripperRect() {
     int width = GetSystemMetrics(SM_CXVSCROLL);
     int height = GetSystemMetrics(SM_CYHSCROLL);
     rcGrip = RectI(sizeClient.dx - width, sizeClient.dy - height, width, height);
 }
void GuiGameListMenuCtrl::onRender(Point2I offset, const RectI &updateRect)
{
   GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;

   F32 xScale = (float) getWidth() / profile->getRowWidth();

   bool profileHasIcons = profile->hasArrows();

   S32 rowHeight = profile->getRowHeight();

   Point2I currentOffset = offset;
   Point2I extent = getExtent();
   Point2I rowExtent(extent.x, rowHeight);
   Point2I textOffset(profile->mTextOffset.x * xScale, profile->mTextOffset.y);
   Point2I textExtent(extent.x - textOffset.x, rowHeight);
   Point2I iconExtent, iconOffset(0.0f, 0.0f);
   if (profileHasIcons)
   {
      iconExtent = profile->getIconExtent();

      // icon is centered vertically plus any specified offset
      S32 iconOffsetY = (rowHeight - iconExtent.y) >> 1;
      iconOffsetY += profile->mIconOffset.y;
      iconOffset = Point2I(profile->mIconOffset.x * xScale, iconOffsetY);
   }
   for (Vector<Row *>::iterator row = mRows.begin(); row < mRows.end(); ++row)
   {
      if (row != mRows.begin())
      {
         // rows other than the first can have padding above them
         currentOffset.y += (*row)->mHeightPad;
         currentOffset.y += rowHeight;
      }

      // select appropriate colors and textures
      ColorI fontColor;
      U32 buttonTextureIndex;
      S32 iconIndex = (*row)->mIconIndex;
      bool useHighlightIcon = (*row)->mUseHighlightIcon;
      if (! (*row)->mEnabled)
      {
         buttonTextureIndex = Profile::TEX_DISABLED;
         fontColor = profile->mFontColorNA;
      }
      else if (row == &mRows[mSelected])
      {
         if (iconIndex != NO_ICON)
         {
            iconIndex++;
         }
         buttonTextureIndex = Profile::TEX_SELECTED;
         fontColor = profile->mFontColorSEL;
      }
      else if ((mHighlighted != NO_ROW) && (row == &mRows[mHighlighted]))
      {
         if (iconIndex != NO_ICON && useHighlightIcon)
         {
            iconIndex++;
         }
         buttonTextureIndex = Profile::TEX_HIGHLIGHT;
         fontColor = profile->mFontColorHL;
      }
      else
      {
         buttonTextureIndex = Profile::TEX_NORMAL;
         fontColor = profile->mFontColor;
      }

      // render the row bitmap
      GFX->getDrawUtil()->clearBitmapModulation();
      GFX->getDrawUtil()->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset, rowExtent), profile->getBitmapArrayRect(buttonTextureIndex));

      // render the row icon if it has one
      if ((iconIndex != NO_ICON) && profileHasIcons && (! profile->getBitmapArrayRect((U32)iconIndex).extent.isZero()))
      {
         iconIndex += Profile::TEX_FIRST_ICON;
         GFX->getDrawUtil()->clearBitmapModulation();
         GFX->getDrawUtil()->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset + iconOffset, iconExtent), profile->getBitmapArrayRect(iconIndex));
      }

      // render the row text
      GFX->getDrawUtil()->setBitmapModulation(fontColor);
      renderJustifiedText(currentOffset + textOffset, textExtent, (*row)->mLabel);
   }

   if (mDebugRender)
   {
      onDebugRender(offset);
   }

   renderChildControls(offset, updateRect);
}