2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_Menu)
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
namespace hiro {
|
|
|
|
|
|
|
|
auto pMenu::construct() -> void {
|
|
|
|
_createBitmap();
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMenu::destruct() -> void {
|
|
|
|
if(hbitmap) { DeleteObject(hbitmap); hbitmap = nullptr; }
|
|
|
|
if(hmenu) { DestroyMenu(hmenu); hmenu = nullptr; }
|
2011-09-05 03:48:23 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMenu::append(sAction action) -> void {
|
|
|
|
_synchronize();
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMenu::remove(sAction action) -> void {
|
|
|
|
_synchronize();
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
Update to v094r43 release.
byuu says:
Updated to compile with all of the new hiro changes. My next step is to
write up hiro API documentation, and move the API from alpha (constantly
changing) to beta (rarely changing), in preparation for the first stable
release (backward-compatible changes only.)
Added "--fullscreen" command-line option. I like this over
a configuration file option. Lets you use the emulator in both modes
without having to modify the config file each time.
Also enhanced the command-line game loading. You can now use any of
these methods:
higan /path/to/game-folder.sfc
higan /path/to/game-folder.sfc/
higan /path/to/game-folder.sfc/program.rom
The idea is to support launchers that insist on loading files only.
Technically, the file can be any name (manifest.bml also works); the
only criteria is that the file actually exists and is a file, and not
a directory. This is a requirement to support the first version (a
directory lacking the trailing / identifier), because I don't want my
nall::string class to query the file system to determine if the string
is an actual existing file or directory for its pathname() / dirname()
functions.
Anyway, every game folder I've made so far has program.rom, and that's
very unlikely to change, so this should be fine.
Now, of course, if you drop a regular "game.sfc" file on the emulator,
it won't even try to load it, unless it's in a folder that ends in .fc,
.sfc, etc. In which case, it'll bail out immediately by being unable to
produce a manifest for what is obviously not really a game folder.
2015-08-30 02:08:26 +00:00
|
|
|
auto pMenu::setImage(const Image& image) -> void {
|
2015-06-12 13:14:38 +00:00
|
|
|
_createBitmap();
|
|
|
|
_synchronize();
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMenu::setText(const string& text) -> void {
|
|
|
|
_synchronize();
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMenu::_createBitmap() -> void {
|
2012-01-26 06:50:09 +00:00
|
|
|
if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
|
|
|
|
|
Update to v094r43 release.
byuu says:
Updated to compile with all of the new hiro changes. My next step is to
write up hiro API documentation, and move the API from alpha (constantly
changing) to beta (rarely changing), in preparation for the first stable
release (backward-compatible changes only.)
Added "--fullscreen" command-line option. I like this over
a configuration file option. Lets you use the emulator in both modes
without having to modify the config file each time.
Also enhanced the command-line game loading. You can now use any of
these methods:
higan /path/to/game-folder.sfc
higan /path/to/game-folder.sfc/
higan /path/to/game-folder.sfc/program.rom
The idea is to support launchers that insist on loading files only.
Technically, the file can be any name (manifest.bml also works); the
only criteria is that the file actually exists and is a file, and not
a directory. This is a requirement to support the first version (a
directory lacking the trailing / identifier), because I don't want my
nall::string class to query the file system to determine if the string
is an actual existing file or directory for its pathname() / dirname()
functions.
Anyway, every game folder I've made so far has program.rom, and that's
very unlikely to change, so this should be fine.
Now, of course, if you drop a regular "game.sfc" file on the emulator,
it won't even try to load it, unless it's in a folder that ends in .fc,
.sfc, etc. In which case, it'll bail out immediately by being unable to
produce a manifest for what is obviously not really a game folder.
2015-08-30 02:08:26 +00:00
|
|
|
if(auto& image = state().image) {
|
|
|
|
nall::image icon;
|
|
|
|
icon.allocate(image.width(), image.height());
|
|
|
|
memory::copy(icon.data(), image.data(), icon.size());
|
2015-06-12 13:14:38 +00:00
|
|
|
icon.alphaBlend(GetSysColor(COLOR_MENU)); //Windows does not alpha blend menu icons properly (leaves black outline)
|
|
|
|
icon.scale(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK), Interpolation::Linear);
|
|
|
|
hbitmap = CreateBitmap(icon);
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Windows actions lack the ability to toggle visibility.
|
|
|
|
//To support this, menus must be destroyed and recreated when toggling any action's visibility.
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMenu::_update() -> void {
|
2011-02-24 09:25:20 +00:00
|
|
|
if(hmenu) DestroyMenu(hmenu);
|
|
|
|
hmenu = CreatePopupMenu();
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
MENUINFO mi{sizeof(MENUINFO)};
|
|
|
|
mi.fMask = MIM_STYLE;
|
|
|
|
mi.dwStyle = MNS_NOTIFYBYPOS; //| MNS_MODELESS;
|
|
|
|
SetMenuInfo(hmenu, &mi);
|
2011-02-24 09:25:20 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
unsigned position = 0;
|
2012-01-26 06:50:09 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
for(auto& action : state().actions) {
|
|
|
|
if(!action->self()) continue;
|
|
|
|
action->self()->position = position;
|
|
|
|
unsigned enabled = action->enabled() ? 0 : MF_GRAYED;
|
|
|
|
|
|
|
|
MENUITEMINFO mii{sizeof(MENUITEMINFO)};
|
|
|
|
mii.fMask = MIIM_DATA;
|
|
|
|
mii.dwItemData = (ULONG_PTR)action.data();
|
|
|
|
|
|
|
|
if(auto menu = dynamic_cast<mMenu*>(action.data())) {
|
|
|
|
if(menu->visible()) {
|
|
|
|
menu->self()->_update();
|
|
|
|
AppendMenu(hmenu, MF_STRING | MF_POPUP | enabled, (UINT_PTR)menu->self()->hmenu, utf16_t(menu->text()));
|
|
|
|
if(auto bitmap = menu->self()->hbitmap) {
|
2012-01-26 06:50:09 +00:00
|
|
|
//Windows XP and below displays MIIM_BITMAP + hbmpItem in its own column (separate from check/radio marks)
|
|
|
|
//this causes too much spacing, so use a custom checkmark image instead
|
2015-06-12 13:14:38 +00:00
|
|
|
mii.fMask |= MIIM_CHECKMARKS;
|
|
|
|
mii.hbmpUnchecked = bitmap;
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
SetMenuItemInfo(hmenu, position++, true, &mii);
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(Hiro_MenuSeparator)
|
|
|
|
else if(auto menuSeparator = dynamic_cast<mMenuSeparator*>(action.data())) {
|
|
|
|
if(menuSeparator->visible()) {
|
|
|
|
AppendMenu(hmenu, MF_SEPARATOR | enabled, position, L"");
|
|
|
|
SetMenuItemInfo(hmenu, position++, true, &mii);
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-01-15 08:29:57 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_MenuItem)
|
|
|
|
else if(auto menuItem = dynamic_cast<mMenuItem*>(action.data())) {
|
|
|
|
if(menuItem->visible()) {
|
|
|
|
AppendMenu(hmenu, MF_STRING | enabled, position, utf16_t(menuItem->text()));
|
|
|
|
if(auto bitmap = menuItem->self()->hbitmap) {
|
|
|
|
mii.fMask |= MIIM_CHECKMARKS;
|
|
|
|
mii.hbmpUnchecked = bitmap;
|
2012-01-15 08:29:57 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
SetMenuItemInfo(hmenu, position++, true, &mii);
|
2012-01-15 08:29:57 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(Hiro_MenuCheckItem)
|
|
|
|
else if(auto menuCheckItem = dynamic_cast<mMenuCheckItem*>(action.data())) {
|
|
|
|
if(menuCheckItem->visible()) {
|
|
|
|
AppendMenu(hmenu, MF_STRING | enabled, position, utf16_t(menuCheckItem->text()));
|
|
|
|
SetMenuItemInfo(hmenu, position++, true, &mii);
|
|
|
|
if(menuCheckItem->checked()) menuCheckItem->setChecked();
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(Hiro_MenuRadioItem)
|
|
|
|
else if(auto menuRadioItem = dynamic_cast<mMenuRadioItem*>(action.data())) {
|
|
|
|
if(menuRadioItem->visible()) {
|
|
|
|
AppendMenu(hmenu, MF_STRING | enabled, position, utf16_t(menuRadioItem->text()));
|
|
|
|
SetMenuItemInfo(hmenu, position++, true, &mii);
|
|
|
|
if(menuRadioItem->checked()) menuRadioItem->setChecked();
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
#endif
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
|
|
|
|
#endif
|