mirror of
https://github.com/holub/mame
synced 2025-04-26 02:07:14 +03:00
Moved background bitmap/texture back into menu.cpp
This commit is contained in:
parent
ecf1c152c1
commit
e0a721a062
@ -82,12 +82,32 @@ bool menu::exclusive_input_pressed(int &iptkey, int key, int repeat)
|
||||
***************************************************************************/
|
||||
|
||||
menu::global_state::global_state(running_machine &machine, ui_options const &options)
|
||||
: widgets_manager(machine, options)
|
||||
: widgets_manager(machine)
|
||||
, m_machine(machine)
|
||||
, m_cleanup_callbacks()
|
||||
, m_bgrnd_bitmap()
|
||||
, m_stack()
|
||||
, m_free()
|
||||
{
|
||||
render_manager &render(machine.render());
|
||||
auto const texture_free([&render](render_texture *texture) { render.texture_free(texture); });
|
||||
|
||||
// create a texture for main menu background
|
||||
m_bgrnd_texture = texture_ptr(render.texture_alloc(render_texture::hq_scale), texture_free);
|
||||
if (options.use_background_image() && (&machine.system() == &GAME_NAME(___empty)))
|
||||
{
|
||||
m_bgrnd_bitmap = std::make_unique<bitmap_argb32>(0, 0);
|
||||
emu_file backgroundfile(".", OPEN_FLAG_READ);
|
||||
render_load_jpeg(*m_bgrnd_bitmap, backgroundfile, nullptr, "background.jpg");
|
||||
|
||||
if (!m_bgrnd_bitmap->valid())
|
||||
render_load_png(*m_bgrnd_bitmap, backgroundfile, nullptr, "background.png");
|
||||
|
||||
if (m_bgrnd_bitmap->valid())
|
||||
m_bgrnd_texture->set_bitmap(*m_bgrnd_bitmap, m_bgrnd_bitmap->cliprect(), TEXFORMAT_ARGB32);
|
||||
else
|
||||
m_bgrnd_bitmap->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,6 +266,9 @@ private:
|
||||
|
||||
void add_cleanup_callback(cleanup_callback &&callback);
|
||||
|
||||
bitmap_argb32 *bgrnd_bitmap() { return m_bgrnd_bitmap.get(); }
|
||||
render_texture * bgrnd_texture() { return m_bgrnd_texture.get(); }
|
||||
|
||||
void reset_topmost(reset_options options) { if (m_stack) m_stack->reset(options); }
|
||||
|
||||
template <typename T>
|
||||
@ -283,6 +286,9 @@ private:
|
||||
running_machine &m_machine;
|
||||
cleanup_callback_vector m_cleanup_callbacks;
|
||||
|
||||
bitmap_ptr m_bgrnd_bitmap;
|
||||
texture_ptr m_bgrnd_texture;
|
||||
|
||||
std::unique_ptr<menu> m_stack;
|
||||
std::unique_ptr<menu> m_free;
|
||||
};
|
||||
|
@ -21,12 +21,11 @@ namespace ui {
|
||||
// ctor
|
||||
//-------------------------------------------------
|
||||
|
||||
widgets_manager::widgets_manager(running_machine &machine, ui_options const &options)
|
||||
widgets_manager::widgets_manager(running_machine &machine)
|
||||
: m_hilight_bitmap(std::make_unique<bitmap_argb32>(256, 1))
|
||||
, m_hilight_texture()
|
||||
, m_hilight_main_bitmap(std::make_unique<bitmap_argb32>(1, 128))
|
||||
, m_hilight_main_texture()
|
||||
, m_bgrnd_bitmap()
|
||||
, m_bgrnd_texture()
|
||||
{
|
||||
render_manager &render(machine.render());
|
||||
@ -56,23 +55,6 @@ widgets_manager::widgets_manager(running_machine &machine, ui_options const &opt
|
||||
|
||||
// create a texture for arrow icons
|
||||
m_arrow_texture = texture_ptr(render.texture_alloc(render_triangle), texture_free);
|
||||
|
||||
// create a texture for main menu background
|
||||
m_bgrnd_texture = texture_ptr(render.texture_alloc(render_texture::hq_scale), texture_free);
|
||||
if (options.use_background_image() && (&machine.system() == &GAME_NAME(___empty)))
|
||||
{
|
||||
m_bgrnd_bitmap = std::make_unique<bitmap_argb32>(0, 0);
|
||||
emu_file backgroundfile(".", OPEN_FLAG_READ);
|
||||
render_load_jpeg(*m_bgrnd_bitmap, backgroundfile, nullptr, "background.jpg");
|
||||
|
||||
if (!m_bgrnd_bitmap->valid())
|
||||
render_load_png(*m_bgrnd_bitmap, backgroundfile, nullptr, "background.png");
|
||||
|
||||
if (m_bgrnd_bitmap->valid())
|
||||
m_bgrnd_texture->set_bitmap(*m_bgrnd_bitmap, m_bgrnd_bitmap->cliprect(), TEXFORMAT_ARGB32);
|
||||
else
|
||||
m_bgrnd_bitmap->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,12 +28,11 @@ TYPE DEFINITIONS
|
||||
class widgets_manager
|
||||
{
|
||||
public:
|
||||
widgets_manager(running_machine &machine, ui_options const &options);
|
||||
widgets_manager(running_machine &machine);
|
||||
|
||||
render_texture *hilight_texture() { return m_hilight_texture.get(); }
|
||||
render_texture *hilight_main_texture() { return m_hilight_main_texture.get(); }
|
||||
render_texture *arrow_texture() { return m_arrow_texture.get(); }
|
||||
bitmap_argb32 *bgrnd_bitmap() { return m_bgrnd_bitmap.get(); }
|
||||
render_texture * bgrnd_texture() { return m_bgrnd_texture.get(); }
|
||||
|
||||
using bitmap_ptr = std::unique_ptr<bitmap_argb32>;
|
||||
@ -45,7 +44,6 @@ private:
|
||||
bitmap_ptr m_hilight_main_bitmap;
|
||||
texture_ptr m_hilight_main_texture;
|
||||
texture_ptr m_arrow_texture;
|
||||
bitmap_ptr m_bgrnd_bitmap;
|
||||
texture_ptr m_bgrnd_texture;
|
||||
|
||||
static void render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
|
||||
|
Loading…
Reference in New Issue
Block a user