// Who When What
// --- ---------- -------------------------------------------------------------
// JLH 12/23/2009 Created this file
+// JLH 12/20/2010 Added settings, menus & toolbars
//
// FIXED:
//#define DEBUGFOO // Various tool debugging...
//#define DEBUGTP // Toolpalette debugging...
-//#include <QtGui>
#include "mainwin.h"
+//#include <QtGui>
//#include <QtOpenGL>
#include "glwidget.h"
-//#include "editwindow.h"
-//#include "charwindow.h"
-//#include "ttedit.h"
+#include "settings.h"
-MainWin::MainWin(): running(true)
-{
- // 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.
+// 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");
- QMenu * menu = menuBar()->addMenu(tr("&File"));
- QToolBar * toolbar = addToolBar(tr("x1"));
- /*QAction */ action = new QAction(tr("Toggle"), this);
+ // 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);
- toolbar->addAction(action);
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);
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()));
// Random hash & trash
// We try to simulate an untuned tank circuit here... :-)
- for(int x=0; x<videoWidget->rasterWidth; x++)
+ for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
{
- for(int y=0; y<videoWidget->rasterHeight; y++)
+ for(uint32_t y=0; y<videoWidget->rasterHeight; 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;
void MainWin::ToggleRunState(void)
{
running = !running;
+
+ if (!running)
+ {
+ for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
+ for(uint32_t y=0; y<videoWidget->rasterHeight; 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)
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)
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);
}