From e2bad233989051ec554a36ba82a761397f089bc5 Mon Sep 17 00:00:00 2001 From: slack Date: Sat, 25 Apr 2009 21:51:47 +0200 Subject: [PATCH] Added view menu with options for hidding disassembly/status --- common/Logger.h | 2 +- qtboi/QtBoiMainWindow.cc | 162 +++++++++++++++++++++++---------------- qtboi/QtBoiMainWindow.h | 6 ++ 3 files changed, 105 insertions(+), 65 deletions(-) diff --git a/common/Logger.h b/common/Logger.h index c1fc48d..d2857aa 100644 --- a/common/Logger.h +++ b/common/Logger.h @@ -39,7 +39,7 @@ class Logger: public Singleton }; Logger(): - out(std::cerr), + out(std::ofstream("wenboi.log")), current_log_level(WARNING), log_start_time(time(NULL)) { diff --git a/qtboi/QtBoiMainWindow.cc b/qtboi/QtBoiMainWindow.cc index 2ae25ff..d5d6425 100644 --- a/qtboi/QtBoiMainWindow.cc +++ b/qtboi/QtBoiMainWindow.cc @@ -38,51 +38,15 @@ QtBoiMainWindow::QtBoiMainWindow(QWidget *parent) emuThread = new QtBoiEmuThread(this); emuThread->start(); + connect(emuThread, SIGNAL(redraw(const uchar*)), this, SLOT(onRedraw(const uchar*))); + connect(emuThread, SIGNAL(emulationPaused()), this, SLOT(onPause())); - loadROM = new QAction(tr("&Load ROM..."), this); - quit = new QAction(tr("&Quit"), this); - emulatorPause = new QAction(tr("&Pause"), this); - emulatorCont = new QAction(tr("&Go"), this); - emulatorStop = new QAction(tr("&Stop"), this); - emulatorStep = new QAction(tr("St&ep"), this); - emulatorReset = new QAction(tr("&Reset"), this); - - scalingGroup = new QActionGroup(this); - scalingNone = new QAction(tr("&None"), scalingGroup); - scalingQImage = new QAction(tr("&QImage"), scalingGroup); - scalingScale2X = new QAction(tr("Scale&2X"), scalingGroup); - scalingNone->setCheckable(true); - scalingQImage->setCheckable(true); - scalingScale2X->setCheckable(true); - scalingQImage->setChecked(true); - - - loadROM->setShortcut(QKeySequence(tr("Ctrl+O", "File|Load ROM..."))); - emulatorCont->setShortcut(QKeySequence(tr("F5", "Emulator|Go"))); - emulatorPause->setShortcut(QKeySequence(tr("F6", "Emulator|Pause"))); - emulatorStep->setShortcut(QKeySequence(tr("F7", "Debug|Step"))); - //emulatorCont->setIcon(QIcon("../icons/player_play.svg")); - //emulatorPause->setIcon(QIcon("../icons/player_pause.svg")); - //loadROM->setIcon(QIcon("../icons/fileopen.svg")); - + createActions(); createMenu(); createToolbar(); - statusbar = statusBar(); - connect(emulatorCont, SIGNAL(triggered()), emuThread, SLOT(cont())); - connect(emulatorCont, SIGNAL(triggered()), this, SLOT(onResume())); - connect(emulatorStop, SIGNAL(triggered()), emuThread, SLOT(stop())); - connect(emulatorPause, SIGNAL(triggered()), emuThread, SLOT(pause())); - connect(emulatorStep, SIGNAL(triggered()), emuThread, SLOT(step())); - connect(emulatorReset, SIGNAL(triggered()), emuThread, SLOT(reset())); - connect(emuThread, SIGNAL(redraw(const uchar*)), this, SLOT(onRedraw(const uchar*))); - connect(emuThread, SIGNAL(emulationPaused()), this, SLOT(onPause())); - connect(scalingNone, SIGNAL(triggered()), this, SLOT(onScalingNone())); - connect(scalingQImage, SIGNAL(triggered()), this, SLOT(onScalingQImage())); - connect(scalingScale2X, SIGNAL(triggered()), this, SLOT(onScalingScale2X())); - - resize(800,600); + //resize(800,600); centralWindow = new QWidget(this); setCentralWidget(centralWindow); @@ -96,11 +60,6 @@ QtBoiMainWindow::QtBoiMainWindow(QWidget *parent) rightVBox->setLayout(rightVBoxLayout); screen = new QLabel(centralWindow); - screen->resize(320,288); - uchar buf[160*144]; - memset(buf, 0, 160*144); - onRedraw(buf); - status = new QtBoiStatusWindow(centralWindow, &emuThread->gb); status->setFont(QFont("courier")); @@ -110,13 +69,17 @@ QtBoiMainWindow::QtBoiMainWindow(QWidget *parent) leftVBoxLayout->addWidget(status); disassembly = new QtBoiDisassemblyWindow(centralWindow, &emuThread->gb, &tags); - connect(disassembly, SIGNAL(anchorClicked(const QUrl&)), this, SLOT(onDisassemblyAnchorClicked(const QUrl&))); - rightVBoxLayout->addWidget(disassembly); - + centralWindow->setLayout(topHBoxLayout); + // draw blank screen, set default visibility for subwindows + onViewDisassemblyWindow(); + onViewStatusWindow(); + uchar buf[160*144]; + memset(buf, 0, 160*144); + onRedraw(buf); } QtBoiMainWindow::~QtBoiMainWindow() @@ -131,6 +94,56 @@ QtBoiMainWindow::~QtBoiMainWindow() } } + +void QtBoiMainWindow::createActions() +{ + loadROM = new QAction(tr("&Load ROM..."), this); + quit = new QAction(tr("&Quit"), this); + emulatorPause = new QAction(tr("&Pause"), this); + emulatorCont = new QAction(tr("&Go"), this); + emulatorStop = new QAction(tr("&Stop"), this); + emulatorStep = new QAction(tr("St&ep"), this); + emulatorReset = new QAction(tr("&Reset"), this); + + viewDisassemblyWindow = new QAction(tr("&Disassembly window"), this); + viewStatusWindow = new QAction(tr("&Status window"), this); + viewDisassemblyWindow->setCheckable(true); + viewStatusWindow->setCheckable(true); + viewDisassemblyWindow->setChecked(true); + viewStatusWindow->setChecked(true); + + scalingGroup = new QActionGroup(this); + scalingNone = new QAction(tr("&None"), scalingGroup); + scalingQImage = new QAction(tr("&QImage"), scalingGroup); + scalingScale2X = new QAction(tr("Scale&2X"), scalingGroup); + scalingNone->setCheckable(true); + scalingQImage->setCheckable(true); + scalingScale2X->setCheckable(true); + scalingQImage->setChecked(true); + + + loadROM->setShortcut(QKeySequence(tr("Ctrl+O", "File|Load ROM..."))); + emulatorCont->setShortcut(QKeySequence(tr("F5", "Emulator|Go"))); + emulatorPause->setShortcut(QKeySequence(tr("F6", "Emulator|Pause"))); + emulatorStep->setShortcut(QKeySequence(tr("F7", "Debug|Step"))); + //emulatorCont->setIcon(QIcon("../icons/player_play.svg")); + //emulatorPause->setIcon(QIcon("../icons/player_pause.svg")); + //loadROM->setIcon(QIcon("../icons/fileopen.svg")); + + connect(emulatorCont, SIGNAL(triggered()), emuThread, SLOT(cont())); + connect(emulatorCont, SIGNAL(triggered()), this, SLOT(onResume())); + connect(emulatorStop, SIGNAL(triggered()), emuThread, SLOT(stop())); + connect(emulatorPause, SIGNAL(triggered()), emuThread, SLOT(pause())); + connect(emulatorStep, SIGNAL(triggered()), emuThread, SLOT(step())); + connect(emulatorReset, SIGNAL(triggered()), emuThread, SLOT(reset())); + connect(viewDisassemblyWindow, SIGNAL(triggered()), this, SLOT(onViewDisassemblyWindow())); + connect(viewStatusWindow, SIGNAL(triggered()), this, SLOT(onViewStatusWindow())); + connect(scalingNone, SIGNAL(triggered()), this, SLOT(onScalingNone())); + connect(scalingQImage, SIGNAL(triggered()), this, SLOT(onScalingQImage())); + connect(scalingScale2X, SIGNAL(triggered()), this, SLOT(onScalingScale2X())); +} + + void QtBoiMainWindow::createMenu() { QMenu *file; @@ -140,6 +153,8 @@ void QtBoiMainWindow::createMenu() QMenu *view; view = menuBar()->addMenu(tr("&View")); + view->addAction(viewDisassemblyWindow); + view->addAction(viewStatusWindow); QMenu *viewScalingMethod; viewScalingMethod = view->addMenu(tr("&Scaling method")); @@ -291,22 +306,22 @@ void QtBoiMainWindow::scale2x(const QImage *src, QImage *dst) if (y < src_h-1) I = src_pixels[src_w*(y+1)+x]; else I = F; } - if (B != H && D != F) { - E0 = D == B ? D : E; - E1 = B == F ? F : E; - E2 = D == H ? D : E; - E3 = H == F ? F : E; - } else { - E0 = E; - E1 = E; - E2 = E; - E3 = E; - } - - int dst_offset = dst->width()*2*y+2*x; - dst_pixels[dst_offset] = (E0 << 16) | (E0 << 8) | E0; - dst_pixels[dst_offset+1] = (E1 << 16) | (E1 << 8) | E1; - dst_pixels[dst_offset+320] = (E2 << 16) | (E2 << 8) | E2; + if (B != H && D != F) { + E0 = D == B ? D : E; + E1 = B == F ? F : E; + E2 = D == H ? D : E; + E3 = H == F ? F : E; + } else { + E0 = E; + E1 = E; + E2 = E; + E3 = E; + } + + int dst_offset = dst->width()*2*y+2*x; + dst_pixels[dst_offset] = (E0 << 16) | (E0 << 8) | E0; + dst_pixels[dst_offset+1] = (E1 << 16) | (E1 << 8) | E1; + dst_pixels[dst_offset+320] = (E2 << 16) | (E2 << 8) | E2; dst_pixels[dst_offset+321] = (E3 << 16) | (E3 << 8) | E3; } } @@ -328,6 +343,25 @@ void QtBoiMainWindow::onScalingScale2X() scalingMethod = SCALING_SCALE2X; } +void QtBoiMainWindow::onViewDisassemblyWindow() +{ + if (viewDisassemblyWindow->isChecked()) { + disassembly->show(); + } else { + disassembly->hide(); + } +} + +void QtBoiMainWindow::onViewStatusWindow() +{ + if (viewStatusWindow->isChecked()) { + status->show(); + } else { + status->hide(); + } +} + + void QtBoiMainWindow::onPause() { status->setText(QString(emuThread->gb.status_string().c_str())); diff --git a/qtboi/QtBoiMainWindow.h b/qtboi/QtBoiMainWindow.h index babe919..8e24113 100644 --- a/qtboi/QtBoiMainWindow.h +++ b/qtboi/QtBoiMainWindow.h @@ -35,6 +35,8 @@ class QtBoiMainWindow: public QMainWindow void onScalingNone(); void onScalingQImage(); void onScalingScale2X(); + void onViewDisassemblyWindow(); + void onViewStatusWindow(); private: enum ScalingMethod {SCALING_NONE, SCALING_QIMAGE, SCALING_SCALE2X}; @@ -43,6 +45,7 @@ class QtBoiMainWindow: public QMainWindow // private functions void scale2x(const QImage *src, QImage *dst); + void createActions(); void createMenu(); void createToolbar(); @@ -75,6 +78,9 @@ class QtBoiMainWindow: public QMainWindow QAction *emulatorStep; QAction *emulatorReset; + QAction *viewDisassemblyWindow; + QAction *viewStatusWindow; + QActionGroup *scalingGroup; QAction *scalingNone; QAction *scalingQImage; -- 2.34.1