void SelectionModelSynchronizer::syncedSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { Q_UNUSED(selected); Q_UNUSED(deselected); if(!_changeSelectionEnabled) return; QItemSelectionModel *selectionModel = qobject_cast<QItemSelectionModel *>(sender()); Q_ASSERT(selectionModel); QItemSelection mappedSelection = selectionModel->selection(); QItemSelection currentSelectionMapped = mapSelectionFromSource(currentSelection(), selectionModel); QItemSelection checkSelection = currentSelectionMapped; checkSelection.merge(mappedSelection, QItemSelectionModel::Deselect); if(checkSelection.isEmpty()) { // that means the new selection contains the current selection (currentSel - newSel = {}) checkSelection = mappedSelection; checkSelection.merge(currentSelectionMapped, QItemSelectionModel::Deselect); if(checkSelection.isEmpty()) { // that means the current selection contains the new selection (newSel - currentSel = {}) // -> currentSel == newSel return; } } setCurrentSelection(mapSelectionToSource(mappedSelection, selectionModel)); }
void SelectionController:: setupGui() { Ui::SaweMainWindow* main = _model->project()->mainWindow(); Ui::MainWindow* ui = main->getItems(); //connect(ui->actionActionAdd_selection, SIGNAL(triggered()), SLOT(receiveAddSelection())); connect(ui->actionActionRemove_selection, SIGNAL(triggered()), SLOT(receiveAddClearSelection())); connect(ui->actionCropSelection, SIGNAL(triggered()), SLOT(receiveCropSelection())); //connect(ui->actionMoveSelection, SIGNAL(toggled(bool)), SLOT(receiveMoveSelection(bool))); //connect(ui->actionMoveSelectionTime, SIGNAL(toggled(bool)), SLOT(receiveMoveSelectionInTime(bool))); ui->actionActionAdd_selection->setEnabled( false ); ui->actionActionRemove_selection->setEnabled( true ); ui->actionCropSelection->setEnabled( true ); ui->actionMoveSelection->setEnabled( false ); ui->actionMoveSelectionTime->setEnabled( false ); Support::ToolBar* toolBarTool = new Support::ToolBar(main); toolBarTool->setObjectName(QString::fromUtf8("toolBarSelectionController")); toolBarTool->setEnabled(true); toolBarTool->setContextMenuPolicy(Qt::NoContextMenu); toolBarTool->setToolButtonStyle(Qt::ToolButtonIconOnly); main->addToolBar(Qt::TopToolBarArea, toolBarTool); connect(ui->actionToggleSelectionToolBox, SIGNAL(toggled(bool)), toolBarTool, SLOT(setVisible(bool))); connect(toolBarTool, SIGNAL(visibleChanged(bool)), ui->actionToggleSelectionToolBox, SLOT(setChecked(bool))); selectionComboBox_ = new Ui::ComboBoxAction(); toolBarTool->addWidget( selectionComboBox_ ); toolBarTool->addAction( ui->actionActionRemove_selection ); toolBarTool->addAction( ui->actionCropSelection ); toolBarTool->setVisible( true ); connect(_model, SIGNAL(selectionChanged()), SLOT(onSelectionChanged())); //connect(_model->project()->head.get(), SIGNAL(headChanged()), SLOT(tryHeadAsSelection())); connect(selectionComboBox_, SIGNAL(toggled(bool)), SLOT(selectionComboBoxToggled())); connect(this, SIGNAL(enabledChanged(bool)), selectionComboBox_, SLOT(setChecked(bool))); deselect_action_ = new QAction(this); connect(deselect_action_, SIGNAL(triggered()), SLOT(deselect())); deselect_action_->setShortcut(Qt::Key_Escape); addAction(deselect_action_); setCurrentSelection(Signal::OperationDesc::ptr()); toolfactory(); renderview_tool_selector->default_tool = this; #ifdef TARGET_hast ui->actionActionRemove_selection->setVisible(false); ui->actionCropSelection->setVisible(false); #endif }
void SelectionController:: setThisAsCurrentTool( bool active ) { if (!active) setCurrentSelection( Signal::OperationDesc::ptr() ); if (active) renderview_tool_selector->setCurrentToolCommand( this ); else renderview_tool_selector->setCurrentTool( this, active ); }
// Set our start values and load our menu textures if it's our first time at the screen. MainMenu::MainMenu() { setCurrentSelection(0); setSplashState(true); setChangedSelection(false); setExiting(false); hScoreString = "High score: "; setSelectedTexture("Select"); setSplashTexture("Splash"); setFontMap("Font"); if (!loaded) { loadTexture(selectedTexture, "../textures/select.png", 1, 1); loadTexture(splashTexture, "../textures/splash.bmp", 1, 1); loadTexture(fontMap, "../textures/fontmap.png", 16, 16); } }
void SelectionController:: deselect() { setCurrentSelection(Signal::OperationDesc::ptr()); }
void SetupScreen::update(sf::RenderWindow& window, const sf::Time& delta, const bool& handleInput) { if(!_connected) { _rejoinTimer -= delta.asSeconds(); if(_rejoinTimer <= 0) { _gameSetup->joinServer(); _rejoinTimer = 5; } return; } // handles input if(handleInput && screenState == Screen::Active) { zf::Mouse& mouse = _game.mouse; sf::Vector2f mousePosF = mouse.getWorldPosition(window); if(mouse.left.thisReleased) { if(setupType == GameType::Local) { if(nameBorder1.bound.contains(mousePosF)) { setCurrentSelection(Name1); } else if(nameBorder2.bound.contains(mousePosF)) { setCurrentSelection(Name2); } else if(_startButton.clickBound.contains(mousePosF)) { _game.startLocalGame(player1.name, player2.name); } } else { if(nameBorder1.bound.contains(mousePosF)) { if(player1.uniqueId == "") { _gameSetup->setRole("1"); } } else if(nameBorder2.bound.contains(mousePosF)) { if(player2.uniqueId == "") { _gameSetup->setRole("2"); } } else if(_startButton.clickBound.contains(mousePosF)) { // make sure we are host if(setupType == GameType::Host) { std::string r = _gameSetup->getLocalRole(); PlayerRole::ePlayerRole role; if(r == "1") { role = PlayerRole::PlayerOne; } else if(r == "2") { role = PlayerRole::PlayerTwo; } else { role = PlayerRole::Observer; } _game.startNetworkGame(_gameSetup, role); } } } } else { _startButton.updateSelection(mousePosF); // if it is not local, then the text field is not allow to be edited. // It will become a button if(setupType != GameType::Local) { updateButtonState(nameBorder1, mousePosF); updateButtonState(nameBorder2, mousePosF); } } } }
SetupScreen::SetupScreen(Game& game, GameType::eGameType st, zf::GameSetup* setup) :Screen(game), setupType(st), name1Text("Player1", game.assets.gameScreenAssets.abilityFont, 20), name2Text("Player2", game.assets.gameScreenAssets.abilityFont, 20) , currentSelection(Name1), _gameSetup(setup), _connected(false), _rejoinTimer(0) , waitingForServerText("Waiting for server ...", game.assets.gameScreenAssets.abilityFont, 20) , _startButton(game.assets.setupScreenAssets.startButtonSelected.createSprite(), game.assets.setupScreenAssets.startButton.createSprite(), ButtonSize) { if(st == GameType::Local) { player1.uniqueId = "Player1"; player1.name = "Player1"; player2.uniqueId = "Player2"; player2.name = "Player2"; _connected = true; setCurrentSelection(Name1); } else if(st == GameType::Host) { if(_gameSetup != 0) { _gameSetup->addGameSetupListener(*this); } name1Text.setString(" "); name2Text.setString(" "); player1.uniqueId = ""; player1.name = ""; player1.role = "1"; player2.uniqueId = ""; player2.name = ""; player2.role = "2"; _connected = true; } else { if(_gameSetup != 0) { _gameSetup->addGameSetupListener(*this); } name1Text.setString(" "); name2Text.setString(" "); } // name and the name box // std::vector<sf::Sprite> nameBoxSprites; for(int i = 0 ; i < 4 ; i++) { nameBoxSprites.push_back(game.assets.setupScreenAssets.nameBox.createSprite()); } nameBoxSprites[None].setColor(sf::Color(255,255,255,255)); nameBoxSprites[Hovered].setColor(sf::Color(220,220,110,255)); nameBoxSprites[Disabled].setColor(sf::Color(200,200,165,255)); nameBoxSprites[Active].setColor(sf::Color(255,255,50,255)); nameBorder1 = zf::SpriteGroup(nameBoxSprites); nameBorder1.setPosition(name1Position); name1Text.setPosition(name1Position + nameOffset); name1Text.setColor(sf::Color(0,0,0)); nameBorder2 = zf::SpriteGroup(nameBoxSprites); nameBorder2.setPosition(name2Position); name2Text.setPosition(name2Position + nameOffset); name2Text.setColor(sf::Color(0,0,0)); // VS TEXT sf::Text tmp("VS", game.assets.gameScreenAssets.abilityFont, 40); tmp.setPosition(vsTextPosition); fixedTexts.push_back(tmp); waitingForServerText.setPosition(waitingForServerOffset); _startButton.setPosition(startButtonPosition); }