Exemple #1
0
void Weather::cursorLeft()
{
    WeatherScreen *ws = prevScreen();
    if (ws && ws->canShowScreen())
    {
        hideScreen();
        showScreen(ws);
        if (!m_paused)
            m_nextpage_Timer->start((int)(1000 * m_nextpageInterval));
    }
}
Exemple #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Create our market
    market = new Market(":/market-data",this,5000);

    // Create the windows
    sim = new SimulationWindow(market, 0);
    dec = new DecryptionWindow(market, 0);
    title = new TitleScreen(0);
    inst1 = new InstructionScreen1(0);
    inst2 = new InstructionScreen2(0);
    //inst3 = new InstructionScreen3(0);
    inst4 = new InstructionScreen4(0);
    inst5 = new InstructionScreen5(0);
    inst6 = new InstructionScreen6(0);
    inst7 = new InstructionScreen7(0);
    inst8 = new InstructionScreen8(0);
    instTest1 = new InstructionScreenTest1(0);
    instTest2 = new InstructionScreenTest2(0);
    instTest3 = new InstructionScreenTest3(0);
    initAlloc = new InitialAllocationScreen(market, 0);
    quest1 = new QuestionScreen1(0);
    fin = new FinalScreen(0);

    ui->stackedWidget->addWidget(title);
    ui->stackedWidget->addWidget(inst1);
    ui->stackedWidget->addWidget(inst2);
    //ui->stackedWidget->addWidget(inst3);
    ui->stackedWidget->addWidget(inst4);
    ui->stackedWidget->addWidget(inst5);
    ui->stackedWidget->addWidget(inst6);
    ui->stackedWidget->addWidget(inst7);
    ui->stackedWidget->addWidget(inst8);
    ui->stackedWidget->addWidget(instTest1);
    ui->stackedWidget->addWidget(instTest2);
    ui->stackedWidget->addWidget(instTest3);
    ui->stackedWidget->addWidget(initAlloc);
    ui->stackedWidget->addWidget(dec);
    ui->stackedWidget->addWidget(sim);
    ui->stackedWidget->addWidget(quest1);
    ui->stackedWidget->addWidget(fin);


    // Make a list of widget pointers, so we can easily swap between them
    widgets = new QList<QWidget*>();
    widgets->push_back(title); //1
    widgets->push_back(inst1); //2
    widgets->push_back(inst2); //3
    //widgets->push_back(inst3); //4
    widgets->push_back(instTest1); //5
    widgets->push_back(instTest2); //6
    widgets->push_back(inst4); //7
    widgets->push_back(inst5); //8
    widgets->push_back(inst6); //9
    widgets->push_back(inst7); //10
    widgets->push_back(instTest3); //11
    widgets->push_back(inst8); //12
    widgets->push_back(initAlloc);
    widgets->push_back(dec);
    widgets->push_back(sim);
    widgets->push_back(quest1);
    widgets->push_back(fin);

    pos = widgets->begin();
    ui->stackedWidget->setCurrentWidget(*pos);
    preNavigation();

    simStarted = false;
    finishedExperiment = false;
    test1Passed = false;
    test2Passed = false;
    test3Passed = false;

    connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextScreen()));
    connect(ui->prevButton, SIGNAL(clicked()), this, SLOT(prevScreen()));

    connect(instTest1,SIGNAL(testPassed()),this,SLOT(passTest1()));
    connect(instTest2,SIGNAL(testPassed()),this,SLOT(passTest2()));
    connect(instTest3->win, SIGNAL(DecryptionCompleted()), this, SLOT(passTest3()));
    connect(market, SIGNAL(newTime(QString)), this, SLOT(updateTime(QString)));
    connect(market, SIGNAL(allocationUpdated(double)), this, SLOT(waitForInitialAlocation(double)));

    connect(quest1, SIGNAL(gimmeANextButton()), this, SLOT(enableNextButton()));

    connect(market, SIGNAL(priceChange(double)), this, SLOT(updateIndex()) );

    // Hide the labels (until the right time)
    ui->simulationDisplay->setHidden(true);

    this->setWindowFlags(Qt::FramelessWindowHint);
    this->showFullScreen();
}
FastQSPWindow::FastQSPWindow(QWidget *parent)
    : QMainWindow(parent), gameWidth(800), gameHeight(600),
      aspectRatio(qreal(gameWidth) / qreal(gameHeight)), scaleFactor(1),
      gameIsOpen(false), netManager(),
      settings (QSettings::IniFormat, QSettings::UserScope, "FastQSP", "config")
{
// Init audio
#if QT_VERSION < 0x050000
  media = new Phonon::MediaObject(this);
  audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
  Phonon::createPath(media, audioOutput);
#else
  player = new QMediaPlayer();
#endif

  // Start timer
  timer.start();

  // Init view
  scene = new QGraphicsScene(this);
  graphicsView = new QGraphicsView(scene, this);
  graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  graphicsView->setUpdatesEnabled(true);
  graphicsView->setFrameStyle(QFrame::NoFrame);

  webView = new QGraphicsWebView();
  webView->page()->setNetworkAccessManager(&netManager);
  webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
  webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
  webView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
  scene->addItem(webView);
  scene->setBackgroundBrush(QBrush(QColor(0, 0, 0)));
  webView->setRenderHints(
      QPainter::Antialiasing | QPainter::HighQualityAntialiasing |
      QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform |
      QPainter::NonCosmeticDefaultPen);
  webView->settings()->setAttribute(QWebSettings::AutoLoadImages, true);
  webView->setAutoFillBackground(false);

  videoPlayer = new QMediaPlayer();
  videoItem = new QGraphicsVideoItem();
  videoItem->setSize(QSize(gameWidth + 4, gameHeight + 4));
  videoItem->setAspectRatioMode(Qt::KeepAspectRatioByExpanding);
  videoPlayer->setVideoOutput(videoItem);
  videoPlayer->setMuted(true);
  videoPlayer->setNotifyInterval(500);
  scene->addItem(videoItem);
  videoItem->hide();

  savestatus = new QGraphicsTextItem;
  savestatus->setDefaultTextColor(Qt::yellow);
  QFont f;
  f.setBold(true);
  f.setPixelSize(20);
  savestatus->setFont(f);
  savestatus->setVisible(false);
  scene->addItem(savestatus);

  connect(videoPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(replayVideo(qint64)));

  // Filter context menu event
  graphicsView->viewport()->installEventFilter(this);

  // Creating menu
  //-File menu--------------------------------------------------------
  QMenu *fileMenu = new QMenu("File");
  fileMenu->addAction("Open file\tCtrl+O", this, SLOT(openFileDialog()));
  QShortcut *openFile = new QShortcut(QKeySequence("Ctrl+O"), this);
  connect(openFile, SIGNAL(activated()), SLOT(openFileDialog()));

//  fileMenu->addAction("Reload QSP file\tc", this, SLOT(openFileDialog())); //for powerairmax
//  QShortcut *reloadFile = new QShortcut(QKeySequence("c"), this); //for powerairmax
  fileMenu->addAction("Reload QSP file\tF3", this, SLOT(reloadQSP()));
  QShortcut *reloadFile = new QShortcut(QKeySequence("F3"), this);
  connect(reloadFile, SIGNAL(activated()), SLOT(reloadQSP()));

  fileMenu->addAction("Exit\tCtrl+Q", this, SLOT(close()));
  QShortcut *exit = new QShortcut(QKeySequence("Ctrl+Q"), this);
  connect(exit, SIGNAL(activated()), SLOT(close()));

  menuBar()->addMenu(fileMenu);

  //-Game menu--------------------------------------------------------
  gameMenu = new QMenu("Game");
  gameMenu->addAction("Save\tCtrl+S", this, SLOT(saveGameDialog()));
  QShortcut *save = new QShortcut(QKeySequence("Ctrl+S"), this);
  connect(save, SIGNAL(activated()), SLOT(saveGameDialog()));

  gameMenu->addAction("Load\tCtrl+L", this, SLOT(loadGameDialog()));
  QShortcut *load = new QShortcut(QKeySequence("Ctrl+L"), this);
  connect(load, SIGNAL(activated()), SLOT(loadGameDialog()));

//  gameMenu->addAction("Quicksave\tz", this, SLOT(saveGameDialog())); //for powerairmax
//  QShortcut *quicksave = new QShortcut(QKeySequence("z"), this); //for powerairmax
  gameMenu->addAction("Quicksave\tF5", this, SLOT(quicksave()));
  QShortcut *quicksave = new QShortcut(QKeySequence("F5"), this);
  connect(quicksave, SIGNAL(activated()), SLOT(quicksave()));

//  gameMenu->addAction("Quickload\tx", this, SLOT(loadGameDialog())); //for powerairmax
//  QShortcut *quickload = new QShortcut(QKeySequence("x"), this); //for powerairmax
  gameMenu->addAction("Quickload\tF2", this, SLOT(quickload()));
  QShortcut *quickload = new QShortcut(QKeySequence("F2"), this);
  connect(quickload, SIGNAL(activated()), SLOT(quickload()));

  gameMenu->addAction("Restart\tCtrl+R", this, SLOT(restartGame()));
  QShortcut *restart = new QShortcut(QKeySequence("Ctrl+R"), this);
  connect(restart, SIGNAL(activated()), SLOT(restartGame()));

  //Game shortcuts
  QShortcut *next = new QShortcut(QKeySequence("space"), this);
  connect(next, SIGNAL(activated()), SLOT(nextScreen()));

  QShortcut *prev= new QShortcut(QKeySequence("backspace"), this);
  connect(prev, SIGNAL(activated()), SLOT(prevScreen()));

  QShortcut *main_screen= new QShortcut(QKeySequence("escape"), this);
  connect(main_screen, SIGNAL(activated()), SLOT(gotoMainScreen()));

  ignoreCRCAction = new QAction("Ignore version check when loading", this);
  ignoreCRCAction->setCheckable(true);
  ignoreCRCAction->setChecked(settings.value("ignoreCRC", false).toBool());
  connect(ignoreCRCAction, SIGNAL(toggled(bool)), this, SLOT(saveIgnoreCRCState()));
  gameMenu->addAction(ignoreCRCAction);

  // TODO: slows the game, move saving to diffrent thread
  autosaveAction = new QAction("Autosave", this);
  autosaveAction->setCheckable(true);
  autosaveAction->setChecked(false);
  // gameMenu->addAction(autosave);

  menuBar()->addMenu(gameMenu);
  gameMenu->setDisabled(true);

  //-Other menu-------------------------------------------------------
  QMenu *otherMenu = new QMenu("Other");
  otherMenu->addAction("Fullscreen\tAlt+Enter", this, SLOT(toggleFullscreen()));
  QShortcut *fullscreen =
      new QShortcut(QKeySequence(Qt::Key_Return + Qt::AltModifier), this);
  otherMenu->addAction("Show html", this, SLOT(showHtml()));
  connect(fullscreen, SIGNAL(activated()), SLOT(toggleFullscreen()));

  muteAction = new QAction("Mute sound", this);
  muteAction ->setCheckable(true);
  muteAction ->setChecked(settings.value("mutedState", false).toBool());
  connect(muteAction, SIGNAL(toggled(bool)), this, SLOT(saveMutedState()));
  otherMenu->addAction(muteAction);

  menuBar()->addMenu(otherMenu);

  //-Help menu--------------------------------------------------------
  QMenu *helpMenu = new QMenu("Help");
  helpMenu->addAction("About", this, SLOT(about()));
  menuBar()->addMenu(helpMenu);
  //------------------------------------------------------------------

  connect(webView, SIGNAL(linkClicked(const QUrl &)),
          SLOT(linkClicked(const QUrl &)), Qt::DirectConnection);
  connect(webView, SIGNAL(loadFinished(bool)), SLOT(toggleUpdate()),
          Qt::DirectConnection);
  connect(webView, SIGNAL(loadStarted()), SLOT(toggleUpdate()),
          Qt::DirectConnection);

  setCentralWidget(graphicsView);

  // Initializing QSP
  QSPInit();
  QSPCallback::QSPCallback();

//  qDebug() << "QSP init finished";
}