void MainWindow::on_actionStart_Server_triggered() { ServerDialog *dialog = new ServerDialog(this); if (!dialog->config()) return; server = new Server(this); if (!server->listen()) { QMessageBox::warning(this, tr("Warning"), tr("Can not start server!")); return; } server->daemonize(); ui->actionStart_Game->disconnect(); #ifdef QT_NO_PROCESS ui->actionStart_Game->setEnabled(false); #else connect(ui->actionStart_Game, SIGNAL(triggered()), this, SLOT(startGameInAnotherInstance())); #endif StartScene *start_scene = qobject_cast<StartScene *>(scene); if (start_scene) { start_scene->switchToServer(server); if (Config.value("EnableMinimizeDialog", false).toBool()) this->on_actionMinimize_to_system_tray_triggered(); } }
void MainWindow::on_actionStart_Server_triggered() { ServerDialog *dialog = new ServerDialog(this); if(!dialog->config()) return; Server *server = new Server(this); if(!server->listen()){ QMessageBox::warning(this, tr("Warning"), tr("Can not start server!")); server->deleteOnReadyToClose(); server->stop(); return; } this->server = server; connect(this, SIGNAL(about_to_exit()), server, SLOT(stop())); server->daemonize(); ui->actionStart_Game->disconnect(); connect(ui->actionStart_Game, SIGNAL(triggered()), this, SLOT(startGameInAnotherInstance())); StartScene *start_scene = qobject_cast<StartScene *>(scene); if(start_scene){ start_scene->switchToServer(server); if(Config.value("EnableMinimizeDialog", false).toBool()) this->on_actionMinimize_to_system_tray_triggered(); } }
void MainWindow::on_actionStart_Server_triggered() { ServerDialog *dialog = new ServerDialog(this); int accept_type = dialog->config(); if (accept_type == 0) return; server = new Server(this); if (!server->listen()) { QMessageBox::warning(this, tr("Warning"), tr("Can not start server!")); return; } server->checkUpnpAndListServer(); if (accept_type == 1) { server->daemonize(); ui->actionStart_Game->disconnect(); connect(ui->actionStart_Game, SIGNAL(triggered()), this, SLOT(startGameInAnotherInstance())); StartScene *start_scene = qobject_cast<StartScene *>(scene); if (start_scene) { start_scene->switchToServer(server); if (Config.value("EnableMinimizeDialog", false).toBool()) this->on_actionMinimize_to_system_tray_triggered(); } } else { Config.HostAddress = "127.0.0.1"; startConnection(); } }
int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status, size_t total, size_t remaining) { if (status == DOWNLOAD_STATUS_CANCELLED) return -1; ServerDialog *sd = reinterpret_cast<ServerDialog*>(ptr); bool finished = false; if (status == DOWNLOAD_STATUS_COMPLETE) { finished = true; } else if (status < 0) { logger->log("Error retreiving server list: %s", sd->mDownload->getError()); sd->mDownloadStatus = DOWNLOADING_ERROR; } else { float progress = (float) remaining / total; if (progress != progress) progress = 0.0f; // check for NaN else if (progress < 0.0f) progress = 0.0f; // no idea how this could ever happen, but why not check for it anyway. else if (progress > 1.0f) progress = 1.0f; MutexLocker lock(&sd->mMutex); sd->mDownloadStatus = DOWNLOADING_IN_PROGRESS; sd->mDownloadProgress = progress; } if (finished) { sd->loadServers(); MutexLocker lock(&sd->mMutex); sd->mDownloadStatus = DOWNLOADING_COMPLETE; } return 0; }
void MainWindow::on_actionStart_Server_triggered() { ServerDialog *dialog = new ServerDialog(this); if(!dialog->config()) return; Server *server = new Server(this); if(! server->listen()){ QMessageBox::warning(this, tr("Warning"), tr("Can not start server!")); return; } server->daemonize(); ui->actionStart_Game->disconnect(); connect(ui->actionStart_Game, SIGNAL(triggered()), this, SLOT(startGameInAnotherInstance())); StartScene *start_scene = qobject_cast<StartScene *>(scene); if(start_scene){ start_scene->switchToServer(server); } }
void GameCreatedCallBackWrapper(struct netemu_kaillera *info, struct game* new_game, void *user_data) { ServerDialog *dialog = (ServerDialog*)user_data; dialog->OnGameListChanged(); }
void UserLeaveCallBackWrapper(NETEMU_WORD id, char *user, char *exit_message, void *user_data) { ServerDialog *dialog = (ServerDialog*)user_data; dialog->OnUserListChanged(); }
void UserJoinCallBackWrapper(struct netemu_kaillera *info, char *user, NETEMU_DWORD ping, char connection, void *user_data) { ServerDialog *dialog = (ServerDialog*)user_data; dialog->OnUserListChanged(); }
void ChatCallBackWrapper(char *user, char *message, void *user_data) { ServerDialog *dialog = (ServerDialog*)user_data; dialog->ChatCallBack(user, message); }