diff --git a/purify/nall/emulation/super-famicom-usart.hpp b/purify/nall/emulation/super-famicom-usart.hpp index 60d8ebbd..68dea605 100755 --- a/purify/nall/emulation/super-famicom-usart.hpp +++ b/purify/nall/emulation/super-famicom-usart.hpp @@ -35,7 +35,7 @@ extern "C" usartproc void usart_init( usart_write = write; } -extern "C" usartproc void usart_main(); +extern "C" usartproc void usart_main(int, char**); // @@ -84,21 +84,19 @@ static void sigint(int) { } int main(int argc, char **argv) { - //requires superuser privileges; otherwise priority = +0 - setpriority(PRIO_PROCESS, 0, -20); + setpriority(PRIO_PROCESS, 0, -20); //requires superuser privileges; otherwise priority = +0 signal(SIGINT, sigint); - bool result = false; - if(argc == 1) result = usart.open("/dev/ttyACM0", 57600, true); - if(argc == 2) result = usart.open(argv[1], 57600, true); - if(result == false) { + if(usart.open("/dev/ttyACM0", 57600, true) == false) { printf("error: unable to open USART hardware device\n"); return 0; } + usart_is_virtual = false; usart_init(usarthw_quit, usarthw_usleep, usarthw_readable, usarthw_read, usarthw_writable, usarthw_write); - usart_main(); + usart_main(argc, argv); usart.close(); + return 0; } diff --git a/purify/nall/emulation/super-famicom.hpp b/purify/nall/emulation/super-famicom.hpp index 70990de0..597f9893 100755 --- a/purify/nall/emulation/super-famicom.hpp +++ b/purify/nall/emulation/super-famicom.hpp @@ -242,14 +242,14 @@ SuperFamicomCartridge::SuperFamicomCartridge(const uint8_t *data, unsigned size) " \n" " \n" " \n" - " \n" + " \n" " \n" " \n" " \n" " \n" ); if(ram_size > 0) markup.append( - " \n" + " \n" " \n" " \n" " \n" @@ -265,7 +265,7 @@ SuperFamicomCartridge::SuperFamicomCartridge(const uint8_t *data, unsigned size) " \n" " \n" " \n" - " \n" + " \n" " \n" " \n" " \n" @@ -274,7 +274,7 @@ SuperFamicomCartridge::SuperFamicomCartridge(const uint8_t *data, unsigned size) " \n" ); if(ram_size > 0) markup.append( - " \n" + " \n" " \n" " \n" " \n" diff --git a/purify/nall/stream/stream.hpp b/purify/nall/stream/stream.hpp index d2ef44c5..9d937729 100755 --- a/purify/nall/stream/stream.hpp +++ b/purify/nall/stream/stream.hpp @@ -69,7 +69,7 @@ struct stream { struct byte { operator uint8_t() const { return s.read(offset); } - byte& operator=(uint8_t data) { s.write(offset, data); } + byte& operator=(uint8_t data) { s.write(offset, data); return *this; } byte(const stream &s, unsigned offset) : s(s), offset(offset) {} private: diff --git a/purify/nall/string.hpp b/purify/nall/string.hpp index 2fbc1619..8c4f6b2c 100755 --- a/purify/nall/string.hpp +++ b/purify/nall/string.hpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/purify/nall/string/base.hpp b/purify/nall/string/base.hpp index c3b01bb3..f70c1247 100755 --- a/purify/nall/string/base.hpp +++ b/purify/nall/string/base.hpp @@ -22,6 +22,8 @@ namespace nall { }; struct string { + inline static string read(const string &filename); + inline void reserve(unsigned); inline bool empty() const; diff --git a/purify/nall/string/static.hpp b/purify/nall/string/static.hpp new file mode 100755 index 00000000..ca521cb0 --- /dev/null +++ b/purify/nall/string/static.hpp @@ -0,0 +1,13 @@ +#ifdef NALL_STRING_INTERNAL_HPP + +namespace nall { + +string string::read(const string &filename) { + string data; + data.readfile(filename); + return data; +} + +} + +#endif diff --git a/purify/nall/vector.hpp b/purify/nall/vector.hpp index 3fbc61d0..13200ea6 100755 --- a/purify/nall/vector.hpp +++ b/purify/nall/vector.hpp @@ -29,7 +29,7 @@ namespace nall { unsigned capacity() const { return poolsize; } T* move() { - T *result = data; + T *result = pool; pool = nullptr; poolsize = 0; objectsize = 0; diff --git a/purify/phoenix/core/core.cpp b/purify/phoenix/core/core.cpp index 3a7b183e..a6a1ce38 100755 --- a/purify/phoenix/core/core.cpp +++ b/purify/phoenix/core/core.cpp @@ -14,7 +14,6 @@ #endif static bool OS_quit = false; -Window Window::None; //Color //===== @@ -211,6 +210,10 @@ Timer::~Timer() { //Window //====== +Window& Window::none() { + return pWindow::none(); +} + void Window::append_(Layout &layout) { if(state.layout.append(layout)) { ((Sizable&)layout).state.window = this; diff --git a/purify/phoenix/core/core.hpp b/purify/phoenix/core/core.hpp index 37930516..1e88ca5d 100755 --- a/purify/phoenix/core/core.hpp +++ b/purify/phoenix/core/core.hpp @@ -167,13 +167,14 @@ struct Timer : private nall::base_from_member, Object { }; struct Window : private nall::base_from_member, Object { - static Window None; nall::function onClose; nall::function onKeyPress; nall::function onKeyRelease; nall::function onMove; nall::function onSize; + static Window& none(); + inline void append() {} inline void remove() {} template void append(T &arg, Args&... args) { append_(arg); append(args...); } diff --git a/purify/phoenix/gtk/dialog-window.cpp b/purify/phoenix/gtk/dialog-window.cpp index b9d64886..eb04bd64 100755 --- a/purify/phoenix/gtk/dialog-window.cpp +++ b/purify/phoenix/gtk/dialog-window.cpp @@ -3,11 +3,11 @@ static string FileDialog(bool save, Window &parent, const string &path, const ls GtkWidget *dialog = gtk_file_chooser_dialog_new( save == 0 ? "Load File" : "Save File", - &parent != &Window::None ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)0, + &parent != &Window::none() ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)nullptr, save == 0 ? GTK_FILE_CHOOSER_ACTION_OPEN : GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - (const gchar*)0 + (const gchar*)nullptr ); if(path) gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), path); @@ -47,11 +47,11 @@ string pDialogWindow::folderSelect(Window &parent, const string &path) { GtkWidget *dialog = gtk_file_chooser_dialog_new( "Select Folder", - &parent != &Window::None ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)0, + &parent != &Window::none() ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)nullptr, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - (const gchar*)0 + (const gchar*)nullptr ); if(path) gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), path); diff --git a/purify/phoenix/gtk/message-window.cpp b/purify/phoenix/gtk/message-window.cpp index d0b4f7b4..7cd2172a 100755 --- a/purify/phoenix/gtk/message-window.cpp +++ b/purify/phoenix/gtk/message-window.cpp @@ -13,7 +13,7 @@ MessageWindow::Response pMessageWindow::information(Window &parent, const string if(buttons == MessageWindow::Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL; if(buttons == MessageWindow::Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO; GtkWidget *dialog = gtk_message_dialog_new( - &parent != &Window::None ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)0, + &parent != &Window::none() ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, buttonsType, "%s", (const char*)text ); gint response = gtk_dialog_run(GTK_DIALOG(dialog)); @@ -26,7 +26,7 @@ MessageWindow::Response pMessageWindow::question(Window &parent, const string &t if(buttons == MessageWindow::Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL; if(buttons == MessageWindow::Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO; GtkWidget *dialog = gtk_message_dialog_new( - &parent != &Window::None ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)0, + &parent != &Window::none() ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, buttonsType, "%s", (const char*)text ); gint response = gtk_dialog_run(GTK_DIALOG(dialog)); @@ -39,7 +39,7 @@ MessageWindow::Response pMessageWindow::warning(Window &parent, const string &te if(buttons == MessageWindow::Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL; if(buttons == MessageWindow::Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO; GtkWidget *dialog = gtk_message_dialog_new( - &parent != &Window::None ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)0, + &parent != &Window::none() ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, buttonsType, "%s", (const char*)text ); gint response = gtk_dialog_run(GTK_DIALOG(dialog)); @@ -52,7 +52,7 @@ MessageWindow::Response pMessageWindow::critical(Window &parent, const string &t if(buttons == MessageWindow::Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL; if(buttons == MessageWindow::Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO; GtkWidget *dialog = gtk_message_dialog_new( - &parent != &Window::None ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)0, + &parent != &Window::none() ? GTK_WINDOW(parent.p.widget) : (GtkWindow*)nullptr, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, buttonsType, "%s", (const char*)text ); gint response = gtk_dialog_run(GTK_DIALOG(dialog)); diff --git a/purify/phoenix/gtk/platform.hpp b/purify/phoenix/gtk/platform.hpp index dfb4986c..344e8239 100755 --- a/purify/phoenix/gtk/platform.hpp +++ b/purify/phoenix/gtk/platform.hpp @@ -103,6 +103,8 @@ struct pWindow : public pObject { GtkAllocation lastAllocation; bool onSizePending; + static Window& none(); + void append(Layout &layout); void append(Menu &menu); void append(Widget &widget); diff --git a/purify/phoenix/gtk/window.cpp b/purify/phoenix/gtk/window.cpp index f1df5584..ae1521a3 100755 --- a/purify/phoenix/gtk/window.cpp +++ b/purify/phoenix/gtk/window.cpp @@ -116,6 +116,12 @@ static void Window_sizeRequest(GtkWidget *widget, GtkRequisition *requisition, W requisition->height = window->state.geometry.height; } +Window& pWindow::none() { + static Window *window = nullptr; + if(window == nullptr) window = new Window; + return *window; +} + void pWindow::append(Layout &layout) { Geometry geometry = this->geometry(); geometry.x = geometry.y = 0; diff --git a/purify/phoenix/qt/dialog-window.cpp b/purify/phoenix/qt/dialog-window.cpp index 82c6af5c..680a6e2e 100755 --- a/purify/phoenix/qt/dialog-window.cpp +++ b/purify/phoenix/qt/dialog-window.cpp @@ -16,7 +16,7 @@ string pDialogWindow::fileOpen(Window &parent, const string &path, const lstring } QString filename = QFileDialog::getOpenFileName( - &parent != &Window::None ? parent.p.qtWindow : 0, "Load File", + &parent != &Window::none() ? parent.p.qtWindow : nullptr, "Open File", QString::fromUtf8(path), QString::fromUtf8(filterList) ); return filename.toUtf8().constData(); @@ -40,7 +40,7 @@ string pDialogWindow::fileSave(Window &parent, const string &path, const lstring } QString filename = QFileDialog::getSaveFileName( - &parent != &Window::None ? parent.p.qtWindow : 0, "Save File", + &parent != &Window::none() ? parent.p.qtWindow : nullptr, "Save File", QString::fromUtf8(path), QString::fromUtf8(filterList) ); return filename.toUtf8().constData(); @@ -48,7 +48,7 @@ string pDialogWindow::fileSave(Window &parent, const string &path, const lstring string pDialogWindow::folderSelect(Window &parent, const string &path) { QString directory = QFileDialog::getExistingDirectory( - &parent != &Window::None ? parent.p.qtWindow : 0, "Select Directory", + &parent != &Window::none() ? parent.p.qtWindow : nullptr, "Select Directory", QString::fromUtf8(path), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); string name = directory.toUtf8().constData(); diff --git a/purify/phoenix/qt/message-window.cpp b/purify/phoenix/qt/message-window.cpp index c850547b..7bceba0f 100755 --- a/purify/phoenix/qt/message-window.cpp +++ b/purify/phoenix/qt/message-window.cpp @@ -20,28 +20,28 @@ static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons but MessageWindow::Response pMessageWindow::information(Window &parent, const string &text, MessageWindow::Buttons buttons) { return MessageWindow_response( - buttons, QMessageBox::information(&parent != &Window::None ? parent.p.qtWindow : 0, " ", + buttons, QMessageBox::information(&parent != &Window::none() ? parent.p.qtWindow : nullptr, " ", QString::fromUtf8(text), MessageWindow_buttons(buttons)) ); } MessageWindow::Response pMessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) { return MessageWindow_response( - buttons, QMessageBox::question(&parent != &Window::None ? parent.p.qtWindow : 0, " ", + buttons, QMessageBox::question(&parent != &Window::none() ? parent.p.qtWindow : nullptr, " ", QString::fromUtf8(text), MessageWindow_buttons(buttons)) ); } MessageWindow::Response pMessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) { return MessageWindow_response( - buttons, QMessageBox::warning(&parent != &Window::None ? parent.p.qtWindow : 0, " ", + buttons, QMessageBox::warning(&parent != &Window::none() ? parent.p.qtWindow : nullptr, " ", QString::fromUtf8(text), MessageWindow_buttons(buttons)) ); } MessageWindow::Response pMessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) { return MessageWindow_response( - buttons, QMessageBox::critical(&parent != &Window::None ? parent.p.qtWindow : 0, " ", + buttons, QMessageBox::critical(&parent != &Window::none() ? parent.p.qtWindow : nullptr, " ", QString::fromUtf8(text), MessageWindow_buttons(buttons)) ); } diff --git a/purify/phoenix/qt/platform.moc b/purify/phoenix/qt/platform.moc index 991dbebf..3b2db923 100755 --- a/purify/phoenix/qt/platform.moc +++ b/purify/phoenix/qt/platform.moc @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'platform.moc.hpp' ** -** Created: Mon Jun 18 07:31:52 2012 +** Created: Sun Jul 22 02:20:29 2012 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.3) ** ** WARNING! All changes made in this file will be lost! diff --git a/purify/phoenix/qt/platform.moc.hpp b/purify/phoenix/qt/platform.moc.hpp index f3e39bb7..9e75fdc8 100755 --- a/purify/phoenix/qt/platform.moc.hpp +++ b/purify/phoenix/qt/platform.moc.hpp @@ -117,6 +117,8 @@ public: QStatusBar *qtStatus; QWidget *qtContainer; + static Window& none(); + void append(Layout &layout); void append(Menu &menu); void append(Widget &widget); diff --git a/purify/phoenix/qt/window.cpp b/purify/phoenix/qt/window.cpp index 9ea0d9a4..c6cb35d6 100755 --- a/purify/phoenix/qt/window.cpp +++ b/purify/phoenix/qt/window.cpp @@ -1,3 +1,9 @@ +Window& pWindow::none() { + static Window *window = nullptr; + if(window == nullptr) window = new Window; + return *window; +} + void pWindow::append(Layout &layout) { Geometry geometry = window.state.geometry; geometry.x = geometry.y = 0; diff --git a/purify/phoenix/windows/dialog-window.cpp b/purify/phoenix/windows/dialog-window.cpp index dda7d5c9..3005c020 100755 --- a/purify/phoenix/windows/dialog-window.cpp +++ b/purify/phoenix/windows/dialog-window.cpp @@ -33,7 +33,7 @@ static string FileDialog(bool save, Window &parent, const string &path, const ls OPENFILENAME ofn; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = &parent != &Window::None ? parent.p.hwnd : 0; + ofn.hwndOwner = &parent != &Window::none() ? parent.p.hwnd : 0; ofn.lpstrFilter = wfilter; ofn.lpstrInitialDir = wdir; ofn.lpstrFile = wfilename; @@ -59,7 +59,7 @@ string pDialogWindow::fileSave(Window &parent, const string &path, const lstring string pDialogWindow::folderSelect(Window &parent, const string &path) { wchar_t wfilename[PATH_MAX + 1] = L""; BROWSEINFO bi; - bi.hwndOwner = &parent != &Window::None ? parent.p.hwnd : 0; + bi.hwndOwner = &parent != &Window::none() ? parent.p.hwnd : 0; bi.pidlRoot = NULL; bi.pszDisplayName = wfilename; bi.lpszTitle = L""; diff --git a/purify/phoenix/windows/message-window.cpp b/purify/phoenix/windows/message-window.cpp index 45008a95..fca126f4 100755 --- a/purify/phoenix/windows/message-window.cpp +++ b/purify/phoenix/windows/message-window.cpp @@ -13,7 +13,7 @@ MessageWindow::Response pMessageWindow::information(Window &parent, const string if(buttons == MessageWindow::Buttons::Ok) flags |= MB_OK; if(buttons == MessageWindow::Buttons::OkCancel) flags |= MB_OKCANCEL; if(buttons == MessageWindow::Buttons::YesNo) flags |= MB_YESNO; - return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); + return MessageWindow_response(buttons, MessageBox(&parent != &Window::none() ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); } MessageWindow::Response pMessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) { @@ -21,7 +21,7 @@ MessageWindow::Response pMessageWindow::question(Window &parent, const string &t if(buttons == MessageWindow::Buttons::Ok) flags |= MB_OK; if(buttons == MessageWindow::Buttons::OkCancel) flags |= MB_OKCANCEL; if(buttons == MessageWindow::Buttons::YesNo) flags |= MB_YESNO; - return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); + return MessageWindow_response(buttons, MessageBox(&parent != &Window::none() ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); } MessageWindow::Response pMessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) { @@ -29,7 +29,7 @@ MessageWindow::Response pMessageWindow::warning(Window &parent, const string &te if(buttons == MessageWindow::Buttons::Ok) flags |= MB_OK; if(buttons == MessageWindow::Buttons::OkCancel) flags |= MB_OKCANCEL; if(buttons == MessageWindow::Buttons::YesNo) flags |= MB_YESNO; - return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); + return MessageWindow_response(buttons, MessageBox(&parent != &Window::none() ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); } MessageWindow::Response pMessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) { @@ -37,5 +37,5 @@ MessageWindow::Response pMessageWindow::critical(Window &parent, const string &t if(buttons == MessageWindow::Buttons::Ok) flags |= MB_OK; if(buttons == MessageWindow::Buttons::OkCancel) flags |= MB_OKCANCEL; if(buttons == MessageWindow::Buttons::YesNo) flags |= MB_YESNO; - return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); + return MessageWindow_response(buttons, MessageBox(&parent != &Window::none() ? parent.p.hwnd : 0, utf16_t(text), L"", flags)); } diff --git a/purify/phoenix/windows/platform.hpp b/purify/phoenix/windows/platform.hpp index ddc60ffd..96811796 100755 --- a/purify/phoenix/windows/platform.hpp +++ b/purify/phoenix/windows/platform.hpp @@ -96,6 +96,8 @@ struct pWindow : public pObject { HBRUSH brush; COLORREF brushColor; + static Window& none(); + void append(Layout &layout); void append(Menu &menu); void append(Widget &widget); @@ -228,7 +230,7 @@ struct pWidget : public pSizable { virtual void setGeometry(const Geometry &geometry); void setVisible(bool visible); - pWidget(Widget &widget) : pSizable(widget), widget(widget) { parentWindow = &Window::None; } + pWidget(Widget &widget) : pSizable(widget), widget(widget) { parentWindow = &Window::none(); } void constructor(); void destructor(); virtual void orphan(); diff --git a/purify/phoenix/windows/timer.cpp b/purify/phoenix/windows/timer.cpp index 39e32a56..99fb5c00 100755 --- a/purify/phoenix/windows/timer.cpp +++ b/purify/phoenix/windows/timer.cpp @@ -1,4 +1,4 @@ -static linear_vector timers; +static vector timers; static void CALLBACK Timer_timeoutProc(HWND hwnd, UINT msg, UINT_PTR timerID, DWORD time) { for(auto &timer : timers) { diff --git a/purify/phoenix/windows/window.cpp b/purify/phoenix/windows/window.cpp index 8552e40f..dc8aea28 100755 --- a/purify/phoenix/windows/window.cpp +++ b/purify/phoenix/windows/window.cpp @@ -12,6 +12,12 @@ void pWindow::updateModality() { static const unsigned FixedStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_BORDER; static const unsigned ResizableStyle = WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME; +Window& pWindow::none() { + static Window *window = nullptr; + if(window == nullptr) window = new Window; + return *window; +} + void pWindow::append(Layout &layout) { Geometry geom = window.state.geometry; geom.x = geom.y = 0; diff --git a/purify/purify.cpp b/purify/purify.cpp index 652afb32..53575093 100755 --- a/purify/purify.cpp +++ b/purify/purify.cpp @@ -99,8 +99,9 @@ void create_super_famicom(const string &filename, uint8_t *data, unsigned size) if(!file::exists({path, "save.rwm"})) file::copy({nall::basename(filename), ".srm"}, {path, "save.rwm"}); //firmware - if(auto position = information.markup.position("firmware=")) { - string firmware = substr(information.markup, position() + 10); + string firmwareID = "("/"); fileName.setText(notdir(name)); - if(directory::exists({pathname, filename}) && valid_extension(name)) { - create_manifest({pathname, filename}); - } else if(filename.iendswith(".zip")) { + if(filename.iendswith(".zip")) { create_zip({pathname, filename}); } else { create_file({pathname, filename}); @@ -375,16 +394,20 @@ struct Application : Window { HorizontalLayout configLayout; Button emulatorButton; Button pathButton; - HorizontalLayout emulatorLayout; - Label emulatorName; - Label emulatorValue; - HorizontalLayout pathLayout; - Label pathName; - Label pathValue; + HorizontalLayout gridLayout; + VerticalLayout labelLayout; + HorizontalLayout emulatorLayout; + Label emulatorName; + Label emulatorValue; + HorizontalLayout pathLayout; + Label pathName; + Label pathValue; + VerticalLayout synchronizeLayout; + Button synchronizeButton; Application() { - setTitle("purify v00.06"); - setGeometry({128, 128, 440, 180}); + setTitle("purify v00.07"); + setGeometry({128, 128, 600, 200}); layout.setMargin(5); title.setFont("Sans, 16, Bold"); title.setText("Choose Action"); @@ -402,6 +425,8 @@ struct Application : Window { pathName.setFont("Sans, 8, Bold"); pathName.setText("Output Path:"); pathValue.setText(settings.path); + synchronizeButton.setImage({resource::synchronize, sizeof resource::synchronize}); + synchronizeButton.setText("Update Manifests"); Font font("Sans, 8, Bold"); unsigned width = max(font.geometry("Emulator:").width, font.geometry("Output Path:").width); @@ -414,18 +439,36 @@ struct Application : Window { layout.append(configLayout, {~0, ~0}, 5); configLayout.append(emulatorButton, {~0, ~0}, 5); configLayout.append(pathButton, {~0, ~0}); - layout.append(emulatorLayout, {~0, 0}, 5); - emulatorLayout.append(emulatorName, {width, 0}, 5); - emulatorLayout.append(emulatorValue, {~0, 0}); - layout.append(pathLayout, {~0, 0}); - pathLayout.append(pathName, {width, 0}, 5); - pathLayout.append(pathValue, {~0, 0}); + layout.append(gridLayout, {~0, 0}); + gridLayout.append(labelLayout, {~0, 0}, 5); + labelLayout.append(emulatorLayout, {~0, 0}, 5); + emulatorLayout.append(emulatorName, {width, 0}, 5); + emulatorLayout.append(emulatorValue, {~0, 0}); + labelLayout.append(pathLayout, {~0, 0}); + pathLayout.append(pathName, {width, 0}, 5); + pathLayout.append(pathValue, {~0, 0}); + gridLayout.append(synchronizeLayout, {0, 0}); + synchronizeLayout.append(synchronizeButton, {0, 0}); onClose = &OS::quit; playButton.onActivate = {&Application::playAction, this}; convertButton.onActivate = {&Application::convertAction, this}; emulatorButton.onActivate = {&Application::emulatorAction, this}; pathButton.onActivate = {&Application::pathAction, this}; + synchronizeButton.onActivate = [&] { + if(MessageWindow::question(*this, + "This will update all manifest.xml files located in your output path.\n" + "This process may take a few minutes to complete.\n" + "The user interface will not be responsive during this time.\n\n" + "Would you like to proceed?" + ) == MessageWindow::Response::No) return; + + layout.setEnabled(false); + OS::processEvents(); + synchronize_manifests(settings.path); + layout.setEnabled(true); + MessageWindow::information(*this, "Process completed. All identified manifests have been updated."); + }; setVisible(); } @@ -498,6 +541,11 @@ int main(int argc, char **argv) { args.append(argument); } + if(args.size() == 1 && args[0] == "synchronize") { + synchronize_manifests(settings.path); + return 0; + } + if(args.size() == 1 && directory::exists(args[0])) { create_folder(args[0]); return 0; diff --git a/purify/resource/resource.cpp b/purify/resource/resource.cpp index 28adf0dc..5d691900 100755 --- a/purify/resource/resource.cpp +++ b/purify/resource/resource.cpp @@ -212,4 +212,36 @@ const uint8_t path[1176] = { 235,6,248,7,188,50,165,151,203,8,55,43,0,0,0,0,73,69,78,68,174,66,96,130, }; +const uint8_t synchronize[912] = { + 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16,0,0,0,16,8,6,0,0,0,31,243,255, + 97,0,0,0,4,115,66,73,84,8,8,8,8,124,8,100,136,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114, + 101,0,119,119,119,46,105,110,107,115,99,97,112,101,46,111,114,103,155,238,60,26,0,0,3,34,73,68,65,84,56,141, + 109,82,77,108,84,101,20,61,247,123,239,149,249,173,51,109,7,91,168,182,10,134,18,166,161,162,51,141,127,209,152,70, + 55,196,96,88,168,188,68,140,144,129,240,179,97,7,27,12,77,12,17,116,97,162,224,3,163,49,76,37,152,52,1,55, + 252,4,33,146,212,194,171,113,209,208,146,212,210,198,1,70,59,180,29,232,204,180,243,222,251,190,235,162,243,146,89,112, + 146,155,220,197,61,39,39,231,92,98,102,248,72,101,178,207,52,232,218,17,16,222,244,164,106,213,132,152,39,194,184,227, + 202,19,0,46,216,150,233,214,221,30,4,112,130,124,129,116,38,187,69,211,196,64,79,215,42,125,93,103,179,209,214,20, + 1,152,81,40,86,48,50,118,191,124,103,250,161,39,21,239,182,45,243,108,122,87,54,195,140,239,0,196,136,153,145,202, + 100,215,27,186,24,217,218,215,29,138,199,130,208,137,208,28,13,32,28,208,17,13,25,8,26,2,51,197,69,28,207,14, + 87,10,197,138,29,13,53,244,62,46,87,13,102,52,17,51,227,213,61,103,79,245,172,107,251,52,24,48,196,173,209,28, + 170,174,7,67,215,228,154,213,177,197,190,244,243,225,222,245,173,164,9,130,16,132,95,174,77,168,183,94,108,23,7,190, + 190,234,56,174,108,209,1,128,153,63,188,51,93,16,174,167,88,49,47,50,227,51,199,149,103,198,167,103,147,19,247,230, + 143,94,239,104,238,218,183,117,83,40,17,11,225,227,119,187,68,45,6,2,160,4,0,72,169,194,85,199,243,146,47,60, + 251,131,148,234,17,128,65,219,50,243,182,101,94,249,227,219,143,94,26,157,44,236,221,125,236,18,238,63,44,97,122,166, + 12,169,24,0,3,0,11,44,175,170,233,169,72,127,99,36,240,85,103,251,202,110,0,83,117,105,235,186,38,118,110,123, + 39,233,118,62,29,69,162,113,5,52,65,190,3,214,107,119,241,95,63,223,188,128,39,227,180,39,213,107,23,135,39,171, + 87,237,169,37,223,188,227,170,0,0,246,91,168,2,48,106,4,174,155,223,0,236,4,224,62,65,88,183,45,243,158,47, + 224,157,63,250,190,6,16,152,25,23,237,127,212,169,243,127,229,164,84,61,182,101,22,235,89,135,179,99,171,74,229,165, + 142,223,71,198,111,0,136,233,0,64,4,16,17,238,254,87,134,33,24,39,7,255,36,0,95,212,147,83,153,108,152,136, + 238,246,110,92,123,38,63,51,151,2,160,1,168,10,0,16,68,4,0,29,137,16,86,183,132,241,229,254,183,169,173,37, + 114,236,149,61,63,223,74,101,178,233,154,198,246,21,134,174,231,242,179,7,242,133,226,235,154,70,174,109,153,174,88,118, + 64,120,92,113,113,97,104,138,61,143,209,190,50,138,195,59,222,8,125,208,151,124,185,181,57,114,45,189,107,192,53,116, + 241,141,84,50,62,247,104,1,77,141,65,210,132,24,4,0,255,145,168,255,199,161,165,137,220,220,228,165,225,201,206,204, + 150,77,225,68,44,136,238,181,9,122,174,61,30,42,150,93,252,59,91,130,227,120,20,9,26,56,119,121,180,226,73,117, + 4,0,150,31,73,49,77,228,230,78,223,60,185,45,249,160,176,240,73,255,247,55,230,143,15,220,44,13,223,206,35,63, + 91,70,213,149,16,68,40,204,151,228,185,203,163,139,82,169,140,109,153,99,0,224,183,240,19,128,237,182,101,114,45,48, + 3,192,123,13,134,182,87,49,111,144,82,197,13,93,155,33,194,80,213,145,135,108,203,252,219,15,247,127,46,85,118,106, + 19,101,204,198,0,0,0,0,73,69,78,68,174,66,96,130, +}; + }; diff --git a/purify/resource/resource.hpp b/purify/resource/resource.hpp index dc0b1d66..e3f2102b 100755 --- a/purify/resource/resource.hpp +++ b/purify/resource/resource.hpp @@ -3,4 +3,5 @@ namespace resource { extern const uint8_t convert[1155]; extern const uint8_t emulator[2544]; extern const uint8_t path[1176]; + extern const uint8_t synchronize[912]; }; diff --git a/purify/resource/resource.xml b/purify/resource/resource.xml index 6fd53817..586b9516 100755 --- a/purify/resource/resource.xml +++ b/purify/resource/resource.xml @@ -4,4 +4,5 @@ + diff --git a/purify/resource/view-refresh.png b/purify/resource/view-refresh.png new file mode 100755 index 00000000..3fd71d6e Binary files /dev/null and b/purify/resource/view-refresh.png differ