Update to v070r11 release.

byuu says:

- phoenix/All: converted all instances of const char* to const
  nall::string&
  - above used to require: label.setText(string("FPS: ", fps)); but can
    now use: label.setText({"FPS", fps});
  - also avoids the need for the internal implementations to have to
    check for null string pointers
- phoenix/GTK+: no longer disabling double buffering on the viewport.
  Does not cause flickering, and fixes redraw issue on window resize
- phoenix/Qt: like phoenix/GTK+, it will use the default font on the
  menubar as well, so child menu items are consistently sized now
- Linux: file browser can list contents of / and won't let you go
  higher; Windows needs a similar guard for n:/ or \\
- UPS soft-patching support added
- external XML memory map loading support added
- cartridge folder support added: if folder ends in .sfc and there is
  ONE .sfc ROM inside it, it will load the folder as if it were a ROM
- input assignment refreshes text instead of reloading the list, this
  saves your position
  - auto-advance wasn't working very well, will try again later
- input clear all button removed since it's pretty fast now to do
  clear+down:repeat
This commit is contained in:
Tim Allen 2010-10-11 21:34:10 +11:00
parent e2db2c24fc
commit 1926561ced
60 changed files with 387 additions and 316 deletions

View File

@ -2,7 +2,7 @@ static void Button_tick(Button *self) {
if(self->onTick) self->onTick();
}
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_button_new_with_label(text);
widget->parent = &parent;
gtk_widget_set_size_request(object->widget, width, height);

View File

@ -2,7 +2,7 @@ static void CheckBox_tick(CheckBox *self) {
if(self->onTick && self->object->locked == false) self->onTick();
}
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_check_button_new_with_label(text);
widget->parent = &parent;
gtk_widget_set_size_request(object->widget, width, height);

View File

