void PlaylistEdit::createConnections() { connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutTano())); connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settings())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open())); connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newPlaylist())); connect(ui->actionDelete, SIGNAL(triggered()), this, SLOT(deleteItem())); connect(ui->actionAdd, SIGNAL(triggered()), this, SLOT(addItem())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save())); connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(exit())); connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(menuOpenExport())); connect(ui->actionExportTvheadend, SIGNAL(triggered()), this, SLOT(exportTvheadend())); connect(ui->actionExportXmltvId, SIGNAL(triggered()), this, SLOT(exportXmltvId())); connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print())); connect(ui->editName, SIGNAL(textChanged(QString)), this, SLOT(setTitle(QString))); connect(ui->buttonApplyNum, SIGNAL(clicked()), this, SLOT(editChannelNumber())); connect(ui->editNumber, SIGNAL(returnPressed()), ui->buttonApplyNum, SLOT(click())); connect(ui->editChannelName, SIGNAL(textChanged(QString)), this, SLOT(editChannelName(QString))); connect(ui->editUrl, SIGNAL(textChanged(QString)), this, SLOT(editChannelUrl(QString))); connect(ui->editCategories, SIGNAL(textChanged(QString)), this, SLOT(editChannelCategories(QString))); connect(ui->editLanguage, SIGNAL(textChanged(QString)), this, SLOT(editChannelLanguage(QString))); connect(ui->editEpg, SIGNAL(textChanged(QString)), this, SLOT(editChannelEpg(QString))); connect(ui->editLogo, SIGNAL(textChanged(QString)), this, SLOT(editChannelLogo(QString))); connect(ui->actionUp, SIGNAL(triggered()), this, SLOT(moveUp())); connect(ui->actionDown, SIGNAL(triggered()), this, SLOT(moveDown())); connect(ui->playlist, SIGNAL(itemSelected(Channel *)), this, SLOT(editItem(Channel *))); #if EDITOR connect(_update, SIGNAL(newUpdate()), this, SLOT(updateAvailable())); connect(ui->actionUpdate, SIGNAL(triggered()), _update, SLOT(check())); #endif #if WITH_EDITOR_VLCQT connect(ui->buttonUpdate, SIGNAL(toggled(bool)), this, SLOT(refreshPlaylist(bool))); #endif }
ICQStatusEditor::ICQStatusEditor( ICQStatusManager *statusManager, QWidget *parent ) : KDialog( parent ), mStatusManager( statusManager ) { setCaption( i18n( "Xtraz Status Editor" ) ); setButtons( KDialog::Ok | KDialog::Cancel ); mUi = new Ui::XtrazICQStatusEditorUI(); QWidget *w = new QWidget( this ); mUi->setupUi( w ); setMainWidget( w ); mUi->statusView->setAlternatingRowColors( true ); mUi->statusView->setTabKeyNavigation( false ); mUi->statusView->setSelectionBehavior( QAbstractItemView::SelectRows ); mUi->statusView->setSelectionMode( QAbstractItemView::SingleSelection ); mUi->statusView->horizontalHeader()->setClickable( false ); mUi->statusView->horizontalHeader()->setStretchLastSection( true ); QList<QIcon> icons; for ( int i = 0; i < Oscar::XSTAT_LAST; ++i ) icons << KIcon( QString( "icq_xstatus%1" ).arg( i ) ); mUi->statusView->setItemDelegate( new StatusDelegate( icons, this ) ); mXtrazStatusModel = new Xtraz::StatusModel( this ); mXtrazStatusModel->setStatuses( mStatusManager->xtrazStatuses() ); mUi->statusView->setModel( mXtrazStatusModel ); mUi->statusView->setCurrentIndex( mXtrazStatusModel->index( 0, 0 ) ); connect( mUi->buttonAdd, SIGNAL(clicked()), this, SLOT(addStatus()) ); connect( mUi->buttonDelete, SIGNAL(clicked()), this, SLOT(deleteStatus()) ); connect( mUi->buttonUp, SIGNAL(clicked()), this, SLOT(moveUp()) ); connect( mUi->buttonDown, SIGNAL(clicked()), this, SLOT(moveDown()) ); connect( this, SIGNAL(okClicked()), this, SLOT(save()) ); connect( mUi->statusView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(updateButtons()) ); updateButtons(); mUi->statusView->setFocus(); }
ManageActionsDialog::ManageActionsDialog(QWidget* parent) : KDialog(parent), pageWidget(new KPageWidget(this)), manageActionsAutorunWidget(new ManageActionsAutorunWidget(this)), listConfiguration(new ListConfiguration(this)) { setCaption( i18n("Manage Actions") ); setMainWidget( pageWidget ); QWidget *baseWidget = new QWidget( this ); ui.setupUi(baseWidget); KPageWidgetItem *generalItem = pageWidget->addPage(baseWidget, i18nc("General settings page", "General")); generalItem->setIcon(KIcon("fork")); generalItem->setHeader(""); ui.pbApplyForAll->setIcon(KIcon("arrow-down-double")); ui.pbAdd->setIcon(KIcon("list-add")); ui.pbRemove->setIcon(KIcon("list-remove")); ui.pbUp->setIcon(KIcon("go-up")); ui.pbDown->setIcon(KIcon("go-down")); connect(ui.pbAdd, SIGNAL(clicked()), this, SLOT(add())); connect(ui.pbRemove, SIGNAL(clicked()), this, SLOT(remove())); connect(ui.pbUp, SIGNAL(clicked()), this, SLOT(moveUp())); connect(ui.pbDown, SIGNAL(clicked()), this, SLOT(moveDown())); connect(ui.leTrigger, SIGNAL(textChanged(QString)), this, SLOT(applyTrigger(QString))); connect(ui.pbApplyForAll, SIGNAL(clicked()), this, SLOT(applyTriggerToAll())); ui.lvPlugins->setIconSize(QSize(24,24)); ui.lvPlugins->setSpacing(2); setButtons(KDialog::Ok); connect(ui.lvPlugins, SIGNAL(clicked(QModelIndex)), this, SLOT(currentSelectionChanged())); ui.twActionConfig->addTab(listConfiguration, i18n("Lists")); ui.twActionConfig->addTab(manageActionsAutorunWidget, i18n("Autorun")); }
void Character::moveToward(Character* aim, bool isDirFixed){ //int aimPosX = aim->getPositionX(); //MessageBox(Value(aimPosX).asString().c_str(), "test"); int offX = aim->getPositionX() - this->getPositionX(); int offY = aim->getPositionY() - this->getPositionY(); if (abs(offY) >= abs(offX)){ if (offY < 0){ moveDown(isDirFixed); } else if (offY > 0){ moveUp(isDirFixed); } } else{ if (offX < 0){ moveLeft(isDirFixed); } else if (offX > 0){ moveRight(isDirFixed); } } }
void doallMoves(from) { char game[ 36 ]; memcpy(game, moves[ from ].game, 36); int level = moves[ from ].level + 1; char have[ 256 ]; memset(have, 0, 256); for (int pos = 0; pos < 36; pos++) { int ccc = game[ pos ]; if ((ccc == '_') || have[ ccc ]) continue; have[ ccc ] = 1; int len = blocks[ ccc ].len; int dir = blocks[ ccc ].dir; if (dir == 0) { moveLeft(game, from, level, pos, ccc, len, 1); if (solved) return; moveRight(game, from, level, pos, ccc, len, 1); if (solved) return; } else { moveUp(game, from, level, pos, ccc, len, 1); if (solved) return; moveDown(game, from, level, pos, ccc, len, 1); if (solved) return; } } }
void GameScene::onTouchEnded(Touch* touch, Event* event) { if (isWin() || isGameOver()) { return; } GestureDetector::GestureType gesture = mGestureDetector.endPoint(touch->getLocation()); bool gestureValid = true; bool moved = false; switch (gesture) { case GestureDetector::MoveLeft: moved = moveLeft(); break; case GestureDetector::MoveRight: moved = moveRight(); break; case GestureDetector::MoveUp: moved = moveUp(); break; case GestureDetector::MoveDown: moved = moveDown(); break; case GestureDetector::Unknown: default: gestureValid = false; break; } if (gestureValid) { if (moved) { generateCard(true); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect( MOVE_SUCESS_SOUND, false); } else { CocosDenshion::SimpleAudioEngine::getInstance()->playEffect( MOVE_FAILED_SOUND, false); } doCheck(); } }
void CLindsey::process() { if(prepareToVanish) exists = false; if(m_timer <= 0) { m_timer = LINDSEY_MOVE_SPEED; yDirection = (yDirection==UP) ? DOWN : UP; } if(yDirection == UP) moveUp(LINDSEY_MOVE_SPEED); else moveDown(LINDSEY_MOVE_SPEED); m_timer--; if(!processActionRoutine()) exists = false; }
/* SwitchesEntryPanel::handleAction * Handles the action [id]. Returns true if the action was handled, * false otherwise *******************************************************************/ bool SwitchesEntryPanel::handleAction(string id) { // Don't handle actions if hidden if (!isActivePanel()) return false; // We're only interested in "anim_" actions if (!id.StartsWith("swch_")) return false; if (id == "swch_new") { add(); } else if (id == "swch_delete") { remove(); } else if (id == "swch_up") { moveUp(); } else if (id == "swch_down") { moveDown(); } // Unknown action else return false; // Action handled return true; }
QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions, const QgsFields& fields, QWidget* parent ): QWidget( parent ), mActions( actions ) { setupUi( this ); QHeaderView *header = attributeActionTable->horizontalHeader(); header->setHighlightSections( false ); header->setStretchLastSection( true ); attributeActionTable->setColumnWidth( 0, 100 ); attributeActionTable->setColumnWidth( 1, 230 ); attributeActionTable->setCornerButtonEnabled( false ); connect( attributeActionTable, SIGNAL( itemSelectionChanged() ), this, SLOT( itemSelectionChanged() ) ); connect( actionName, SIGNAL( textChanged( QString ) ), this, SLOT( updateButtons() ) ); connect( actionAction, SIGNAL( textChanged() ), this, SLOT( updateButtons() ) ); connect( moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) ); connect( moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) ); connect( removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) ); connect( addDefaultActionsButton, SIGNAL( clicked() ), this, SLOT( addDefaultActions() ) ); connect( browseButton, SIGNAL( clicked() ), this, SLOT( browse() ) ); connect( insertButton, SIGNAL( clicked() ), this, SLOT( insert() ) ); connect( updateButton, SIGNAL( clicked() ), this, SLOT( update() ) ); connect( insertFieldButton, SIGNAL( clicked() ), this, SLOT( insertField() ) ); connect( insertExpressionButton, SIGNAL( clicked() ), this, SLOT( insertExpression() ) ); connect( chooseIconButton, SIGNAL( clicked() ), this, SLOT( chooseIcon() ) ); init(); // Populate the combo box with the field names. Will the field names // change? If so, they need to be passed into the init() call, or // some access to them retained in this class. for ( int idx = 0; idx < fields.count(); ++idx ) fieldComboBox->addItem( fields[idx].name() ); }
void scramble_times(Board_t* board, int times){ int i; for(i=0; i<times; i++){ switch(rand()%4){ case 0: if((*board).zero_r>0) moveUp(board); break; case 1: if((*board).zero_r<(BOARD_SIZE-1)) moveDown(board); break; case 2: if((*board).zero_c>0) moveLeft(board); break; case 3: if((*board).zero_c<(BOARD_SIZE-1)) moveRight(board); break; } } }
/** * Attempt to jump JUMP_HEIGHT spaces up and to the left * NOTE: If there are not JUMP_HEIGHT spaces, player will stay at the highest * point until JUMP_HEIGHT moves upward have been made. The player will * then move down until the floor is reached. Player will move left a * space for each move up and down unless a wall or floor is hit. * * @param dungeon A pointer to the dungeon * @param dungeon A pointer to the object to move * * @return RESULT_WIN if the player has won the game * RESULT_DIE if the player has died in the game * else 0 */ int jumpRight(Dungeon* dungeon, Object* object) { int result=0; object->direction->y = DIR_UP; object->direction->x = DIR_RIGHT; for(int up=1; up<=JUMP_HEIGHT; up++) { if((result = moveUp(dungeon, object))) return result; if((result = moveRight(dungeon, object))) return result; if((result = moveEnemies(dungeon, object->moves))) return result; sendCurrentDungeonView(dungeon->start); } object->direction->y = DIR_DOWN; if((result = checkFloor(dungeon, object))) return result; object->direction->x = 0; return 0; }
void FrenzyWindow::keyPressEvent(QKeyEvent * event) { switch(event->key()) { case Qt::UpArrow: emit moveUp(); break; case Qt::DownArrow: emit moveDown(); break; case Qt::LeftArrow: emit moveLeft(); break; case Qt::RightArrow: emit moveRight(); break; default: event->ignore(); break; } }
// calls other move functions void gameBoard::move(char direction) { // move tiles up if (direction == 'w') { moveUp(); } // move tiles down else if (direction == 's') { moveDown(); } // move tiles left else if (direction == 'a') { moveLeft(); } // move tiles right else if (direction == 'd') { moveRight(); } }
QgsAttributeActionDialog::QgsAttributeActionDialog( const QgsActionManager& actions, QWidget* parent ) : QWidget( parent ) , mLayer( actions.layer() ) { setupUi( this ); QHeaderView* header = mAttributeActionTable->horizontalHeader(); header->setHighlightSections( false ); header->setStretchLastSection( true ); mAttributeActionTable->setColumnWidth( 0, 100 ); mAttributeActionTable->setColumnWidth( 1, 230 ); mAttributeActionTable->setCornerButtonEnabled( false ); mAttributeActionTable->setEditTriggers( QAbstractItemView::AnyKeyPressed | QAbstractItemView::SelectedClicked ); connect( mAttributeActionTable, SIGNAL( itemDoubleClicked( QTableWidgetItem* ) ), this, SLOT( itemDoubleClicked( QTableWidgetItem* ) ) ); connect( mAttributeActionTable, SIGNAL( itemSelectionChanged() ), this, SLOT( updateButtons() ) ); connect( mMoveUpButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) ); connect( mMoveDownButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) ); connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( remove() ) ); connect( mAddButton, SIGNAL( clicked( bool ) ), this, SLOT( insert() ) ); connect( mAddDefaultActionsButton, SIGNAL( clicked() ), this, SLOT( addDefaultActions() ) ); init( actions, mLayer->attributeTableConfig() ); }
void Game::specialKeyPressed(int key, int x, int y) { if (m_GameOver) return; switch (key) { case GLUT_KEY_UP: { auto paddlePtr = static_cast<Paddle*>(m_Entities["Paddle"].get()); paddlePtr->moveUp(); } break; case GLUT_KEY_DOWN: { auto paddlePtr = static_cast<Paddle*>(m_Entities["Paddle"].get()); paddlePtr->moveDown(); } break; default: break; } }
void Bullet::draw() { moveUp(); //glColor3f(0.0, 1.0, 0.0); if(x < 0) x = 0; if(y < 0) y = 0; if(x > boundryX+height) x = boundryX; if(y > boundryY) { // y = boundryY; isVisible = false; } glEnable(GL_TEXTURE_2D); //glEnable(GL_BLEND); glColor4ub(255,255,255,255); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glBegin(GL_POLYGON); glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y + height, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f(x + width, y + height, 0.0); glTexCoord2f(1.0f, 1.0f); glVertex3f(x + width, y, 0.0); glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y, 0.0); glEnd(); glDisable(GL_TEXTURE_2D); }
ProjectBuildSetWidget::ProjectBuildSetWidget( QWidget* parent ) : QWidget( parent ), m_view( 0 ), m_ui( new Ui::ProjectBuildSetWidget ) { m_ui->setupUi( this ); m_ui->addItemButton->setIcon( KIcon( "list-add" ) ); connect( m_ui->addItemButton, SIGNAL( clicked() ), this, SLOT( addItems() ) ); m_ui->removeItemButton->setIcon( KIcon( "list-remove" ) ); connect( m_ui->removeItemButton, SIGNAL( clicked() ), this, SLOT( removeItems() ) ); m_ui->upButton->setIcon( KIcon( "go-up" ) ); connect( m_ui->upButton, SIGNAL( clicked() ), SLOT( moveUp() ) ); m_ui->downButton->setIcon( KIcon( "go-down" ) ); connect( m_ui->downButton, SIGNAL( clicked() ), SLOT( moveDown() ) ); m_ui->topButton->setIcon( KIcon( "go-top" ) ); connect( m_ui->topButton, SIGNAL( clicked() ), SLOT( moveToTop() ) ); m_ui->bottomButton->setIcon( KIcon( "go-bottom" ) ); connect( m_ui->bottomButton, SIGNAL( clicked() ), SLOT( moveToBottom() ) ); m_ui->itemView->horizontalHeader()->setStretchLastSection(true); m_ui->itemView->verticalHeader()->setVisible(false); m_ui->itemView->setContextMenuPolicy( Qt::CustomContextMenu ); connect( m_ui->itemView, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT(showContextMenu(const QPoint&) ) ); layout()->setMargin(0); }
ActionCustomizer::ActionCustomizer(const QList<QAction*> &available, const QList<QAction*> &enabled, QWidget *parent) : QDialog(parent) { setupUi(this); setWindowTitle(tr("Customize actions")); foreach (QAction *act, enabled){ if (!act) continue; QListWidgetItem *item = new QListWidgetItem(act->icon(), act->text(), listWidget_ENABLED, 0); if (act->isSeparator()) item->setText(tr("-- Separator --")); enabled_items.insert(item, act); } foreach (QAction *act, available){ if (!act || enabled.contains(act)) continue; QListWidgetItem *item = new QListWidgetItem(act->icon(), act->text(), listWidget_AVAILABLE, 0); if (act->isSeparator()) item->setText(tr("-- Separator --")); avail_items.insert(item, act); } connect(pushButton_DOWN, SIGNAL(clicked()), this, SLOT(moveDown())); connect(pushButton_UP, SIGNAL(clicked()), this, SLOT(moveUp())); connect(pushButton_REM, SIGNAL(clicked()), this, SLOT(moveToAvailable())); connect(pushButton_ADD, SIGNAL(clicked()), this, SLOT(moveToEnabled())); connect(buttonBox, SIGNAL(accepted()),this, SLOT(accepted())); }
ExportDirectoryDialog::ExportDirectoryDialog(QWidget *parent, const QString &dirPath) : QDialog(parent, Qt::WindowTitleHint|Qt::WindowSystemMenuHint), ui(new Ui::ExportDirectoryDialog) { ui->setupUi(this); webView = new QWebView; timer = new QTimer(this); timer->setSingleShot(true); if(!dirPath.isEmpty()){ ui->dirPathLineEdit->setText(dirPath); ui->browerPushButton->setEnabled(false); } ui->dirPathLineEdit->setReadOnly(true); ui->seperateHtmlRadioButton->setChecked(true); ui->seperateCssAndHtmlcheckBox->setEnabled(false); ui->keepDirCheckBox->setChecked(true); ui->exportPathWidget->setHidden(true); m_model = new QStandardItemModel(this); clearModel(); ui->filesTreeView->setModel(m_model); ui->filesTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers); m_conf = Configuration::getInstance(); connect(ui->browerPushButton, SIGNAL(clicked()), this, SLOT(browerSourceDirSlot())); connect(ui->upPushButton, SIGNAL(clicked()), this, SLOT(moveUp())); connect(ui->downPushButton, SIGNAL(clicked()), this, SLOT(moveDown())); connect(ui->removePushButton, SIGNAL(clicked()), this, SLOT(removeOne())); connect(ui->suddirCheckBox, SIGNAL(clicked()), this, SLOT(fillData())); connect(ui->seperatePDFRadioButton, SIGNAL(toggled(bool)), ui->seperateCssAndHtmlcheckBox, SLOT(setDisabled(bool))); connect(ui->singlePDFRadioButton, SIGNAL(toggled(bool)), ui->seperateCssAndHtmlcheckBox, SLOT(setDisabled(bool))); connect(ui->keepDirCheckBox, SIGNAL(toggled(bool)), ui->exportPathWidget, SLOT(setHidden(bool))); connect(ui->exportPushButton, SIGNAL(clicked()), this, SLOT(exportBtnSlot())); connect(ui->exportPathBrowerPushButton, SIGNAL(clicked()), this, SLOT(exportPathBrowerSlot())); connect(this, SIGNAL(exportFinish()), this, SLOT(exportFinishSlot())); connect(this, SIGNAL(exportNext()), this, SLOT(exportOneByOne())); }
// 控制敌方向上一层地板移动 void Enemy::upFloor() { log("Enemy::upFloor"); //首先获取主角相对于敌人的位置 RelativeDirection rd = getActorRD(); if (canUpSuccess(getPosition())) { // 如果可以向上移动则向上移动 log("Enemy::upFloor::moveUp"); moveUp(); } //否则搜索上一层次离自己最近的 else if (isAboveFloor(getPosition())){ //否则尽量靠近主角 // 要判断敌人是否在地板上才能决定左右移动 if (!isInOneFloor()) { //不在同一层的话 auto floor = getCurUpperFloor(getPosition()); RelativeDirection rd = getUpperFloorRD(floor); if (rd == RD_LEFT) { moveLeft(); } else { moveRight(); } } } }
unsigned int fuzzMove(unsigned int rseed){ for(int counter=0; counter < 1e4; counter++){ game* state=rndState(floor(36.*rand_r(&rseed)/(float)RAND_MAX), rand_r(&rseed), rand_r(&rseed)/(float)RAND_MAX); game* backUp=cpyGame(state); moveUp(state); if(tstBookkeeping(state)!=0) printf("moveUp bookkeeping error %i\n", tstBookkeeping(state)); if(tstScore(state, backUp)!=0) printf("move Up tstScore error %i\n", tstScore(state, backUp)); delGame(state); state=cpyGame(backUp); moveDown(state); if(tstBookkeeping(state)!=0) printf("moveDown bookkeeping error %i\n", tstBookkeeping(state)); if(tstScore(state, backUp)!=0) printf("moveDown tstScore error %i\n", tstScore(state, backUp)); delGame(state); state=cpyGame(backUp); moveLeft(state); if(tstBookkeeping(state)!=0) printf("moveLeft bookkeeping error %i\n", tstBookkeeping(state)); if(tstScore(state, backUp)!=0) printf("moveLeft tstScore error %i\n", tstScore(state, backUp)); delGame(state); state=cpyGame(backUp); moveRight(state); if(tstBookkeeping(state)!=0) printf("moveRight bookkeeping error %i\n", tstBookkeeping(state)); if(tstScore(state, backUp)!=0) printf("moveRight tstScore error %i\n", tstScore(state, backUp)); if(counter% 1000 == 0)printf("Loop %i passed. \n", counter); delGame(state); delGame(backUp); } return rseed; }
void Snake::move() { if(storeTime <= clock()- 70 && gameStatus==CONTINUE) { if(direction== rightDir) { moveRight(); } else if(direction== leftDir) { moveLeft(); } else if(direction== upDir) { moveUp(); } else//(direction== downDir) { moveDown(); } glutPostRedisplay(); } }
void FPcamera::Crouch(const double dt, float heightOffset) { if (dt > 0) { float diffY = (heightOffset + 10.f); if (position.y > diffY) { moveDown(dt, 50.f); if (position.y < diffY) { float posTarDiff = target.y - position.y; position.y = diffY; target.y = position.y + posTarDiff; } } } else if (dt < 0) { float diffY = (heightOffset + 20.f); if (position.y < diffY) { moveUp(-dt, 50.f); if (position.y > diffY) { float posTarDiff = target.y - position.y; position.y = diffY; target.y = position.y + posTarDiff; } } } }
/* TextureXPanel::onTextureListKeyDown * Called when a key is pressed in the texture list *******************************************************************/ void TextureXPanel::onTextureListKeyDown(wxKeyEvent& e) { // Check if keypress matches any keybinds wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers())); // Go through matching binds for (unsigned a = 0; a < binds.size(); a++) { string name = binds[a]; // Copy if (name == "copy") { copy(); return; } // Cut else if (name == "cut") { copy(); removeTexture(); return; } // Paste else if (name == "paste") { paste(); return; } // Move texture up else if (name == "txed_tex_up") { moveUp(); return; } // Move texture down else if (name == "txed_tex_down") { moveDown(); return; } // New texture else if (name == "txed_tex_new") { newTexture(); return; } // New texture from patch else if (name == "txed_tex_new_patch") { newTextureFromPatch(); return; } // New texture from file else if (name == "txed_tex_new_file") { newTextureFromFile(); return; } // Delete texture else if (name == "txed_tex_delete") { removeTexture(); return; } } // Not handled here, send off to be handled by a parent window e.Skip(); }
/* TextureXPanel::onBtnMoveUp * Called when the 'Move Up' button is clicked *******************************************************************/ void TextureXPanel::onBtnMoveUp(wxCommandEvent& e) { moveUp(); }
dialog::RESULT fileSelect::run() { if (!init(size_)) { return dialog::R_NCREAT; } refresh(); // Handle keyboard. keyMapping::KEYLABEL label; bool cont = true; while (cont) { label = handleKeyboard(); switch (label) { case keyMapping::K_HELP: { if (showHelp() == dialog::R_RESIZE) { // Resized window. return dialog::R_RESIZE; } break; } case keyMapping::K_QUIT: { cont = false; break; } case keyMapping::K_DOWN: { moveDown(); refresh(); break; } case keyMapping::K_UP: { moveUp(); refresh(); break; } case keyMapping::K_LIST_START: { toStart(); refresh(); break; } case keyMapping::K_LIST_END: { toEnd(); refresh(); break; } case keyMapping::K_MARK: { handleMark(); moveDown(); refresh(); break; } case keyMapping::K_SELECT: { pressed_select_key_ = true; cont = false; break; } case keyMapping::K_MARK_ALL: { handleMarkAll(); break; } case keyMapping::K_RESIZE: { // Close this window, and make the parent // resize its window. return dialog::R_RESIZE; break; } default: { refresh(); break; } } } return dialog::R_QUIT; }
bool TocDlg::eventFilter(QObject *obj, QEvent *event) { if(event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); QString text; switch(keyEvent->key()) { case Qt::Key_Q: text = "1"; break; case Qt::Key_W: text = "2"; break; case Qt::Key_E: text = "3"; break; case Qt::Key_R: text = "4"; break; case Qt::Key_T: text = "5"; break; case Qt::Key_Y: text = "6"; break; case Qt::Key_U: text = "7"; break; case Qt::Key_I: text = "8"; break; case Qt::Key_O: text = "9"; break; case Qt::Key_P: text = "0"; break; case 0x2e: text = "%"; break; case 0x01001103: text = "%"; break; case Qt::Key_Up: { if(isPageUpdated) { on_actionUpdatePage_triggered(); isPageUpdated = false; } int cur_num = getCurrentItemPosFromBegin(m_docview->getToc(),m_ui->treeWidget->currentItem(), 0); if((cur_num<=((curPage-1)*pageStrCount)+1) && (curPage==pageCount) && (pageCount>2)){ moveUpPage(); moveDownPage(); } moveUp(); } break; case Qt::Key_Down: moveDown(); break; case Qt::Key_Select: qDebug() << focusWidget()->objectName().toAscii().data(); { QString s = m_ui->treeWidget->currentIndex().data(Qt::UserRole).toString(); m_docview->goToXPointer(s); close(); return true; } break; } if(keyEvent->key() >= Qt::Key_0 && keyEvent->key() <= Qt::Key_9) text = keyEvent->text(); if(!text.isEmpty()) { if(m_ui->pageNumEdit->text().lastIndexOf('%')>0) return true; if(text == QString('%')) { if(m_ui->pageNumEdit->text().toDouble()>100) return true; } m_ui->pageNumEdit->setText(m_ui->pageNumEdit->text() + text); return true; } } return false; }
//Key press event: Does most of the things in this editor: void CodeEditor::keyPressEvent(QKeyEvent *e) { e->accept(); /* Code Editor features: • Code completion • Auto Indentation • Autoclose for () [] {} " ' and comments */ //First: The keyboard controlling Qt::KeyboardModifiers mods = e->modifiers(); bool Shift = mods.testFlag(Qt::ShiftModifier); bool Ctrl = mods.testFlag(Qt::ControlModifier); // COMMAND key on Mac OS bool Alt = mods.testFlag(Qt::AltModifier); switch(e->key()) { //Movement & selection case Qt::Key_Right: moveRight(Ctrl,Shift); break; case Qt::Key_Left: moveLeft(Ctrl,Shift); break; case Qt::Key_Up: moveUp(Shift); break; case Qt::Key_Down: moveDown(Shift); break; case Qt::Key_Home: if(Ctrl)moveToBeginOfDocument(Shift); else moveToLineBegin(Shift); break; case Qt::Key_End: if(Ctrl)moveToEndOfDocument(Shift); else moveToLineEnd(Shift); break; //Deleting and clearing case Qt::Key_Backspace: deleteLeft(Ctrl); break; case Qt::Key_Delete: deleteRight(Ctrl); break; //Misc case Qt::Key_Escape: //Close the completer if it's shown break; case Qt::Key_Enter: case Qt::Key_Return: newLineAtCursor(); break; //Function keys case Qt::Key_Tab: insertTextAtCursor("\t"); break; case Qt::Key_Insert: if(Shift)paste(); else if(Ctrl)copySelection(); else insertMode=!insertMode; break; case Qt::Key_F3: //Search & replace functionality TODO: not important break; case Qt::Key_F1: case Qt::Key_F2: case Qt::Key_F4: case Qt::Key_F5: case Qt::Key_F6: case Qt::Key_F7: case Qt::Key_F8: case Qt::Key_F9: case Qt::Key_F10: case Qt::Key_F11: case Qt::Key_F12: case Qt::Key_F13: case Qt::Key_F14: case Qt::Key_F15: case Qt::Key_F16: case Qt::Key_F17: case Qt::Key_F18: case Qt::Key_F19: case Qt::Key_F20: case Qt::Key_F21: case Qt::Key_F22: case Qt::Key_F23: case Qt::Key_F24: //Just NO-OP for now! break; //NO-OPs: case Qt::Key_CapsLock: case Qt::Key_NumLock: case Qt::Key_ScrollLock: case Qt::Key_Pause: case Qt::Key_Print: case Qt::Key_SysReq: case Qt::Key_Control: case Qt::Key_Alt: case Qt::Key_AltGr: case Qt::Key_Super_L: case Qt::Key_Super_R: case Qt::Key_Meta: break; default: if(e->key()==Qt::Key_V && Ctrl)paste(); else if(e->key()==Qt::Key_C && Ctrl)copySelection(); else if(e->key()==Qt::Key_X && Ctrl){copySelection();clearSelection();} else if(e->key()==Qt::Key_Z && Ctrl)undo(); else if(e->key()==Qt::Key_Y && Ctrl)redo(); else if(e->key()==Qt::Key_A && Ctrl)selectAll(); //Type the character: else if(!Ctrl)insertTextAtCursor(e->text()); } cursorVisible=true; viewport()->repaint(); }
//********************************************************************** // void CAdjacentCellMovementProcess::execute() // execute //********************************************************************** void CAdjacentCellMovementProcess::execute() { #ifndef OPTIMIZE try { #endif // Base Execution CMovementProcess::execute(); for (int i = 0; i < iWorldHeight; ++i) { for (int j = 0; j < iWorldWidth; ++j) { // Get Current Squares pBaseSquare = pWorld->getBaseSquare(i, j); pDiff = pWorld->getDifferenceSquare(i, j); if (!pBaseSquare->getEnabled()) continue; // Loop Through Categories and Ages for (int k = 0; k < getCategoryCount(); ++k) { for (int l = 0; l < iBaseColCount; ++l) { dCurrent = pBaseSquare->getValue( vCategoryIndex[k], l); if(CComparer::isZero(dCurrent)) continue; // get up/down/left/right layer values and convert to proportions if (sLayer != "") { if ( (i+1) < pWorld->getHeight() ) dLayerValueDown = pLayer->getValue(i+1, j); else dLayerValueDown = 0.0; if ( (i-1) >= 0 ) dLayerValueUp = pLayer->getValue(i-1, j); else dLayerValueUp = 0.0; if ( (j+1) < pWorld->getWidth() ) dLayerValueRight = pLayer->getValue(i, j+1); else dLayerValueRight = 0.0; if ( (j-1) >= 0 ) dLayerValueLeft = pLayer->getValue(i, j-1); else dLayerValueLeft = 0.0; dLayerTotal = dLayerValueUp + dLayerValueDown + dLayerValueLeft + dLayerValueRight; if(dLayerTotal > 0.0) { dValue = dCurrent * dProportion * vSelectivityIndex[k]->getResult(l); dLayerValueUp = dValue * dLayerValueUp/dLayerTotal; dLayerValueDown = dValue * dLayerValueDown/dLayerTotal; dLayerValueLeft = dValue * dLayerValueLeft/dLayerTotal; dLayerValueRight = dValue * dLayerValueRight/dLayerTotal; } else { dLayerValueUp = 0.0; dLayerValueDown = 0.0; dLayerValueLeft = 0.0; dLayerValueRight = 0.0; } // or if no layer defined, then just move 1/4 each way } else { dValue = dCurrent * dProportion * vSelectivityIndex[k]->getResult(l); dLayerValueUp = 0.25 * dValue; dLayerValueDown = 0.25 * dValue; dLayerValueLeft = 0.25 * dValue; dLayerValueRight = 0.25 * dValue; } // Move moveUp(i, j, vCategoryIndex[k], l, dLayerValueUp); moveDown(i, j, vCategoryIndex[k], l, dLayerValueDown); moveLeft(i, j, vCategoryIndex[k], l, dLayerValueLeft); moveRight(i, j, vCategoryIndex[k], l, dLayerValueRight); } } } } #ifndef OPTIMIZE } catch (string &Ex) { Ex = "CAdjacentCellMovementProcess.execute(" + getLabel() + ")->" + Ex; throw Ex; } #endif }
// Настройка возможных действий void RecordTableScreen::setupActions(void) { // Добавление записи // a->setShortcut(tr("Ctrl+X")); actionAddNewToEnd = new QAction(tr("Add note"), this); actionAddNewToEnd->setStatusTip(tr("Add a new note")); actionAddNewToEnd->setIcon(QIcon(":/resource/pic/note_add.svg")); connect(actionAddNewToEnd, SIGNAL(triggered()), recordTableController, SLOT(addNewToEndContext())); // Добавление записи до actionAddNewBefore = new QAction(tr("Add note before"), this); actionAddNewBefore->setStatusTip(tr("Add a note before selected")); connect(actionAddNewBefore, SIGNAL(triggered()), recordTableController, SLOT(addNewBeforeContext())); // Добавление записи после actionAddNewAfter = new QAction(tr("Add note after"), this); actionAddNewAfter->setStatusTip(tr("Add a note after selected")); connect(actionAddNewAfter, SIGNAL(triggered()), recordTableController, SLOT(addNewAfterContext())); // Редактирование записи actionEditField = new QAction(tr("Edit properties (name, author, tags...)"), this); actionEditField->setStatusTip(tr("Edit note properties (name, author, tags...)")); actionEditField->setIcon(QIcon(":/resource/pic/note_edit.svg")); connect(actionEditField, SIGNAL(triggered()), recordTableController, SLOT(onEditFieldContext())); // Блокировка записи actionBlock = new QAction(tr("Block/Unblock note"), this); actionBlock->setStatusTip(tr("Block or unblock change note")); actionBlock->setIcon(QIcon(":/resource/pic/note_block.svg")); connect(actionBlock, SIGNAL(triggered()), recordTableController, SLOT(onBlockContext())); // Удаление записи actionDelete = new QAction(tr("Delete note(s)"), this); actionDelete->setStatusTip(tr("Delete note(s)")); actionDelete->setIcon(QIcon(":/resource/pic/note_delete.svg")); connect(actionDelete, SIGNAL(triggered()), recordTableController, SLOT(deleteContext())); // Удаление записи с копированием в буфер обмена actionCut = new QAction(tr("&Cut note(s)"), this); actionCut->setStatusTip(tr("Cut notes(s) to clipboard")); actionCut->setIcon(QIcon(":/resource/pic/cb_cut.svg")); connect(actionCut, SIGNAL(triggered()), recordTableController, SLOT(cut())); // Копирование записи (записей) в буфер обмена actionCopy = new QAction(tr("&Copy note(s)"), this); actionCopy->setStatusTip(tr("Copy note(s) to clipboard")); actionCopy->setIcon(QIcon(":/resource/pic/cb_copy.svg")); connect(actionCopy, SIGNAL(triggered()), recordTableController, SLOT(copy())); // Вставка записи из буфера обмена actionPaste = new QAction(tr("&Paste note(s)"), this); actionPaste->setStatusTip(tr("Paste note(s) from clipboard")); actionPaste->setIcon(QIcon(":/resource/pic/cb_paste.svg")); connect(actionPaste, SIGNAL(triggered()), recordTableController, SLOT(paste())); // Настройка внешнего вида таблицы конечных записей actionSettings = new QAction(tr("&View settings"), this); actionSettings->setStatusTip(tr("Setup table view settins")); actionSettings->setIcon(QIcon(":/resource/pic/edit_settings.svg")); connect(actionSettings, SIGNAL(triggered()), recordTableController, SLOT(settings())); // Перемещение записи вверх actionMoveUp = new QAction(tr("&Move Up"), this); actionMoveUp->setStatusTip(tr("Move note up")); actionMoveUp->setIcon(QIcon(":/resource/pic/move_up.svg")); connect(actionMoveUp, SIGNAL(triggered()), recordTableController, SLOT(moveUp())); // Перемещение записи вниз actionMoveDn=new QAction(tr("&Move Down"), this); actionMoveDn->setStatusTip(tr("Move note down")); actionMoveDn->setIcon(QIcon(":/resource/pic/move_dn.svg")); connect(actionMoveDn, SIGNAL(triggered()), recordTableController, SLOT(moveDn())); // Поиск по базе (клик связывается с действием в MainWindow) actionFindInBase=new QAction(tr("Find in base"), this); actionFindInBase->setStatusTip(tr("Find in base")); actionFindInBase->setIcon(QIcon(":/resource/pic/find_in_base.svg")); // Синхронизация actionSyncro=new QAction(tr("Synchronization"), this); actionSyncro->setStatusTip(tr("Run synchronization")); actionSyncro->setIcon(QIcon(":/resource/pic/synchronization.svg")); connect(actionSyncro, SIGNAL(triggered()), this, SLOT(onSyncroClick())); // Перемещение по истории посещаемых записей назад actionWalkHistoryPrevious=new QAction(tr("Previous viewing note"), this); actionWalkHistoryPrevious->setShortcut(tr("Ctrl+<")); actionWalkHistoryPrevious->setStatusTip(tr("Previous note has been viewing")); actionWalkHistoryPrevious->setIcon(QIcon(":/resource/pic/walk_history_previous.svg")); connect(actionWalkHistoryPrevious, SIGNAL(triggered()), this, SLOT(onWalkHistoryPreviousClick())); // Перемещение по истории посещаемых записей вперед actionWalkHistoryNext=new QAction(tr("Next viewing note"), this); actionWalkHistoryNext->setShortcut(tr("Ctrl+>")); actionWalkHistoryNext->setStatusTip(tr("Next note has been viewing")); actionWalkHistoryNext->setIcon(QIcon(":/resource/pic/walk_history_next.svg")); connect(actionWalkHistoryNext, SIGNAL(triggered()), this, SLOT(onWalkHistoryNextClick())); // Кнопка Назад (Back) в мобильном интерфейсе actionBack=new QAction(tr("Back to item tree"), this); actionBack->setStatusTip(tr("Back to item tree")); actionBack->setIcon(QIcon(":/resource/pic/mobile_back.svg")); connect(actionBack, SIGNAL(triggered()), this, SLOT(onBackClick())); // Действия по сортировке actionSort = new QAction(tr("Toggle sorting"), this); actionSort->setStatusTip(tr("Enable/disable sorting by column")); actionSort->setIcon(QIcon(":/resource/pic/sort.svg")); connect(actionSort, SIGNAL(triggered()), recordTableController, SLOT(onSortClick())); // Кнопка вызова печати таблицы конечных записей actionPrint = new QAction(tr("Print table"), this); actionPrint->setStatusTip(tr("Print current notes table")); actionPrint->setIcon(QIcon(":/resource/pic/print_table.svg")); connect(actionPrint, SIGNAL(triggered()), recordTableController, SLOT(onPrintClick())); // Кнопка копирования ссылки на запись actionCopyRecordReference = new QAction(tr("Copy note reference"), this); actionCopyRecordReference->setStatusTip(tr("Copy note reference to clipboard")); actionCopyRecordReference->setIcon(QIcon(":/resource/pic/note_reference.svg")); connect(actionCopyRecordReference, SIGNAL(triggered()), this, SLOT(onCopyRecordReference())); // Кнопка переключения режима одинарного выбора и мультивыбора actionSwitchSelectionMode = new QAction(tr("Switch select/multiselect"), this); actionSwitchSelectionMode->setStatusTip(tr("Switch note selection mode (Notice: if multiselect is on, drag-and-drop is disabled)")); actionSwitchSelectionMode->setIcon(QIcon(":/resource/pic/switch_note_selection_mode.svg")); connect(actionSwitchSelectionMode, SIGNAL(triggered()), recordTableController, SLOT(onSwitchSelectionMode())); // Сразу после создания все действия запрещены disableAllActions(); }