X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fmainwin.cpp;h=deef6b4a7f5995cc91ed6014020c8f3090851729;hb=5e11cea96160bd958c1b271940bf97ecfa257b15;hp=dba74e7bad8f946a59ad2b17ff7df4f3a366763e;hpb=94e1e961b57f253b760298ab0bae96a7de6d20fa;p=virtualjaguar diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index dba74e7..deef6b4 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -8,6 +8,7 @@ // Who When What // --- ---------- ------------------------------------------------------------- // JLH 12/23/2009 Created this file +// JLH 12/20/2010 Added settings, menus & toolbars // // FIXED: @@ -22,31 +23,78 @@ //#define DEBUGFOO // Various tool debugging... //#define DEBUGTP // Toolpalette debugging... -//#include #include "mainwin.h" +//#include //#include #include "glwidget.h" -//#include "editwindow.h" -//#include "charwindow.h" -//#include "ttedit.h" +#include "settings.h" -MainWin::MainWin() -{ - // The way BSNES controls things is by setting a timer with a zero - // timeout, sleeping if not emulating anything. Seems there has to be a - // better way. +// The way BSNES controls things is by setting a timer with a zero +// timeout, sleeping if not emulating anything. Seems there has to be a +// better way. + +// It has a novel approach to plugging-in/using different video/audio/input +// methods, can we do something similar or should we just use the built-in +// QOpenGL? - // It has a novel approach to plugging-in/using different video/audio/input - // methods, can we do something similar or should we just use the built-in - // QOpenGL? +// We're going to try to use the built-in OpenGL support and see how it goes. +// 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. -// ((TTEdit *)qApp)->charWnd = new CharWindow(this); +MainWin::MainWin() +{ videoWidget = new GLWidget(this); setCentralWidget(videoWidget); setWindowIcon(QIcon(":/res/vj.xpm")); setWindowTitle("Virtual Jaguar v2.0.0"); + // Create actions + + quitAppAct = new QAction(tr("E&xit"), this); + quitAppAct->setShortcuts(QKeySequence::Quit); + quitAppAct->setStatusTip(tr("Quit Virtual Jaguar")); + connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close())); + + action = new QAction(QIcon(":/res/power.png"), tr("&Power"), this); + action->setStatusTip(tr("Toggle running state")); + action->setCheckable(true); + connect(action, SIGNAL(triggered()), this, SLOT(ToggleRunState())); + + zoomActs = new QActionGroup(this); + + x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs); + x1Act->setStatusTip(tr("Set window zoom to 100%")); + x1Act->setCheckable(true); +// connect(x1Act, SIGNAL(triggered()), this, SLOT(???())); + + x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs); + x2Act->setStatusTip(tr("Set window zoom to 200%")); + x2Act->setCheckable(true); +// connect(x2Act, SIGNAL(triggered()), this, SLOT(???())); + + x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs); + x3Act->setStatusTip(tr("Set window zoom to 300%")); + x3Act->setCheckable(true); +// connect(x3Act, SIGNAL(triggered()), this, SLOT(???())); + + blurAct = new QAction(QIcon(":/res/generic.png"), tr("Blur"), this); + blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST")); + blurAct->setCheckable(true); + connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur())); + + // Create menus & toolbars + + QMenu * fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(action); + fileMenu->addAction(quitAppAct); + + QToolBar * toolbar = addToolBar(tr("Stuff")); + toolbar->addAction(action); + toolbar->addAction(x1Act); + toolbar->addAction(x2Act); + toolbar->addAction(x3Act); + toolbar->addAction(blurAct); #if 0 // createActions(); newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); @@ -99,13 +147,13 @@ MainWin::MainWin() statusBar()->showMessage(tr("Ready")); ReadSettings(); - -// connect(textEdit->document(), SIGNAL(contentsChanged()), -// this, SLOT(documentWasModified())); - -// setCurrentFile(""); setUnifiedTitleAndToolBarOnMac(true); + // Set toolbar button based on setting read in (sync the UI)... + blurAct->setChecked(vjs.glFilter); + x1Act->setChecked(true); + running = action->isChecked(); + // Set up timer based loop for animation... timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(Timer())); @@ -124,11 +172,14 @@ void MainWin::Open(void) void MainWin::Timer(void) { + if (!running) + return; + // Random hash & trash // We try to simulate an untuned tank circuit here... :-) - for(int x=0; xrasterWidth; x++) + for(uint32_t x=0; xrasterWidth; x++) { - for(int y=0; yrasterHeight; y++) + for(uint32_t y=0; yrasterHeight; y++) { videoWidget->buffer[(y * videoWidget->textureWidth) + x] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;// | (rand() & 0xFF);//0x000000FF; // buffer[(y * textureWidth) + x] = x*y; @@ -138,6 +189,37 @@ void MainWin::Timer(void) videoWidget->updateGL(); } +void MainWin::ToggleRunState(void) +{ + running = !running; + + if (!running) + { + for(uint32_t x=0; xrasterWidth; x++) + for(uint32_t y=0; yrasterHeight; y++) + videoWidget->buffer[(y * videoWidget->textureWidth) + x] = 0x00000000; + + videoWidget->updateGL(); + } +} + +void MainWin::SetZoom100(void) +{ +} + +void MainWin::SetZoom200(void) +{ +} + +void MainWin::SetZoom300(void) +{ +} + +void MainWin::ToggleBlur(void) +{ + vjs.glFilter = !vjs.glFilter; +} + void MainWin::ReadSettings(void) { QSettings settings("Underground Software", "Virtual Jaguar"); @@ -145,11 +227,18 @@ void MainWin::ReadSettings(void) QSize size = settings.value("size", QSize(400, 400)).toSize(); resize(size); move(pos); -//videoWidget->updateGL(); -// pos = settings.value("charWndPos", QPoint(0, 0)).toPoint(); -// size = settings.value("charWndSize", QSize(200, 200)).toSize(); -// ((TTEdit *)qApp)->charWnd->resize(size); -// ((TTEdit *)qApp)->charWnd->move(pos); + + vjs.useJoystick = settings.value("useJoystick", false).toBool(); + vjs.joyport = settings.value("joyport", 0).toInt(); + vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool(); + vjs.frameSkip = settings.value("frameSkip", 0).toInt(); + vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool(); + vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool(); + vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool(); + vjs.fullscreen = settings.value("fullscreen", false).toBool(); + vjs.useOpenGL = settings.value("useOpenGL", true).toBool(); + vjs.glFilter = settings.value("glFilterType", 0).toInt(); + vjs.renderType = settings.value("renderType", 0).toInt(); } void MainWin::WriteSettings(void) @@ -157,7 +246,17 @@ void MainWin::WriteSettings(void) QSettings settings("Underground Software", "Virtual Jaguar"); settings.setValue("pos", pos()); settings.setValue("size", size()); -// settings.setValue("charWndPos", ((TTEdit *)qApp)->charWnd->pos()); -// settings.setValue("charWndSize", ((TTEdit *)qApp)->charWnd->size()); + + settings.setValue("useJoystick", vjs.useJoystick); + settings.setValue("joyport", vjs.joyport); + settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC); + settings.setValue("frameSkip", vjs.frameSkip); + settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS); + settings.setValue("DSPEnabled", vjs.DSPEnabled); + settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP); + settings.setValue("fullscreen", vjs.fullscreen); + settings.setValue("useOpenGL", vjs.useOpenGL); + settings.setValue("glFilterType", vjs.glFilter); + settings.setValue("renderType", vjs.renderType); }