vector<pair<int,int>> ERModel::loadPosition() { vector<pair<int,int>> positionSet; vector<string> posFileSplitedSet; vector<string> componentPositionSet; string posFileName = removeExtension(_fileName) + TEXT_EXTENSION_POS; ifstream inputPositionFile; inputPositionFile.open(posFileName); if (!inputPositionFile.is_open()) return positionSet; // 取得輸入檔案的所有字元 string posText((istreambuf_iterator<char>(inputPositionFile)),istreambuf_iterator<char>()); inputPositionFile.close(); // 將每一筆的Sx,Sy切出來變成vector<string>的一項是110 100 posFileSplitedSet = Toolkit::splitFunction(posText, TEXT_ENDLINE); // 最後一組是空的 for(int i = 0; i < posFileSplitedSet.size() - 1; i++) { componentPositionSet = Toolkit::splitFunction(posFileSplitedSet[i], SPACE); positionSet.push_back(make_pair(atoi(componentPositionSet[PARAMETER_POSITIONFILEX].c_str()), atoi(componentPositionSet[PARAMETER_POSITIONFILEY].c_str()))); } return positionSet; }
bool XmlStateTab::save(QDomElement& elParent) const { QDomDocument doc = elParent.ownerDocument(); QDomElement elChild = doc.createElement(QLatin1String("Sky:Tab")); elParent.appendChild(elChild); if (!saveIdentifier(elChild)) { return false; } const char* s = posText(mPositions); if (s) { elChild.appendChild(doc.createElement(QString::fromUtf8(s))); } return saveChildren(elChild); }
void Game::DrawTexts() { sf::Font& font = sResourceManager->GetFont("arial.ttf"); sf::Vector2f topLeft; topLeft.x = window.getView().getCenter().x - window.getSize().x / 2.f; topLeft.y = window.getView().getCenter().y - window.getSize().y / 2.f; if (State == GAME_STATE_LOADING_LEVEL) { sf::Text text("Loading Level", font); text.setColor(sf::Color::White); text.setPosition(window.getView().getCenter().x - 90.f, window.getView().getCenter().y - 35.f); text.setStyle(sf::Text::Style::Bold); window.draw(text); } // Draw debug information if (debugMode) { // Draw the FPS text on the screen sf::Text fpsText(std::to_string(fps) + " FPS", font); fpsText.setColor(sf::Color::Red); fpsText.setStyle(sf::Text::Style::Bold); fpsText.setPosition(topLeft); fpsText.setCharacterSize(12); window.draw(fpsText); if (State == GAME_STATE_PLAYING) { Player* plr = GetPlayer(0); sf::Text posText("X: " + std::to_string(plr->Position.x) + " Y: " + std::to_string(plr->Position.y), font); posText.setColor(sf::Color::Red); posText.setStyle(sf::Text::Style::Bold); posText.setPosition(topLeft.x, topLeft.y + window.getSize().y - 17.f); posText.setCharacterSize(12); window.draw(posText); } } }
void CSkinBtn::DrawButton() { CPoint posText(0,0); if(m_bRePain == FALSE) { CClientDC dc(this); CRect rect; GetClientRect(&rect); CDC memDC; memDC.CreateCompatibleDC(&dc); CBitmap Screen; Screen.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height()); memDC.SelectObject(&Screen); Screen.DeleteObject(); //画背景 memDC.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &m_memDC, 0, 0, SRCCOPY); CString str(_T("")); GetWindowText(str); memDC.SetBkMode(TRANSPARENT); memDC.SelectObject(m_pFont); CDC MemDC; MemDC.CreateCompatibleDC(&dc); BITMAP bm; if(m_IconDraw) { CRect rImage; rImage.top = 0; rImage.left = 0; BOOL bRetValue; ICONINFO ii; ::ZeroMemory(&ii, sizeof(ICONINFO)); bRetValue = ::GetIconInfo(m_IconIn, &ii); if (bRetValue == FALSE) { if (m_IconIn) ::DestroyIcon(m_IconIn); rImage.bottom = 16; rImage.right = 16; } else { rImage.right = (DWORD)(ii.xHotspot * 2); rImage.bottom = (DWORD)(ii.yHotspot * 2); } ::DeleteObject(ii.hbmMask); ::DeleteObject(ii.hbmColor); //int nXOffset = (rect.Width() - rImage.right)/2; int nYOffset = (rect.Height() - rImage.bottom)/2;//rect.Width(), rect.Height() if(nYOffset < 0) nYOffset = 0; rImage.top += nYOffset; posText.x = rImage.right + 2; posText.y = (rect.Height() - 20)/2; if(posText.y < 0) posText.y = 0; switch(m_state) { case NORMAL: // Ole'! memDC.DrawState(rImage.TopLeft(), rImage.Size(), m_IconIn, DSS_NORMAL, (CBrush*)NULL); memDC.SetTextColor(GetFGColor()); // memDC.TextOut(m_textPos.x,m_textPos.y,str); break; case HOVER: // Ole'! memDC.DrawState(rImage.TopLeft(), rImage.Size(), m_IconOut, DSS_NORMAL, (CBrush*)NULL); memDC.SetTextColor(RGB(36,93,219)); // memDC.TextOut(m_textPos.x,m_textPos.y,str); if(m_bDrawRantage) { memDC.MoveTo(rect.left,rect.top); memDC.LineTo(rect.right,rect.top); memDC.MoveTo(rect.left,rect.top); memDC.LineTo(rect.left,rect.bottom); memDC.MoveTo(rect.left,rect.bottom - 1); memDC.LineTo(rect.right,rect.bottom - 1); memDC.MoveTo(rect.right - 1,rect.top); memDC.LineTo(rect.right - 1,rect.bottom); } // memDC.SetBkColor(TRANSPARENT); // memDC.Rectangle(rect); break; case DOWN: // Ole'! // SetTimer(2,20,NULL); memDC.DrawState(rImage.TopLeft(), rImage.Size(), m_IconOut, DSS_NORMAL, (CBrush*)NULL); memDC.SetTextColor(GetBGColor()); // memDC.TextOut(m_textPos.x,m_textPos.y,str); break; case DISABLE: memDC.DrawState(rImage.TopLeft(), rImage.Size(), m_IconIn, DSS_NORMAL, (CBrush*)NULL); memDC.SetTextColor(GetFGColor()); // memDC.TextOut(m_textPos.x,m_textPos.y,str); break; default: break; } } else { CString ss; GetWindowText(ss); m_imgNormal.GetBitmap(&bm); int nYOffset = (rect.Height() - bm.bmHeight)/2;//rect.Width(), rect.Height() if(nYOffset < 0) nYOffset = 0; posText.x = rect.left + bm.bmWidth + 2; posText.y = (rect.Height() - 20)/2; if(posText.y < 0) posText.y = 0; posText = m_textPos; if(m_ShowState == 1) {//强制设成选取中状态 m_imgDown.GetBitmap(&bm); // SetTimer(2,20,NULL); MemDC.SelectObject(&m_imgDown); if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right) memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth, bm.bmHeight,SRCCOPY); else memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY); memDC.SetTextColor(GetBGColor()); } else { switch(m_state) { case NORMAL: m_imgNormal.GetBitmap(&bm); MemDC.SelectObject(&m_imgNormal); if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right) memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth, bm.bmHeight,SRCCOPY); else memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY); memDC.SetTextColor(GetFGColor()); // memDC.TextOut(m_textPos.x,m_textPos.y,str); break; case HOVER: m_imgHover.GetBitmap(&bm); MemDC.SelectObject(&m_imgHover); if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right) memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth, bm.bmHeight,SRCCOPY); else memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY); if(m_bDrawRantage) { memDC.SetTextColor(GetBGColor()); memDC.TextOut(m_textPos.x,m_textPos.y,str); memDC.MoveTo(rect.left,rect.top); memDC.LineTo(rect.right,rect.top); memDC.MoveTo(rect.left,rect.top); memDC.LineTo(rect.left,rect.bottom); memDC.MoveTo(rect.left,rect.bottom - 1); memDC.LineTo(rect.right,rect.bottom - 1); memDC.MoveTo(rect.right - 1,rect.top); memDC.LineTo(rect.right - 1,rect.bottom); } break; case DOWN: m_imgDown.GetBitmap(&bm); // SetTimer(2,20,NULL); MemDC.SelectObject(&m_imgDown); if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right) memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth, bm.bmHeight,SRCCOPY); else memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY); memDC.SetTextColor(GetBGColor()); // memDC.TextOut(m_textPos.x,m_textPos.y,str); break; case DISABLE: m_imgDisable.GetBitmap(&bm); MemDC.SelectObject(&m_imgDisable); if(bm.bmHeight>rect.bottom || bm.bmWidth>rect.right) memDC.StretchBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,bm.bmWidth, bm.bmHeight,SRCCOPY); else memDC.BitBlt(0,0,rect.right,rect.bottom,&MemDC,0,0,SRCCOPY); memDC.SetTextColor(GetFGColor()); // memDC.TextOut(m_textPos.x,m_textPos.y,str); break; default: break; } } } if(!str.IsEmpty()) { memDC.TextOut(posText.x,posText.y,str); } dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY); memDC.DeleteDC(); MemDC.DeleteDC(); } }
void CSkinBtn::DrawButtonNullPicture() { if(m_bRePain == FALSE) { CPoint posText(0,0); CClientDC dc(this); CRect rect; GetClientRect(&rect); CDC memDC; memDC.CreateCompatibleDC(&dc); CBitmap Screen; Screen.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height()); memDC.SelectObject(&Screen); Screen.DeleteObject(); //画背景 memDC.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &m_memDC, 0, 0, SRCCOPY); CString str(_T("")); GetWindowText(str); int nLen = str.GetLength(); if(nLen > 3) posText.x = (rect.Width())/5; else posText.x = (rect.Width())/3; if(posText.x < 0) posText.x = 0; posText.y = (rect.Height() - 20)/2; if(posText.y < 0) posText.y = 0; memDC.SetBkMode(TRANSPARENT); memDC.SelectObject(m_pFont); CDC MemDC; MemDC.CreateCompatibleDC(&dc); switch(m_state) { case NORMAL: memDC.SetTextColor(GetBGColor()); break; case HOVER: if(m_bDrawRantage) { memDC.SetTextColor(RGB(36,93,219)); memDC.MoveTo(rect.left,rect.top); memDC.LineTo(rect.right,rect.top); memDC.MoveTo(rect.left,rect.top); memDC.LineTo(rect.left,rect.bottom); memDC.MoveTo(rect.left,rect.bottom - 1); memDC.LineTo(rect.right,rect.bottom - 1); memDC.MoveTo(rect.right - 1,rect.top); memDC.LineTo(rect.right - 1,rect.bottom); } break; case DOWN: memDC.SetTextColor(GetBGColor()); break; case DISABLE: memDC.SetTextColor(GetFGColor()); // memDC.TextOut(m_textPos.x,m_textPos.y,str); break; default: break; } if(!str.IsEmpty()) { memDC.TextOut(posText.x,posText.y,str); } dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY); memDC.DeleteDC(); MemDC.DeleteDC(); } }