SimMainWindow::SimMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::SimMainWindow) { ui->setupUi(this); mEngine = new LifeEngine(100,100); mView = new LifeEngineView(mEngine); mLifeFileView = new LifeFileView; mLifesView = new LifesView(mEngine); mUndoStack = new QUndoStack(this); mOldLifeCount = 0; ui->dock1->setWidget(mLifeFileView); ui->dock2->setWidget(mLifesView); ui->dock1->setWindowTitle(mLifeFileView->windowTitle()); ui->dock2->setWindowTitle(mLifesView->windowTitle()); setCentralWidget(mView); ui->menuEdit->addActions(mLifeFileView->actions()); ui->menuEdit->addSeparator(); ui->menuEdit->addActions(mLifesView->actions()); connect(mView->gridView()->grid(),SIGNAL(squareClicked(QPoint)),this,SLOT(clicked(QPoint))); connect(ui->actionRun,SIGNAL(triggered()),this,SLOT(startSimulation())); connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newSim())); connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(saveSim())); connect(ui->actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAsSim())); connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openSim())); connect(ui->actionClear,SIGNAL(triggered()),this,SLOT(clear())); connect(ui->actionAnimator,SIGNAL(triggered()),this,SLOT(showAnimator())); connect(ui->actionLifeEditor,SIGNAL(triggered()),this,SLOT(showLifeEditor())); connect(mLifesView,SIGNAL(changed()),this,SLOT(refresh())); connect(mLifesView,SIGNAL(clicked()),this,SLOT(setGridSelection())); connect(ui->actionAboutQt,SIGNAL(triggered()),this,SLOT(showAboutQt())); connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout())); connect(ui->actionUndo,SIGNAL(triggered()),mUndoStack,SLOT(undo())); connect(ui->actionRedo,SIGNAL(triggered()),mUndoStack,SLOT(redo())); connect(mUndoStack,SIGNAL(canUndoChanged(bool)),ui->actionUndo,SLOT(setEnabled(bool))); connect(mUndoStack,SIGNAL(canRedoChanged(bool)),ui->actionRedo,SLOT(setEnabled(bool))); ui->actionSave->setEnabled(false); newSim(); }
void MenuServeur::processEvents() { sf::Event event; while (mWindow.pollEvent(event)) { if (event.type==sf::Event::KeyPressed) { switch(event.key.code) { case sf::Keyboard::Escape: mWindow.close(); break; case sf::Keyboard::Return: //retour menu break; case sf::Keyboard::R: resetGame(); break; }} switch (event.type) { case sf::Event::MouseButtonPressed: if (event.mouseButton.button == sf::Mouse::Left) { Square square(squareClicked(event.mouseButton.x,event.mouseButton.y)); if (square != UNKNOWN) { if (mBoard.addMove(mPlayer,square)) { addSprite(square); updateOutcome(); displayOutcome(); if (mOutcome == UNFINISHED) swapPlayer(); else // Xwin(); resetGame(); } } } break; case sf::Event::Closed: mWindow.close(); break; } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { for (int i=0;i<9;++i) for(int j=0;j<9;++j) { square[i][j] = new QPushButton("",this); connect(square[i][j],SIGNAL(released()),this,SLOT(squareClicked())); } for (int i=0;i<9;++i) { number[i]=new QPushButton(QString::number(i+1),this); connect(number[i],SIGNAL(released()),this,SLOT(numberClicked())); } emtyButton = new QPushButton("Emty",this); emtyButton->setGeometry(QRect(QPoint(25,460),QSize(150,40))); connect(emtyButton,SIGNAL(released()),this,SLOT(emtyClicked())); solveButton = new QPushButton("Solve",this); solveButton->setGeometry(QRect(QPoint(200,340),QSize(115,67))); connect(solveButton,SIGNAL(released()),this,SLOT(solveClicked())); clearButton = new QPushButton("Clear",this); clearButton->setGeometry(QRect(QPoint(200,433),QSize(115,67))); connect(clearButton,SIGNAL(released()),this,SLOT(clearClicked())); redText = new QPalette(); redText->setColor(QPalette::ButtonText,Qt::red); blueText = new QPalette(); blueText->setColor(QPalette::ButtonText,Qt::blue); blackText = new QPalette(); blackText->setColor(QPalette::ButtonText,Qt::black); setSquareGeo(); setNumberGeo(); }