// Change Password dialog UINT NmChangePasswordProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { RPC *r = (RPC *)param; char tmp1[MAX_SIZE]; char tmp2[MAX_SIZE]; RPC_SET_PASSWORD t; // Validate arguments if (hWnd == NULL) { return 0; } switch (msg) { case WM_INITDIALOG: FormatText(hWnd, 0, r->Sock->RemoteHostname); FormatText(hWnd, S_TITLE, r->Sock->RemoteHostname); break; case WM_COMMAND: GetTxtA(hWnd, E_PASSWORD1, tmp1, sizeof(tmp1)); GetTxtA(hWnd, E_PASSWORD2, tmp2, sizeof(tmp2)); switch (LOWORD(wParam)) { case E_PASSWORD1: case E_PASSWORD2: SetEnable(hWnd, IDOK, StrCmp(tmp1, tmp2) == 0); break; } switch (wParam) { case IDOK: Zero(&t, sizeof(t)); Sha0(t.HashedPassword, tmp1, StrLen(tmp1)); if (CALL(hWnd, NcSetPassword(r, &t))) { MsgBox(hWnd, MB_ICONINFORMATION, _UU("NM_PASSWORD_MSG")); EndDialog(hWnd, true); } break; case IDCANCEL: Close(hWnd); break; } break; case WM_CLOSE: EndDialog(hWnd, false); break; } return 0; }
//! 响应删除联系人操作 void LinkmanSystem::OnDelLinkMan(const CGUID &OwnerGuid, const char *pOptName, LONG lGroupID, const CGUID &AimGuid, const char *pAimName) { LONG lIdx = m_LGSManage.GetIndexByID(lGroupID); if (-1 == lIdx) return; //! 如果拥有者在本服 map<CGUID, VecLinkmanGroup>::iterator ite = m_mapPlayerLinkman.find(OwnerGuid); if (m_mapPlayerLinkman.end() != ite) { assert(NULL != GetGame()->FindPlayer(OwnerGuid)); if((long)ite->second.size() <= lIdx) { char szGUID[256] = {0}; OwnerGuid.tostring(szGUID); //玩家[%s]好友的组数小于WS发过来的组数! Log4c::Error(ROOT_MODULE,"%-15s %s",__FUNCTION__,FormatText("GS_PLAYER_18", szGUID)); return; } //! 找到联系人组 LinkmanGroup &tmpLinkmanGroup = (ite->second)[lIdx]; //! 删除联系人 tmpLinkmanGroup.DelMember(AimGuid, TRUE, pAimName); //! 离婚情况,要判断称号 const LinkmanGroupSetup* pLinkmanGroupSetup = m_LGSManage.GetLinkmanGroupSetup_ByOrder(lIdx); if (NULL != pLinkmanGroupSetup && eKW_ServerKeep == pLinkmanGroupSetup->m_uKeepWay) { if (eAAT_Spouse == pLinkmanGroupSetup->m_uAutoAddWay) { CPlayer *pPlayer = GetGame()->FindPlayer(OwnerGuid); pPlayer->UpdateTitle(TRUE); } } } //! 如果被添加者在本服 ite = m_mapPlayerLinkman.find(AimGuid); if (m_mapPlayerLinkman.end() != ite) { assert(NULL != GetGame()->FindPlayer(AimGuid)); //! 找到联系人组 if((long)ite->second.size() <= lIdx) { char szGUID[256] = {0}; OwnerGuid.tostring(szGUID); //玩家[%s]好友的组数小于WS发过来的组数! Log4c::Error(ROOT_MODULE,"%-15s %s",__FUNCTION__,FormatText("GS_PLAYER_19", szGUID)); return; } LinkmanGroup &tmpLinkmanGroup = (ite->second)[lIdx]; tmpLinkmanGroup.DelCompriseMePlayer(OwnerGuid, pOptName); } }
void CBFontTT::DrawTextDD(BYTE* Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) { CBRenderDD* m_Renderer = (CBRenderDD*)Game->m_Renderer; if(FAILED(CreateWinFont())) return; HDC hDC; m_Renderer->m_BackBuffer->GetDC(&hDC); HFONT OldFont = (HFONT)SelectObject(hDC, m_HFont); ::SetBkMode(hDC, TRANSPARENT); int TextX = 0; SetTextAlign(hDC, Align, Width, &TextX); BYTE* ConvertedText = CBTextUtils::ConvertToNative(Game->m_TextEncoding, Text, MaxLength); for(int i=0; i<m_Layers.GetSize(); i++) { ::SetTextColor(hDC, CBUtils::D3D2COLORREF(m_Layers[i]->m_Color)); FormatText(X + TextX+m_Layers[i]->m_OffsetX, Y+m_Layers[i]->m_OffsetY, ConvertedText, hDC, Width, MaxHeight); } ::SelectObject(hDC, OldFont); m_Renderer->m_BackBuffer->ReleaseDC(hDC); DeleteWinFont(); delete [] ConvertedText; }
//! 判断一个玩家【OwnerGuid】是否与另一个玩家【OtherOneGuid】存在在指定的关系 BOOL LinkmanSystem::CheckRelation(const CGUID &OwnerGuid, const CGUID &OtherOneGuid, eLinkmanGroupType eRelationType) { LONG lIdx = m_LGSManage.GetIndexByType(eRelationType); if (-1 == lIdx) return FALSE; map<CGUID, VecLinkmanGroup>::iterator ite = m_mapPlayerLinkman.find(OwnerGuid); if (m_mapPlayerLinkman.end() != ite) { //! 找到联系人组 if((long)ite->second.size() > lIdx) { LinkmanGroup &tmpLinkmanGroup = (ite->second)[lIdx]; return tmpLinkmanGroup.FindMember(OtherOneGuid); } else { char szGUID[256] = {0}; OwnerGuid.tostring(szGUID); //发生不应该的错误, 玩家的联系人数据中没有第[%d]组,需要检查 Log4c::Error(ROOT_MODULE,"%-15s %s",__FUNCTION__,FormatText("GS_PLAYER_30", lIdx)); } } return FALSE; }
// Mission Screen Draw logic void DrawMissionScreen(void) { // Draw MISSION screen here! DrawTexture(texBackground, 0,0, WHITE); DrawTexturePro(texBackline, sourceRecBackLine, destRecBackLine, (Vector2){0,0},0, Fade(WHITE, fadeBackLine)); if (writeNumber) DrawTextEx(fontMission, FormatText("Filtración #%02i ", currentMission + 1), numberPosition, missionSize + 10, 0, numberColor); DrawTextEx(fontMission, TextSubtext(missions[currentMission].brief, 0, missionLenght), missionPosition, missionSize, 0, missionColor); if (writeKeyword && blinkKeyWord) DrawTextEx(fontMission, FormatText("Keyword: %s", missions[currentMission].key), keywordPosition, missionSize + 10, 0, keywordColor); if (showButton) { if (!writeEnd) DrawButton("saltar"); else DrawButton("codificar"); } }
// Level07 Screen Draw logic void DrawLevel07Screen(void) { // Draw Level07 screen here! DrawCircleV(leftCirclePos, circleRadius, leftCircleColor); DrawCircleV(middleCirclePos, circleRadius, middleCircleColor); DrawCircleV(rightCirclePos, circleRadius, rightCircleColor); if (leftCircleActive) DrawCircleV(leftBtnPos, btnRadius, GRAY); else DrawCircleV(leftBtnPos, btnRadius, LIGHTGRAY); if (middleCircleActive) DrawCircleV(middleBtnPos, btnRadius, GRAY); else DrawCircleV(middleBtnPos, btnRadius, LIGHTGRAY); if (rightCircleActive) DrawCircleV(rightBtnPos, btnRadius, GRAY); else DrawCircleV(rightBtnPos, btnRadius, LIGHTGRAY); if (levelFinished) { DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); DrawText("LEVEL 07", GetScreenWidth()/2 - MeasureText("LEVEL 07", 30)/2, 20, 30, GRAY); DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); } else DrawText("LEVEL 07", GetScreenWidth()/2 - MeasureText("LEVEL 07", 30)/2, 20, 30, LIGHTGRAY); }
wxString COARfile::FormatMessages(const vector<int> &vn, int nIndent, const wxDateTime *pTime) const { const COARmessage *pmsg; wxString sRtn; wxString s; // should be an odd number of spaces, because a char will // be replaced by a line feed (\n) bool bFirst = true; for(vector<int>::const_iterator itr = vn.begin(); itr != vn.end(); ++itr) { pmsg = GetMessageByNumber(*itr,pTime); if((pmsg != NULL) && !pmsg->GetHidden() && pmsg->DisplayOsiris()) { s = pmsg->GetText(); FormatText(&s,nIndent); if(!s.IsEmpty()) { if(!bFirst) { sRtn.Append(_T("\n")); } sRtn.Append(s); bFirst = false; } } } return sRtn; }
void CCodeEditor::DealText() { if (ParseText()) { FormatText(this->toPlainText()); } }
// Draw game (one frame) void DrawGame(void) { BeginDrawing(); ClearBackground(RAYWHITE); if (!gameOver) { DrawRectangleRec(player.rec, player.color); if (wave == FIRST) DrawText("FIRST WAVE", screenWidth/2 - MeasureText("FIRST WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha)); else if (wave == SECOND) DrawText("SECOND WAVE", screenWidth/2 - MeasureText("SECOND WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha)); else if (wave == THIRD) DrawText("THIRD WAVE", screenWidth/2 - MeasureText("THIRD WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha)); for (int i = 0; i < activeEnemies; i++) { if (enemy[i].active) DrawRectangleRec(enemy[i].rec, enemy[i].color); } for (int i = 0; i < NUM_SHOOTS; i++) { if (shoot[i].active) DrawRectangleRec(shoot[i].rec, shoot[i].color); } DrawText(FormatText("%04i", score), 20, 20, 40, GRAY); if (victory) DrawText("YOU WIN", screenWidth/2 - MeasureText("YOU WIN", 40)/2, screenHeight/2 - 40, 40, BLACK); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); } else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); EndDrawing(); }
//----------------------------------------------------------------------------- /// generates XML to encode X, Y, Z, and W integer values specified by the /// input array /// /// \param pIntConstants array of four floats values to encode as X, Y, Z, W /// \return generated XML string //----------------------------------------------------------------------------- gtASCIIString GetXMLIntegerConstant(int* pIntConstants) { return FormatText("<X>%i</X><Y>%i</Y><Z>%i</Z><W>%i</W>", pIntConstants[0], pIntConstants[1], pIntConstants[2], pIntConstants[3]); }
//----------------------------------------------------------------------------- /// generates XML to encode X, Y, Z, and W float values specified by the /// input array /// /// \param pFloatConstants array of four floats values to encode as X, Y, Z, W /// \return generated XML string //----------------------------------------------------------------------------- gtASCIIString GetXMLFloatConstant(float* pFloatConstants) { return FormatText("<X>%f</X><Y>%f</Y><Z>%f</Z><W>%f</W>", pFloatConstants[0], pFloatConstants[1], pFloatConstants[2], pFloatConstants[3]); }
//----------------------------------------------------------------------------- /// Debugging helper //----------------------------------------------------------------------------- void HookVtableImmediate::Debug() { for (VTableMap::iterator Ivt = m_VTableMap.begin(); Ivt != m_VTableMap.end(); Ivt++) { ptrdiff_t** vtable = Ivt->first; std::string tmp = FormatText("%s(0x%p): ", m_Name, vtable).asCharArray(); for (int i = 0; i < 10; i++) { tmp += FormatText("0x%p,", vtable[i]).asCharArray(); } tmp += "\n"; Log(logMESSAGE, "%s", tmp.c_str()); } }
// Draw game (one frame) void DrawGame(void) { BeginDrawing(); ClearBackground(RAYWHITE); if (!gameOver) { // Draw missiles for (int i = 0; i < MAX_MISSILES; i++) { if (missile[i].active) { DrawLine(missile[i].origin.x, missile[i].origin.y, missile[i].position.x, missile[i].position.y, RED); if (framesCounter % 16 < 8) DrawCircle(missile[i].position.x, missile[i].position.y, 3, YELLOW); } } // Draw interceptors for (int i = 0; i < MAX_INTERCEPTORS; i++) { if (interceptor[i].active) { DrawLine(interceptor[i].origin.x, interceptor[i].origin.y, interceptor[i].position.x, interceptor[i].position.y, GREEN); if (framesCounter % 16 < 8) DrawCircle(interceptor[i].position.x, interceptor[i].position.y, 3, BLUE); } } // Draw explosions for (int i = 0; i < MAX_EXPLOSIONS; i++) { if (explosion[i].active) DrawCircle(explosion[i].position.x, explosion[i].position.y, EXPLOSION_RADIUS*explosion[i].radiusMultiplier, EXPLOSION_COLOR); } // Draw buildings and launchers for (int i = 0; i < LAUNCHERS_AMOUNT; i++) { if (launcher[i].active) DrawRectangle(launcher[i].position.x - LAUNCHER_SIZE/2, launcher[i].position.y - LAUNCHER_SIZE/2, LAUNCHER_SIZE, LAUNCHER_SIZE, GRAY); } for (int i = 0; i < BUILDINGS_AMOUNT; i++) { if (building[i].active) DrawRectangle(building[i].position.x - BUILDING_SIZE/2, building[i].position.y - BUILDING_SIZE/2, BUILDING_SIZE, BUILDING_SIZE, LIGHTGRAY); } // Draw score DrawText(FormatText("SCORE %4i", score), 20, 20, 40, LIGHTGRAY); if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY); } else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY); EndDrawing(); }
void CMsgBoxDlg::SetText(CString newVal,BOOL bFormat) { m_strText = newVal; if (bFormat) { FormatText(); } }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values"); int framesCounter = 0; // Variable used to count frames int randValue = GetRandomValue(-8,5); // Get a random integer number between -8 and 5 (both included) SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- framesCounter++; // Every two seconds (120 frames) a new random value is generated if (((framesCounter/120)%2) == 1) { randValue = GetRandomValue(-8,5); framesCounter = 0; } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON); DrawText(FormatText("%i", randValue), 360, 180, 80, LIGHTGRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
//-------------------------------------------------------------------------- /// Write a chunk of XML that will ultimately be written to disk as a metadata file. /// \param outMetadataXML A generated chunk of XML based on the contents of this instance. //-------------------------------------------------------------------------- void TraceMetadata::WriteToXML(gtASCIIString& outMetadataXML) { gtASCIIString metadataXML; metadataXML += XML("Location", FormatText("%s", mMetadataFilepath.c_str()).asCharArray()); metadataXML += XML("FrameNumber", FormatText("%u", mFrameIndex).asCharArray()); metadataXML += XML("Architecture", FormatText("%u", mArchitecture).asCharArray()); gtASCIIString contentsXML; contentsXML += XML("LinkedTrace", FormatText("%s", mPathToTraceFile.c_str()).asCharArray()); contentsXML += XML("FrameBufferImage", FormatText("%s", mPathToFrameBufferImage.c_str()).asCharArray()); // Pull this section of the contents out of the internal FrameInfo structure. mFrameInfo.WriteToXML(contentsXML); // Surround the generated contents string with a parent element metadataXML += XML("Contents", contentsXML.asCharArray()); // Now surround the entire chunk with an "XML" block so there's a single root node. outMetadataXML = XML("XML", metadataXML.asCharArray()); }
void CProgressCtrlX::UpdateTooltipText(int nPos) { if (m_wndToolTip.GetSafeHwnd () == NULL) return; CDrawInfo info; // retrieve current position and range info.nCurPos = nPos; CProgress::GetRange(info.nLower, info.nUpper); info.dwStyle = m_fToolTipFormat; CString sText = FormatText(info, GetTooltipText(), CalcPos(info)); if (!sText.IsEmpty()) m_wndToolTip.UpdateTipText(sText, this); }
// Initialize void NmMainDlgInit(HWND hWnd, RPC *r) { // Validate arguments if (r == NULL || hWnd == NULL) { return; } SetIcon(hWnd, 0, ICO_ROUTER); FormatText(hWnd, 0, r->Sock->RemoteHostname); DlgFont(hWnd, S_STATUS, 11, true); NmMainDlgRefresh(hWnd, r); }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel"); int boxPositionY = screenHeight/2 - 40; int scrollSpeed = 4; // Scrolling speed in pixels SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- boxPositionY -= (GetMouseWheelMove()*scrollSpeed); //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON); DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY); DrawText(FormatText("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
//! 响应初始化消息 void LinkmanSystem::OnInitMessage(CMessage *pMsg) { BOOL bSendToC = pMsg->GetByte(); CGUID PlayerGuid; pMsg->GetGUID(PlayerGuid); CPlayer *pPlayer = GetGame()->FindPlayer(PlayerGuid);; if(m_mapPlayerLinkman.end() != m_mapPlayerLinkman.find(PlayerGuid)) { m_mapPlayerLinkman.erase(PlayerGuid); #ifdef _DEBUG char szGuid[64] = {0}; PlayerGuid.tostring(szGuid); char szPlayerName[64] = {0}; if(NULL != pPlayer) { memmove(szPlayerName, pPlayer->GetName(), 20); } //初始化玩家联系人数据时发现联系人已经存在!![玩家名称:“%s”、玩家ID:“%s”] Log4c::Error(ROOT_MODULE,"%-15s %s",__FUNCTION__,FormatText("GS_PLAYER_15", szPlayerName, szGuid)); #endif } CMessage msgClient(MSG_S2C_LINKMAN_INIT); VecLinkmanGroup vLinkmanGroup; LONG lGroupNum = m_LGSManage.GetGroupNum(); for (LONG i = 0; i < lGroupNum; ++i) { LinkmanGroup tmpLinkmanGroup(m_LGSManage.GetLinkmanGroupSetup_ByOrder(i), PlayerGuid); tmpLinkmanGroup.Decode_FromWs(pMsg); if(bSendToC) tmpLinkmanGroup.Serialize_ForClient(&msgClient); vLinkmanGroup.push_back(tmpLinkmanGroup); } m_mapPlayerLinkman.insert(pair<CGUID, VecLinkmanGroup>(PlayerGuid, vLinkmanGroup)); //! 发送到客户端 if(bSendToC) msgClient.SendToPlayer(PlayerGuid); if(pPlayer) pPlayer->UpdateTitle(TRUE); }
void HavokImport::HandleRagdollOnNonAccum(INode* accumChild, INode* ragdollParent) { const int MaxChar = 512; char buffer[MaxChar]; //Fix for nonaccumNodes //TSTR name(A2THelper(buffer, parent->GetName().c_str(), _countof(buffer))); ragdollParent->SetName(FormatText(TEXT("Ragdoll_%s"), accumChild->GetName())); Object *Obj = ragdollParent->GetObjectRef(); if (Obj->SuperClassID() == GEN_DERIVOB_CLASS_ID) { while (Obj->SuperClassID() == GEN_DERIVOB_CLASS_ID) { IDerivedObject *DerObj = static_cast<IDerivedObject *> (Obj); const int nMods = DerObj->NumModifiers(); for (int i = 0; i < nMods; i++) { Modifier *Mod = DerObj->GetModifier(i); if (Mod->ClassID() == HK_RIGIDBODY_MODIFIER_CLASS_ID) { ICustAttribContainer* cc = Mod->GetCustAttribContainer(); if (cc) { //reset Mod->DeleteCustAttribContainer(); } Mod->AllocCustAttribContainer(); cc = Mod->GetCustAttribContainer(); CustAttrib* c = (CustAttrib*)CreateInstance(CUST_ATTRIB_CLASS_ID, Class_ID(0x6e663460, 0x32682c72)); IParamBlock2* custModParameters = c->GetParamBlock(0); custModParameters->SetValue(0, 0, accumChild, 0); cc->InsertCustAttrib(0, c); } } Obj = DerObj->GetObjRef(); } } }
//-------------------------------------------------------------- /// Binds to ip address and port /// \param s Input socket /// \return Bound socket address or 0 for failure to bind //-------------------------------------------------------------- static NetSocket* WebServerBind(NetSocket* s) { if (s->Bind((u_short)s_dwPort) == false) { if (s_dwPort == 80) { MessageBoxError("Can't listen on port 80, this port is probably being used by another application.\n\nCommon apps that use this port are:\n 1 ) Skype\n 2 ) a local webserver\n\nPlease use the –port=<arg> command-line option to use an alternate port.\nRemember that you'll have to use include the new port number when connecting to the server.\n"); } else { MessageBoxError(FormatText("Port %u is already in use by another application.", s_dwPort)); } s->close(); return (0); } return s; }
// Level06 Screen Draw logic void DrawLevel06Screen(void) { // Draw Level06 screen DrawRectangleRec(centerRec, LIGHTGRAY); for (int i = 0; i < 4; i++) { DrawRectangleRec(movingRecs[i], GRAY); } if (!done & (mouseOverNum >= 0)) DrawRectangleLines(movingRecs[mouseOverNum].x - 5, movingRecs[mouseOverNum].y - 5, movingRecs[mouseOverNum].width + 10, movingRecs[mouseOverNum].height + 10, Fade(LIGHTGRAY, 0.8f)); if (levelFinished) { DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f)); DrawText("LEVEL 06", GetScreenWidth()/2 - MeasureText("LEVEL 06", 30)/2, 20, 30, GRAY); DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY); } else DrawText("LEVEL 06", GetScreenWidth()/2 - MeasureText("LEVEL 06", 30)/2, 20, 30, LIGHTGRAY); }
std::string CapturedAPICalls::GetCaptureLog() { std::string tmp = ""; if (m_captureList.empty() == false) { tmp.reserve((const int)(m_captureList.size() + 1) * 80); if (m_pActiveDevice != NULL) { tmp += FormatText("MainContext=0x%p\n", m_pActiveDevice).asCharArray(); } for (CaptureList::iterator iter = m_captureList.begin(); iter != m_captureList.end(); ++iter) { tmp += FormatString("%d ", (*iter)->GetThreadID()) + (*iter)->Print() + "\n"; } } return tmp; }
int CBFontTT::GetTextHeight(BYTE* Text, int Width) { if(FAILED(CreateWinFont())) return 0; HDC hDC = CreateCompatibleDC(NULL); SetMapMode(hDC, MM_TEXT); HGDIOBJ OldFont = SelectObject(hDC, m_HFont); BYTE* ConvertedText = CBTextUtils::ConvertToNative(Game->m_TextEncoding, Text); int Ret = FormatText(0, 0, ConvertedText, hDC, Width, -1); delete [] ConvertedText; ::SelectObject(hDC, OldFont); DeleteDC(hDC); DeleteWinFont(); return Ret; }
//----------------------------------------------------------------------------- /// generates XML with a node and a hex value /// /// \param strNode node name /// \param ptr string containing the URL /// \return generated XML string //----------------------------------------------------------------------------- gtASCIIString XMLHexPtr(const char* strNode, const void* ptr) { #ifdef _WIN32 const char* text = "0x%p"; #else const char* text = "%p"; // special case for NULL pointer; don't print (nil). Client expects // 32 or 64 bit hex value returned if (ptr == NULL) { #ifdef X64 text = "0x000000000000000%d"; #else text = "0x0000000%d"; #endif } #endif return XML(strNode, FormatText(text, ptr).asCharArray()); }
// Login dialog UINT NmLogin(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { NM_LOGIN *login = (NM_LOGIN *)param; char tmp[MAX_SIZE]; // Validate arguments if (hWnd == NULL) { return 0; } switch (msg) { case WM_INITDIALOG: FormatText(hWnd, S_TITLE, login->Hostname); break; case WM_COMMAND: switch (wParam) { case IDOK: GetTxtA(hWnd, E_PASSWORD, tmp, sizeof(tmp)); Hash(login->hashed_password, tmp, StrLen(tmp), true); EndDialog(hWnd, true); break; case IDCANCEL: Close(hWnd); break; } break; case WM_CLOSE: EndDialog(hWnd, false); break; } return 0; }
//----------------------------------------------------------------------------- /// Create a streaming socket to communicate between the plugin and the /// webserver. This avoids the duplication. A new thread is created each time a /// streaming request comes in. This is because the client socket changes so /// this change will need propagating to the thread so it knows where to send /// the requests back to. /// The streaming socket uses the next port after the web server port, so if /// the webserver is using port 8080, the streaming port will be 8081 /// \param pRequestHeader the request header to pass to the plugin /// \param pClientSocket the socket used for communication /// \return true is successful, false otherwise //----------------------------------------------------------------------------- bool ProcessTracker::CreateStreamSocket(HTTPRequestHeader* pRequestHeader, NetSocket* pClientSocket) { CloseStreamThread(); CloseStreamSockets(); // figure out which port to use. For now, use the port the web server is using + 1 DWORD port = GetWebServerPort() + 1; pRequestHeader->GetHeaderData()->dwPort = port; // no other threads will be running now so this should be safe m_serverSocket = NetSocket::Create(); if (m_serverSocket == NULL) { Log(logERROR, "Error creating streamSocket\n"); return false; } // try and bind to the streaming port if (m_serverSocket->Bind((u_short)port) == false) { MessageBoxError(FormatText("Port %u is already in use by another application.", port)); m_serverSocket->close(); return false; } // try to listen next if (m_serverSocket->Listen() == false) { m_serverSocket->close(); return false; } m_streamThread = ForkAndWaitForPluginStream(pClientSocket); return true; }
bool NetHandler::Init() { m_ServerInitSendFlag = NF_NULL; // 加载 [Setup.ini], [LogSetup.ini], [SetupEx.ini]及 [ServerSetup.ini] 配置 if (!LoadSetup()) { return false; } InitNetEnv(); // 创建服务器端 if (!InitNetServer()) { return false; } // 连接到LogServer if (0 == m_serverSetup.useLogServer) { Log4c::Warn(ROOT_MODULE,FormatText("GAME_NET_SERVERINVALID", "LogServer")); } else { ConnectServer(NF_LOG_SERVER); } ConnectServer(NF_DB_SERVER); // 连接到DBServer ConnectServer(NF_LOGIN_SERVER); // 连接到LoginServer // 装载内存影射文件配置 LoadMapFileSetup(); CSMClient::GetSM()->InitOk(); return true; }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "Floppy Bird"); InitAudioDevice(); // Initialize audio device Sound coin = LoadSound("resources/coin.wav"); Sound jump = LoadSound("resources/jump.wav"); Texture2D background = LoadTexture("resources/background.png"); Texture2D tubes = LoadTexture("resources/tubes.png"); Texture2D floppy = LoadTexture("resources/floppy.png"); Vector2 floppyPos = { 80, screenHeight/2 - floppy.height/2 }; Vector2 tubesPos[MAX_TUBES]; int tubesSpeedX = 2; for (int i = 0; i < MAX_TUBES; i++) { tubesPos[i].x = 400 + 280*i; tubesPos[i].y = -GetRandomValue(0, 120); } Rectangle tubesRecs[MAX_TUBES*2]; bool tubesActive[MAX_TUBES]; for (int i = 0; i < MAX_TUBES*2; i += 2) { tubesRecs[i].x = tubesPos[i/2].x; tubesRecs[i].y = tubesPos[i/2].y; tubesRecs[i].width = tubes.width; tubesRecs[i].height = 255; tubesRecs[i+1].x = tubesPos[i/2].x; tubesRecs[i+1].y = 600 + tubesPos[i/2].y - 255; tubesRecs[i+1].width = tubes.width; tubesRecs[i+1].height = 255; tubesActive[i/2] = true; } int backScroll = 0; int score = 0; int hiscore = 0; bool gameover = false; bool superfx = false; SetTargetFPS(60); //--------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- backScroll--; if (backScroll <= -800) backScroll = 0; for (int i = 0; i < MAX_TUBES; i++) tubesPos[i].x -= tubesSpeedX; for (int i = 0; i < MAX_TUBES*2; i += 2) { tubesRecs[i].x = tubesPos[i/2].x; tubesRecs[i+1].x = tubesPos[i/2].x; } if (IsKeyDown(KEY_SPACE) && !gameover) floppyPos.y -= 3; else floppyPos.y += 1; if (IsKeyPressed(KEY_SPACE) && !gameover) PlaySound(jump); // Check Collisions for (int i = 0; i < MAX_TUBES*2; i++) { if (CheckCollisionCircleRec((Vector2){ floppyPos.x + floppy.width/2, floppyPos.y + floppy.height/2 }, floppy.width/2, tubesRecs[i])) { gameover = true; } else if ((tubesPos[i/2].x < floppyPos.x) && tubesActive[i/2] && !gameover) { score += 100; tubesActive[i/2] = false; PlaySound(coin); superfx = true; if (score > hiscore) hiscore = score; } } if (gameover && IsKeyPressed(KEY_ENTER)) { for (int i = 0; i < MAX_TUBES; i++) { tubesPos[i].x = 400 + 280*i; tubesPos[i].y = -GetRandomValue(0, 120); } for (int i = 0; i < MAX_TUBES*2; i += 2) { tubesRecs[i].x = tubesPos[i/2].x; tubesRecs[i].y = tubesPos[i/2].y; tubesRecs[i+1].x = tubesPos[i/2].x; tubesRecs[i+1].y = 600 + tubesPos[i/2].y - 255; tubesActive[i/2] = true; } floppyPos.x = 80; floppyPos.y = screenHeight/2 - floppy.height/2; gameover = false; score = 0; } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawTexture(background, backScroll, 0, WHITE); DrawTexture(background, screenWidth + backScroll, 0, WHITE); if (!gameover) { DrawTextureEx(floppy, floppyPos, 0, 1.0, WHITE); //DrawCircleLines(floppyPos.x + floppy.width/2, floppyPos.y + floppy.height/2, floppy.width/2, RED); } for (int i = 0; i < MAX_TUBES; i++) { if (tubesPos[i].x <= 800) DrawTextureEx(tubes, tubesPos[i], 0, 1.0, WHITE); //DrawRectangleLines(tubesRecs[i*2].x, tubesRecs[i*2].y, tubesRecs[i*2].width, tubesRecs[i*2].height, RED); //DrawRectangleLines(tubesRecs[i*2 + 1].x, tubesRecs[i*2 + 1].y, tubesRecs[i*2 + 1].width, tubesRecs[i*2 + 1].height, RED); } DrawText(FormatText("%04i", score), 20, 20, 40, PINK); DrawText(FormatText("HI-SCORE: %04i", hiscore), 20, 70, 20, VIOLET); if (gameover) { DrawText("GAME OVER", 100, 180, 100, MAROON); DrawText("PRESS ENTER to RETRY!", 280, 280, 20, RED); } if (superfx) { DrawRectangle(0, 0, screenWidth, screenHeight, GOLD); superfx = false; } EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadTexture(background); // Texture unloading UnloadTexture(tubes); // Texture unloading UnloadTexture(floppy); // Texture unloading UnloadSound(coin); // Unload sound data UnloadSound(jump); // Unload sound data CloseAudioDevice(); // Close audio device CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }