X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fmainwin.cpp;h=ea4f8d46156b273f93cc936f04562bcfa36ffdb8;hb=19cb30261693d5c56c79d87030cfe8e1dc9ca033;hp=739756ed1915251717f35168ebafb1e13689f1a2;hpb=e285d9bb9ae73f64443fa4add30119dc422c4d08;p=virtualjaguar diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 739756e..ea4f8d4 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -1,9 +1,9 @@ // // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window -// by James L. Hammons +// by James Hammons // (C) 2009 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // Who When What // --- ---------- ------------------------------------------------------------- @@ -34,6 +34,7 @@ #include "mainwin.h" #include "SDL.h" +#include "app.h" #include "glwidget.h" #include "about.h" #include "help.h" @@ -70,9 +71,10 @@ // We'll make the VJ core modular so that it doesn't matter what GUI is in // use, we can drop it in anywhere and use it as-is. -MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit(true), - cartridgeLoaded(false), CDActive(false),//, alpineLoadSuccessful(false), - pauseForFileSelector(false) +MainWin::MainWin(QString filenameToRun): running(true), powerButtonOn(false), + showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false), + //, alpineLoadSuccessful(false), + pauseForFileSelector(false), loadAndGo(false), plzDontKillMyComputer(false) { videoWidget = new GLWidget(this); setCentralWidget(videoWidget); @@ -97,18 +99,30 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( // Create actions quitAppAct = new QAction(tr("E&xit"), this); - quitAppAct->setShortcuts(QKeySequence::Quit); +// quitAppAct->setShortcuts(QKeySequence::Quit); +// quitAppAct->setShortcut(QKeySequence(tr("Alt+x"))); + quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q"))); quitAppAct->setStatusTip(tr("Quit Virtual Jaguar")); connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close())); - powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this); + powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off); + powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On); + powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off); + powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On); + +// powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this); + powerAct = new QAction(powerGreen, tr("&Power"), this); powerAct->setStatusTip(tr("Powers Jaguar on/off")); powerAct->setCheckable(true); powerAct->setChecked(false); // powerAct->setDisabled(true); connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState())); - pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this); + QIcon pauseIcon; + pauseIcon.addFile(":/res/pause-off", QSize(), QIcon::Normal, QIcon::Off); + pauseIcon.addFile(":/res/pause-on", QSize(), QIcon::Normal, QIcon::On); +// pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this); + pauseAct = new QAction(pauseIcon, tr("Pause"), this); pauseAct->setStatusTip(tr("Toggles the running state")); pauseAct->setCheckable(true); pauseAct->setDisabled(true); @@ -173,6 +187,10 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( useCDAct->setCheckable(true); connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage())); + frameAdvanceAct = new QAction(QIcon(":/res/generic.png"), tr("&Frame Advance"), this); + frameAdvanceAct->setShortcut(QKeySequence(tr("F7"))); + connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance())); + // Misc. connections... connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString))); connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause())); @@ -182,6 +200,7 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( fileMenu = menuBar()->addMenu(tr("&Jaguar")); fileMenu->addAction(powerAct); fileMenu->addAction(pauseAct); + fileMenu->addAction(frameAdvanceAct); fileMenu->addAction(filePickAct); fileMenu->addAction(useCDAct); fileMenu->addAction(configAct); @@ -219,6 +238,7 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( // running = powerAct->isChecked(); ntscAct->setChecked(vjs.hardwareTypeNTSC); palAct->setChecked(!vjs.hardwareTypeNTSC); + powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen); // Do this in case original size isn't correct (mostly for the first-run case) ResizeMainWindow(); @@ -241,7 +261,15 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( WriteLog("VJ: Initializing jaguar subsystem...\n"); JaguarInit(); - filePickWin->ScanSoftwareFolder(allowUnknownSoftware); + if (!filenameToRun.isEmpty()) + { + loadAndGo = true; + // Attempt to load/run the file the user passed in... + LoadSoftware(filenameToRun); + memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS + // Prevent the scanner from running... + return; + } // Load up the default ROM if in Alpine mode: if (vjs.hardwareTypeAlpine) @@ -261,9 +289,13 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( // Attempt to load/run the ABS file... LoadSoftware(vjs.absROMPath); memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS + // Prevent the scanner from running... + return; } else memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Otherwise, use the stock BIOS + + filePickWin->ScanSoftwareFolder(allowUnknownSoftware); } void MainWin::closeEvent(QCloseEvent * event) @@ -424,6 +456,9 @@ void MainWin::Timer(void) if (showUntunedTankCircuit) { + // Some machines can't handle this, so we give them the option to disable it. :-) + if (!plzDontKillMyComputer) + { // Random hash & trash // We try to simulate an untuned tank circuit here... :-) for(uint32_t x=0; xrasterWidth; x++) @@ -434,6 +469,7 @@ void MainWin::Timer(void) = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24; } } + } } else { @@ -526,6 +562,7 @@ void MainWin::SetZoom300(void) void MainWin::SetNTSC(void) { + powerAct->setIcon(powerRed); timer->setInterval(16); vjs.hardwareTypeNTSC = true; ResizeMainWindow(); @@ -533,6 +570,7 @@ void MainWin::SetNTSC(void) void MainWin::SetPAL(void) { + powerAct->setIcon(powerGreen); timer->setInterval(20); vjs.hardwareTypeNTSC = false; ResizeMainWindow(); @@ -572,7 +610,10 @@ void MainWin::Unpause(void) if (pauseForFileSelector) { pauseForFileSelector = false; - ToggleRunState(); + + // Some nutter might have unpaused while in the file selector, so check for that + if (!running) + ToggleRunState(); } } @@ -595,7 +636,7 @@ void MainWin::LoadSoftware(QString file) powerButtonOn = false; TogglePowerState(); - if (!vjs.hardwareTypeAlpine) + if (!vjs.hardwareTypeAlpine && !loadAndGo) { QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1") .arg(filePickWin->GetSelectedPrettyName()); @@ -625,6 +666,14 @@ void MainWin::ToggleCDUsage(void) #endif } +void MainWin::FrameAdvance(void) +{ +//printf("Frame Advance...\n"); + // Execute 1 frame, then exit (only useful in Pause mode) + JaguarExecuteNew(); + videoWidget->updateGL(); +} + void MainWin::ResizeMainWindow(void) { videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256));