mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
byuu says: Changelog: - nall::lstring -> nall::string_vector - added IntegerBitField<type, lo, hi> -- hopefully it works correctly... - Multitap 1-4 -> Super Multitap 2-5 - fixed SFC PPU CGRAM read regression - huge amounts of SFC PPU IO register cleanups -- .bits really is lovely - re-added the read/write(VRAM,OAM,CGRAM) helpers for the SFC PPU - but they're now optimized to the realities of the PPU (16-bit data sizes / no address parameter / where appropriate) - basically used to get the active-display overrides in a unified place; but also reduces duplicate code in (read,write)IO
81 lines
2.3 KiB
C++
81 lines
2.3 KiB
C++
#if defined(Hiro_MessageDialog)
|
|
|
|
MessageDialog::MessageDialog(const string& text) {
|
|
state.text = text;
|
|
}
|
|
|
|
auto MessageDialog::error(const string_vector& buttons) -> string {
|
|
state.buttons = buttons;
|
|
state.icon = Icon::Prompt::Error;
|
|
return _run();
|
|
}
|
|
|
|
auto MessageDialog::information(const string_vector& buttons) -> string {
|
|
state.buttons = buttons;
|
|
state.icon = Icon::Prompt::Information;
|
|
return _run();
|
|
}
|
|
|
|
auto MessageDialog::question(const string_vector& buttons) -> string {
|
|
state.buttons = buttons;
|
|
state.icon = Icon::Prompt::Question;
|
|
return _run();
|
|
}
|
|
|
|
auto MessageDialog::setParent(shared_pointer<mWindow> parent) -> type& {
|
|
state.parent = parent;
|
|
return *this;
|
|
}
|
|
|
|
auto MessageDialog::setText(const string& text) -> type& {
|
|
state.text = text;
|
|
return *this;
|
|
}
|
|
|
|
auto MessageDialog::setTitle(const string& title) -> type& {
|
|
state.title = title;
|
|
return *this;
|
|
}
|
|
|
|
auto MessageDialog::warning(const string_vector& buttons) -> string {
|
|
state.buttons = buttons;
|
|
state.icon = Icon::Prompt::Warning;
|
|
return _run();
|
|
}
|
|
|
|
auto MessageDialog::_run() -> string {
|
|
Window window;
|
|
VerticalLayout layout{&window};
|
|
HorizontalLayout messageLayout{&layout, Size{~0, 0}, 5};
|
|
Canvas messageIcon{&messageLayout, Size{16, 16}, 5};
|
|
Label messageText{&messageLayout, Size{~0, 0}};
|
|
HorizontalLayout controlLayout{&layout, Size{~0, 0}};
|
|
Widget controlSpacer{&controlLayout, Size{~0, 0}};
|
|
|
|
layout.setMargin(5);
|
|
messageIcon.setIcon(state.icon);
|
|
messageText.setText(state.text);
|
|
for(auto n : range(state.buttons)) {
|
|
Button button{&controlLayout, Size{80, 0}, 5};
|
|
button.onActivate([&, n] { state.response = state.buttons[n]; window.setModal(false); });
|
|
button.setText(state.buttons[n]);
|
|
button.setFocused(); //the last button will have effective focus
|
|
}
|
|
|
|
signed widthMessage = 5 + 16 + 5 + Font().size(state.text).width() + 5;
|
|
signed widthButtons = 5 + state.buttons.size() * 85;
|
|
signed width = max(320, widthMessage, widthButtons);
|
|
|
|
window.onClose([&] { window.setModal(false); });
|
|
window.setTitle(state.title);
|
|
window.setResizable(false);
|
|
window.setSize({width, layout.minimumSize().height()});
|
|
window.setCentered(state.parent);
|
|
window.setVisible();
|
|
window.setModal();
|
|
window.setVisible(false);
|
|
|
|
return state.response;
|
|
}
|
|
|
|
#endif
|