void event_numeric(irc_session_t *session,unsigned int event,const char *origin, const char **params, unsigned count) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); switch (event) { case LIBIRC_RFC_ERR_NICKNAMEINUSE: case LIBIRC_RFC_ERR_NICKCOLLISION: irc_auto_rename_nick(session); return; case LIBIRC_RFC_RPL_TOPIC: //topic notification on join if (count>2) { CslIrcEvent evt(context->Target,CslIrcEvent::TOPIC,A2U(params[1])); evt.Ints.Add(event); evt.AddCharData(params[2]); wxPostEvent(context->EvtHandler,evt); } return; case LIBIRC_RFC_RPL_NAMREPLY: if (count>3) { irc_notify_player_list(session,params[2],params[3]); return; } break; case LIBIRC_RFC_RPL_ENDOFNAMES: return; case LIBIRC_RFC_ERR_CANNOTSENDTOCHAN: if (count>2) { CslIrcEvent evt(context->Target,CslIrcEvent::NUMERIC,A2U(params[1])); evt.Ints.Add(event); evt.AddCharData(params[2]); wxPostEvent(context->EvtHandler,evt); return; } break; } wxUint32 i; wxString s,p; s<<event<<wxT(": "); for (i=0;i<count;i++) { p=A2U(params[i]); if (!p.CmpNoCase(context->Server->Network->Nick)) continue; s<<p<<wxT(" "); } CslIrcEvent evt(context->Target,CslIrcEvent::NUMERIC,s); evt.Ints.Add(event); wxPostEvent(context->EvtHandler,evt); }
bool CslGameRedEclipse::ParsePlayerPong(wxUint32 protocol,ucharbuf& buf,CslPlayerStatsData& info) const { char text[_MAXDEFSTR]; info.ID=getint(buf); if (protocol>=104) info.Ping=getint(buf); getstring(text,buf); info.Name=A2U(text); getstring(text,buf); info.Team=A2U(text); info.Frags=getint(buf); if (protocol>=104) info.Flagscore=getint(buf); info.Deaths=getint(buf); info.Teamkills=getint(buf); if (protocol>=103) info.Accuracy=getint(buf); info.Health=getint(buf); info.Armour=getint(buf); info.Weapon=getint(buf); info.Privileges=getint(buf); switch (getint(buf)) { case CS_ALIVE: info.State=CSL_PLAYER_STATE_ALIVE; break; case CS_DEAD: info.State=CSL_PLAYER_STATE_DEAD; break; case CS_SPAWNING: info.State=CSL_PLAYER_STATE_SPAWNING; break; case CS_EDITING: info.State=CSL_PLAYER_STATE_EDITING; break; case CS_SPECTATOR: info.State=CSL_PLAYER_STATE_SPECTATOR; break; case CS_WAITING: info.State=CSL_PLAYER_STATE_WAITING; break; default: info.State=CSL_PLAYER_STATE_UNKNOWN; break; } return !buf.overread(); }
bool FileView::init() { if(!FKCW_UIWidget_WidgetWindow::init()) return false; /************************************************************************/ /* 文件菜单 */ /************************************************************************/ m_pFileMenuComboBox = ComboBox::create(CCSize(70, 32), 3); m_pFileMenuComboBox->setTag(1111); //标识 m_pFileMenuComboBox->setPosition(CCSize(70, 25)/2); m_pFileMenuComboBox->setText(A2U("文件").c_str()); this->addChild(m_pFileMenuComboBox); m_pFileMenuComboBox->addString(A2U("新建").c_str()); m_pFileMenuComboBox->addString(A2U("文件..").c_str()); m_pFileMenuComboBox->addString(A2U("文件夹..").c_str()); m_pFileMenuComboBox->setOnComboBoxChangeListener(this, fkcw_uiwidget_combobox_change_selector(FileView::onFileComboBoxChange)); /************************************************************************/ /* 文件选择框 */ /************************************************************************/ m_pFileSelectComboBox = ComboBox::create(CCSize(1080, 32), 3); m_pFileSelectComboBox->setTag(2222); //标识 m_pFileSelectComboBox->setText(A2U("请点击左侧文件菜单,新建或载入配置文件").c_str()); m_pFileSelectComboBox->setPosition(CCSize(1080, 25)/2 + ccp(70+5, 0)); this->addChild(m_pFileSelectComboBox); m_pFileSelectComboBox->setOnComboBoxChangeListener(this, fkcw_uiwidget_combobox_change_selector(FileView::onFileComboBoxChange)); return true; }
void MainScreen::serverListen(const char* ip, short post) { if (!m_isLoadConfigFile) { MessageBox(NULL, L"请先正确载入配置文件", L"", 0); return; } //保证当前只有一个Server if (m_pNetworkServer != NULL) { return; } m_pNetworkServer = new NetworkServer(); m_pNetworkServer->registerOnMessageReceived (this, netserver_backcall_received_selector(MainScreen::onServerMessageReceived)); //收到消息 m_pNetworkServer->registerOnConnected (this, netserver_backcall_selector(MainScreen::onServerConnected)); //连接成功 m_pNetworkServer->registerOnDisconnected (this, netserver_backcall_selector(MainScreen::onServerDisconnected)); //销毁 m_pNetworkServer->registerOnConnectedEnded (this, netserver_backcall_selector(MainScreen::onServerConnectedEnded)); //断开 m_pNetworkServer->registerOnExceptionCaught (this, netserver_backcall_selector(MainScreen::onServerExceptionCaught)); //异常 m_pNetworkServer->setListenIp(ip); m_pNetworkServer->setListenPost(post); m_pNetworkServer->listen(); IpPostView* pListenView = (IpPostView*)getViewByID(ID_LISTEN_VIEW); pListenView->setButtonText(A2U("断开").c_str()); LogView* pServerLogView = (LogView*)getViewByID(ID_SERVER_LOG_VIEW); pServerLogView->safeModeLog(A2U("开始监听...")); }
//已改 void MainScreen::onMessageListViewDataSourceMessage(MessageListView* pSender) { vector<string> mainItems = XmlParser::getInstance()->getMainElementCStrings(); for (unsigned int i=0; i<mainItems.size(); i++) { string mainBuf = mainItems.at(i); pSender->addMainItem(A2U(mainBuf.c_str())); short mainTypeBuf = XmlParser::GetMainType(mainBuf); vector<string> subItems = XmlParser::getInstance()->getSubElementCstrings(mainTypeBuf); for (unsigned int j=0; j<subItems.size(); j++) { string subString = XmlParser::GetSubString(subItems.at(j).c_str()); pSender->addSubItem(i, A2U(subString.c_str())); } pSender->addSubItemAddButton(i); } AttributeListView* pAttributeListView = (AttributeListView*)getViewByID(ID_ATTRIBUTE_LIST_VIEW); pAttributeListView->setTitle(""); pAttributeListView->clear(); FKCW_UIWidget_Button* pSendMessageButton = (FKCW_UIWidget_Button*)getViewByID(ID_SEND_MESSAGE_BUTTON); pSendMessageButton->setEnabled(false); }
void MainScreen::onClientConnectedEnded() { LogView* pClientLogView = (LogView*)getViewByID(ID_CLIENT_LOG_VIEW); pClientLogView->log(A2U("客户端断开")); IpPostView* pConnectView = (IpPostView*)getViewByID(ID_CONNECT_VIEW); pConnectView->setButtonText(A2U("连接").c_str()); }
void event_join(irc_session_t *session,const char* WXUNUSED(event),const char *origin, const char **params,unsigned int WXUNUSED(count)) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target); evt.Channel=A2U(params[0]); evt.Strings.Add(A2U(origin)); evt.Type=context->Server->Network->Nick==A2U(origin) ? CslIrcEvent::JOIN : CslIrcEvent::JOINED; wxPostEvent(context->EvtHandler,evt); }
void MainScreen::onAttributeListViewSelectedItemMessage(AttributeListView* pSender, string attributeName) { string attName = XmlParser::GetAttName(U2A(attributeName.c_str())); string attType = XmlParser::GetAttType(U2A(attributeName.c_str())); string attData = XmlParser::GetAttData(U2A(attributeName.c_str())); //全局 m_attName = attName; AttributeEditView* pAttributeEditView = (AttributeEditView*)getViewByID(ID_ATTRIBUTE_EDIT_VIEW); pAttributeEditView->setAttName(A2U(attName.c_str())); pAttributeEditView->setTypeName(A2U(attType.c_str())); pAttributeEditView->setData(A2U(attData.c_str())); pAttributeEditView->setEnabled(true); }
void irc_notify_player_list(irc_session_t *session,const char *channel,const char *players) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); wxString c=A2U(channel); wxString p=A2U(players); wxStringTokenizer tkz(p,wxT(" \t")); CslIrcEvent evt(context->Target,CslIrcEvent::NAMES,c); while (tkz.HasMoreTokens()) evt.Strings.Add(tkz.GetNextToken()); wxPostEvent(context->EvtHandler,evt); }
void MainScreen::clientConnect(const char* ip, short post) { if (!m_isLoadConfigFile) { MessageBox(NULL, L"请先正确载入配置文件", L"", 0); return; } FKCW_SimpleNet_InetAddress oAddres; oAddres.setIp(ip); oAddres.setPort(post); NetworkClient::sharedDelegate()->setInetAddress(oAddres); NetworkClient::sharedDelegate()->setSoTimeout(3.0f); NetworkClient::sharedDelegate()->registerOnConnected(this, netclient_backcall_selector(MainScreen::onClientConnected)); NetworkClient::sharedDelegate()->registerOnConnectTimeout(this, netclient_backcall_selector(MainScreen::onClientConnectTimeout)); NetworkClient::sharedDelegate()->registerOnMessageReceived(this, netclient_backcall_received_selector(MainScreen::onClientMessageReceived)); NetworkClient::sharedDelegate()->registerOnExceptionCaught(this, netclient_backcall_selector(MainScreen::onClientExceptionCaught)); NetworkClient::sharedDelegate()->registerOnDisconnected(this, netclient_backcall_selector(MainScreen::onClientDisconnected)); NetworkClient::sharedDelegate()->registerOnConnectedEnded(this, netclient_backcall_selector(MainScreen::onClientConnectedEnded)); NetworkClient::sharedDelegate()->connect(); LogView* pClientLogView = (LogView*)getViewByID(ID_CLIENT_LOG_VIEW); pClientLogView->log(A2U("尝试连接服务器...")); }
void MainScreen::onFileViewOpenFileMessage(string strFilePathName) { //载入XML文件 bool isCorrectLoad = XmlParser::getInstance()->loadFile(U2A(strFilePathName.c_str()).c_str()); if (!isCorrectLoad) { MessageBox(NULL, L"加载XML失败", L"错误", 0); m_isLoadConfigFile = false; return; } m_isLoadConfigFile = true; LogView* pClientLogView = (LogView*)getViewByID(ID_CLIENT_LOG_VIEW); pClientLogView->log(A2U("配置文件加载成功")); //更新MessageListView数据源 MessageListView* pMessageListView = (MessageListView*)getViewByID(ID_MESSAGE_LIST_VIEW); pMessageListView->updateDataResouse(); AttributeListView* pAttributeListView = (AttributeListView*)getViewByID(ID_ATTRIBUTE_LIST_VIEW); pAttributeListView->setTitle(""); pAttributeListView->clear(); FKCW_UIWidget_Button* pAddMessageButton = (FKCW_UIWidget_Button*)getViewByID(ID_ADD_MAIN_MESSAGE_BUTTON); pAddMessageButton->setEnabled(true); }
void MainScreen::onAttributeListViewDataSourceMessage(AttributeListView* pSender) { vector<string> attributeItems = XmlParser::getInstance()->getAttributeCstrings(m_mainType, m_subType); for (unsigned int i = 0; i < attributeItems.size(); i++) { string item = attributeItems.at(i); int cutIndex = item.find(")") + 2; string head = item.substr(0, cutIndex); string tail = item.substr(cutIndex); /* //处理超长字符串 if (tail.size() > 8) { tail = tail.substr(0, 8) + "..."; } */ pSender->addItem(A2U((head + tail).c_str())); } pSender->addItemAddButton(); AttributeEditView* pAttributeEditView = (AttributeEditView*)getViewByID(ID_ATTRIBUTE_EDIT_VIEW); pAttributeEditView->setEnabled(false); }
void MainScreen::onMessageListViewReviseSubItemMessage(MessageListView* pSender, string mainTitle, string subTitle) { short mainType = XmlParser::GetMainType(U2A(mainTitle.c_str())); short subType = XmlParser::GetSubType(U2A(subTitle.c_str())); string subName = XmlParser::GetNoFBTypeToSubName(U2A(subTitle.c_str())); short fbm = XmlParser::getInstance()->getSubElementFBM(mainType, subType); short fbs = XmlParser::getInstance()->getSubElementFBS(mainType, subType); char cFbm[15]; char cFbs[15]; char cSubType[15]; _itoa(fbm, cFbm, 10); _itoa(fbs, cFbs, 10); _itoa(subType, cSubType, 10); ReviseSubMessageDialog* pReviseSubMessageDialog = ReviseSubMessageDialog::create(mainType, subType); pReviseSubMessageDialog->setPosition(SCREEN_CENTER_POS); pReviseSubMessageDialog->setEditBoxFbm(cFbm); pReviseSubMessageDialog->setEditBoxFbs(cFbs); pReviseSubMessageDialog->setEditBoxSubName(A2U(subName.c_str())); pReviseSubMessageDialog->setEditBoxSubType(cSubType); m_pWindow->addChild(pReviseSubMessageDialog); pReviseSubMessageDialog->setDelegate(this); }
void event_quit(irc_session_t *session,const char* WXUNUSED(event), const char *origin,const char **params,unsigned int count) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target,CslIrcEvent::QUIT,A2U(origin)); if (count>0) evt.AddCharData(params[0]); wxPostEvent(context->EvtHandler,evt); }
void event_privmsg(irc_session_t *session,const char* WXUNUSED(event), const char *origin,const char **params,unsigned int count) { if (count<2 || !*params[1]) return; CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target,CslIrcEvent::PRIVMSG,A2U(origin)); evt.AddCharData(params[1]); wxPostEvent(context->EvtHandler,evt); }
void MainScreen::serverClose() { if (m_pNetworkServer != NULL) { m_pNetworkServer->close(); m_pNetworkServer = NULL; } IpPostView* pListenView = (IpPostView*)getViewByID(ID_LISTEN_VIEW); pListenView->setButtonText(A2U("监听").c_str()); }
void event_ctcp_action(irc_session_t *session,const char* WXUNUSED(event),const char *origin, const char **params,unsigned int count) { if (count<2) return; CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target,CslIrcEvent::ACTION,A2U(params[0])); evt.AddCharData(origin); evt.AddCharData(params[1]); wxPostEvent(context->EvtHandler,evt); }
bool QtSnapshot::SaveImage(char* OutPutName) { #ifdef WIN32 std::wstring tem = A2U(OutPutName); QString saveName = ""; saveName = QString::fromStdWString(tem); bool bRet = this->QPImgGrab.save(saveName, "png"); #else bool bRet = this->QPImgGrab.save(OutPutName, "png"); #endif return bRet; }
void MainScreen::onMessageListViewSelectedSubItemMessage(MessageListView* pSender, string mainTitle, string subTitle) { //为全局变量赋值 m_mainType = XmlParser::GetMainType(U2A(mainTitle.c_str())); m_subType = XmlParser::GetSubType(U2A(subTitle.c_str())); short fbm = XmlParser::getInstance()->getSubElementFBM(m_mainType, m_subType); short fbs = XmlParser::getInstance()->getSubElementFBS(m_mainType, m_subType); char cFbm[26]; char cFbs[26]; _itoa(fbm, cFbm, 10); _itoa(fbs, cFbs, 10); AttributeListView* pAttributeListView = (AttributeListView*)getViewByID(ID_ATTRIBUTE_LIST_VIEW); pAttributeListView->setTitle(subTitle); pAttributeListView->setSubTitle(A2U(" 反馈主类型:") + cFbm + A2U(" 反馈子类型:") + cFbs); pAttributeListView->updateDataResouse(); FKCW_UIWidget_Button* pSendMessageButton = (FKCW_UIWidget_Button*)getViewByID(ID_SEND_MESSAGE_BUTTON); pSendMessageButton->setEnabled(true); }
void MainScreen::onSendButtonClick(CCObject* pSender) { FKCW_SimpleNet_Buffer sBuffer; MsgPack sMsgPack = XmlParser::getInstance()->getMsgPack(m_mainType, m_subType); MsgPackUnpack::pack(sBuffer, sMsgPack); NetworkClient::sharedDelegate()->send(&sBuffer); char clog[128]; sprintf(clog, "开始发送消息: MainType-%d SubType-%d", m_mainType, m_subType); LogView* pClientLogView = (LogView*)getViewByID(ID_CLIENT_LOG_VIEW); pClientLogView->log(A2U(clog)); }
void event_nick(irc_session_t *session, const char* WXUNUSED(event), const char *origin,const char **params,unsigned int count) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); if (count<1) return; CslIrcEvent evt(context->Target,CslIrcEvent::NICK,A2U(origin)); if (context->Server->Network->Nick==A2U(origin)) { context->Server->Network->Nick=A2U(params[0]); evt.Ints.Add(1); } else evt.Ints.Add(0); evt.Strings.Add(A2U(params[0])); wxPostEvent(context->EvtHandler,evt); }
// update information for current-cursor position --------------------------- void __fastcall TPlot::UpdatePoint(int x, int y) { gtime_t time; TPoint p(x,y); double enu[3]={0},rr[3],pos[3],xx,yy,r,xl[2],yl[2],q[2],az,el,snr; int i; char tstr[64]; AnsiString msg; trace(4,"UpdatePoint: x=%d y=%d\n",x,y); if (PlotType==PLOT_TRK) { // track-plot if (norm(OPos,3)>0.0) { GraphT->ToPos(p,enu[0],enu[1]); ecef2pos(OPos,pos); enu2ecef(pos,enu,rr); for (i=0;i<3;i++) rr[i]+=OPos[i]; ecef2pos(rr,pos); msg=LatLonStr(pos,8); } } else if (PlotType==PLOT_SKY||PlotType==PLOT_MPS) { // sky-plot GraphS->GetLim(xl,yl); GraphS->ToPos(p,q[0],q[1]); r=(xl[1]-xl[0]<yl[1]-yl[0]?xl[1]-xl[0]:yl[1]-yl[0])*0.45; if ((el=90.0-90.0*norm(q,2)/r)>0.0) { az=el>=90.0?0.0:ATAN2(q[0],q[1])*R2D; if (az<0.0) az+=360.0; msg.sprintf("AZ=%5.1f" CHARDEG " EL=%4.1f" CHARDEG,az,el); } } else if (PlotType==PLOT_SNRE) { // snr-el-plot GraphE[0]->ToPos(p,q[0],q[1]); msg.sprintf("EL=%4.1f " CHARDEG,q[0]); } else { GraphG[0]->ToPos(p,xx,yy); time=gpst2time(Week,xx); if (TimeLabel==2) time=utc2gpst(time); // UTC else if (TimeLabel==3) time=timeadd(gpst2utc(time),-9*3600.0); // JST TimeStr(time,0,1,tstr); msg=tstr; } Panel22->Visible=true; Message2->Caption=A2U(msg); }
bool CslGameRedEclipse::ParseTeamPong(wxUint32 protocol,ucharbuf& buf,CslTeamStatsData& info) const { wxInt32 i; char text[_MAXDEFSTR]; getstring(text,buf); info.Name=A2U(text); info.Score=getint(buf); i=getint(buf); if (i>0) while (i--) info.Bases.add(getint(buf)); return !buf.overread(); }
//------------------------------------------------------------------------- int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); AppDelegate app; CCEGLView* eglView = CCEGLView::sharedOpenGLView(); eglView->setViewName(A2U("FKImageTool图片格式转译&查看工具").c_str()); eglView->setFrameSize(1624, 1024); eglView->setFrameZoomFactor(0.8f); return CCApplication::sharedApplication()->run(); }
// show legand in status-bar ------------------------------------------------ void __fastcall TPlot::ShowLegend(AnsiString *msgs) { TLabel *ql[]={QL1,QL2,QL3,QL4,QL5,QL6,QL7}; int i,sel=!BtnSol1->Down&&BtnSol2->Down?1:0; trace(3,"ShowLegend\n"); for (i=0;i<7;i++) { if (!msgs||msgs[i]=="") { ql[i]->Caption=" "; ql[i]->Width=1; } else { ql[i]->Caption=A2U(msgs[i]); ql[i]->Font->Color=MColor[sel][i+1]; } } }
void event_kick(irc_session_t *session,const char* WXUNUSED(event), const char *origin,const char **params,unsigned count) { if (count<2) return; CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target,CslIrcEvent::KICK,A2U(params[0])); evt.AddCharData(origin); if (count>1) { evt.AddCharData(params[1]); if (count>2) evt.AddCharData(params[2]); } wxPostEvent(context->EvtHandler,evt); }
static pascal OSErr MacCallbackGetUrl(const AppleEvent *in,AppleEvent *out,long ptr) { Size l=0; OSErr err=noErr; DescType type=typeChar; if ((err=AESizeOfParam(in,keyDirectObject,&type,&l))==noErr && l) { char buf[l+1]; if ((err=AEGetParamPtr(in,keyDirectObject,type,0,&buf,l,&l))==noErr && l) { buf[l]=0; const CslApp& app=::wxGetApp(); app.IpcCall(A2U(buf),app.GetTopWindow()); } } return noErr; }
void CslIrcThread::LibIrcError(CslIrcContext *context,wxInt32 error) { LOG_DEBUG("libirc error (%d): \n",error,irc_strerror(errno)); wxEvtHandler *handler=context->EvtHandler; CslIrcEvent evt(context->Target,CslIrcEvent::ERR); evt.Strings.Add(A2U(irc_strerror(error))); evt.Ints.Add(error); switch (error) { case LIBIRC_ERR_INVAL: wxASSERT_MSG(error!=LIBIRC_ERR_INVAL,wxT("Invalid arguments.")); break; case LIBIRC_ERR_RESOLV: case LIBIRC_ERR_SOCKET: case LIBIRC_ERR_CONNECT: case LIBIRC_ERR_CLOSED: case LIBIRC_ERR_NOMEM: RemoveContext(context); break; case LIBIRC_ERR_ACCEPT: case LIBIRC_ERR_NODCCSEND: case LIBIRC_ERR_READ: case LIBIRC_ERR_WRITE: case LIBIRC_ERR_STATE: case LIBIRC_ERR_TIMEOUT: case LIBIRC_ERR_OPENFILE: break; case LIBIRC_ERR_TERMINATED: RemoveContext(context); break; } wxPostEvent(handler,evt); }
void MainScreen::onServerExceptionCaught() { LogView* pServerLogView = (LogView*)getViewByID(ID_SERVER_LOG_VIEW); pServerLogView->safeModeLog(A2U("服务器已关闭")); }
void MainScreen::onServerDisconnected() { LogView* pServerLogView = (LogView*)getViewByID(ID_SERVER_LOG_VIEW); pServerLogView->safeModeLog(A2U("与客户端连接断开")); }