/** * Update slot items based on tcStores state */ void tcStoresGui::UpdateGui() { tcStores* stores = GetStores(); if (stores == 0) return; // mark all slots not updated for (size_t n=0; n<slots.size(); n++) { slots[n].SetUpdated(false); } std::string s; size_t nTypes = stores->GetNumberItemTypes(); for (size_t n=0; (n<nTypes)&&(n<slots.size()); n++) { tcContainerSlot& slot = slots[n]; const tcStores::StoreItemInfo& itemInfo = stores->GetItemInfo(n); const std::string& itemName = itemInfo.className; unsigned int itemQuantity = itemInfo.quantity; unsigned int itemId = itemInfo.id; AddOrUpdateItem(slot, itemName, itemQuantity, false, itemId, stores); slot.SetUpdated(true); } // add items that are on-the-move const std::vector<tcStores::StoreItemInfo>& moveSummary = stores->GetMoveSummary(); size_t nMoves = moveSummary.size(); for (size_t n=0; (n<nMoves)&&((n+nTypes)<slots.size()); n++) { tcContainerSlot& slot = slots[n+nTypes]; const std::string& itemName = moveSummary[n].className; unsigned long itemQuantity = moveSummary[n].quantity; AddOrUpdateItem(slot, itemName, itemQuantity, true, moveSummary[n].id, stores); slot.SetUpdated(true); } // delete items that were not updated for (size_t n=0; n<slots.size(); n++) { if (!slots[n].IsUpdated()) { slots[n].ClearItem(); } } nPages = ((slotsPerPage - 1 + stores->GetNumberItemTypes()) / slotsPerPage); size_t maxPages = (maxSlots - 1 + slotsPerPage) / slotsPerPage; if (nPages > maxPages) nPages = maxPages; // update page boxes pageBoxes.clear(); if (nPages > 1) // don't bother showing icon for single page { float xPageBox = float(mnWidth) - 10.0f; float yPageBox = 30.0f; float wPageBox = 7.0f; for (size_t n=0; n<nPages; n++) { // float yOffset = float(n)*wPageBox; pageBoxes.push_back(tcRect(xPageBox, xPageBox + wPageBox, yPageBox, yPageBox + wPageBox)); yPageBox += wPageBox + 2.0f; } } }
void CGVEditTail::OnDraw( DrawStruct *DrawStc ) { char tOut[2]; CBrush tBrush; tOut[1] = 0; CGenedocDoc *pDoc = ((CGenedocView *)DrawStc->pView)->GetDocument(); if ( DrawStc->pDC->IsPrinting() ) { if ( pDoc->m_UserVars.m_PrintShading ) return; DrawStc->pDC->SetBkMode ( TRANSPARENT ); } POSITION tPos = ViewDataList.GetHeadPosition(); DWORD CurrentDisplayLoc = m_YPosition; while ( tPos != NULL ) { CString * tGStr = (CString *)ViewDataList.GetNext(tPos); if ( (CurrentDisplayLoc + m_LineHeight) > DrawStc->ReDrawTop // && CurrentDisplayLoc <= DrawStc->ReDrawBottom && CurrentDisplayLoc < DrawStc->ReDrawBottom ) { int cCount = tGStr->GetLength(); for ( int tCount = 0; tCount < cCount; tCount++ ) { UINT tXLoc1 = tCount*m_CharWidth + m_CharWidth + m_XPosition; UINT tXLoc2 = tCount*m_CharWidth + m_XPosition; if ( tXLoc1 > DrawStc->ReDrawLeft && tXLoc2 <= DrawStc->ReDrawRight ) { COLORREF TextColor, BkColor; pDoc->GetLevelColors(&pDoc->m_UserVars.m_Vars, 0, &TextColor, &BkColor ); CRect tcRect( tXLoc2 - DrawStc->DisplayXPosition, (int)(CurrentDisplayLoc - DrawStc->DisplayYPosition) + DrawStc->PrintYOffset, tXLoc1 - DrawStc->DisplayXPosition, (int)(CurrentDisplayLoc + m_LineHeight - DrawStc->DisplayYPosition) + DrawStc->PrintYOffset ); if ( DrawStc->pDC->IsPrinting() ) { tBrush.CreateSolidBrush( BkColor ); DrawStc->pDC->FillRect ( tcRect, &tBrush ); tBrush.DeleteObject(); } DrawStc->pDC->SetBkColor( BkColor ); tOut[0] = (*tGStr)[tCount]; DrawStc->pDC->SetTextColor( TextColor ); if ( DrawStc->pDC->IsPrinting() ) { DrawStc->pDC->TextOut( tXLoc2 - DrawStc->DisplayXPosition, (int)(CurrentDisplayLoc - DrawStc->DisplayYPosition) + DrawStc->PrintYOffset, tOut, 1 ); } else { DrawStc->pDC->ExtTextOut( tXLoc2 - DrawStc->DisplayXPosition, (int)(CurrentDisplayLoc - DrawStc->DisplayYPosition) + DrawStc->PrintYOffset, ETO_OPAQUE, tcRect, tOut, 1 , (int *)(&m_CharWidth) ); } // DrawStc->pDC->DrawText( tOut, 1, tcRect, // DT_CENTER | DT_NOCLIP | DT_SINGLELINE | DT_NOPREFIX // ); } } } CurrentDisplayLoc += m_LineHeight; } /* if ( !DrawStc->pDC->IsPrinting() ) { if ( Selected ) { DrawStc->pDC->InvertRect( ViewRect); } } */ }
// |aTexCoordRect| is the rectangle from the texture that we want to // draw using the given program. The program already has a necessary // offset and scale, so the geometry that needs to be drawn is a unit // square from 0,0 to 1,1. // // |aTexSize| is the actual size of the texture, as it can be larger // than the rectangle given by |aTexCoordRect|. void CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg, const Rect& aTexCoordRect, TextureSource *aTexture) { NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized"); GLuint vertAttribIndex = aProg->AttribLocation(ShaderProgramOGL::VertexCoordAttrib); GLuint texCoordAttribIndex = aProg->AttribLocation(ShaderProgramOGL::TexCoordAttrib); NS_ASSERTION(texCoordAttribIndex != GLuint(-1), "no texture coords?"); // Given what we know about these textures and coordinates, we can // compute fmod(t, 1.0f) to get the same texture coordinate out. If // the texCoordRect dimension is < 0 or > width/height, then we have // wraparound that we need to deal with by drawing multiple quads, // because we can't rely on full non-power-of-two texture support // (which is required for the REPEAT wrap mode). GLContext::RectTriangles rects; GLenum wrapMode = aTexture->AsSourceOGL()->GetWrapMode(); IntSize realTexSize = aTexture->GetSize(); if (!mGLContext->CanUploadNonPowerOfTwo()) { realTexSize = IntSize(NextPowerOfTwo(realTexSize.width), NextPowerOfTwo(realTexSize.height)); } // We need to convert back to actual texels here to get proper behaviour with // our GL helper functions. Should fix this sometime. // I want to vomit. IntRect texCoordRect = IntRect(NS_roundf(aTexCoordRect.x * aTexture->GetSize().width), NS_roundf(aTexCoordRect.y * aTexture->GetSize().height), NS_roundf(aTexCoordRect.width * aTexture->GetSize().width), NS_roundf(aTexCoordRect.height * aTexture->GetSize().height)); // This is fairly disgusting - if the texture should be flipped it will have a // negative height, in which case we un-invert the texture coords and pass the // flipped 'flag' to the functions below. We can't just use the inverted coords // because our GL funtions use an explicit flag. bool flipped = false; if (texCoordRect.height < 0) { flipped = true; texCoordRect.y = texCoordRect.YMost(); texCoordRect.height = -texCoordRect.height; } if (wrapMode == LOCAL_GL_REPEAT) { rects.addRect(/* dest rectangle */ 0.0f, 0.0f, 1.0f, 1.0f, /* tex coords */ texCoordRect.x / GLfloat(realTexSize.width), texCoordRect.y / GLfloat(realTexSize.height), texCoordRect.XMost() / GLfloat(realTexSize.width), texCoordRect.YMost() / GLfloat(realTexSize.height), flipped); } else { nsIntRect tcRect(texCoordRect.x, texCoordRect.y, texCoordRect.width, texCoordRect.height); GLContext::DecomposeIntoNoRepeatTriangles(tcRect, nsIntSize(realTexSize.width, realTexSize.height), rects, flipped); } DrawWithVertexBuffer2(mGLContext, mVBOs, LOCAL_GL_TRIANGLES, rects.elements(), vertAttribIndex, rects.vertexPointer(), texCoordAttribIndex, rects.texCoordPointer()); }