From 6618dd130b72fa3c19b7583855f227160c3384c1 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Sat, 5 Jan 2019 21:23:00 -0600 Subject: [PATCH] Add "settings" dialog, fixes to work with MXE cross-compilation. --- .gitignore | 4 +- src/fileio.cpp | 131 ++++++++++++++++++++++++++++++++++++++++- src/fileio.h | 25 ++++---- src/global.cpp | 5 +- src/global.h | 6 +- src/mainwin.cpp | 26 +++++++- src/mainwin.h | 8 +-- src/settingsdialog.cpp | 44 ++++++++++++++ src/settingsdialog.h | 27 +++++++++ wozmaker.pro | 4 +- 10 files changed, 254 insertions(+), 26 deletions(-) create mode 100644 src/settingsdialog.cpp create mode 100644 src/settingsdialog.h diff --git a/.gitignore b/.gitignore index ad3055e..e37d149 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ mandelbrot/ gmon.out analysis1.ods wozmaker -Makefile +Makefile* res/*.xcf .qmake.stash +release/ +win64/ diff --git a/src/fileio.cpp b/src/fileio.cpp index 3261c2c..d8ff465 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -171,11 +171,13 @@ Really, this crap should go into fileio.cpp. !!! FIX !!! if (Global::a2rSize > (60 + Uint32LE(Global::a2r->strmSize))) { - Global::metadata = (A2RMetadata *)((uint8_t *)Global::a2r + (60 + Uint32LE(Global::a2r->strmSize))); + Global::metadata = (Metadata *)((uint8_t *)Global::a2r + (60 + Uint32LE(Global::a2r->strmSize))); // Make sure it's plausible metadata if (memcmp(Global::metadata->metaTag, "META", 4) != 0) Global::metadata = NULL; + else + UnpackMetadata(Global::metadata); } // Unpack TMNG & XTMG streams to simplify analysis @@ -289,3 +291,130 @@ bool WriteWOZFile(const char * filename) return true; } + +void UnpackMetadata(Metadata * data) +{ + uint32_t start = 0; + uint32_t end = Uint32LE(data->metaSize); + uint32_t i = 0; + Global::metaCount = 0; + + while (start < end) + { + if (i < 255) + Global::meta[Global::metaCount][i++] = data->data[start]; + + start++; + + if (data->data[start] == '\x0A') + { + Global::meta[Global::metaCount][i] = 0; + Global::metaCount++; + i = 0; + start++; + } + } +} + + +uint8_t * GetMetadata(const char * keyword) +{ + uint32_t kwLen = strlen(keyword); + + for(uint8_t i=0; i= kwLen) + && (memcmp(Global::meta[i], keyword, kwLen) == 0)) + { + return &Global::meta[i][kwLen]; + } + } + + return NULL; +} + + +uint16_t GetRequiredMachineBits(void) +{ + uint8_t * kw = GetMetadata("requires_machine\x09"); + uint32_t kwLen = strlen((char *)kw); + uint16_t bits = 0; + char type[8]; + uint8_t typeLen = 0; + + for(uint32_t i=0; i class A2R; -class A2RMetadata; class A2RStream; +class Metadata; class Global { @@ -13,7 +13,7 @@ class Global public: static A2R * a2r; static uint32_t a2rSize; - static A2RMetadata * metadata; + static Metadata * metadata; static A2RStream * stream[800]; static uint32_t numStreams; static uint8_t bitStream[80000]; @@ -38,6 +38,8 @@ class Global static uint8_t bStream[141][80000]; static uint32_t bStreamLen[141]; static uint32_t bStreamLenBits[141]; + static uint8_t meta[32][256]; + static uint8_t metaCount; }; #endif // __GLOBAL_H__ diff --git a/src/mainwin.cpp b/src/mainwin.cpp index e98031d..4ca0ae1 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -17,6 +17,7 @@ #include "mainwidget.h" #include "navwidget.h" #include "nibblewidget.h" +#include "settingsdialog.h" #include "waveformwidget.h" @@ -31,8 +32,11 @@ MainWin::MainWin() loadFile = CreateAction(tr("&Open"), tr("Open A2R"), tr("Open an A2R file"), QIcon(), QKeySequence(tr("ctrl+o"))); connect(loadFile, SIGNAL(triggered()), this, SLOT(HandleLoadFile())); - newGame = CreateAction(tr("&New"), tr("New Game"), tr("Start a new game of Warehouse Man Deluxe"), QIcon(), QKeySequence(tr("ctrl+n"))); -// connect(newGame, SIGNAL(triggered()), this, SLOT(HandleNewGame())); + saveFile = CreateAction(tr("&Save"), tr("Save WOZ"), tr("Save a WOZ file"), QIcon(), QKeySequence(tr("ctrl+s"))); + connect(saveFile, SIGNAL(triggered()), this, SLOT(HandleSaveFile())); + + settings = CreateAction(tr("&Disk Settings"), tr("Disk Settings"), tr("Settings for the loaded A2R file"), QIcon(), QKeySequence(tr("ctrl+d"))); + connect(settings, SIGNAL(triggered()), this, SLOT(HandleSettings())); undoAction = CreateAction(tr("&Undo"), tr(""), tr(""), QIcon(), QKeySequence(tr("ctrl+z"))); // connect(undoAction, SIGNAL(triggered()), this, SLOT(HandleUndo())); @@ -66,6 +70,8 @@ MainWin::MainWin() QMenu * menu = menuBar()->addMenu(tr("&File")); menu->addAction(loadFile); + menu->addAction(saveFile); + menu->addAction(settings); menu->addSeparator(); // menu->addAction(undoAction); // menu->addAction(resetLevel); @@ -197,6 +203,22 @@ void MainWin::HandleLoadFile(void) } +void MainWin::HandleSaveFile(void) +{ +} + + +void MainWin::HandleSettings(void) +{ + SettingsDialog dlg(this); + + if (dlg.exec() == false) + return; + + // Deal with stuff here, since user hit "OK" button +} + + void MainWin::AboutWozMaker(void) { QMessageBox::about(this, tr("About WOZ Maker"), tr("WOZ Maker v1.0.0\n\nWritten by James Hammons\n\nCopyright (C) 2018 Underground Software")); diff --git a/src/mainwin.h b/src/mainwin.h index b3edaaa..a7e9cdc 100644 --- a/src/mainwin.h +++ b/src/mainwin.h @@ -27,22 +27,22 @@ class MainWin: public QMainWindow protected slots: void closeEvent(QCloseEvent * event); void HandleLoadFile(void); + void HandleSaveFile(void); + void HandleSettings(void); void AboutWozMaker(void); -// bool LoadA2R(const QString); private: MainWidget * mainWidget; InfoWidget * infoWidget; NavWidget * navWidget; QAction * loadFile; + QAction * saveFile; + QAction * settings; - QAction * newGame; QAction * undoAction; - QAction * gameOptions; QAction * gameStats; - QAction * appExit; QAction * appAbout; QAction * resetLevel; diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp new file mode 100644 index 0000000..3321f30 --- /dev/null +++ b/src/settingsdialog.cpp @@ -0,0 +1,44 @@ +// +// settingsdialog.cpp: Dialog for changing Architektonas settings +// +// Part of the Architektonas Project +// (C) 2011 Underground Software +// See the README and GPLv3 files for licensing and warranty information +// +// JLH = James Hammons +// +// WHO WHEN WHAT +// --- ---------- ------------------------------------------------------------ +// JLH 06/04/2011 Created this file + +#include "settingsdialog.h" +//#include "baseunittab.h" +//#include "generaltab.h" + + +SettingsDialog::SettingsDialog(QWidget * parent/*= 0*/): QDialog(parent) +{ +// tabWidget = new QTabWidget; +// generalTab = new GeneralTab(this); +// baseunitTab = new BaseUnitTab(this); +// tabWidget->addTab(generalTab, tr("General")); +// tabWidget->addTab(baseunitTab, tr("Base Unit")); + + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + QVBoxLayout * mainLayout = new QVBoxLayout; +// mainLayout->addWidget(tabWidget); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + + setWindowTitle(tr("WOZ Maker Disk Settings")); +} + + +SettingsDialog::~SettingsDialog() +{ +} + diff --git a/src/settingsdialog.h b/src/settingsdialog.h new file mode 100644 index 0000000..79ff882 --- /dev/null +++ b/src/settingsdialog.h @@ -0,0 +1,27 @@ +#ifndef __SETTINGSDIALOG_H__ +#define __SETTINGSDIALOG_H__ + +#include + +//class GeneralTab; +//class BaseUnitTab; + +class SettingsDialog: public QDialog +{ + Q_OBJECT + + public: + SettingsDialog(QWidget * parent = 0); + ~SettingsDialog(); + + private: +// QTabWidget * tabWidget; + QDialogButtonBox * buttonBox; + + public: +// GeneralTab * generalTab; +// BaseUnitTab * baseunitTab; +}; + +#endif // __SETTINGSDIALOG_H__ + diff --git a/wozmaker.pro b/wozmaker.pro index 8c42cb9..f4e68db 100644 --- a/wozmaker.pro +++ b/wozmaker.pro @@ -1,6 +1,6 @@ # Use 'qmake -o Makefile wozmaker.pro' -CONFIG += qt warn_on release debug +CONFIG += qt warn_on release c++11 RESOURCES += res/resources.qrc #LIBS += -Ldxflib/lib -ldxf #LIBS += -lao @@ -31,6 +31,7 @@ HEADERS = \ src/mainwin.h \ src/navwidget.h \ src/nibblewidget.h \ + src/settingsdialog.h \ src/waveformwidget.h SOURCES = \ @@ -46,5 +47,6 @@ SOURCES = \ src/mainwin.cpp \ src/navwidget.cpp \ src/nibblewidget.cpp \ + src/settingsdialog.cpp \ src/waveformwidget.cpp -- 2.37.2