void MainWindow::createActions() { QLOG_TRACE() << "MainWindow::createActions()"; stopAllAction = new QAction(tr("&Stop All"), this); stopAllAction->setToolTip(tr("Stop all tracks that are playing")); stopAllAction->setStatusTip(tr("Stop all tracks that are playing")); connect(stopAllAction, SIGNAL(triggered()), this, SLOT(stopAll())); addAction = new QAction(tr("&Add"), this); addAction->setToolTip(tr("Add tracks to the playlist")); addAction->setStatusTip(tr("Add tracks to the playlist")); connect(addAction, SIGNAL(triggered()), this, SLOT(addTracks())); editAction = new QAction(tr("&Edit"), this); editAction->setToolTip(tr("Toggle edit mode")); editAction->setStatusTip(tr("Toggle edit mode")); editAction->setCheckable(true); connect(editAction, SIGNAL(triggered()), this, SLOT(toggleEditMode())); clearAction = new QAction(tr("&Clear"), this); clearAction->setToolTip(tr("Clear the playlist")); clearAction->setStatusTip(tr("Clear the playlist")); connect(clearAction, SIGNAL(triggered()), this, SLOT(clearPlaylist())); }
MainWindow::MainWindow(App *a) : m_close_shutdown(false), m_app(a) { setupUi(this); setDocumentName(""); instruments->setIconSize(QSize(16,16)); speed->setRange(MIN_SPEED, MAX_SPEED); tempo->setRange(MIN_TEMPO, MAX_TEMPO); rows->setRange(1, MAX_PATTERN_LENGTH); frames->setRange(1, MAX_FRAMES); title->setMaxLength(MAX_SONGINFO_LENGTH); author->setMaxLength(MAX_SONGINFO_LENGTH); copyright->setMaxLength(MAX_SONGINFO_LENGTH); instrumentName->setMaxLength(MAX_INSTRUMENT_NAME_LENGTH); QObject::connect(actionNew, SIGNAL(triggered()), this, SLOT(newDoc())); actionNew->setIcon(QIcon::fromTheme("document-new")); QObject::connect(action_Open, SIGNAL(triggered()), this, SLOT(open())); action_Open->setIcon(QIcon::fromTheme("document-open")); QObject::connect(action_Save, SIGNAL(triggered()), this, SLOT(save())); action_Save->setIcon(QIcon::fromTheme("document-save")); QObject::connect(actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs())); QObject::connect(action_Create_NSF, SIGNAL(triggered()), this, SLOT(unimplemented())); QObject::connect(actionCreate_WAV, SIGNAL(triggered()), this, SLOT(createWAV())); QObject::connect(actionImport_MIDI, SIGNAL(triggered()), this, SLOT(unimplemented())); QObject::connect(action_Configuration, SIGNAL(triggered()), this, SLOT(unimplemented())); QObject::connect(actionE_xit, SIGNAL(triggered()), this, SLOT(quit())); QObject::connect(actionModule_Properties, SIGNAL(triggered()), this, SLOT(moduleProperties())); QObject::connect(action_ViewToolbar, SIGNAL(toggled(bool)), this, SLOT(viewToolbar(bool))); QObject::connect(action_ViewStatusBar, SIGNAL(toggled(bool)), this, SLOT(viewStatusBar(bool))); QObject::connect(action_ViewControlpanel, SIGNAL(toggled(bool)), this, SLOT(viewControlpanel(bool))); QObject::connect(toolBar, SIGNAL(visibilityChanged(bool)), action_ViewToolbar, SLOT(setChecked(bool))); QObject::connect(controlPanel, SIGNAL(visibilityChanged(bool)), this, SLOT(controlPanelVisibilityChanged())); QObject::connect(action_About, SIGNAL(triggered()), this, SLOT(about())); QObject::connect(actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); QObject::connect(songs, SIGNAL(activated(int)), this, SLOT(setSong(int))); QObject::connect(incPattern, SIGNAL(clicked()), this, SLOT(incrementPattern())); QObject::connect(decPattern, SIGNAL(clicked()), this, SLOT(decrementPattern())); QObject::connect(instruments, SIGNAL(itemSelectionChanged()), this, SLOT(instrumentSelect())); QObject::connect(instrumentName, SIGNAL(textEdited(QString)), this, SLOT(instrumentNameChange(QString))); QObject::connect(instruments, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(instrumentDoubleClicked(QModelIndex))); QObject::connect(speed, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int))); QObject::connect(tempo, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int))); QObject::connect(rows, SIGNAL(valueChanged(int)), this, SLOT(rowsChange(int))); QObject::connect(frames, SIGNAL(valueChanged(int)), this, SLOT(framesChange(int))); QObject::connect(title, SIGNAL(editingFinished()), this, SLOT(changeSongTitle())); QObject::connect(author, SIGNAL(editingFinished()), this, SLOT(changeSongAuthor())); QObject::connect(copyright, SIGNAL(editingFinished()), this, SLOT(changeSongCopyright())); QObject::connect(action_Play, SIGNAL(triggered()), this, SLOT(play())); action_Play->setIcon(QIcon::fromTheme("media-playback-start")); QObject::connect(action_Stop, SIGNAL(triggered()), this, SLOT(stop())); action_Stop->setIcon(QIcon::fromTheme("media-playback-stop")); QObject::connect(actionToggle_edit_mode, SIGNAL(triggered()), this, SLOT(toggleEditMode())); actionToggle_edit_mode->setIcon(QIcon::fromTheme("media-record")); QObject::connect(addInstrument_button, SIGNAL(clicked()), this, SLOT(addInstrument_2A03())); addInstrument_button->setIcon(QIcon::fromTheme("list-add")); addInstrument_button->setText(tr("Add Instrument")); QObject::connect(removeInstrument_button, SIGNAL(clicked()), this, SLOT(removeInstrument())); removeInstrument_button->setIcon(QIcon::fromTheme("list-remove")); removeInstrument_button->setText(tr("Remove Instrument")); QObject::connect(editInstrument_button, SIGNAL(clicked()), this, SLOT(editInstrument())); editInstrument_button->setText(tr("Edit Instrument")); { QMenu *m = new QMenu(this); QAction *add2a03 = m->addAction(tr("New 2A03 Instrument")); QAction *addmmc5 = m->addAction(tr("New MMC5 Instrument")); QAction *addvrc6 = m->addAction(tr("New VRC6 Instrument")); QAction *addvrc7 = m->addAction(tr("New VRC7 Instrument")); QAction *addfds = m->addAction(tr("New FDS Instrument")); QObject::connect(add2a03, SIGNAL(triggered()), this, SLOT(addInstrument_2A03())); QObject::connect(addvrc6, SIGNAL(triggered()), this, SLOT(addInstrument_VRC6())); QObject::connect(addvrc7, SIGNAL(triggered()), this, SLOT(addInstrument_VRC7())); QObject::connect(addmmc5, SIGNAL(triggered()), this, SLOT(addInstrument_MMC5())); QObject::connect(addfds , SIGNAL(triggered()), this, SLOT(addInstrument_FDS())); m->setDefaultAction(add2a03); addInstrument_button->setMenu(m); } QObject::connect(step, SIGNAL(valueChanged(int)), this, SLOT(changeEditSettings())); QObject::connect(keyRepetition, SIGNAL(stateChanged(int)), this, SLOT(changeEditSettings())); { // recent files int capacity = gui::recentFileCapacity(); m_recentFiles = new QAction*[capacity]; for (int i = 0; i < capacity; i++) { QAction *a = new QAction(this); a->setVisible(false); connect(a, SIGNAL(triggered()), this, SLOT(openRecentFile())); m_recentFiles[i] = a; menuRecent->addAction(a); } // end recent files } reloadRecentFiles(); // the designer doesn't allow adding widgets { octave = new QComboBox; for (int i = 0; i < 8; i++) { octave->addItem(QString("%1").arg(i)); } connect(octave, SIGNAL(currentIndexChanged(int)), this, SLOT(octaveChange())); toolBar->addWidget(new QLabel(tr("Octave"))); toolBar->addWidget(octave); } // temporary style changing (for demonstration) { menu_View->addSeparator(); QMenu *styles = new QMenu(tr("Styles")); QAction *style_default = styles->addAction(tr("Default")); QAction *style_monochrome = styles->addAction(tr("Monochrome")); menu_View->addMenu(styles); connect(style_default, SIGNAL(triggered()), this, SLOT(selectDefaultStyle())); connect(style_monochrome, SIGNAL(triggered()), this, SLOT(selectMonochromeStyle())); } QMenu *m = new QMenu; m->addAction(tr("New 2A03 instrument")); actionAdd_instrument->setMenu(m); setDocInfo(m_app->activeDocInfo()); m_instrumenteditor = new InstrumentEditor(this); blockSignals(true); blockSignals(false); }
void Kolf::startNewGame() { NewGameDialog *dialog = 0; int firstHole = 1; if (loadedGame.isNull()) { dialog = new NewGameDialog(filename.isNull(), dummy, "New Game Dialog"); if (dialog->exec() != QDialog::Accepted) goto end; } players.clear(); delete scoreboard; scoreboard = new ScoreBoard(dummy, "Score Board"); layout->addWidget(scoreboard, 1, 0); scoreboard->show(); if (loadedGame.isNull()) { PlayerEditor *curEditor = 0; int newId = 1; for (curEditor = dialog->players()->first(); curEditor; curEditor = dialog->players()->next(), ++newId) { players.append(Player()); players.last().ball()->setColor(curEditor->color()); players.last().setName(curEditor->name()); players.last().setId(newId); } competition = dialog->competition(); filename = filename.isNull()? dialog->course() : filename; } else { KConfig config(loadedGame); config.setGroup("0 Saved Game"); if (isTutorial) filename = KGlobal::dirs()->findResource("appdata", "tutorial.kolf"); else filename = config.readEntry("Course", QString::null); if (filename.isNull()) return; competition = config.readBoolEntry("Competition", false); firstHole = config.readNumEntry("Current Hole", 1); players.clear(); KolfGame::scoresFromSaved(&config, players); } for (PlayerList::Iterator it = players.begin(); it != players.end(); ++it) scoreboard->newPlayer((*it).name()); delete spacer; spacer = 0; delete game; game = new KolfGame(obj, &players, filename, dummy); game->setStrict(competition); connect(game, SIGNAL(newHole(int)), scoreboard, SLOT(newHole(int))); connect(game, SIGNAL(scoreChanged(int, int, int)), scoreboard, SLOT(setScore(int, int, int))); connect(game, SIGNAL(parChanged(int, int)), scoreboard, SLOT(parChanged(int, int))); connect(game, SIGNAL(modifiedChanged(bool)), this, SLOT(updateModified(bool))); connect(game, SIGNAL(newPlayersTurn(Player *)), this, SLOT(newPlayersTurn(Player *))); connect(game, SIGNAL(holesDone()), this, SLOT(gameOver())); connect(game, SIGNAL(checkEditing()), this, SLOT(checkEditing())); connect(game, SIGNAL(editingStarted()), this, SLOT(editingStarted())); connect(game, SIGNAL(editingEnded()), this, SLOT(editingEnded())); connect(game, SIGNAL(inPlayStart()), this, SLOT(inPlayStart())); connect(game, SIGNAL(inPlayEnd()), this, SLOT(inPlayEnd())); connect(game, SIGNAL(maxStrokesReached(const QString &)), this, SLOT(maxStrokesReached(const QString &))); connect(game, SIGNAL(largestHole(int)), this, SLOT(updateHoleMenu(int))); connect(game, SIGNAL(titleChanged(const QString &)), this, SLOT(titleChanged(const QString &))); connect(game, SIGNAL(newStatusText(const QString &)), this, SLOT(newStatusText(const QString &))); connect(game, SIGNAL(currentHole(int)), this, SLOT(setCurrentHole(int))); connect(holeAction, SIGNAL(activated(const QString &)), game, SLOT(switchHole(const QString &))); connect(nextAction, SIGNAL(activated()), game, SLOT(nextHole())); connect(prevAction, SIGNAL(activated()), game, SLOT(prevHole())); connect(firstAction, SIGNAL(activated()), game, SLOT(firstHole())); connect(lastAction, SIGNAL(activated()), game, SLOT(lastHole())); connect(randAction, SIGNAL(activated()), game, SLOT(randHole())); connect(editingAction, SIGNAL(activated()), game, SLOT(toggleEditMode())); connect(newHoleAction, SIGNAL(activated()), game, SLOT(addNewHole())); connect(clearHoleAction, SIGNAL(activated()), game, SLOT(clearHole())); connect(resetHoleAction, SIGNAL(activated()), game, SLOT(resetHole())); connect(undoShotAction, SIGNAL(activated()), game, SLOT(undoShot())); //connect(replayShotAction, SIGNAL(activated()), game, SLOT(replay())); connect(aboutAction, SIGNAL(activated()), game, SLOT(showInfoDlg())); connect(useMouseAction, SIGNAL(toggled(bool)), game, SLOT(setUseMouse(bool))); connect(useAdvancedPuttingAction, SIGNAL(toggled(bool)), game, SLOT(setUseAdvancedPutting(bool))); connect(soundAction, SIGNAL(toggled(bool)), game, SLOT(setSound(bool))); connect(showGuideLineAction, SIGNAL(toggled(bool)), game, SLOT(setShowGuideLine(bool))); connect(showInfoAction, SIGNAL(toggled(bool)), game, SLOT(setShowInfo(bool))); game->setUseMouse(useMouseAction->isChecked()); game->setUseAdvancedPutting(useAdvancedPuttingAction->isChecked()); game->setShowInfo(showInfoAction->isChecked()); game->setShowGuideLine(showGuideLineAction->isChecked()); game->setSound(soundAction->isChecked()); layout->addWidget(game, 0, 0, AlignCenter); game->show(); game->setFocus(); setEditingEnabled(true); endAction->setEnabled(true); setHoleMovementEnabled(true); setHoleOtherEnabled(true); aboutAction->setEnabled(true); highScoreAction->setEnabled(true); printAction->setEnabled(true); saveAction->setEnabled(true); saveAsAction->setEnabled(true); saveGameAction->setEnabled(true); saveGameAsAction->setEnabled(true); clearHoleAction->setEnabled(false); newHoleAction->setEnabled(false); newAction->setEnabled(false); loadGameAction->setEnabled(false); tutorialAction->setEnabled(false); // so game can do stuff that needs to be done // after things above are connected game->startFirstHole(firstHole); end: delete dialog; }
void gameController::keyPress(SDL_keysym *keysym) { // function to handle key press events static const float keyVel = 10.0f; fsPoint2i p = m_oMouseLocWorld.loc; switch (keysym->sym) { case SDLK_c: { m_pCurrentLevel->m_map.m_pQuadTree->setAllObjects(false); std::cout << "Resetting.\n"; break; } case SDLK_v: { m_pCurrentLevel->m_map.BreakUp(p.x , p.y); std::cout << "Splitting.\n"; break; } case SDLK_a: m_pPlayer->vel.x -= keyVel; break; case SDLK_d: m_pPlayer->vel.x += keyVel; break; case SDLK_w: m_pPlayer->vel.y -= keyVel; break; case SDLK_s: m_pPlayer->vel.y += keyVel; break; case SDLK_e: toggleEditMode(); break; case SDLK_t: { std::cout << "Toggling jitter.\n"; m_bJitter = !m_bJitter; break; } case SDLK_q: m_pCamera.vel = fsPoint2f(0,0); m_pCamera.loc = fsPoint2f(0,0); break; case SDLK_ESCAPE: // ESC key was pressed Quit(0); break; case SDLK_F1: /* F1 key was pressed * this toggles fullscreen mode */ toggleFullscreen(); break; case SDLK_LEFT: m_pPlayer->vel.x -= keyVel; break; case SDLK_RIGHT: m_pPlayer->vel.x += keyVel; break; case SDLK_UP: m_pPlayer->vel.y -= keyVel; break; case SDLK_DOWN: m_pPlayer->vel.y += keyVel; break; case SDLK_TAB: toggleFullscreen(); break; default: m_pCurrentLevel->m_map.Key(keysym->sym - '0', p.x,p.y); break; } return; }