void parseCordinate(char * cmd) { float feedRate=NAN; float tarX=NAN,tarY=NAN,tarZ=NAN,tarE=NAN; char * tmp; char * str; str = strtok_r(cmd, " ", &tmp); while(str!=NULL){ str = strtok_r(0, " ", &tmp); if(str[0]=='X'){ tarX = atof(str+1); }else if(str[0]=='Y'){ tarY = atof(str+1); }else if(str[0]=='Z'){ tarZ = atof(str+1); }else if(str[0]=='E'){ tarE = atof(str+1); }else if(str[0]=='F'){ feedRate = atof(str+1); feedRate/=60.0f; // change to mm/sec } } prepareMove(tarX,tarY,tarZ,tarE,feedRate); }
void scene::mousePressEvent(QGraphicsSceneMouseEvent *event) { if(event->button()==Qt::LeftButton and currenttool!=-1) { bool check=false; for(int i=0;i<handles.size();i++) { if(handles.at(i)->contains(event->scenePos())) check=true; } if(!check) prepareItem(event->scenePos().toPoint()); else { prepareMove(event->scenePos().toPoint()); } } }
void IntroWidget::onIntroNext() { if (!createNext()) return; moving = 1; prepareMove(); }
void IntroWidget::onIntroBack() { if (!current) return; moving = (current == 4) ? -2 : -1; prepareMove(); }
void NBFolderView::createAndSetupActions() { connect( IconView, SIGNAL( peek( QModelIndex ) ), this, SLOT( doPeek( QModelIndex ) ) ); connect( IconView, SIGNAL( open( QModelIndex ) ), this, SLOT( doOpen( QModelIndex ) ) ); connect( IconView, SIGNAL( open( QString ) ), this, SLOT( doOpen( QString ) ) ); connect( IconView, SIGNAL( contextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) ); connect( IconView, SIGNAL( actionsMenuRequested( QPoint ) ), this, SLOT( showActionsMenu( QPoint ) ) ); connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ) ); connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateActions() ) ); connect( IconView, SIGNAL( link( QStringList, QString ) ), this, SLOT( link( QStringList, QString ) ) ); // DragDrop copy connect( IconView, SIGNAL( copy( QStringList, QString ) ), this, SLOT( copy( QStringList, QString ) ) ); // DragDrop move connect( IconView, SIGNAL( move( QStringList, QString ) ), this, SLOT( move( QStringList, QString ) ) ); // Update actions once the directory is loaded connect( fsModel, SIGNAL( directoryLoaded( QString ) ), this, SLOT( updateActions() ) ); // Peek peekAct = new QAction( QIcon( ":/icons/peek.png" ), "Pee&k", this ); peekAct->setShortcuts( Settings->shortcuts( "Peek" ) ); connect( peekAct, SIGNAL( triggered() ), this, SLOT( doPeek() ) ); addAction( peekAct ); // Home Dir actHomeDir = new QAction( QIcon( ":/icons/home.png" ), "&Home", this ); actHomeDir->setShortcuts( Settings->shortcuts( "GoHome" ) ); connect( actHomeDir, SIGNAL( triggered() ), this, SLOT( loadHomeDir() ) ); addAction( actHomeDir ); // Home actGoHome = new QAction( QIcon( ":/icons/home.png" ), "&Home", this ); actGoHome->setShortcut( tr( "Alt+Shift+Home" ) ); connect( actGoHome, SIGNAL( triggered() ), this, SLOT( doOpenHome() ) ); addAction( actGoHome ); // Up actParDir = new QAction( QIcon( ":/icons/up.png" ), "&Up", this ); actParDir->setShortcuts( Settings->shortcuts( "GoUp" ) ); connect( actParDir, SIGNAL( triggered() ), fsModel, SLOT( goUp() ) ); addAction( actParDir ); // Back actPrevDir = new QAction( QIcon( ":/icons/prev.png" ), "&Back", this ); actPrevDir->setShortcuts( Settings->shortcuts( "GoLeft" ) ); connect( actPrevDir, SIGNAL( triggered() ), fsModel, SLOT( goBack() ) ); addAction( actPrevDir ); // Forward actNextDir = new QAction( QIcon( ":/icons/next.png" ), "&Forward", this ); actNextDir->setShortcuts( Settings->shortcuts( "GoRight" ) ); connect( actNextDir, SIGNAL( triggered() ), fsModel, SLOT( goForward() ) ); addAction( actNextDir ); // New Folder actNewDir = new QAction( QIcon::fromTheme( "folder-new" ), "New folder", this ); actNewDir->setShortcuts( Settings->shortcuts( "NewFolder" ) ); connect( actNewDir, SIGNAL( triggered() ), this, SLOT( newFolder() ) ); addAction( actNewDir ); // New file actNewFile = new QAction( QIcon::fromTheme( "document-new" ), "New File", this ); actNewFile->setShortcuts( Settings->shortcuts( "NewFile" ) ); connect( actNewFile, SIGNAL( triggered() ), this, SLOT( newFile() ) ); addAction( actNewFile ); // New file actNewEncFS = new QAction( QIcon::fromTheme( "document-new" ), "New Encrypted Directory", this ); actNewEncFS->setShortcuts( Settings->shortcuts( "NewEncFS" ) ); connect( actNewEncFS, SIGNAL( triggered() ), this, SLOT( createEncFS() ) ); addAction( actNewEncFS ); // Copy copyAct = new QAction( QIcon( ":/icons/copy.png" ), "&Copy", this ); copyAct->setShortcuts( Settings->shortcuts( "Copy" ) ); connect( copyAct, SIGNAL( triggered() ), this, SLOT( prepareCopy() ) ); addAction( copyAct ); // Move moveAct = new QAction( QIcon( ":/icons/cut.png" ), "Cu&t", this ); moveAct->setShortcuts( Settings->shortcuts( "Cut" ) ); connect( moveAct, SIGNAL( triggered() ), this, SLOT( prepareMove() ) ); addAction( moveAct ); // Paste pasteAct = new QAction( QIcon( ":/icons/paste.png" ), "&Paste", this ); pasteAct->setShortcuts( Settings->shortcuts( "Paste" ) ); connect( pasteAct, SIGNAL( triggered() ), this, SLOT( prepareIO() ) ); addAction( pasteAct ); // Rename renameAct = new QAction( QIcon( ":/icons/rename.png" ), "&Rename", this ); renameAct->setShortcuts( Settings->shortcuts( "Rename" ) ); connect( renameAct, SIGNAL( triggered() ), this, SLOT( doRename() ) ); addAction( renameAct ); // Reload reloadAct = new QAction( QIcon( ":/icons/reload.png" ), "Re&fresh", this ); reloadAct->setShortcuts( Settings->shortcuts( "Reload" ) ); connect( reloadAct, SIGNAL( triggered() ), this, SLOT( doReload() ) ); addAction( reloadAct ); // showDotFiles showHideDotFiles = new QAction( QIcon( ":/icons/showDotFiles.png" ), "Show &Hidden", this ); showHideDotFiles->setShortcuts( Settings->shortcuts( "ToggleHidden" ) ); connect( showHideDotFiles, SIGNAL( triggered() ), this, SLOT( doToggleHidden() ) ); addAction( showHideDotFiles ); // Trash trashAct = new QAction( QIcon( ":/icons/trash.png" ), "Move to trash", this ); trashAct->setShortcuts( Settings->shortcuts( "Trash" ) ); connect( trashAct, SIGNAL( triggered() ), this, SLOT( doSendToTrash() ) ); addAction( trashAct ); // Delete delAct = new QAction( QIcon( ":/icons/delete.png" ), "Delete", this ); delAct->setShortcuts( Settings->shortcuts( "Delete" ) ); connect( delAct, SIGNAL( triggered() ), this, SLOT( doDelete() ) ); addAction( delAct ); // Properties propertiesAct = new QAction( QIcon( ":/icons/props.png" ), "&Properties", this ); propertiesAct->setShortcuts( Settings->shortcuts( "Properties" ) ); connect( propertiesAct, SIGNAL( triggered() ), this, SIGNAL( showProperties() ) ); addAction( propertiesAct ); // Permissions permissionsAct = new QAction( QIcon::fromTheme( "system-users" ), "P&ermissions", this ); permissionsAct->setShortcuts( Settings->shortcuts( "Permissions" ) ); connect( permissionsAct, SIGNAL( triggered() ), this, SIGNAL( showPermissions() ) ); addAction( permissionsAct ); // Open a virtual terminal emulator openVTE = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE", this ); openVTE->setShortcuts( Settings->shortcuts( "Terminal" ) ); connect( openVTE, SIGNAL( triggered() ), this, SLOT( openTerminal() ) ); addAction( openVTE ); // Open a virtual terminal emulator openVTEin = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE Here", this ); // openVTEin->setShortcuts( Settings->shortcuts( "Terminal" ) ); connect( openVTEin, SIGNAL( triggered() ), this, SLOT( openTerminalIn() ) ); // Select All QAction *selectAllAct = new QAction( "&Select All", this ); selectAllAct->setShortcuts( Settings->shortcuts( "SelectAll" ) ); connect( selectAllAct, SIGNAL( triggered() ), this, SLOT( selectAll() ) ); addAction( selectAllAct ); // Sorting sortByNameAct = new QAction( QIcon::fromTheme( "format-text-underline" ), "&Name", this ); sortByNameAct->setCheckable( true ); connect( sortByNameAct, SIGNAL( triggered() ), this, SLOT( sortByName() ) ); sortByTypeAct = new QAction( QIcon::fromTheme( "preferences-other" ), "&Type", this ); sortByTypeAct->setCheckable( true ); connect( sortByTypeAct, SIGNAL( triggered() ), this, SLOT( sortByType() ) ); sortBySizeAct = new QAction( QIcon( ":/icons/size.png" ), "&Size", this ); sortBySizeAct->setCheckable( true ); connect( sortBySizeAct, SIGNAL( triggered() ), this, SLOT( sortBySize() ) ); sortByDateAct = new QAction( QIcon::fromTheme( "office-calendar" ), "&Date", this ); sortByDateAct->setCheckable( true ); connect( sortByDateAct, SIGNAL( triggered() ), this, SLOT( sortByDate() ) ); QActionGroup *sortGroup = new QActionGroup( this ); sortGroup->addAction( sortByNameAct ); sortGroup->addAction( sortByTypeAct ); sortGroup->addAction( sortBySizeAct ); sortGroup->addAction( sortByDateAct ); switch( ( int )Settings->value( "SortColumn" ) ) { case 0: { sortByNameAct->setChecked( true ); break; } case 1: { sortBySizeAct->setChecked( true ); break; } case 2: { sortByTypeAct->setChecked( true ); break; } case 4: { sortByDateAct->setChecked( true ); break; } } groupsAct = new QAction( QIcon::fromTheme( "view-group", QIcon( ":/icons/groups.png" ) ), "Show in &Groups", this ); groupsAct->setCheckable( true ); groupsAct->setChecked( Settings->value( "Grouping" ) ); connect( groupsAct, SIGNAL( triggered() ), this, SIGNAL( toggleGroups() ) ); // Add bookmark addBookMarkAct = new QAction( QIcon( ":/icons/bookmark.png" ), "Add &Bookmark", this ); addBookMarkAct->setShortcuts( Settings->shortcuts( "AddBookmark" ) ); connect( addBookMarkAct, SIGNAL( triggered() ), this, SLOT( addBookMark() ) ); addAction( addBookMarkAct ); /* Add to SuperStart */ addToSuperStartAct = new QAction( QIcon( ":/icons/superstart.png" ), "Add to S&uperStart", this ); addToSuperStartAct->setShortcut( tr( "Ctrl+U" ) ); connect( addToSuperStartAct, SIGNAL( triggered() ), this, SLOT( addToSuperStart() ) ); addAction( addToSuperStartAct ); updateActions(); };
/** * Verarbeitet den Zug. * * @param timeIntervalSinceLastFrame Zeit in ms, die seit der Berechnung des letzten Bildes * vergangen ist (nötig für die Animation der Spielfiguren). */ void processMove(float timeIntervalSinceLastFrame) { // aktuellen Spiel-Zustand auswerten und die entsprechenden Aktionen ausführen switch (gameState) { case GAME_STATE_RUNNING: { // Spiel läuft // Prüfung, ob der aktuelle Spieler senen Zug beeendet hat if (currentPlayer->state == PLAYER_STATE_POST_MOVING) { // Prüfung, ob der Spieler auf einem Sonderfeld gelandet ist if (field.spaces[currentPlayer->targetSpaceIndex].type == SPECIAL_SPACE) { // Spieler ist auf einem Sonderfeld gelandet. Es wird per Zufall bestimmt, ob er // vor oder zurück darf und wie weit. // Vorzeichen bestimmen, 0: Spieler darf vor, 1: Spieler muss zurück int sign = rand() % 2; // Betrag bestimmen int value = rand() % MAX_DIE_PIP_COUNT + 1; // Betrag evtl. negieren value *= sign == 0 ? +1 : -1; // neues Ziel setzen setPlayerTargetSpace(currentPlayer, currentPlayer->targetSpaceIndex + value); // Hinweis anzeigen char text[256]; sprintf(text, "%s ist auf einem Sonderfeld gelandet und %s %d %s %s", currentPlayer->name, value >= 0 ? "darf um" : "muss", abs(value), abs(value) == 1 ? "Feld" : "Felder", value >= 0 ? "vorruecken" : "zurueck"); showToast(text, TOAST_DURATION_LONG); // Zug vorbereiten prepareMove(currentPlayer); } else if (currentPlayer->targetSpaceIndex < field.length - 1) { // Aktueller Spieler hat das Zielfeld noch nicht erreicht. Es wird der nächste // Spieler bestimmt und die dafür nötigen Aktionen ausgeführt. // aktuellen Spieler schon mal für seinen nächsten Zug vorbereiten if (currentPlayer->type == PLAYER_TYPE_HUMAN) { // menschlicher Spieler muss warten, bis der "Würfeln"-Button gedrückt wird currentPlayer->state = PLAYER_STATE_WAITING; } else { // Computer-Spieler kann gleich würfeln und ziehen currentPlayer->state = PLAYER_STATE_PRE_MOVING; } // aktuellen Spieler aktualisieren setCurrentPlayer((currentPlayerIndex + 1) % PLAYER_COUNT); // evtl. den "Würfeln"-Button anzeigen if (currentPlayer->type == PLAYER_TYPE_HUMAN) { showView("diceButton"); } } else { // Der aktuelle Spieler hat das Ziel erreicht und gewinnt. // Hinweis anzeigen char text[256]; sprintf(text, "%s erreicht als erster das Ziel und gewinnt", currentPlayer->name); showToast(text, TOAST_DURATION_LONG); // Spiel-Zustand aktualisieren gameState = GAME_STATE_GAME_OVER; } } // den Zug vom aktuellen Spieler weiterverarbeiten lassen processPlayerMove(currentPlayer, timeIntervalSinceLastFrame); break; } case GAME_STATE_GAME_OVER: { // Spiel ist zu Ende LOGD("Game state is GAME_STATE_GAME_OVER"); break; } default: break; } }