// требует установки diCurr bool LoadConnect(uchar ibCanal) { if (fConnect == 1) { if ((diLast.ibPort == 0xFF) || (diLast.ibPhone == 0xFF)) { KeyBreakConnect(); return(0); } else if (BreakConnect() == 1) { if (NeedDisconnect() == 1) { diNext = diCurr; diCurr = diLast; bool fAlt = SafeDisconnect(); diCurr = diNext; if (fAlt == 0) { ShowLo(szNoDisconnect); InitConnect(); return(0); } } ibDig = ibCanal; if (SafeConnect() == 0) { ShowLo(szNoConnect); InitConnect(); return(0); } } else ibDig = ibCanal; } else { ibDig = ibCanal; if (SafeConnect() == 0) { ShowLo(szNoConnect); InitConnect(); return(0); } } return(1); }
void ampsWidgetAutheticateUser::Init(void) { m_UI.m_lineEditPassword->setEchoMode(QLineEdit::Password); m_UI.m_lineEditUsername->setText("qck"); m_UI.m_lineEditPassword->setText("magic"); InitConnect(); }
void CUdpClient::handle_read(unsigned char * buf,const boost::system::error_code& error,size_t bytes_transferred) { if(!error) { RecordFrameData(buf,bytes_transferred,true); //调用CProtocol模块处理recvbuf中bytes_transferred字节的报文 if (protocol_) { protocol_->RecvProcess(buf,bytes_transferred); } //再继续读数据 ReadFromConnect(buf); } else { AddStatusLogWithSynT("UdpClient通道读数据过程中发生错误\n"); CloseConnect(); UninitConnect(); InitConnect(); OpenConnect(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); m_pScheAlgo = nullptr; m_Timer = new QTimer; InitWidget(); InitConnect(); }
// Disconnect void _Menu::HandleDisconnect(bool WasSinglePlayer) { if(WasSinglePlayer) { InitTitle(); } else { InitConnect(true); _Label *Label = Assets.Labels["label_menu_connect_message"]; Label->Color = COLOR_RED; Label->Text = "Disconnected from server"; } }
TcpGateDialog::TcpGateDialog(QDialog *parent) : QDialog(parent), ui(new Ui::TcpGateDialog) { ui->setupUi(this); connect(ui->btnClear, SIGNAL(clicked()), this, SLOT(onClkBtnClear())); connect(ui->btnAbout, SIGNAL(clicked()), this, SLOT(onClkBtnAbout())); connect(ui->btnHome, SIGNAL(clicked()), this, SLOT(onClkBtnHome())); connect(&m_timer, SIGNAL(timeout()), this, SLOT(onTimer())); InitListen(); InitConnect(); }
// Handle mouse event void _Menu::MouseEvent(const _MouseEvent &MouseEvent) { if(State == STATE_NONE) return; if(!CurrentLayout) return; if(MouseEvent.Button == SDL_BUTTON_LEFT) CurrentLayout->HandleInput(MouseEvent.Pressed); // Get clicked element _Element *Clicked = CurrentLayout->GetClickedElement(); if(Clicked) { bool DoubleClick = false; if(PreviousClick == Clicked && PreviousClickTimer < MENU_DOUBLECLICK_TIME) { PreviousClick = nullptr; DoubleClick = true; } else PreviousClick = Clicked; PreviousClickTimer = 0.0; switch(State) { case STATE_TITLE: { if(Clicked->Identifier == "button_title_play") { PlayState.Connect(true); } else if(Clicked->Identifier == "button_title_joinserver") { InitConnect(true); } else if(Clicked->Identifier == "button_title_mapeditor") { InitEditor(); } else if(Clicked->Identifier == "button_title_exit") { Framework.Done = true; } } break; case STATE_CHARACTERS: { if(CharactersState == CHARACTERS_NONE) { if(Clicked->Identifier == "button_characters_delete") { size_t SelectedSlot = GetSelectedCharacter(); if(SelectedSlot < CharacterSlots.size() && CharacterSlots[SelectedSlot].Used) { _Buffer Packet; Packet.Write<PacketType>(PacketType::CHARACTERS_DELETE); Packet.Write<uint8_t>((uint8_t)SelectedSlot); PlayState.Network->SendPacket(Packet); } } else if(Clicked->Identifier == "button_characters_play") { size_t SelectedSlot = GetSelectedCharacter(); if(SelectedSlot < CharacterSlots.size() && CharacterSlots[SelectedSlot].Used) { PlayCharacter(SelectedSlot); } } else if(Clicked->Identifier == "button_characters_back") { PlayState.Network->Disconnect(); } else if(Clicked->Identifier.substr(0, CharacterButtonPrefix.size()) == CharacterButtonPrefix) { // Deselect slots _Element *CharactersElement = Assets.Elements["element_menu_characters"]; for(auto &Element : CharactersElement->Children) { if(Element->Identifier.substr(0, CharacterButtonPrefix.size()) == CharacterButtonPrefix) { _Button *Button = (_Button *)Element; Button->Checked = false; } } // Set selection size_t SelectedSlot = (size_t)(intptr_t)Clicked->UserData; CharacterSlots[SelectedSlot].Button->Checked = true; // Open new character screen if(!CharacterSlots[SelectedSlot].Used) InitNewCharacter(); UpdateCharacterButtons(); if(DoubleClick && SelectedSlot < CharacterSlots.size()) { PlayCharacter(SelectedSlot); } } } else if(CharactersState == CHARACTERS_CREATE) { if(Clicked->Identifier == NewCharacterPortraitPrefix || Clicked->Identifier == NewCharacterBuildPrefix) { size_t SelectedID = (size_t)(intptr_t)Clicked->UserData; // Unselect all portraits and select the clicked element for(auto &Element : Clicked->Parent->Children) { _Button *Button = (_Button *)Element; Button->Checked = false; if((size_t)(intptr_t)Button->UserData == SelectedID) { _TextBox *Name = Assets.TextBoxes["textbox_newcharacter_name"]; FocusedElement = Name; Name->ResetCursor(); Button->Checked = true; } } ValidateCreateCharacter(); } else if(Clicked->Identifier == "button_newcharacter_create") { CreateCharacter(); } else if(Clicked->Identifier == "button_newcharacter_cancel") { RequestCharacterList(); } } } break; case STATE_CONNECT: { if(Clicked->Identifier == "button_connect_connect") { if(!PlayState.Network->IsDisconnected()) { PlayState.Network->Disconnect(true); InitConnect(false); } else ConnectToHost(); } else if(Clicked->Identifier == "button_connect_back") { InitTitle(true); } } break; case STATE_ACCOUNT: { if(Clicked->Identifier == "button_account_login") { SendAccountInfo(); } else if(Clicked->Identifier == "button_account_create") { SendAccountInfo(true); } else if(Clicked->Identifier == "button_account_back") { InitConnect(true); } } break; case STATE_INGAME: { if(Clicked->Identifier == "button_ingame_resume") { InitPlay(); } else if(Clicked->Identifier == "button_ingame_disconnect") { PlayState.Network->Disconnect(); } } break; default: break; } } }
// Handle key event void _Menu::KeyEvent(const _KeyEvent &KeyEvent) { if(State == STATE_NONE) return; switch(State) { case STATE_TITLE: { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) Framework.Done = true; else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) { PlayState.Connect(true); } } } break; case STATE_CHARACTERS: { if(CharactersState == CHARACTERS_NONE) { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) PlayState.Network->Disconnect(); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) { size_t SelectedSlot = GetSelectedCharacter(); if(SelectedSlot >= CharacterSlots.size()) SelectedSlot = 0; if(CharacterSlots[SelectedSlot].Used) { PlayCharacter(SelectedSlot); } } } } else if(CharactersState == CHARACTERS_CREATE){ ValidateCreateCharacter(); if(KeyEvent.Pressed) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) RequestCharacterList(); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) CreateCharacter(); } } } break; case STATE_CONNECT: { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) InitTitle(true); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) ConnectToHost(); else if(KeyEvent.Scancode == SDL_SCANCODE_TAB) FocusNextElement(); } } break; case STATE_ACCOUNT: { if(KeyEvent.Pressed && !KeyEvent.Repeat) { if(KeyEvent.Scancode == SDL_SCANCODE_ESCAPE) InitConnect(true); else if(KeyEvent.Scancode == SDL_SCANCODE_RETURN) SendAccountInfo(); else if(KeyEvent.Scancode == SDL_SCANCODE_TAB) FocusNextElement(); } } break; case STATE_INGAME: { } break; default: break; } }
void InitConnectKey(void) { InitConnect(); //fQuery = 0; }