@ -2,7 +2,7 @@ void ComboBox_change(ComboBox *self) {
if(self->object->locked == false && self->onChange) self->onChange();
}
void ComboBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void ComboBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_combo_box_new_text();
widget->parent = &parent;
gtk_widget_set_size_request(object->widget, width, height);
@ -28,7 +28,7 @@ void ComboBox::reset() {
counter = 0;
}
void ComboBox::addItem(const char *text) {
void ComboBox::addItem(const string &text) {
gtk_combo_box_append_text(GTK_COMBO_BOX(object->widget), text);
if(counter++ == 0) setSelection(0);
}

View File

@ -2,7 +2,7 @@ static void EditBox_change(EditBox *self) {
if(self->object->locked == false && self->onChange) self->onChange();
}
void EditBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void EditBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_scrolled_window_new(0, 0);
widget->parent = &parent;
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(object->widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@ -42,7 +42,7 @@ string EditBox::text() {
return text;
}
void EditBox::setText(const char *text) {
void EditBox::setText(const string &text) {
object->locked = true;
gtk_text_buffer_set_text(object->textBuffer, text, -1);
object->locked = false;

View File

@ -1,4 +1,4 @@
bool Font::create(const char *name, unsigned size, Font::Style style) {
bool Font::create(const string &name, unsigned size, Font::Style style) {
font->font = pango_font_description_new();
pango_font_description_set_family(font->font, name);
pango_font_description_set_size(font->font, size * PANGO_SCALE);

View File

@ -87,7 +87,7 @@ unsigned OS::desktopHeight() {
return gdk_screen_get_height(gdk_screen_get_default());
}
string OS::folderSelect(Window &parent, const char *path) {
string OS::folderSelect(Window &parent, const string &path) {
string name;
GtkWidget *dialog = gtk_file_chooser_dialog_new(
@ -111,7 +111,7 @@ string OS::folderSelect(Window &parent, const char *path) {
return name;
}
string OS::fileOpen(Window &parent, const char *filter, const char *path) {
string OS::fileOpen(Window &parent, const string &filter, const string &path) {
string name;
GtkWidget *dialog = gtk_file_chooser_dialog_new(
@ -148,7 +148,7 @@ string OS::fileOpen(Window &parent, const char *filter, const char *path) {
return name;
}
string OS::fileSave(Window &parent, const char *filter, const char *path) {
string OS::fileSave(Window &parent, const string &filter, const string &path) {
string name;
GtkWidget *dialog = gtk_file_chooser_dialog_new(

View File

@ -25,7 +25,7 @@ struct Font : Object {
Bold = 1,
Italic = 2,
};
bool create(const char *name, unsigned size, Font::Style style = Style::None);
bool create(const nall::string &name, unsigned size, Font::Style style = Style::None);
Font();
~Font();
//private:
@ -48,8 +48,8 @@ struct Action : Object {
};
struct Menu : Action {
void create(Window &parent, const char *text);
void create(Menu &parent, const char *text);
void create(Window &parent, const nall::string &text);
void create(Menu &parent, const nall::string &text);
};
struct MenuSeparator : Action {
@ -58,20 +58,20 @@ struct MenuSeparator : Action {
struct MenuItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(Menu &parent, const nall::string &text);
};
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(Menu &parent, const nall::string &text);
bool checked();
void setChecked(bool checked = true);
};
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(MenuRadioItem &parent, const char *text);
void create(Menu &parent, const nall::string &text);
void create(MenuRadioItem &parent, const nall::string &text);
bool checked();
void setChecked();
private:
@ -95,7 +95,7 @@ struct Widget : Object {
struct Window : Widget {
nall::function<bool ()> onClose;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
bool focused();
void setFocused();
Geometry geometry();
@ -103,8 +103,8 @@ struct Window : Widget {
void setDefaultFont(Font &font);
void setFont(Font &font);
void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue);
void setTitle(const char *text);
void setStatusText(const char *text);
void setTitle(const nall::string &text);
void setStatusText(const nall::string &text);
void setMenuVisible(bool visible = true);
void setStatusVisible(bool visible = true);
Window();
@ -116,7 +116,7 @@ struct Window : Widget {
struct Button : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
};
struct Canvas : Widget {
@ -132,16 +132,16 @@ struct Canvas : Widget {
struct CheckBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
bool checked();
void setChecked(bool checked = true);
};
struct ComboBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void reset();
void addItem(const char *text);
void addItem(const nall::string &text);
unsigned selection();
void setSelection(unsigned item);
ComboBox();
@ -151,12 +151,12 @@ private:
struct EditBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setFocused();
void setEditable(bool editable = true);
void setWordWrap(bool wordWrap = true);
nall::string text();
void setText(const char *text);
void setText(const nall::string &text);
};
struct HorizontalSlider : Widget {
@ -167,23 +167,23 @@ struct HorizontalSlider : Widget {
};
struct Label : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void setText(const char *text);
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setText(const nall::string &text);
};
struct ListBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
nall::function<void (unsigned)> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setFocused();
void setHeaderVisible(bool headerVisible = true);
void setCheckable(bool checkable = true);
void setFont(Font &font);
void reset();
void resizeColumnsToContent();
void addItem(const char *text);
void setItem(unsigned row, const char *text);
void addItem(const nall::string &text);
void setItem(unsigned row, const nall::string &text);
bool checked(unsigned row);
void setChecked(unsigned row, bool checked = true);
nall::optional<unsigned> selection();
@ -201,8 +201,8 @@ struct ProgressBar : Widget {
struct RadioBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
bool checked();
void setChecked();
private:
@ -212,10 +212,10 @@ private:
struct TextBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setEditable(bool editable = true);
nall::string text();
void setText(const char *text);
void setText(const nall::string &text);
};
struct VerticalSlider : Widget {
@ -242,10 +242,10 @@ struct MessageWindow : Object {
Yes,
No,
};
static Response information(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response question(Window &parent, const char *text, Buttons = Buttons::YesNo);
static Response warning(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response critical(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response information(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
static Response question(Window &parent, const nall::string &text, Buttons = Buttons::YesNo);
static Response warning(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
static Response critical(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
};
struct OS : Object {
@ -255,9 +255,9 @@ struct OS : Object {
static void quit();
static unsigned desktopWidth();
static unsigned desktopHeight();
static nall::string folderSelect(Window &parent, const char *path = "");
static nall::string fileOpen(Window &parent, const char *filter, const char *path = "");
static nall::string fileSave(Window &parent, const char *filter, const char *path = "");
static nall::string folderSelect(Window &parent, const nall::string &path = "");
static nall::string fileOpen(Window &parent, const nall::string &filter, const nall::string &path = "");
static nall::string fileSave(Window &parent, const nall::string &filter, const nall::string &path = "");
//private:
static void initialize();
};

View File

@ -1,4 +1,4 @@
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_label_new(text);
widget->parent = &parent;
gtk_misc_set_alignment(GTK_MISC(object->widget), 0.0, 0.5);
@ -8,6 +8,6 @@ void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsig
gtk_widget_show(object->widget);
}
void Label::setText(const char *text) {
void Label::setText(const string &text) {
gtk_label_set_text(GTK_LABEL(object->widget), text);
}

View File

@ -19,7 +19,7 @@ static void ListBox_tick(GtkCellRendererToggle *cell, gchar *path_string, ListBo
if(self->onTick) self->onTick(index);
}
void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
listBox->selection = -1;
object->widget = gtk_scrolled_window_new(0, 0);
widget->parent = &parent;
@ -111,7 +111,7 @@ void ListBox::resizeColumnsToContent() {
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(object->subWidget));
}
void ListBox::addItem(const char *text) {
void ListBox::addItem(const string &text) {
lstring list;
list.split("\t", text);
GtkTreeIter iter;
@ -120,7 +120,7 @@ void ListBox::addItem(const char *text) {
foreach(item, list) gtk_list_store_set(listBox->store, &iter, index++, (const char*)item, -1);
}
void ListBox::setItem(unsigned row, const char *text) {
void ListBox::setItem(unsigned row, const string &text) {
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(object->subWidget));
GtkTreeIter iter;
for(unsigned i = 0; i <= row; i++) {

View File

@ -28,7 +28,7 @@ Action::Action() {
action->font = 0;
}
void Menu::create(Window &parent, const char *text) {
void Menu::create(Window &parent, const string &text) {
action->font = parent.window->defaultFont;
object->menu = gtk_menu_new();
object->widget = gtk_menu_item_new_with_label(text);
@ -38,7 +38,7 @@ void Menu::create(Window &parent, const char *text) {
gtk_widget_show(object->widget);
}
void Menu::create(Menu &parent, const char *text) {
void Menu::create(Menu &parent, const string &text) {
action->font = parent.action->font;
object->menu = gtk_menu_new();
object->widget = gtk_menu_item_new_with_label(text);
@ -60,7 +60,7 @@ static void MenuItem_tick(MenuItem *self) {
if(self->onTick) self->onTick();
}
void MenuItem::create(Menu &parent, const char *text) {
void MenuItem::create(Menu &parent, const string &text) {
action->font = parent.action->font;
object->widget = gtk_menu_item_new_with_label(text);
g_signal_connect_swapped(G_OBJECT(object->widget), "activate", G_CALLBACK(MenuItem_tick), (gpointer)this);
@ -73,7 +73,7 @@ static void MenuCheckItem_tick(MenuCheckItem *self) {
if(self->onTick && self->object->locked == false) self->onTick();
}
void MenuCheckItem::create(Menu &parent, const char *text) {
void MenuCheckItem::create(Menu &parent, const string &text) {
action->font = parent.action->font;
object->widget = gtk_check_menu_item_new_with_label(text);
g_signal_connect_swapped(G_OBJECT(object->widget), "toggled", G_CALLBACK(MenuCheckItem_tick), (gpointer)this);
@ -96,7 +96,7 @@ static void MenuRadioItem_tick(MenuRadioItem *self) {
if(self->onTick && self->checked() && self->object->locked == false) self->onTick();
}
void MenuRadioItem::create(Menu &parent, const char *text) {
void MenuRadioItem::create(Menu &parent, const string &text) {
first = this;
action->font = parent.action->font;
object->parentMenu = &parent;
@ -107,7 +107,7 @@ void MenuRadioItem::create(Menu &parent, const char *text) {
gtk_widget_show(object->widget);
}
void MenuRadioItem::create(MenuRadioItem &parent, const char *text) {
void MenuRadioItem::create(MenuRadioItem &parent, const string &text) {
first = parent.first;
action->font = parent.action->font;
object->parentMenu = parent.object->parentMenu;

View File

@ -8,56 +8,56 @@ static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons but
return MessageWindow::Response::Ok;
}
MessageWindow::Response MessageWindow::information(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::information(Window &parent, const string &text, MessageWindow::Buttons buttons) {
GtkButtonsType buttonsType = GTK_BUTTONS_OK;
if(buttons == Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL;
if(buttons == Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO;
GtkWidget *dialog = gtk_message_dialog_new(
&parent != &Window::None ? GTK_WINDOW(parent.object->widget) : (GtkWindow*)0,
GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, buttonsType, "%s", text
GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, buttonsType, "%s", (const char*)text
);
gint response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return MessageWindow_response(buttons, response);
}
MessageWindow::Response MessageWindow::question(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) {
GtkButtonsType buttonsType = GTK_BUTTONS_OK;
if(buttons == Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL;
if(buttons == Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO;
GtkWidget *dialog = gtk_message_dialog_new(
&parent != &Window::None ? GTK_WINDOW(parent.object->widget) : (GtkWindow*)0,
GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, buttonsType, "%s", text
GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, buttonsType, "%s", (const char*)text
);
gint response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return MessageWindow_response(buttons, response);
}
MessageWindow::Response MessageWindow::warning(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) {
GtkButtonsType buttonsType = GTK_BUTTONS_OK;
if(buttons == Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL;
if(buttons == Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO;
GtkWidget *dialog = gtk_message_dialog_new(
&parent != &Window::None ? GTK_WINDOW(parent.object->widget) : (GtkWindow*)0,
GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, buttonsType, "%s", text
GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, buttonsType, "%s", (const char*)text
);
gint response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return MessageWindow_response(buttons, response);
}
MessageWindow::Response MessageWindow::critical(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) {
GtkButtonsType buttonsType = GTK_BUTTONS_OK;
if(buttons == Buttons::OkCancel) buttonsType = GTK_BUTTONS_OK_CANCEL;
if(buttons == Buttons::YesNo) buttonsType = GTK_BUTTONS_YES_NO;
GtkWidget *dialog = gtk_message_dialog_new(
&parent != &Window::None ? GTK_WINDOW(parent.object->widget) : (GtkWindow*)0,
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, buttonsType, "%s", text
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, buttonsType, "%s", (const char*)text
);
gint response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);

View File

@ -2,7 +2,7 @@ static void RadioBox_tick(RadioBox *self) {
if(self->onTick && self->checked() && self->object->locked == false) self->onTick();
}
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
first = this;
object->parentWindow = &parent;
object->widget = gtk_radio_button_new_with_label(0, text);
@ -14,7 +14,7 @@ void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, un
gtk_widget_show(object->widget);
}
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
first = parent.first;
object->parentWindow = parent.object->parentWindow;
object->widget = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(parent.object->widget), text);

View File

@ -6,7 +6,7 @@ static void TextBox_change(TextBox *self) {
if(self->object->locked == false && self->onChange) self->onChange();
}
void TextBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void TextBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_entry_new();
widget->parent = &parent;
gtk_entry_set_text(GTK_ENTRY(object->widget), text);
@ -26,7 +26,7 @@ string TextBox::text() {
return gtk_entry_get_text(GTK_ENTRY(object->widget));
}
void TextBox::setText(const char *text) {
void TextBox::setText(const string &text) {
object->locked = true;
gtk_entry_set_text(GTK_ENTRY(object->widget), text);
object->locked = false;

View File

@ -1,7 +1,7 @@
void Viewport::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height) {
object->widget = gtk_drawing_area_new();
widget->parent = &parent;
gtk_widget_set_double_buffered(object->widget, false);
//gtk_widget_set_double_buffered(object->widget, false);
gtk_widget_set_size_request(object->widget, width, height);
GdkColor color;

View File

@ -7,7 +7,7 @@ static gint Window_close(Window *window) {
return true;
}
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
object->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_move(GTK_WINDOW(object->widget), x, y);
@ -76,11 +76,11 @@ void Window::setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) {
gtk_widget_modify_bg(object->widget, GTK_STATE_NORMAL, &color);
}
void Window::setTitle(const char *text) {
void Window::setTitle(const string &text) {
gtk_window_set_title(GTK_WINDOW(object->widget), text);
}
void Window::setStatusText(const char *text) {
void Window::setStatusText(const string &text) {
gtk_statusbar_pop(GTK_STATUSBAR(object->status), 1);
gtk_statusbar_push(GTK_STATUSBAR(object->status), 1, text);
}

View File

@ -1,7 +1,7 @@
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
button->setParent(parent.window->container);
button->setGeometry(x, y, width, height);
button->setText(text);
button->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) button->setFont(*parent.window->defaultFont);
button->show();
button->connect(button, SIGNAL(released()), SLOT(onTick()));

View File

@ -1,7 +1,7 @@
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
checkBox->setParent(parent.window->container);
checkBox->setGeometry(x, y, width, height);
checkBox->setText(text);
checkBox->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) checkBox->setFont(*parent.window->defaultFont);
checkBox->show();
checkBox->connect(checkBox, SIGNAL(stateChanged(int)), SLOT(onTick()));

View File

@ -1,11 +1,11 @@
void ComboBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void ComboBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
comboBox->setParent(parent.window->container);
comboBox->setGeometry(x, y, width, height);
if(*text) {
lstring list;
list.split("\n", text);
foreach(item, list) addItem((const char*)item);
foreach(item, list) addItem(item);
}
comboBox->connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(onChange()));
@ -17,8 +17,8 @@ void ComboBox::reset() {
while(comboBox->count()) comboBox->removeItem(0);
}
void ComboBox::addItem(const char *text) {
comboBox->addItem(text);
void ComboBox::addItem(const string &text) {
comboBox->addItem(QString::fromUtf8(text));
}
unsigned ComboBox::selection() {

View File

@ -1,13 +1,14 @@
void EditBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void EditBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
editBox->setParent(parent.window->container);
editBox->setGeometry(x, y, width, height);
editBox->setText(text);
editBox->setPlainText(QString::fromUtf8(text));
if(parent.window->defaultFont) editBox->setFont(*parent.window->defaultFont);
editBox->show();
editBox->connect(editBox, SIGNAL(textChanged()), SLOT(onChange()));
}
void EditBox::setEditable(bool editable) {
editBox->setReadOnly(editable == false);
}
void EditBox::setWordWrap(bool wordWrap) {
@ -15,9 +16,11 @@ void EditBox::setWordWrap(bool wordWrap) {
}
string EditBox::text() {
return editBox->toPlainText().toUtf8().constData();
}
void EditBox::setText(const char *text) {
void EditBox::setText(const string &text) {
editBox->setPlainText(QString::fromUtf8(text));
}
EditBox::EditBox() {

View File

@ -1,5 +1,5 @@
bool Font::create(const char *name, unsigned size, Font::Style style) {
font->setFamily(name);
bool Font::create(const string &name, unsigned size, Font::Style style) {
font->setFamily(QString::fromUtf8(name));
font->setPointSize(size);
font->setBold((style & Style::Bold) == Style::Bold);
font->setItalic((style & Style::Italic) == Style::Italic);

View File

@ -1,13 +1,13 @@
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
label->setParent(parent.window->container);
label->setGeometry(x, y, width, height);
label->setText(text);
label->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) label->setFont(*parent.window->defaultFont);
label->show();
}
void Label::setText(const char *text) {
label->setText(text);
void Label::setText(const string &text) {
label->setText(QString::fromUtf8(text));
}
Label::Label() {

View File

@ -1,4 +1,4 @@
void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
listBox->setParent(parent.window->container);
listBox->setGeometry(x, y, width, height);
listBox->setAllColumnsShowFocus(true);
@ -7,7 +7,7 @@ void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, uns
lstring list;
list.split("\t", text);
QStringList labels;
foreach(item, list) labels << (const char*)item;
foreach(item, list) labels << QString::fromUtf8(item);
listBox->setColumnCount(list.size());
listBox->setHeaderLabels(labels);
for(unsigned i = 0; i < list.size(); i++) listBox->resizeColumnToContents(i);
@ -41,7 +41,7 @@ void ListBox::resizeColumnsToContent() {
for(unsigned i = 0; i < listBox->columnCount(); i++) listBox->resizeColumnToContents(i);
}
void ListBox::addItem(const char *text) {
void ListBox::addItem(const string &text) {
object->locked = true;
auto items = listBox->findItems("", Qt::MatchContains);
QTreeWidgetItem *item = new QTreeWidgetItem(listBox);
@ -49,16 +49,16 @@ void ListBox::addItem(const char *text) {
item->setData(0, Qt::UserRole, (unsigned)items.size());
lstring list;
list.split("\t", text);
for(unsigned i = 0; i < list.size(); i++) item->setText(i, (const char*)list[i]);
for(unsigned i = 0; i < list.size(); i++) item->setText(i, QString::fromUtf8(list[i]));
object->locked = false;
}
void ListBox::setItem(unsigned row, const char *text) {
void ListBox::setItem(unsigned row, const string &text) {
object->locked = true;
QTreeWidgetItem *item = listBox->topLevelItem(row);
lstring list;
list.split("\t", text);
for(unsigned i = 0; i < list.size(); i++) item->setText(i, (const char*)list[i]);
for(unsigned i = 0; i < list.size(); i++) item->setText(i, QString::fromUtf8(list[i]));
object->locked = false;
}

View File

@ -1,10 +1,14 @@
void Menu::create(Window &parent, const char *text) {
menu->setTitle(text);
void Menu::create(Window &parent, const string &text) {
menu->parent = &parent;
if(menu->parent->window->defaultFont) menu->setFont(*menu->parent->window->defaultFont);
menu->setTitle(QString::fromUtf8(text));
parent.window->menuBar->addMenu(menu);
}
void Menu::create(Menu &parent, const char *text) {
menu->setTitle(text);
void Menu::create(Menu &parent, const string &text) {
menu->parent = parent.menu->parent;
if(menu->parent->window->defaultFont) menu->setFont(*menu->parent->window->defaultFont);
menu->setTitle(QString::fromUtf8(text));
parent.menu->addMenu(menu);
}
@ -52,8 +56,8 @@ MenuSeparator::MenuSeparator() {
menuSeparator = new MenuSeparator::Data(*this);
}
void MenuItem::create(Menu &parent, const char *text) {
menuItem->setText(text);
void MenuItem::create(Menu &parent, const string &text) {
menuItem->setText(QString::fromUtf8(text));
menuItem->connect(menuItem, SIGNAL(triggered()), SLOT(onTick()));
parent.menu->addAction(menuItem);
}
@ -78,8 +82,8 @@ MenuItem::MenuItem() {
menuItem = new MenuItem::Data(*this);
}
void MenuCheckItem::create(Menu &parent, const char *text) {
menuCheckItem->setText(text);
void MenuCheckItem::create(Menu &parent, const string &text) {
menuCheckItem->setText(QString::fromUtf8(text));
menuCheckItem->setCheckable(true);
menuCheckItem->connect(menuCheckItem, SIGNAL(triggered()), SLOT(onTick()));
parent.menu->addAction(menuCheckItem);
@ -113,22 +117,22 @@ MenuCheckItem::MenuCheckItem() {
menuCheckItem = new MenuCheckItem::Data(*this);
}
void MenuRadioItem::create(Menu &parent, const char *text) {
void MenuRadioItem::create(Menu &parent, const string &text) {
menuRadioItem->parent = &parent;
menuRadioItem->actionGroup = new QActionGroup(0);
menuRadioItem->actionGroup->addAction(menuRadioItem);
menuRadioItem->setText(text);
menuRadioItem->setText(QString::fromUtf8(text));
menuRadioItem->setCheckable(true);
menuRadioItem->setChecked(true);
menuRadioItem->connect(menuRadioItem, SIGNAL(changed()), SLOT(onTick()));
menuRadioItem->parent->menu->addAction(menuRadioItem);
}
void MenuRadioItem::create(MenuRadioItem &parent, const char *text) {
void MenuRadioItem::create(MenuRadioItem &parent, const string &text) {
menuRadioItem->parent = parent.menuRadioItem->parent;
menuRadioItem->actionGroup = parent.menuRadioItem->actionGroup;
menuRadioItem->actionGroup->addAction(menuRadioItem);
menuRadioItem->setText(text);
menuRadioItem->setText(QString::fromUtf8(text));
menuRadioItem->setCheckable(true);
menuRadioItem->connect(menuRadioItem, SIGNAL(changed()), SLOT(onTick()));
menuRadioItem->parent->menu->addAction(menuRadioItem);

View File

@ -16,26 +16,30 @@ static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons but
return MessageWindow::Response::Ok;
}
MessageWindow::Response MessageWindow::information(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::information(Window &parent, const string &text, MessageWindow::Buttons buttons) {
return MessageWindow_response(
buttons, QMessageBox::information(&parent != &Window::None ? parent.window : 0, " ", text, MessageWindow_buttons(buttons))
buttons, QMessageBox::information(&parent != &Window::None ? parent.window : 0, " ",
QString::fromUtf8(text), MessageWindow_buttons(buttons))
);
}
MessageWindow::Response MessageWindow::question(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) {
return MessageWindow_response(
buttons, QMessageBox::question(&parent != &Window::None ? parent.window : 0, " ", text, MessageWindow_buttons(buttons))
buttons, QMessageBox::question(&parent != &Window::None ? parent.window : 0, " ",
QString::fromUtf8(text), MessageWindow_buttons(buttons))
);
}
MessageWindow::Response MessageWindow::warning(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) {
return MessageWindow_response(
buttons, QMessageBox::warning(&parent != &Window::None ? parent.window : 0, " ", text, MessageWindow_buttons(buttons))
buttons, QMessageBox::warning(&parent != &Window::None ? parent.window : 0, " ",
QString::fromUtf8(text), MessageWindow_buttons(buttons))
);
}
MessageWindow::Response MessageWindow::critical(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) {
return MessageWindow_response(
buttons, QMessageBox::critical(&parent != &Window::None ? parent.window : 0, " ", text, MessageWindow_buttons(buttons))
buttons, QMessageBox::critical(&parent != &Window::None ? parent.window : 0, " ",
QString::fromUtf8(text), MessageWindow_buttons(buttons))
);
}

View File

@ -69,14 +69,15 @@ unsigned OS::desktopHeight() {
return QApplication::desktop()->screenGeometry().height();
}
string OS::folderSelect(Window &parent, const char *path) {
string OS::folderSelect(Window &parent, const string &path) {
QString directory = QFileDialog::getExistingDirectory(
&parent != &Window::None ? parent.window : 0, "Select Directory", path, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
&parent != &Window::None ? parent.window : 0, "Select Directory",
QString::fromUtf8(path), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
);
return directory.toUtf8().constData();
}
string OS::fileOpen(Window &parent, const char *filter, const char *path) {
string OS::fileOpen(Window &parent, const string &filter, const string &path) {
string filters;
lstring list;
list.split("\n", filter);
@ -93,12 +94,13 @@ string OS::fileOpen(Window &parent, const char *filter, const char *path) {
filters.rtrim(";;");
QString filename = QFileDialog::getOpenFileName(
&parent != &Window::None ? parent.window : 0, "Open File", path, (const char*)filters
&parent != &Window::None ? parent.window : 0, "Open File",
QString::fromUtf8(path), QString::fromUtf8(filters)
);
return filename.toUtf8().constData();
}
string OS::fileSave(Window &parent, const char *filter, const char *path) {
string OS::fileSave(Window &parent, const string &filter, const string &path) {
string filters;
lstring list;
list.split("\n", filter);
@ -115,7 +117,8 @@ string OS::fileSave(Window &parent, const char *filter, const char *path) {
filters.rtrim(";;");
QString filename = QFileDialog::getSaveFileName(
&parent != &Window::None ? parent.window : 0, "Save File", path, (const char*)filters
&parent != &Window::None ? parent.window : 0, "Save File",
QString::fromUtf8(path), QString::fromUtf8(filters)
);
return filename.toUtf8().constData();
}

View File

@ -25,7 +25,7 @@ struct Font : Object {
Bold = 1,
Italic = 2,
};
bool create(const char *name, unsigned size, Font::Style style = Style::None);
bool create(const nall::string &name, unsigned size, Font::Style style = Style::None);
Font();
~Font();
//private:
@ -44,8 +44,8 @@ struct Action : Object {
};
struct Menu : Action {
void create(Window &parent, const char *text);
void create(Menu &parent, const char *text);
void create(Window &parent, const nall::string &text);
void create(Menu &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
@ -70,7 +70,7 @@ struct MenuSeparator : Action {
struct MenuItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(Menu &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
@ -83,7 +83,7 @@ struct MenuItem : Action {
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(Menu &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
@ -98,8 +98,8 @@ struct MenuCheckItem : Action {
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(MenuRadioItem &parent, const char *text);
void create(Menu &parent, const nall::string &text);
void create(MenuRadioItem &parent, const nall::string &text);
bool visible();
void setVisible(bool visible = true);
bool enabled();
@ -129,14 +129,14 @@ struct Widget : Object {
struct Window : Widget {
nall::function<bool ()> onClose;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
Geometry geometry();
void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
void setDefaultFont(Font &font);
void setFont(Font &font);
void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue);
void setTitle(const char *text);
void setStatusText(const char *text);
void setTitle(const nall::string &text);
void setStatusText(const nall::string &text);
void setMenuVisible(bool visible = true);
void setStatusVisible(bool visible = true);
bool focused();
@ -149,7 +149,7 @@ struct Window : Widget {
struct Button : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
Button();
//private:
struct Data;
@ -170,7 +170,7 @@ struct Canvas : Widget {
struct CheckBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
bool checked();
void setChecked(bool checked = true);
CheckBox();
@ -181,9 +181,9 @@ struct CheckBox : Widget {
struct ComboBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void reset();
void addItem(const char *text);
void addItem(const nall::string &text);
unsigned selection();
void setSelection(unsigned row);
ComboBox();
@ -194,11 +194,11 @@ struct ComboBox : Widget {
struct EditBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setEditable(bool editable = true);
void setWordWrap(bool wordWrap = true);
nall::string text();
void setText(const char *text);
void setText(const nall::string &text);
EditBox();
//private:
struct Data;
@ -217,8 +217,8 @@ struct HorizontalSlider : Widget {
};
struct Label : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void setText(const char *text);
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setText(const nall::string &text);
Label();
//private:
struct Data;
@ -229,13 +229,13 @@ struct ListBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
nall::function<void (unsigned)> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setHeaderVisible(bool headerVisible = true);
void setCheckable(bool checkable = true);
void reset();
void resizeColumnsToContent();
void addItem(const char *text);
void setItem(unsigned row, const char *text);
void addItem(const nall::string &text);
void setItem(unsigned row, const nall::string &text);
bool checked(unsigned row);
void setChecked(unsigned row, bool checked = true);
nall::optional<unsigned> selection();
@ -257,8 +257,8 @@ struct ProgressBar : Widget {
struct RadioBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
bool checked();
void setChecked();
RadioBox();
@ -270,10 +270,10 @@ struct RadioBox : Widget {
struct TextBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setEditable(bool editable = true);
nall::string text();
void setText(const char *text);
void setText(const nall::string &text);
TextBox();
//private:
struct Data;
@ -312,10 +312,10 @@ struct MessageWindow : Object {
Yes,
No,
};
static Response information(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response question(Window &parent, const char *text, Buttons = Buttons::YesNo);
static Response warning(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response critical(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response information(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
static Response question(Window &parent, const nall::string &text, Buttons = Buttons::YesNo);
static Response warning(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
static Response critical(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
};
struct OS : Object {
@ -325,9 +325,9 @@ struct OS : Object {
static void quit();
static unsigned desktopWidth();
static unsigned desktopHeight();
static nall::string folderSelect(Window &parent, const char *path = "");
static nall::string fileOpen(Window &parent, const char *filter, const char *path = "");
static nall::string fileSave(Window &parent, const char *filter, const char *path = "");
static nall::string folderSelect(Window &parent, const nall::string &path = "");
static nall::string fileOpen(Window &parent, const nall::string &filter, const nall::string &path = "");
static nall::string fileSave(Window &parent, const nall::string &filter, const nall::string &path = "");
//private:
struct Data;
static Data *os;

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'qt.moc.hpp'
**
** Created: Wed Oct 6 18:50:06 2010
** Created: Thu Oct 7 19:16:16 2010
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!

View File

@ -19,8 +19,9 @@ public:
struct Menu::Data : public QMenu {
public:
Menu &self;
Window *parent;
Data(Menu &self) : self(self) {
Data(Menu &self) : self(self), parent(0) {
}
};

View File

@ -1,23 +1,23 @@
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
radioBox->parent = &parent;
radioBox->buttonGroup = new QButtonGroup;
radioBox->buttonGroup->addButton(radioBox);
radioBox->setParent(radioBox->parent->window->container);
radioBox->setGeometry(x, y, width, height);
radioBox->setText(text);
radioBox->setText(QString::fromUtf8(text));
radioBox->setChecked(true);
if(parent.window->defaultFont) radioBox->setFont(*parent.window->defaultFont);
radioBox->show();
radioBox->connect(radioBox, SIGNAL(toggled(bool)), SLOT(onTick()));
}
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
radioBox->parent = parent.radioBox->parent;
radioBox->buttonGroup = parent.radioBox->buttonGroup;
radioBox->buttonGroup->addButton(radioBox);
radioBox->setParent(radioBox->parent->window->container);
radioBox->setGeometry(x, y, width, height);
radioBox->setText(text);
radioBox->setText(QString::fromUtf8(text));
if(radioBox->parent->window->defaultFont) radioBox->setFont(*radioBox->parent->window->defaultFont);
radioBox->show();
radioBox->connect(radioBox, SIGNAL(toggled(bool)), SLOT(onTick()));

View File

@ -1,7 +1,7 @@
void TextBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void TextBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
textBox->setParent(parent.window->container);
textBox->setGeometry(x, y, width, height);
textBox->setText(text);
textBox->setText(QString::fromUtf8(text));
if(parent.window->defaultFont) textBox->setFont(*parent.window->defaultFont);
textBox->show();
textBox->connect(textBox, SIGNAL(returnPressed()), SLOT(onActivate()));
@ -16,8 +16,8 @@ string TextBox::text() {
return textBox->text().toUtf8().constData();
}
void TextBox::setText(const char *text) {
textBox->setText(text);
void TextBox::setText(const string &text) {
textBox->setText(QString::fromUtf8(text));
}
TextBox::TextBox() {

View File

@ -1,5 +1,5 @@
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
window->setWindowTitle(text);
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
window->setWindowTitle(QString::fromUtf8(text));
window->move(x, y);
window->layout = new QVBoxLayout(window);
@ -48,12 +48,12 @@ void Window::setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) {
window->setAutoFillBackground(true);
}
void Window::setTitle(const char *text) {
window->setWindowTitle(text);
void Window::setTitle(const string &text) {
window->setWindowTitle(QString::fromUtf8(text));
}
void Window::setStatusText(const char *text) {
window->statusBar->showMessage(text, 0);
void Window::setStatusText(const string &text) {
window->statusBar->showMessage(QString::fromUtf8(text), 0);
}
void Window::setMenuVisible(bool visible) {

View File

@ -1,4 +1,4 @@
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindow(
L"BUTTON", utf16_t(text),
WS_CHILD | WS_TABSTOP | WS_VISIBLE,

View File

@ -1,4 +1,4 @@
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void CheckBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindow(
L"BUTTON", utf16_t(text),
WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_CHECKBOX,

View File

@ -1,4 +1,4 @@
void ComboBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void ComboBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindowEx(
0, L"COMBOBOX", L"",
WS_CHILD | WS_TABSTOP | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
@ -27,7 +27,7 @@ void ComboBox::reset() {
SendMessage(widget->window, CB_RESETCONTENT, 0, 0);
}
void ComboBox::addItem(const char *text) {
void ComboBox::addItem(const string &text) {
SendMessage(widget->window, CB_ADDSTRING, 0, (LPARAM)(wchar_t*)utf16_t(text));
if(SendMessage(widget->window, CB_GETCOUNT, 0, 0) == 1) setSelection(0);
}

View File

@ -1,4 +1,4 @@
void EditBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void EditBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindowEx(
WS_EX_CLIENTEDGE, L"EDIT", L"",
WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL | ES_MULTILINE | ES_WANTRETURN |
@ -21,7 +21,7 @@ string EditBox::getText() {
return text;
}
void EditBox::setText(const char *text) {
void EditBox::setText(const string &text) {
string output = text;
output.replace("\r", "");
output.replace("\n", "\r\n");

View File

@ -1,4 +1,4 @@
static HFONT Font_createFont(const char *name, unsigned size, bool bold, bool italic) {
static HFONT Font_createFont(const string &name, unsigned size, bool bold, bool italic) {
return CreateFont(
-(size * 96.0 / 72.0 + 0.5),
0, 0, 0, bold == false ? FW_NORMAL : FW_BOLD, italic, 0, 0, 0, 0, 0, 0, 0,
@ -6,7 +6,7 @@ static HFONT Font_createFont(const char *name, unsigned size, bool bold, bool it
);
}
bool Font::create(const char *name, unsigned size, Font::Style style) {
bool Font::create(const string &name, unsigned size, Font::Style style) {
font->font = Font_createFont(
name, size,
(style & Font::Style::Bold) == Font::Style::Bold,

View File

@ -1,4 +1,4 @@
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindow(
L"phoenix_label", L"",
WS_CHILD | WS_VISIBLE,
@ -10,7 +10,7 @@ void Label::create(Window &parent, unsigned x, unsigned y, unsigned width, unsig
setText(text);
}
void Label::setText(const char *text) {
void Label::setText(const string &text) {
SetWindowText(widget->window, utf16_t(text));
}

View File

@ -1,4 +1,4 @@
void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void ListBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindowEx(
WS_EX_CLIENTEDGE, WC_LISTVIEW, L"",
WS_CHILD | WS_TABSTOP | WS_VISIBLE |
@ -48,7 +48,7 @@ void ListBox::resizeColumnsToContent() {
}
}
void ListBox::addItem(const char *text) {
void ListBox::addItem(const string &text) {
lstring list;
list.split("\t", text);
LVITEM item;
@ -70,7 +70,7 @@ void ListBox::addItem(const char *text) {
if(listBox->columns == 1) ListView_SetColumnWidth(widget->window, 0, LVSCW_AUTOSIZE_USEHEADER);
}
void ListBox::setItem(unsigned row, const char *text) {
void ListBox::setItem(unsigned row, const string &text) {
lstring list;
list.split("\t", text);
for(unsigned i = 0; i < list.size(); i++) {

View File

@ -3,13 +3,13 @@ Action::Action() {
action = new Action::Data;
}
void Menu::create(Window &parent, const char *text) {
void Menu::create(Window &parent, const string &text) {
action->parentMenu = parent.window->menu;
action->menu = CreatePopupMenu();
AppendMenu(parent.window->menu, MF_STRING | MF_POPUP, (UINT_PTR)action->menu, utf16_t(text));
}
void Menu::create(Menu &parent, const char *text) {
void Menu::create(Menu &parent, const string &text) {
action->parentMenu = parent.action->menu;
action->menu = CreatePopupMenu();
AppendMenu(parent.action->menu, MF_STRING | MF_POPUP, (UINT_PTR)action->menu, utf16_t(text));
@ -46,7 +46,7 @@ void MenuSeparator::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
void MenuItem::create(Menu &parent, const char *text) {
void MenuItem::create(Menu &parent, const string &text) {
action->parent = &parent;
AppendMenu(parent.action->menu, MF_STRING, object->id, utf16_t(text));
}
@ -64,7 +64,7 @@ void MenuItem::setEnabled(bool enabled) {
EnableMenuItem(action->parent->action->menu, object->id, MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_GRAYED));
}
void MenuCheckItem::create(Menu &parent, const char *text) {
void MenuCheckItem::create(Menu &parent, const string &text) {
action->parent = &parent;
AppendMenu(parent.action->menu, MF_STRING, object->id, utf16_t(text));
}
@ -95,7 +95,7 @@ void MenuCheckItem::setChecked(bool checked) {
CheckMenuItem(action->parent->action->menu, object->id, checked ? MF_CHECKED : MF_UNCHECKED);
}
void MenuRadioItem::create(Menu &parent, const char *text) {
void MenuRadioItem::create(Menu &parent, const string &text) {
action->parent = &parent;
action->radioParent = this;
action->items.append(this);
@ -103,7 +103,7 @@ void MenuRadioItem::create(Menu &parent, const char *text) {
setChecked();
}
void MenuRadioItem::create(MenuRadioItem &parent, const char *text) {
void MenuRadioItem::create(MenuRadioItem &parent, const string &text) {
action->parent = parent.action->parent;
action->radioParent = parent.action->radioParent;
action->radioParent->action->items.append(this);

View File

@ -8,7 +8,7 @@ static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons but
return MessageWindow::Response::Ok;
}
MessageWindow::Response MessageWindow::information(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::information(Window &parent, const string &text, MessageWindow::Buttons buttons) {
UINT flags = MB_ICONINFORMATION;
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;
@ -16,7 +16,7 @@ MessageWindow::Response MessageWindow::information(Window &parent, const char *t
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.widget->window : 0, utf16_t(text), L"", flags));
}
MessageWindow::Response MessageWindow::question(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) {
UINT flags = MB_ICONQUESTION;
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;
@ -24,7 +24,7 @@ MessageWindow::Response MessageWindow::question(Window &parent, const char *text
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.widget->window : 0, utf16_t(text), L"", flags));
}
MessageWindow::Response MessageWindow::warning(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) {
UINT flags = MB_ICONWARNING;
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;
@ -32,7 +32,7 @@ MessageWindow::Response MessageWindow::warning(Window &parent, const char *text,
return MessageWindow_response(buttons, MessageBox(&parent != &Window::None ? parent.widget->window : 0, utf16_t(text), L"", flags));
}
MessageWindow::Response MessageWindow::critical(Window &parent, const char *text, MessageWindow::Buttons buttons) {
MessageWindow::Response MessageWindow::critical(Window &parent, const string &text, MessageWindow::Buttons buttons) {
UINT flags = MB_ICONERROR;
if(buttons == Buttons::Ok) flags |= MB_OK;
if(buttons == Buttons::OkCancel) flags |= MB_OKCANCEL;

View File

@ -1,4 +1,4 @@
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
radioBox->parentWindow = &parent;
radioBox->parent = this;
radioBox->parent->radioBox->items.append(this);
@ -13,7 +13,7 @@ void RadioBox::create(Window &parent, unsigned x, unsigned y, unsigned width, un
setChecked();
}
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void RadioBox::create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
radioBox->parentWindow = parent.radioBox->parentWindow;
radioBox->parent = parent.radioBox->parent;
radioBox->parent->radioBox->items.append(this);

View File

@ -1,4 +1,4 @@
void TextBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void TextBox::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindowEx(
WS_EX_CLIENTEDGE, L"EDIT", utf16_t(text),
WS_CHILD | WS_TABSTOP | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
@ -17,7 +17,7 @@ string TextBox::text() {
return utf8_t(text);
}
void TextBox::setText(const char *text) {
void TextBox::setText(const string &text) {
object->locked = true;
SetWindowText(widget->window, utf16_t(text));
object->locked = false;

View File

@ -1,4 +1,4 @@
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
void Window::create(unsigned x, unsigned y, unsigned width, unsigned height, const string &text) {
widget->window = CreateWindowEx(
0, L"phoenix_window", utf16_t(text),
WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX,
@ -52,11 +52,11 @@ void Window::setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue) {
window->brush = CreateSolidBrush(window->brushColor);
}
void Window::setTitle(const char *text) {
void Window::setTitle(const string &text) {
SetWindowText(widget->window, utf16_t(text));
}
void Window::setStatusText(const char *text) {
void Window::setStatusText(const string &text) {
SendMessage(window->status, SB_SETTEXT, 0, (LPARAM)(wchar_t*)utf16_t(text));
}

View File

@ -142,7 +142,7 @@ unsigned OS::desktopHeight() {
return GetSystemMetrics(SM_CYSCREEN);
}
string OS::folderSelect(Window &parent, const char *path) {
string OS::folderSelect(Window &parent, const string &path) {
wchar_t wfilename[PATH_MAX + 1] = L"";
BROWSEINFO bi;
bi.hwndOwner = &parent != &Window::None ? parent.widget->window : 0;
@ -169,7 +169,7 @@ string OS::folderSelect(Window &parent, const char *path) {
return utf8_t(wfilename);
}
string OS::fileOpen(Window &parent, const char *filter, const char *path) {
string OS::fileOpen(Window &parent, const string &filter, const string &path) {
string dir = path;
dir.replace("/", "\\");
@ -215,7 +215,7 @@ string OS::fileOpen(Window &parent, const char *filter, const char *path) {
return utf8_t(wfilename);
}
string OS::fileSave(Window &parent, const char *filter, const char *path) {
string OS::fileSave(Window &parent, const string &filter, const string &path) {
string dir = path;
dir.replace("/", "\\");

View File

@ -4,6 +4,8 @@ struct Window;
struct Object {
Object();
Object& operator=(const Object&) = delete;
Object(const Object&) = delete;
//private:
struct Data;
Data *object;
@ -24,7 +26,7 @@ struct Font : Object {
Bold = 1,
Italic = 2,
};
bool create(const char *name, unsigned size, Font::Style style = Style::None);
bool create(const nall::string &name, unsigned size, Font::Style style = Style::None);
Font();
~Font();
//private:
@ -45,8 +47,8 @@ struct Action : Object {
};
struct Menu : Action {
void create(Window &parent, const char *text);
void create(Menu &parent, const char *text);
void create(Window &parent, const nall::string &text);
void create(Menu &parent, const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
};
@ -59,14 +61,14 @@ struct MenuSeparator : Action {
struct MenuItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(Menu &parent, const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
};
struct MenuCheckItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(Menu &parent, const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
@ -75,8 +77,8 @@ struct MenuCheckItem : Action {
struct MenuRadioItem : Action {
nall::function<void ()> onTick;
void create(Menu &parent, const char *text);
void create(MenuRadioItem &parent, const char *text);
void create(Menu &parent, const nall::string &text);
void create(MenuRadioItem &parent, const nall::string &text);
bool enabled();
void setEnabled(bool enabled = true);
bool checked();
@ -100,14 +102,14 @@ struct Widget : Object {
struct Window : Widget {
nall::function<bool ()> onClose;
void create(unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setDefaultFont(Font &font);
void setFont(Font &font);
Geometry geometry();
void setGeometry(unsigned x, unsigned y, unsigned width, unsigned height);
void setBackgroundColor(uint8_t red, uint8_t green, uint8_t blue);
void setTitle(const char *text);
void setStatusText(const char *text);
void setTitle(const nall::string &text);
void setStatusText(const nall::string &text);
void setMenuVisible(bool visible = true);
void setStatusVisible(bool visible = true);
Window();
@ -120,7 +122,7 @@ struct Window : Widget {
struct Button : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
};
struct Canvas : Widget {
@ -136,16 +138,16 @@ struct Canvas : Widget {
struct CheckBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
bool checked();
void setChecked(bool checked = true);
};
struct ComboBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void reset();
void addItem(const char *text);
void addItem(const nall::string &text);
unsigned selection();
void setSelection(unsigned item);
ComboBox();
@ -156,9 +158,9 @@ struct ComboBox : Widget {
struct EditBox : Widget {
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
nall::string getText();
void setText(const char *text);
void setText(const nall::string &text);
void setEditable(bool editable = true);
void setWordWrap(bool wordWrap = true);
EditBox();
@ -179,21 +181,21 @@ struct HorizontalSlider : Widget {
};
struct Label : Widget {
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void setText(const char *text);
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setText(const nall::string &text);
};
struct ListBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
nall::function<void (unsigned)> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void setHeaderVisible(bool headerVisible = true);
void setCheckable(bool checkable = true);
void reset();
void resizeColumnsToContent();
void addItem(const char *text);
void setItem(unsigned row, const char *text);
void addItem(const nall::string &text);
void setItem(unsigned row, const nall::string &text);
bool checked(unsigned row);
void setChecked(unsigned row, bool checked = true);
nall::optional<unsigned> selection();
@ -212,8 +214,8 @@ struct ProgressBar : Widget {
struct RadioBox : Widget {
nall::function<void ()> onTick;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
void create(RadioBox &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
bool checked();
void setChecked();
RadioBox();
@ -225,9 +227,9 @@ struct RadioBox : Widget {
struct TextBox : Widget {
nall::function<void ()> onActivate;
nall::function<void ()> onChange;
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text = "");
void create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const nall::string &text = "");
nall::string text();
void setText(const char *text);
void setText(const nall::string &text);
void setEditable(bool editable = true);
};
@ -259,10 +261,10 @@ struct MessageWindow : Object {
Yes,
No,
};
static Response information(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response question(Window &parent, const char *text, Buttons = Buttons::YesNo);
static Response warning(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response critical(Window &parent, const char *text, Buttons = Buttons::Ok);
static Response information(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
static Response question(Window &parent, const nall::string &text, Buttons = Buttons::YesNo);
static Response warning(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
static Response critical(Window &parent, const nall::string &text, Buttons = Buttons::Ok);
};
struct OS : Object {
@ -272,9 +274,9 @@ struct OS : Object {
static void quit();
static unsigned desktopWidth();
static unsigned desktopHeight();
static nall::string folderSelect(Window &parent, const char *path = "");
static nall::string fileOpen(Window &parent, const char *filter, const char *path = "");
static nall::string fileSave(Window &parent, const char *filter, const char *path = "");
static nall::string folderSelect(Window &parent, const nall::string &path = "");
static nall::string fileOpen(Window &parent, const nall::string &filter, const nall::string &path = "");
static nall::string fileSave(Window &parent, const nall::string &filter, const nall::string &path = "");
//private:
static void initialize();
struct Data;

View File

@ -1,7 +1,7 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
static const char Version[] = "070.10";
static const char Version[] = "070.11";
static const unsigned SerializerVersion = 13;
}
}

View File

@ -4,10 +4,10 @@ ui_objects += $(if $(call streq,$(platform),win),resource)
# platform
ifeq ($(platform),x)
phoenix_compile = $(call compile,-DPHOENIX_GTK `pkg-config --cflags gtk+-2.0`)
link += `pkg-config --libs gtk+-2.0`
# phoenix_compile = $(call compile,-DPHOENIX_QT `pkg-config --cflags QtCore QtGui`)
# link += `pkg-config --libs QtCore QtGui`
# phoenix_compile = $(call compile,-DPHOENIX_GTK `pkg-config --cflags gtk+-2.0`)
# link += `pkg-config --libs gtk+-2.0`
phoenix_compile = $(call compile,-DPHOENIX_QT `pkg-config --cflags QtCore QtGui`)
link += `pkg-config --libs QtCore QtGui`
ruby := video.glx video.xv video.sdl
ruby += audio.alsa audio.openal audio.oss audio.pulseaudio audio.pulseaudiosimple audio.ao

View File

@ -3,6 +3,7 @@
#include <nall/base64.hpp>
#include <nall/config.hpp>
#include <nall/directory.hpp>
#include <nall/filemap.hpp>
#include <nall/input.hpp>
#include <nall/ups.hpp>
#include <nall/snes/info.hpp>

View File

@ -67,6 +67,7 @@ bool Cartridge::loadSuperGameBoy(const char *basename, const char *slotname) {
}
void Cartridge::unload() {
patchApplied = false;
if(SNES::cartridge.loaded() == false) return;
saveMemory(SNES::memory::cartram, baseName, ".srm");
saveMemory(SNES::memory::cartrtc, baseName, ".rtc");
@ -84,6 +85,7 @@ bool Cartridge::loadCartridge(SNES::MappedRAM &memory, string &XML, const char *
if(file::exists(filename) == false) return false;
file fp;
if(fp.open(filename, file::mode_read) == false) return false;
if(XML.readfile(string(nall::basename(filename), ".xml")) == false) XML = "";
unsigned size = fp.size();
if((size & 0x7fff) == 512) {
@ -94,8 +96,24 @@ bool Cartridge::loadCartridge(SNES::MappedRAM &memory, string &XML, const char *
fp.read(data, size);
fp.close();
filemap patchFile;
if(XML == "" && patchFile.open(string(nall::basename(filename), ".ups"), filemap::mode_read)) {
unsigned targetSize;
ups patcher;
if(patcher.apply(patchFile.handle(), patchFile.size(), data, size, (uint8_t*)0, targetSize) == ups::result_t::target_too_small) {
uint8_t *targetData = new uint8_t[targetSize];
if(patcher.apply(patchFile.handle(), patchFile.size(), data, size, targetData, targetSize) == ups::result_t::success) {
delete[] data;
data = targetData;
size = targetSize;
patchApplied = true;
}
}
patchFile.close();
}
if(XML == "") XML = snes_information(data, size).xml_memory_map;
memory.copy(data, size);
XML = snes_information(data, size).xml_memory_map;
delete[] data;
return true;
}

View File

@ -8,6 +8,7 @@ struct Cartridge {
string baseName, slotAName, slotBName;
string baseXML, slotAXML, slotBXML;
bool patchApplied;
private:
bool loadCartridge(SNES::MappedRAM &memory, string &XML, const char *filename);

View File

@ -14,7 +14,13 @@ void FileBrowser::create() {
setGeometry(0, 0, 640, y);
pathBox.onActivate = []() { fileBrowser.setFolder(fileBrowser.pathBox.text()); };
pathBox.onActivate = []() {
string path = fileBrowser.pathBox.text();
path.transform("\\", "/");
if(strend(path, "/") == false) path.append("/");
fileBrowser.setFolder(path);
};
browseButton.onTick = { &FileBrowser::folderBrowse, this };
upButton.onTick = { &FileBrowser::folderUp, this };
contentsBox.onActivate = { &FileBrowser::fileActivate, this };
@ -22,7 +28,7 @@ void FileBrowser::create() {
void FileBrowser::fileOpen(FileBrowser::Mode requestedMode, function<void (string)> requestedCallback) {
callback = requestedCallback;
if(mode == requestedMode && string(folder, "/") == config.path.current) {
if(mode == requestedMode && folder == config.path.current) {
setVisible();
contentsBox.setFocused();
return;
@ -71,7 +77,6 @@ void FileBrowser::setFolder(const char *pathname) {
folder = pathname;
folder.transform("\\", "/");
folder.rtrim("/");
pathBox.setText(folder);
lstring contentsList = directory::contents(folder);
foreach(item, contentsList) {
@ -95,19 +100,44 @@ void FileBrowser::folderBrowse() {
}
void FileBrowser::folderUp() {
setFolder(dir(folder));
string path = folder;
path.rtrim_once("/");
if(path != "") setFolder(dir(path));
}
void FileBrowser::fileActivate() {
if(auto position = contentsBox.selection()) {
string filename = contents[position()];
if(strend(filename, "/")) {
setFolder(string(folder, "/", filename));
string cartridgeName = cartridgeFolder(filename);
if(cartridgeName == "") {
setFolder(string(folder, filename));
} else {
loadFile({ folder, cartridgeName });
}
} else {
setVisible(false);
filename = string(folder, "/", filename);
config.path.current = dir(filename);
if(callback) callback(filename);
loadFile({ folder, filename });
}
}
}
string FileBrowser::cartridgeFolder(const char *pathname) {
if(strend(pathname, ".sfc/") == false) return "";
lstring list = directory::files(string(folder, "/", pathname));
string filename;
foreach(item, list) {
if(strend(item, ".sfc")) {
if(filename != "") return ""; //more than one cartridge in this folder
filename = item;
}
}
return string(pathname, filename);
}
void FileBrowser::loadFile(const string &filename) {
setVisible(false);
config.path.current = folder;
if(callback) callback(filename);
}

View File

@ -18,6 +18,8 @@ private:
void folderUp();
void fileActivate();
void setFolder(const char *pathname);
string cartridgeFolder(const char *pathname);
void loadFile(const string &filename);
};
extern FileBrowser fileBrowser;

View File

@ -33,13 +33,15 @@ void MainWindow::create() {
systemPort2Multitap.create(systemPort2None, "Multitap");
systemPort2Mouse.create(systemPort2None, "Mouse");
systemPort2SuperScope.create(systemPort2None, "Super Scope");
systemPort2Justifier.create(systemPort2None, "Justifier");
systemPort2Justifiers.create(systemPort2None, "Justifiers");
if(config.controller.port2 == 0) systemPort2None.setChecked();
if(config.controller.port2 == 1) systemPort2Gamepad.setChecked();
if(config.controller.port2 == 2) systemPort2Multitap.setChecked();
if(config.controller.port2 == 3) systemPort2Mouse.setChecked();
if(config.controller.port2 == 4) systemPort2SuperScope.setChecked();
if(config.controller.port2 == 5) systemPort2Justifiers.setChecked();
if(config.controller.port2 == 5) systemPort2Justifier.setChecked();
if(config.controller.port2 == 6) systemPort2Justifiers.setChecked();
settings.create(*this, "Settings");
settingsVideoMode.create(settings, "Video Mode");
@ -134,7 +136,8 @@ void MainWindow::create() {
systemPort2Multitap.onTick = []() { config.controller.port2 = 2; utility.setControllers(); };
systemPort2Mouse.onTick = []() { config.controller.port2 = 3; utility.setControllers(); };
systemPort2SuperScope.onTick = []() { config.controller.port2 = 4; utility.setControllers(); };
systemPort2Justifiers.onTick = []() { config.controller.port2 = 5; utility.setControllers(); };
systemPort2Justifier.onTick = []() { config.controller.port2 = 5; utility.setControllers(); };
systemPort2Justifiers.onTick = []() { config.controller.port2 = 6; utility.setControllers(); };
settingsVideoMode1x.onTick = []() { utility.setScale(1); };
settingsVideoMode2x.onTick = []() { utility.setScale(2); };

View File

@ -21,6 +21,7 @@ struct MainWindow : TopLevelWindow {
MenuRadioItem systemPort2Multitap;
MenuRadioItem systemPort2Mouse;
MenuRadioItem systemPort2SuperScope;
MenuRadioItem systemPort2Justifier;
MenuRadioItem systemPort2Justifiers;
Menu settings;
Menu settingsVideoMode;

View File

@ -101,7 +101,7 @@ void Interface::video_refresh(const uint16_t *data, unsigned width, unsigned hei
time(&current);
if(current != previous) {
utility.setStatus(string("FPS: ", frameCounter));
utility.setStatus({ "FPS: ", frameCounter });
frameCounter = 0;
previous = current;
}

View File

@ -152,7 +152,7 @@ void Application::loadGeometry() {
void Application::saveGeometry() {
foreach(window, windows) {
Geometry geom = window->geometry();
window->position = string(geom.x, ",", geom.y);
window->position = { geom.x, ",", geom.y };
}
geometryConfig.save(string(config.path.user, "bsnes-phoenix-geometry.cfg"));
}

View File

@ -33,15 +33,14 @@ void InputSettings::create() {
mouseMiddle.setVisible(false);
mouseRight.create(*this, x + 105 + 105, y, 100, height, "Mouse Right");
mouseRight.setVisible(false);
clearAllButton.create(*this, 515 - 85 - 85, y, 80, height, "Clear All");
clearButton.create(*this, 515 - 85, y, 80, height, "Clear");
y += height + 5;
setGeometry(0, 0, 515, y);
refreshDevices();
portBox.onChange = { &InputSettings::refreshDevices, this };
deviceBox.onChange = { &InputSettings::refreshMappings, this };
portChanged();
portBox.onChange = { &InputSettings::portChanged, this };
deviceBox.onChange = { &InputSettings::deviceChanged, this };
mappingList.onActivate = { &InputSettings::assignInput, this };
mouseXaxis.onTick = []() { inputSettings.setMapping(Scancode::encode(mouse(inputSettings.activeMouse)[Mouse::Xaxis])); };
@ -50,13 +49,12 @@ void InputSettings::create() {
mouseMiddle.onTick = []() { inputSettings.setMapping(Scancode::encode(mouse(inputSettings.activeMouse)[Mouse::Button1])); };
mouseRight.onTick = []() { inputSettings.setMapping(Scancode::encode(mouse(inputSettings.activeMouse)[Mouse::Button2])); };
clearAllButton.onTick = { &InputSettings::clearAll, this };
clearButton.onTick = { &InputSettings::clearSelected, this };
clearButton.onTick = { &InputSettings::clearInput, this };
onClose = []() { inputSettings.endAssignment(); return true; };
}
void InputSettings::refreshDevices() {
void InputSettings::portChanged() {
deviceBox.reset();
InputMapper::ControllerPort &port = (
portBox.selection() == 0
@ -64,13 +62,11 @@ void InputSettings::refreshDevices() {
: (InputMapper::ControllerPort&)inputMapper.port2
);
for(unsigned i = 0; i < port.size(); i++) {
deviceBox.addItem(port[i]->name);
}
refreshMappings();
for(unsigned i = 0; i < port.size(); i++) deviceBox.addItem(port[i]->name);
deviceChanged();
}
void InputSettings::refreshMappings() {
void InputSettings::deviceChanged() {
mappingList.reset();
InputMapper::ControllerPort &port = (
portBox.selection() == 0
@ -87,6 +83,22 @@ void InputSettings::refreshMappings() {
mappingList.resizeColumnsToContent();
}
void InputSettings::mappingChanged() {
InputMapper::ControllerPort &port = (
portBox.selection() == 0
? (InputMapper::ControllerPort&)inputMapper.port1
: (InputMapper::ControllerPort&)inputMapper.port2
);
InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()];
for(unsigned i = 0; i < controller.size(); i++) {
string mapping = controller[i]->mapping;
if(mapping == "") mapping = "None";
mappingList.setItem(i, string(controller[i]->name, "\t", mapping));
}
mappingList.resizeColumnsToContent();
}
void InputSettings::assignInput() {
if(auto position = mappingList.selection()) {
InputMapper::ControllerPort &port = (
@ -118,6 +130,21 @@ void InputSettings::assignInput() {
}
}
void InputSettings::clearInput() {
if(auto position = mappingList.selection()) {
InputMapper::ControllerPort &port = (
portBox.selection() == 0
? (InputMapper::ControllerPort&)inputMapper.port1
: (InputMapper::ControllerPort&)inputMapper.port2
);
InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()];
controller[position()]->mapping = "";
inputMapper.bind();
endAssignment();
}
}
void InputSettings::setMapping(const char *mapping) {
activeInput->mapping = mapping;
inputMapper.bind();
@ -135,7 +162,8 @@ void InputSettings::endAssignment() {
mouseLeft.setVisible(false);
mouseMiddle.setVisible(false);
mouseRight.setVisible(false);
refreshMappings();
mappingChanged();
mappingList.setFocused();
}
void InputSettings::inputEvent(uint16_t scancode, int16_t value) {
@ -189,38 +217,6 @@ void InputSettings::calibrateJoypads() {
joypadsCalibrated = true;
}
void InputSettings::clearAll() {
if(MessageWindow::question(inputSettings, "Clear all input mappings?", MessageWindow::Buttons::YesNo) == MessageWindow::Response::Yes) {
InputMapper::ControllerPort &port = (
portBox.selection() == 0
? (InputMapper::ControllerPort&)inputMapper.port1
: (InputMapper::ControllerPort&)inputMapper.port2
);
InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()];
for(unsigned i = 0; i < controller.size(); i++) controller[i]->mapping = "";
inputMapper.bind();
refreshMappings();
endAssignment();
}
}
void InputSettings::clearSelected() {
if(auto position = mappingList.selection()) {
InputMapper::ControllerPort &port = (
portBox.selection() == 0
? (InputMapper::ControllerPort&)inputMapper.port1
: (InputMapper::ControllerPort&)inputMapper.port2
);
InputMapper::Controller &controller = (InputMapper::Controller&)*port[deviceBox.selection()];
controller[position()]->mapping = "";
inputMapper.bind();
refreshMappings();
endAssignment();
}
}
InputSettings::InputSettings() {
joypadsCalibrated = false;
joypadsCalibrating = false;

View File

@ -9,7 +9,6 @@ struct InputSettings : TopLevelWindow {
Button mouseLeft;
Button mouseMiddle;
Button mouseRight;
Button clearAllButton;
Button clearButton;
void inputEvent(uint16_t scancode, int16_t value);
@ -23,14 +22,13 @@ private:
int16_t joypadCalibration[Joypad::Count][Joypad::Axes];
unsigned activeMouse;
void refreshDevices();
void refreshMappings();
void portChanged();
void deviceChanged();
void mappingChanged();
void setMapping(const char *mapping);
void assignInput();
void clearInput();
void endAssignment();
void clearAll();
void clearSelected();
};
extern InputSettings inputSettings;

View File

@ -1,11 +1,11 @@
#include "../base.hpp"
Utility utility;
void Utility::setTitle(const char *text) {
void Utility::setTitle(const string &text) {
if(*text) {
mainWindow.setTitle(string(text, " - ", SNES::Info::Name, " v", SNES::Info::Version));
mainWindow.setTitle({ text, " - ", SNES::Info::Name, " v", SNES::Info::Version });
} else {
mainWindow.setTitle(string(SNES::Info::Name, " v", SNES::Info::Version));
mainWindow.setTitle({ SNES::Info::Name, " v", SNES::Info::Version });
}
}
@ -24,12 +24,12 @@ void Utility::updateStatus() {
}
}
void Utility::setStatus(const char *text) {
void Utility::setStatus(const string &text) {
static char profile[] = { '[', SNES::Info::Profile[0], ']', ' ', 0 };
statusText = string(profile, text);
statusText = { profile, text };
}
void Utility::showMessage(const char *text) {
void Utility::showMessage(const string &text) {
statusMessage = text;
statusTime = time(0);
}
@ -48,7 +48,8 @@ void Utility::setControllers() {
case 2: SNES::input.port_set_device(1, SNES::Input::Device::Multitap); break;
case 3: SNES::input.port_set_device(1, SNES::Input::Device::Mouse); break;
case 4: SNES::input.port_set_device(1, SNES::Input::Device::SuperScope); break;
case 5: SNES::input.port_set_device(1, SNES::Input::Device::Justifiers); break;
case 5: SNES::input.port_set_device(1, SNES::Input::Device::Justifier); break;
case 6: SNES::input.port_set_device(1, SNES::Input::Device::Justifiers); break;
}
}
@ -82,7 +83,10 @@ void Utility::cartridgeLoaded() {
stateManager.load();
mainWindow.synchronize();
utility.setTitle(notdir(cartridge.baseName));
utility.showMessage(string("Loaded ", notdir(cartridge.baseName)));
utility.showMessage({
"Loaded ", notdir(cartridge.baseName),
cartridge.patchApplied ? ", and applied UPS patch" : ""
});
}
void Utility::cartridgeUnloaded() {
@ -100,9 +104,9 @@ void Utility::saveState(unsigned slot) {
if(fp.open(filename, file::mode_write)) {
fp.write(s.data(), s.size());
fp.close();
showMessage(string("Saved state ", slot));
showMessage({ "Saved state ", slot });
} else {
showMessage(string("Failed to save state ", slot));
showMessage({ "Failed to save state ", slot });
}
}
@ -117,9 +121,9 @@ void Utility::loadState(unsigned slot) {
serializer s(data, size);
delete[] data;
if(SNES::system.unserialize(s) == true) {
showMessage(string("Loaded state ", slot));
showMessage({ "Loaded state ", slot });
} else {
showMessage(string("Failed to load state ", slot));
showMessage({ "Failed to load state ", slot });
}
}
}

View File

@ -1,8 +1,8 @@
struct Utility : property<Utility> {
void setTitle(const char *text);
void setTitle(const string &text);
void updateStatus();
void setStatus(const char *text);
void showMessage(const char *text);
void setStatus(const string &text);
void showMessage(const string &text);
void setControllers();
void setScale(unsigned scale = 0);