void CSItemsList::loadItems(char *protoName) { char dbSetting[32]; mir_snprintf(dbSetting, "%s_ItemsCount", protoName); unsigned int itemsCount = getWord(dbSetting, DEFAULT_ITEMS_COUNT); for (unsigned int i = 1; i <= itemsCount; i++) { StatusItem* item = new StatusItem(); DBVARIANT dbv; mir_snprintf(dbSetting, "%s_Item%dIcon", protoName, i); item->m_iIcon = getByte(dbSetting, DEFAULT_ITEM_ICON); mir_snprintf(dbSetting, "%s_Item%dTitle", protoName, i); if (!getWString(dbSetting, &dbv)) { mir_wstrcpy(item->m_tszTitle, dbv.ptszVal); db_free(&dbv); } else item->m_tszTitle[0] = 0; mir_snprintf(dbSetting, "%s_Item%dMessage", protoName, i); if (!getWString(dbSetting, &dbv)) { mir_wstrcpy(item->m_tszMessage, dbv.ptszVal); db_free(&dbv); } else item->m_tszMessage[0] = 0; mir_snprintf(dbSetting, "%s_Item%dFavourite", protoName, i); item->m_bFavourite = (BOOL)getByte(dbSetting, DEFAULT_ITEM_IS_FAVOURITE); m_list->add(item); } }
int message_post(LuaState* state) { wstring from = getWString(state, 1); wstring subject = getWString(state, 2); wstring body = getWString(state, 3); Mission* mission = rMain()->getMission(); mission->postMessage(from, subject, body); return 0; }
void getPlayerName(std::wstring &identity) { unsigned long mask, base, offset, current, shortGUID, testGUID; mask = getInt32(nameStorePtr + nameMaskOffset); base = getInt32(nameStorePtr + nameBaseOffset); shortGUID = g_playerGUID & 0xffffffff; // Only half the guid is used to check for a hit if (mask == 0xffffffff) { identity.clear(); return; } offset = 12 * (mask & shortGUID); // select the appropriate linked list current=getInt32(base + offset + 8); // ptr to lower half of GUID of first element offset = getInt32(base + offset); // this plus 4 is the offset for the next element if ((current == 0) || (current & 0x1)) { identity.clear(); return; } testGUID=getInt32(current); while (testGUID != shortGUID) { current=getInt32(current + offset + 4); if ((current == 0) || (current & 0x1)) { identity.clear(); return; } testGUID=getInt32(current); } getWString(current + nameStringOffset, identity); }
int station_set_name(LuaState* state) { wstring stationName = getWString(state, 1); if(stationName != L"") { rMain()->getMission()->getStation()->setName(stationName); } return 0; }
bool StatsSet::getUInt( const char *name, unsigned int *val, unsigned int defVal ) { std::wstring ws; std::wstring ws_def(L"0"); getWString( name, ws, ws_def ); unsigned int v = 0; int r = swscanf( ws.c_str(), L"%u", &v ); if( r <= 0 ) (*val) = defVal; // 0 tokens were read by swscanf or EOL reached unexpectedly else (*val) = v; return true; }
bool StatsSet::getDouble( const char *name, double *val, double defVal ) { std::wstring ws; std::wstring ws_def(L"0.0"); getWString( name, ws, ws_def ); double v = 0.0; int r = swscanf( ws.c_str(), L"%lf", &v ); if( r <= 0 ) (*val) = defVal; // 0 tokens were read by swscanf or EOL reached unexpectedly else (*val) = v; return true; }
bool StatsSet::getString( const char *name, std::string& val, std::string& defVal ) { std::wstring ws; std::wstring ws_def( L"" ); getWString( name, ws, ws_def ); // always returns true const wchar_t *cws = ws.c_str(); char *c_tmp = (char *)malloc( ws.size() + 16 ); if( c_tmp ) { l2c_unicode_to_ansi( cws, c_tmp, ws.size()+1 ); c_tmp[ws.size()] = 0; val.assign( c_tmp, ws.size() ); free( c_tmp ); } else val = defVal; return true; }
LRESULT imsdkDemoLogin::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { int id = wParam; if (id == 7){ --m_secGetSignCode; if (m_secGetSignCode == 0){ m_pSignCodeBtn->SetEnabled(); m_pSignCodeBtn->SetText(_T("获取验证码")); ::KillTimer(GetHWND(), 7); } else { std::string strText = std::to_string(m_secGetSignCode) + "s后重试"; auto strT = getWString(strText.c_str()); m_pSignCodeBtn->SetText(strT.c_str()); } } bHandled = TRUE; return 0; }
void imsdkDemoLogin::Notify(TNotifyUI& msg) { if (msg.sType == _T("click")) { if (msg.pSender == m_pCloseBtn) { PostQuitMessage(0); return; } if (msg.pSender == m_pLoginBtn) { CEditUI* pEditServer = static_cast<CEditUI*>(m_pm.FindControl(_T("editServer"))); CEditUI* pEditAccount = static_cast<CEditUI*>(m_pm.FindControl(_T("editAccount"))); CEditUI* pEditPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("editPassword"))); std::string server = getString(pEditServer->GetText().GetData()); std::string account = getString(pEditAccount->GetText().GetData()); std::string password = getString(pEditPassword->GetText().GetData()); gClientDemo.login(server, account, password, std::bind(&imsdkDemoLogin::onLoginCb, this, std::placeholders::_1)); //Close(7); } if (msg.pSender == m_pSignCodeBtn) { CEditUI* pEditServer = static_cast<CEditUI*>(m_pm.FindControl(_T("signServer"))); CEditUI* pEditPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("signPhone"))); std::string server = getString(pEditServer->GetText().GetData()); std::string phone = getString(pEditPhone->GetText().GetData()); gClientDemo.getRegCode(server, phone); m_secGetSignCode = 30; m_pSignCodeBtn->SetEnabled(false); std::string strText = std::to_string(m_secGetSignCode) + "s后重试"; auto strT = getWString(strText.c_str()); m_pSignCodeBtn->SetText(strT.c_str()); ::SetTimer(GetHWND(), 7, 1000, NULL); } if (msg.pSender == m_pSignUpBtn) { CEditUI* pEditAccount = static_cast<CEditUI*>(m_pm.FindControl(_T("signAccount"))); CEditUI* pEditPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("signPassword"))); CEditUI* pEditSignCode = static_cast<CEditUI*>(m_pm.FindControl(_T("signCode"))); std::string account = getString(pEditAccount->GetText().GetData()); std::string password = getString(pEditPassword->GetText().GetData()); std::string signcode = getString(pEditSignCode->GetText().GetData()); gClientDemo.reg(account, password, signcode); } } else if (msg.sType == _T("selectchanged")) { CDuiString name = msg.pSender->GetName(); CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("login"))); if (name == _T("optLogin")){ CEditUI* pEditAccount = static_cast<CEditUI*>(m_pm.FindControl(_T("editAccount"))); CEditUI* pEditPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("editPassword"))); pEditAccount->SetText(_T("手机号")); pEditPassword->SetText(_T("密码")); pControl->SelectItem(0); } else if (name == _T("optSignUp")) { CEditUI* pEditPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("signPhone"))); CEditUI* pEditAccount = static_cast<CEditUI*>(m_pm.FindControl(_T("signAccount"))); CEditUI* pEditPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("signPassword"))); CEditUI* pEditSignCode = static_cast<CEditUI*>(m_pm.FindControl(_T("signCode"))); pEditPhone->SetText(_T("手机号")); pEditAccount->SetText(_T("用户名")); pEditPassword->SetText(_T("密码")); pEditSignCode->SetText(_T("验证码")); pControl->SelectItem(1); } } else if (msg.sType == _T("return")) { // Enter键注册、登录 CTabLayoutUI* pTab = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("login"))); if (0 == pTab->GetCurSel()){ // CEditUI* pEditServer = static_cast<CEditUI*>(m_pm.FindControl(_T("editServer"))); CEditUI* pEditAccount = static_cast<CEditUI*>(m_pm.FindControl(_T("editAccount"))); CEditUI* pEditPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("editPassword"))); if (pEditPassword->IsFocused()) { std::string server = getString(pEditServer->GetText().GetData()); std::string account = getString(pEditAccount->GetText().GetData()); std::string password = getString(pEditPassword->GetText().GetData()); gClientDemo.login(server, account, password, std::bind(&imsdkDemoLogin::onLoginCb, this, std::placeholders::_1)); } if (pEditAccount->IsFocused()) { pEditPassword->SetFocus(); } } else { CEditUI* pEditAccount = static_cast<CEditUI*>(m_pm.FindControl(_T("signAccount"))); CEditUI* pEditPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("signPassword"))); CEditUI* pEditSignCode = static_cast<CEditUI*>(m_pm.FindControl(_T("signCode"))); std::string account = getString(pEditAccount->GetText().GetData()); std::string password = getString(pEditPassword->GetText().GetData()); std::string signcode = getString(pEditSignCode->GetText().GetData()); gClientDemo.reg(account, password, signcode); } } }