void MpClientSetupUi::initWindow() { window->SetStyle(Style::Fullscreen); window->SetRequisition(Vector2f((float)ct::WindowWidth, (float)ct::WindowHeight)); mainBox = Box::Create(Box::Orientation::VERTICAL, 5); auto closeButton = Button::Create("Close"); closeButton->GetSignal(Widget::OnLeftClick).Connect(backAction); mainBox->Pack(createAlignment(closeButton, Vector2f(0.0f, 0.0f), Vector2f(1.0f, 0.0f))); nameEntry = Entry::Create("Player 1"); nameEntry->SetMaximumLength(10); auto nameFrame = Frame::Create("Your name:"); nameFrame->Add(nameEntry); nameFrame->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.3f)); mainBox->Pack(createAlignment(nameFrame, Vector2f(0.5f, 0.0f), Vector2f(1.0f, 0.0f))); serverBox = Box::Create(Box::Orientation::VERTICAL, 5); auto serverFrame = Frame::Create("Avaliable servers:"); serverFrame->Add(serverBox); serverFrame->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.5f)); mainBox->Pack(serverFrame, true, true); window->Add(createAlignment(mainBox, Vector2f(0.5f, 0.5f), Vector2f(0.9f, 0.9f))); }
void MpHostSetupUi::initWindow() { window->SetStyle(Style::Fullscreen); window->SetRequisition(Vector2f((float)ct::WindowWidth, (float)ct::WindowHeight)); mainBox = Box::Create(Box::Orientation::VERTICAL, 5); auto closeButton = Button::Create("Close"); closeButton->GetSignal(Widget::OnLeftClick).Connect(backAction); mainBox->Pack(createAlignment(closeButton, Vector2f(0.0f, 0.0f), Vector2f(1.0f, 0.0f))); auto nameBox = Box::Create(Box::Orientation::HORIZONTAL, 5); nameEntry = Entry::Create("Player 1"); nameEntry->SetMaximumLength(10); nameEntry->SetRequisition(Vector2f(ct::WindowWidth * 0.1f, 0.0f)); auto createButton = Button::Create("Create"); createButton->GetSignal(Widget::OnLeftClick).Connect(bind(&MpHostSetupUi::triggerCreateServer, this)); nameBox->Pack(nameEntry, true, true); nameBox->Pack(createButton, true, true); nameFrame = Frame::Create("Your name:"); nameFrame->Add(nameBox); nameFrame->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.1f)); mainBox->Pack(createAlignment(nameFrame, Vector2f(0.5f, 0.01f), Vector2f(1.0f, 0.0f))); window->Add(createAlignment(mainBox, Vector2f(0.5f, 0.5f), Vector2f(0.9f, 0.9f))); }
void MpHostSetupUi::createServer() { string name = nameEntry->GetText(); if (name.empty()) { return; } nameEntry = nullptr; nameFrame->RemoveAll(); auto nameLabel = Label::Create(name); nameLabel->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.05f)); nameLabel->SetAlignment(Vector2f(0.5f, 0.5f)); nameFrame->Add(createAlignment(nameLabel, Vector2f(0.5f, 0.5f), Vector2f(0.0f, 0.0f))); mainBox->Pack(Label::Create("Waiting for players..."), false, false); playerBox = Box::Create(Box::Orientation::VERTICAL, 5); auto playerFrame = Frame::Create("Currently connected:"); playerFrame->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.5f)); playerFrame->Add(playerBox); mainBox->Pack(playerFrame, true, true); auto startButton = Button::Create("Start game!"); startButton->GetSignal(Widget::OnLeftClick).Connect(startGameAction); mainBox->Pack(startButton, false, false); createServerAction(name); }
std::string generate_consensus(const std::vector<std::string>& sequences, const std::vector<std::string>& qualities, AlignmentParams params, bool sorted) { std::vector<uint32_t> indices; prepare_indices(indices, sequences, sorted); std::shared_ptr<Graph> graph = createGraph(sequences[indices.front()], qualities[indices.front()]); graph->topological_sort(); for (uint32_t i = 1; i < sequences.size(); ++i) { auto alignment = createAlignment(sequences[indices[i]], graph, params); alignment->align_sequence_to_graph(); alignment->backtrack(); graph->add_alignment(std::move(alignment), sequences[indices[i]], qualities[indices[i]]); } return graph->generate_consensus(); }
void MainMenuUi::initWindow() { window->SetStyle(Style::Fullscreen); window->SetRequisition(Vector2f((float) ct::WindowWidth, (float) ct::WindowHeight)); auto mMpLabel = Label::Create("Minesweeper: Multiplayer Edition"); mMpLabel->SetAlignment(Vector2f(0.5f, 0.5f)); mMpLabel->SetClass("MMpLabel"); auto playSpButton = Button::Create("Play Singleplayer"); playSpButton->GetSignal(Widget::OnLeftClick).Connect(playSpAction); auto playLocalMpButton = Button::Create("Play Local Multiplayer"); playLocalMpButton->GetSignal(Widget::OnLeftClick).Connect(playLocalMpAction); auto exitButton = Button::Create("Exit"); exitButton->GetSignal(Widget::OnLeftClick).Connect(exitAction); auto mainBox = Box::Create(Box::Orientation::VERTICAL, 2); auto playBox = Box::Create(Box::Orientation::VERTICAL, 2); playBox->Pack(playSpButton); playBox->Pack(playLocalMpButton); auto playFrame = Frame::Create("Play"); playFrame->Add(playBox); playFrame->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.2f)); auto boardSizeBox = Box::Create(Box::Orientation::HORIZONTAL, 5); boardSizeScale = Scale::Create(8.0f, 20.0f, 1.0f, Scale::Orientation::HORIZONTAL); boardSizeScale->SetValue(15.0f); boardSizeScale->SetRequisition(Vector2f(0.0f, ct::WindowWidth * 0.08f)); boardSizeScale->GetAdjustment()->GetSignal(Adjustment::OnChange) .Connect(bind(&MainMenuUi::updateBoardSize, this)); boardSizeLabel = Label::Create(); boardSizeLabel->SetRequisition(Vector2f(ct::WindowWidth * 0.05f, 0.0f)); boardSizeBox->Pack(Label::Create("Size:"), false, false); boardSizeBox->Pack(createAlignment(boardSizeScale, Vector2f(0.5f, 0.5f), Vector2f(1.0f, 1.0f))); boardSizeBox->Pack(createAlignment(boardSizeLabel, Vector2f(1.0f, 0.5f), Vector2f(0.0f, 0.0f)), false, false); auto mineCountBox = Box::Create(Box::Orientation::HORIZONTAL, 5); mineCountScale = Scale::Create(Range::Orientation::HORIZONTAL); mineCountScale->SetIncrements(1.0f, 1.0f); mineCountScale->SetRequisition(Vector2f(0.0f, ct::WindowWidth * 0.08f)); mineCountScale->GetAdjustment()->GetSignal(Adjustment::OnChange) .Connect(bind(&MainMenuUi::updateMineCount, this)); mineCountLabel = Label::Create(); mineCountLabel->SetRequisition(Vector2f(ct::WindowWidth * 0.05f, 0.0f)); mineCountBox->Pack(Label::Create("Mines: "), false, false); mineCountBox->Pack(createAlignment(mineCountScale, Vector2f(0.5f, 0.5f), Vector2f(1.0f, 1.0f))); mineCountBox->Pack(createAlignment(mineCountLabel, Vector2f(1.0f, 0.5f), Vector2f(0.0f, 0.0f)), false, false); updateBoardSize(); auto settingsBox = Box::Create(Box::Orientation::VERTICAL, 0); settingsBox->Pack(boardSizeBox); settingsBox->Pack(mineCountBox); auto settingsFrame = Frame::Create("Settings"); settingsFrame->Add(settingsBox); settingsFrame->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.15f)); mainBox->Pack(mMpLabel); mainBox->Pack(playFrame); mainBox->Pack(settingsFrame); mainBox->Pack(exitButton); window->Add(createAlignment(mainBox, Vector2f(0.5f, 0.5f), Vector2f(0.7f, 0.7f))); }
void GameUi::initWindow() { window->SetStyle(Style::Fullscreen); window->SetRequisition(Vector2f((float)ct::WindowWidth, (float)ct::WindowHeight)); auto mainBox = Box::Create(Box::Orientation::VERTICAL); auto topBox = Box::Create(Box::Orientation::HORIZONTAL); auto backButton = Button::Create("Back"); backButton->GetSignal(Widget::OnLeftClick).Connect(closeAction); topBox->Pack(backButton, false, false); clockLabel = Label::Create("00:00"); clockLabel->SetAlignment(Vector2f(1.0f, 0.5f)); topBox->Pack(createAlignment(clockLabel, Vector2f(1.0f, 0.5f)), true, true); auto middleBox = Box::Create(Box::Orientation::HORIZONTAL); auto gameBox = Box::Create(Box::Orientation::HORIZONTAL, 5); auto table = Table::Create(); int buttonSize = (int) (ct::WindowHeight * 0.7 / gameSettings.boardSize); for (int l = 0; l < gameSettings.boardSize; l++) { for (int c = 0; c < gameSettings.boardSize; c++) { auto tileButton = getNewButton(l, c, buttonSize); tileButtons[l][c] = tileButton; table->Attach(tileButton, Rect<Uint32>(c, l, 1, 1)); } } gameBox->Pack(table, false, false); if (gameSettings.isMp) { auto rightPane = Box::Create(Box::Orientation::VERTICAL); rightPane->Pack(scoreboard.getWidget()); auto turnFrame = Frame::Create("Turn"); auto turnBox = Box::Create(Box::Orientation::VERTICAL, 5); revealCountBar = ProgressBar::Create(ProgressBar::Orientation::HORIZONTAL); revealCountBar->SetFraction(0); revealCountBar->SetRequisition(Vector2f(10, 10)); turnBox->Pack(revealCountBar); auto turnEndButton = Button::Create("End turn"); turnEndButton->GetSignal(Widget::OnLeftClick).Connect(bind(&GameUi::onTurnEnd, this)); turnBox->Pack(turnEndButton); turnFrame->Add(turnBox); rightPane->Pack(turnFrame); gameBox->Pack(rightPane); } middleBox->Pack(createAlignment(gameBox, Vector2f(0.5f, 0.5f))); auto bottomBox = Box::Create(Box::Orientation::HORIZONTAL); messageLabel = Label::Create("Good luck!"); messageTimeout = sf::seconds(3); bottomBox->Pack(messageLabel, false, true); bottomBox->Pack(Separator::Create(Separator::Orientation::VERTICAL), true, true); flagCountLabel = Label::Create(getFlagCountStr()); auto mineCountLabel = Label::Create(string("/") + to_string(gameSettings.mineCount)); auto mineStatBox = Box::Create(Box::Orientation::HORIZONTAL, 2); mineStatBox->Pack(flagCountLabel, false, false); mineStatBox->Pack(mineCountLabel, false, false); bottomBox->Pack(createAlignment(mineStatBox, Vector2f(1.0f, 0.5f), Vector2f(0.0f, 0.0f)), true, true); mainBox->Pack(topBox, true, true); mainBox->Pack(gameBox, true, true); mainBox->Pack(bottomBox, true, true); window->Add(createAlignment(mainBox, Vector2f(0.5f, 0.5f), Vector2f(0.0f, 0.0f))); selectTile(selectedPoint); }