mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-23 06:32:32 +01:00
byuu says: Main reason for this WIP was because of all the added lines to hiro for selective component disabling. May as well get all the diff-noise apart from code changes. It also merges something I've been talking to Cydrak about ... making nall::string::(integer,decimal) do built-in binary,octal,hex decoding instead of just failing on those. This will have fun little side effects all over the place, like being able to view a topic on my forum via "forum.byuu.org/topic/0b10010110", heh. There are two small changes to higan itself, though. First up, I fixed the resampler ratio when loading non-SNES games. Tested and I can play Game Boy games fine now. Second, I hooked up menu option hiding for reset and controller selection. Right now, this works like higan v094, but I'm thinking I might want to show the "Device -> Controller" even if that's all that's there. It kind of jives nicer with the input settings window to see the labels there, I think. And if we ever do add more stuff, it'll be nice that people already always expect that menu there. Remaining issues: * add slotted cart loader (SGB, BSX, ST) * add DIP switch selection window (NSS) * add timing configuration (video/audio sync)
270 lines
6.8 KiB
C++
270 lines
6.8 KiB
C++
#if defined(Hiro_Object)
|
|
|
|
mObject::mObject() {
|
|
Application::initialize();
|
|
}
|
|
|
|
mObject::~mObject() {
|
|
}
|
|
|
|
auto mObject::allocate() -> pObject* {
|
|
return new pObject(*this);
|
|
}
|
|
|
|
auto mObject::construct() -> void {
|
|
if(delegate) return;
|
|
delegate = allocate();
|
|
signal(construct);
|
|
}
|
|
|
|
auto mObject::destruct() -> void {
|
|
if(!delegate) return;
|
|
signal(destruct);
|
|
delete delegate;
|
|
delegate = nullptr;
|
|
}
|
|
|
|
//
|
|
|
|
//this is used to control dynamic allocation of pObject delegates
|
|
//an mObject is abstract only if it has no top-level object (eg a Button not attached to any Window)
|
|
//if the mObject is not abstract, the pObject delegate is allocated immediately
|
|
//otherwise, the pObject is not allocated until it is attached to a non-abstract parent
|
|
auto mObject::abstract() const -> bool {
|
|
if(dynamic_cast<const mWindow*>(this)) return false;
|
|
#if defined(Hiro_PopupMenu)
|
|
if(dynamic_cast<const mPopupMenu*>(this)) return false;
|
|
#endif
|
|
if(auto object = parent()) return object->abstract();
|
|
return true;
|
|
}
|
|
|
|
auto mObject::enabled(bool recursive) const -> bool {
|
|
if(!recursive || !state.enabled) return state.enabled;
|
|
if(auto object = parent()) return object->enabled(true);
|
|
return true;
|
|
}
|
|
|
|
auto mObject::focused() const -> bool {
|
|
if(signal(focused)) return true;
|
|
return false;
|
|
}
|
|
|
|
auto mObject::font(bool recursive) const -> string {
|
|
if(!recursive || state.font) return state.font;
|
|
if(auto object = parent()) return object->font(true);
|
|
return Application::font();
|
|
}
|
|
|
|
auto mObject::offset() const -> signed {
|
|
return state.offset;
|
|
}
|
|
|
|
auto mObject::offset(signed displacement) -> type& {
|
|
state.offset += displacement;
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::parent() const -> mObject* {
|
|
return state.parent;
|
|
}
|
|
|
|
#if defined(Hiro_ComboButton)
|
|
auto mObject::parentComboButton(bool recursive) const -> mComboButton* {
|
|
if(auto comboButton = dynamic_cast<mComboButton*>(parent())) return comboButton;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentComboButton(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_Frame)
|
|
auto mObject::parentFrame(bool recursive) const -> mFrame* {
|
|
if(auto frame = dynamic_cast<mFrame*>(parent())) return frame;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentFrame(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_IconView)
|
|
auto mObject::parentIconView(bool recursive) const -> mIconView* {
|
|
if(auto iconView = dynamic_cast<mIconView*>(parent())) return iconView;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentIconView(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_Layout)
|
|
auto mObject::parentLayout(bool recursive) const -> mLayout* {
|
|
if(auto layout = dynamic_cast<mLayout*>(parent())) return layout;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentLayout(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_ListView)
|
|
auto mObject::parentListView(bool recursive) const -> mListView* {
|
|
if(auto listView = dynamic_cast<mListView*>(parent())) return listView;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentListView(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_Menu)
|
|
auto mObject::parentMenu(bool recursive) const -> mMenu* {
|
|
if(auto menu = dynamic_cast<mMenu*>(parent())) return menu;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentMenu(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_MenuBar)
|
|
auto mObject::parentMenuBar(bool recursive) const -> mMenuBar* {
|
|
if(auto menuBar = dynamic_cast<mMenuBar*>(parent())) return menuBar;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentMenuBar(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_PopupMenu)
|
|
auto mObject::parentPopupMenu(bool recursive) const -> mPopupMenu* {
|
|
if(auto popupMenu = dynamic_cast<mPopupMenu*>(parent())) return popupMenu;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentPopupMenu(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_Sizable)
|
|
auto mObject::parentSizable(bool recursive) const -> mSizable* {
|
|
if(auto sizable = dynamic_cast<mSizable*>(parent())) return sizable;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentSizable(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_TabFrame)
|
|
auto mObject::parentTabFrame(bool recursive) const -> mTabFrame* {
|
|
if(auto tabFrame = dynamic_cast<mTabFrame*>(parent())) return tabFrame;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentTabFrame(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_TabFrame)
|
|
auto mObject::parentTabFrameItem(bool recursive) const -> mTabFrameItem* {
|
|
if(auto tabFrameItem = dynamic_cast<mTabFrameItem*>(parent())) return tabFrameItem;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentTabFrameItem(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_TreeView)
|
|
auto mObject::parentTreeView(bool recursive) const -> mTreeView* {
|
|
if(auto treeView = dynamic_cast<mTreeView*>(parent())) return treeView;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentTreeView(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_TreeView)
|
|
auto mObject::parentTreeViewItem(bool recursive) const -> mTreeViewItem* {
|
|
if(auto treeViewItem = dynamic_cast<mTreeViewItem*>(parent())) return treeViewItem;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentTreeViewItem(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_Widget)
|
|
auto mObject::parentWidget(bool recursive) const -> mWidget* {
|
|
if(auto widget = dynamic_cast<mWidget*>(parent())) return widget;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentWidget(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
#if defined(Hiro_Window)
|
|
auto mObject::parentWindow(bool recursive) const -> mWindow* {
|
|
if(auto window = dynamic_cast<mWindow*>(parent())) return window;
|
|
if(recursive) {
|
|
if(auto object = parent()) return object->parentWindow(true);
|
|
}
|
|
return nullptr;
|
|
}
|
|
#endif
|
|
|
|
auto mObject::remove() -> type& {
|
|
signal(remove);
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::reset() -> type& {
|
|
signal(reset);
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::setEnabled(bool enabled) -> type& {
|
|
state.enabled = enabled;
|
|
signal(setEnabled, this->enabled(true));
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::setFocused() -> type& {
|
|
signal(setFocused);
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::setFont(const string& font) -> type& {
|
|
state.font = font;
|
|
signal(setFont, this->font(true));
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::setParent(mObject* parent, signed offset) -> type& {
|
|
destruct();
|
|
state.parent = parent;
|
|
state.offset = offset;
|
|
if(!abstract()) construct();
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::setVisible(bool visible) -> type& {
|
|
state.visible = visible;
|
|
signal(setVisible, this->visible(true));
|
|
return *this;
|
|
}
|
|
|
|
auto mObject::visible(bool recursive) const -> bool {
|
|
if(!recursive || !state.visible) return state.visible;
|
|
if(auto object = parent()) return object->visible(true);
|
|
return true;
|
|
}
|
|
|
|
#endif
|