bsnes/hiro/core/application.cpp
Tim Allen 393c2395bb Update to v106r48 release.
byuu says:

The problems with the Windows and Qt4 ports have all been resolved,
although there's a fairly gross hack on a few Qt widgets to not destruct
once Application::quit() is called to avoid a double free crash (I'm
unsure where Qt is destructing the widgets internally.) The Cocoa port
compiles again at least, though it's bound to have endless problems. I
improved the Label painting in the GTK ports, which fixes the background
color on labels inside TabFrame widgets.

I've optimized the Makefile system even further.

I added a "redo state" command to bsnes, which is created whenever you
load the undo state. There are also hotkeys for both now, although I
don't think they're really something you want to map hotkeys to.

I moved the nall::Locale object inside hiro::Application, so that it can
be used to translate the BrowserDialog and MessageDialog window strings.

I improved the Super Game Boy emulation of `MLT_REQ`, fixing Pokemon
Yellow's custom border and probably more stuff.

Lots of other small fixes and improvements. Things are finally stable
once again after the harrowing layout redesign catastrophe.

Errata:

  - ICD::joypID should be set to 3 on reset(). joypWrite() may as well
    take uint1 instead of bool.
  - hiro/Qt: remove pWindow::setMaximumSize() comment; found a
    workaround for it
  - nall/GNUmakefile: don't set object.path if it's already set (allow
    overrides before including the file)
2018-07-16 16:16:26 +10:00

136 lines
3 KiB
C++

#if defined(Hiro_Application)
Application::State Application::state;
auto Application::doMain() -> void {
if(state.onMain) return state.onMain();
}
auto Application::font() -> Font {
return state.font;
}
auto Application::locale() -> Locale& {
return state.locale;
}
auto Application::modal() -> bool {
return state.modal > 0;
}
auto Application::name() -> string {
return state.name;
}
auto Application::onMain(const function<void ()>& callback) -> void {
state.onMain = callback;
}
auto Application::run() -> void {
return pApplication::run();
}
auto Application::pendingEvents() -> bool {
return pApplication::pendingEvents();
}
auto Application::processEvents() -> void {
return pApplication::processEvents();
}
auto Application::quit() -> void {
state.quit = true;
return pApplication::quit();
}
auto Application::scale() -> float {
return state.scale;
}
auto Application::scale(float value) -> float {
return value * state.scale;
}
auto Application::setFont(const Font& font) -> void {
state.font = font;
}
auto Application::setName(const string& name) -> void {
state.name = name;
}
auto Application::setScale(float scale) -> void {
state.scale = scale;
}
auto Application::unscale(float value) -> float {
return value * (1.0 / state.scale);
}
//Windows
//=======
auto Application::Windows::doModalChange(bool modal) -> void {
if(state.windows.onModalChange) return state.windows.onModalChange(modal);
}
auto Application::Windows::doScreenSaver() -> bool {
if(state.windows.onScreenSaver) return state.windows.onScreenSaver();
return true; //true = allow screen saver (default); false = suppress screen saver
}
auto Application::Windows::onModalChange(const function<void (bool)>& callback) -> void {
state.windows.onModalChange = callback;
}
auto Application::Windows::onScreenSaver(const function<bool ()>& callback) -> void {
state.windows.onScreenSaver = callback;
}
//Cocoa
//=====
auto Application::Cocoa::doAbout() -> void {
if(state.cocoa.onAbout) return state.cocoa.onAbout();
}
auto Application::Cocoa::doActivate() -> void {
if(state.cocoa.onActivate) return state.cocoa.onActivate();
}
auto Application::Cocoa::doPreferences() -> void {
if(state.cocoa.onPreferences) return state.cocoa.onPreferences();
}
auto Application::Cocoa::doQuit() -> void {
if(state.cocoa.onQuit) return state.cocoa.onQuit();
}
auto Application::Cocoa::onAbout(const function<void ()>& callback) -> void {
state.cocoa.onAbout = callback;
}
auto Application::Cocoa::onActivate(const function<void ()>& callback) -> void {
state.cocoa.onActivate = callback;
}
auto Application::Cocoa::onPreferences(const function<void ()>& callback) -> void {
state.cocoa.onPreferences = callback;
}
auto Application::Cocoa::onQuit(const function<void ()>& callback) -> void {
state.cocoa.onQuit = callback;
}
//Internal
//========
auto Application::initialize() -> void {
static bool initialized = false;
if(initialized == false) {
initialized = true;
return pApplication::initialize();
}
}
#endif