void ScProcess::prepareActions(Settings::Manager * settings) { QAction * action; const QString interpreterCategory(tr("Interpreter")); mActions[ToggleRunning] = action = new QAction(tr("Boot or Quit Interpreter"), this); connect(action, SIGNAL(triggered()), this, SLOT(toggleRunning()) ); //settings->addAction( action, "interpreter-toggle-running", interpreterCategory); mActions[Start] = action = new QAction(QIcon::fromTheme("system-run"), tr("Boot Interpreter"), this); connect(action, SIGNAL(triggered()), this, SLOT(startLanguage()) ); settings->addAction( action, "interpreter-start", interpreterCategory); mActions[Stop] = action = new QAction(QIcon::fromTheme("system-shutdown"), tr("Quit Interpreter"), this); connect(action, SIGNAL(triggered()), this, SLOT(stopLanguage()) ); settings->addAction( action, "interpreter-stop", interpreterCategory); mActions[Restart] = action = new QAction( QIcon::fromTheme("system-reboot"), tr("Reboot Interpreter"), this); connect(action, SIGNAL(triggered()), this, SLOT(restartLanguage()) ); settings->addAction( action, "interpreter-restart", interpreterCategory); mActions[RecompileClassLibrary] = action = new QAction( QIcon::fromTheme("system-reboot"), tr("Recompile Class Library"), this); action->setShortcut(tr("Ctrl+Shift+l", "Recompile Class Library)")); connect(action, SIGNAL(triggered()), this, SLOT(recompileClassLibrary()) ); settings->addAction( action, "interpreter-recompile-lib", interpreterCategory); mActions[StopMain] = action = new QAction( QIcon::fromTheme("media-playback-stop"), tr("Stop"), this); action->setShortcut(tr("Ctrl+.", "Stop (a.k.a. cmd-period)")); action->setShortcutContext(Qt::ApplicationShortcut); connect(action, SIGNAL(triggered()), this, SLOT(stopMain())); settings->addAction( action, "interpreter-main-stop", interpreterCategory); connect( mActions[Start], SIGNAL(changed()), this, SLOT(updateToggleRunningAction()) ); connect( mActions[Stop], SIGNAL(changed()), this, SLOT(updateToggleRunningAction()) ); onProcessStateChanged(QProcess::NotRunning); }
// Try actions void MainWindow::on_action_Toggle_Try_triggered() { toggleRunning(); }
int main(int argc, char* argv[]) { sSdlWrapper* wrap = initializeSDLWrapper("Snake", 800, 600, 32, 1, 1); game* gameEngine = initGame(wrap, 32, 24); int Selection = 0; sTextGFX* startUnsel = createText(wrap, "Start Game", 0xFFFFFFFF); sTextGFX* startSel = createText(wrap, "Start Game", 0xFFFFF000); sTextGFX* exitUnsel = createText(wrap, "Exit Game" , 0xFFFFFFFF); sTextGFX* exitSel = createText(wrap, "Exit Game" , 0xFFFFF000); sLinkedList* titleList = 0; FILE* titleFile = fopen("snake.pic", "r"); listInitialize(&titleList, sizeofPoint(), NULL); for(int x = 0; x < 32; x++) for(int y = 0; y < 24; y++) if(x == 0 || x == (31) || y == 0 || y == (23)) { point* toAdd = createPoint(x,y); listPushFront(titleList, (void*)toAdd); free(toAdd); } while(isRunning(wrap)) { beginFrame(wrap); if(State == -1) { readTitleFile(titleList, titleFile); renderList(titleList, wrap); } else if(State == 1) tick(gameEngine); else { if(Selection == 0) { renderText(wrap, startSel, 400, 300); renderText(wrap, exitUnsel, 400, 325); } else { renderText(wrap, startUnsel, 400, 300); renderText(wrap, exitSel, 400, 325); } if(keyDown(wrap, SDLK_DOWN)) Selection = 1; if(keyDown(wrap,SDLK_UP)) Selection = 0; if(keyDown(wrap, SDLK_RETURN)) { if(Selection == 0) { State = 1; setupGame(gameEngine); } else toggleRunning(wrap); } renderList(titleList, wrap); } if(keyPressed(wrap, SDLK_ESCAPE)) toggleRunning(wrap); endFrame(wrap); } listClear(titleList); free(titleList); destroyText(startUnsel); destroyText(startSel); destroyText(exitUnsel); destroyText(exitSel); deinitializeWrapper(wrap); destroyGame(gameEngine); free(wrap); return 0; }