summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/cheat.cpp
diff options
context:
space:
mode:
author npwoods <npwoods@alumni.cmu.edu>2019-06-30 12:16:44 -0400
committer R. Belmont <rb6502@users.noreply.github.com>2019-06-30 12:16:44 -0400
commit1047b8cafeab7a32eefec524ca0621573186c125 (patch)
tree4f0db565575ce5eee913bc1cc29c4bcf2a8cd164 /src/frontend/mame/cheat.cpp
parent66939696f1e68ec35964c3577b256131603fcc8a (diff)
Refactored UI font metrics (#5291)
* Changed the various usages of UI_*COLOR to be calls to src/frontend/mame/ui/moptions.h The various UI_*COLOR macros were implemented as calls to decode_ui_color, which cached the values for the various options in a static array, which was obviously a gross hack. This refactoring is strategic because I am trying to confine awareness of mame_ui_manager to code in src/frontend/mame/ui, and the implementation of decode_ui_color() relied on the ability to access mame_ui_manager as a singleton from outside this code. * Created a ui_colors object, so that queries for UI RGB values would not always require parsing strings * Replaced UI_TARGET_FONT_[ROWS|HEIGHT] and UI_BOX_[LR|TD]_BORDER macros with property calls These macros were implemented with a call to a function (get_font_rows()) that opportunistically stashed the results of option accesses in static variables; in other words, a gross hack Because get_font_rows() attempted to access mame_ui_manager as a singleton, it was an obstactle to providing an alternative implementation of ui_manager * Remove stray debugging cruft that found a way into the other PR
Diffstat (limited to 'src/frontend/mame/cheat.cpp')
-rw-r--r--src/frontend/mame/cheat.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp
index 1ac5039fa7f..815c788e241 100644
--- a/src/frontend/mame/cheat.cpp
+++ b/src/frontend/mame/cheat.cpp
@@ -1061,8 +1061,14 @@ cheat_manager::cheat_manager(running_machine &machine)
if (!machine.options().cheat())
return;
- m_output.resize(UI_TARGET_FONT_ROWS * 2);
- m_justify.resize(UI_TARGET_FONT_ROWS * 2);
+ // in its current form, cheat_manager is tightly coupled to mame_ui_manager; therefore we
+ // expect this call to succeed
+ mame_ui_manager *ui = dynamic_cast<mame_ui_manager *>(&machine.ui());
+ assert(ui);
+
+ int target_font_rows = ui->options().font_rows();
+ m_output.resize(target_font_rows * 2);
+ m_justify.resize(target_font_rows * 2);
// request a callback
machine.add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(&cheat_manager::frame_update, this));