remove ui/ui.h dependency from emu.h (for couriersud)

This commit is contained in:
Vas Crabb 2016-04-10 17:48:38 +10:00
parent 7d1ec41744
commit 0c502775b6
5 changed files with 71 additions and 82 deletions

View File

@ -158,7 +158,6 @@ files {
MAME_DIR .. "src/emu/mame.h",
MAME_DIR .. "src/emu/machine.cpp",
MAME_DIR .. "src/emu/machine.h",
MAME_DIR .. "src/emu/machine.ipp",
MAME_DIR .. "src/emu/mconfig.cpp",
MAME_DIR .. "src/emu/mconfig.h",
MAME_DIR .. "src/emu/memarray.cpp",

View File

@ -106,9 +106,6 @@ typedef device_t * (*machine_config_constructor)(machine_config &config, device_
#include "sound.h"
#include "speaker.h"
// user interface
#include "ui/ui.h"
// generic helpers
#include "devcb.h"
#include "dispatch.h"
@ -118,6 +115,5 @@ typedef device_t * (*machine_config_constructor)(machine_config &config, device_
// member templates that don't like incomplete types
#include "device.ipp"
#include "machine.ipp"
#endif /* __EMU_H__ */

View File

@ -1202,6 +1202,24 @@ void running_machine::nvram_save()
}
}
}
//**************************************************************************
// OUTPUT
//**************************************************************************
void running_machine::popup_clear() const
{
ui().popup_time(0, " ");
}
void running_machine::popup_message(util::format_argument_pack<std::ostream> const &args) const
{
std::string const temp(string_format(args));
ui().popup_time(temp.length() / 40 + 2, temp);
}
//**************************************************************************
// CALLBACK ITEMS
//**************************************************************************

View File

@ -17,6 +17,7 @@
#ifndef __MACHINE_H__
#define __MACHINE_H__
#include "strformat.h"
#include "vecstream.h"
#include <time.h>
@ -274,6 +275,8 @@ private:
std::string nvram_filename(device_t &device) const;
void nvram_load();
void nvram_save();
void popup_clear() const;
void popup_message(util::format_argument_pack<std::ostream> const &args) const;
// internal callbacks
static void logfile_callback(const running_machine &machine, const char *buffer);
@ -382,4 +385,54 @@ private:
mutable util::ovectorstream m_string_buffer;
};
//**************************************************************************
// MEMBER TEMPLATES
//**************************************************************************
/*-------------------------------------------------
popmessage - pop up a user-visible message
-------------------------------------------------*/
template <typename Format, typename... Params>
inline void running_machine::popmessage(Format &&fmt, Params &&... args) const
{
// if the format is NULL, it is a signal to clear the popmessage
// otherwise, generate the buffer and call the UI to display the message
if (is_null<Format>::value(fmt))
popup_clear();
else
popup_message(util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
}
/*-------------------------------------------------
logerror - log to the debugger and any other
OSD-defined output streams
-------------------------------------------------*/
template <typename Format, typename... Params>
inline void running_machine::logerror(Format &&fmt, Params &&... args) const
{
// process only if there is a target
if (!m_logerror_list.empty())
{
g_profiler.start(PROFILER_LOGERROR);
// dump to the buffer
m_string_buffer.clear();
m_string_buffer.seekp(0);
util::stream_format(m_string_buffer, std::forward<Format>(fmt), std::forward<Params>(args)...);
m_string_buffer.put('\0');
// log to all callbacks
char const *const str(&m_string_buffer.vec()[0]);
for (auto &cb : m_logerror_list)
(cb->m_func)(*this, str);
g_profiler.stop();
}
}
#endif /* __MACHINE_H__ */

View File

@ -1,77 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
machine.ipp
Controls execution of the core MAME system.
***************************************************************************/
#pragma once
#ifndef __EMU_H__
#error Dont include this file directly; include emu.h instead.
#endif
#ifndef __MACHINE_IPP__
#define __MACHINE_IPP__
#include "strformat.h"
//**************************************************************************
// MEMBER TEMPLATES
//**************************************************************************
/*-------------------------------------------------
popmessage - pop up a user-visible message
-------------------------------------------------*/
template <typename Format, typename... Params>
inline void running_machine::popmessage(Format &&fmt, Params &&... args) const
{
if (is_null<Format>::value(fmt))
{
// if the format is NULL, it is a signal to clear the popmessage
ui().popup_time(0, " ");
}
else
{
// otherwise, generate the buffer and call the UI to display the message
std::string const temp(string_format(std::forward<Format>(fmt), std::forward<Params>(args)...));
// pop it in the UI
ui().popup_time(temp.length() / 40 + 2, "%s", temp.c_str());
}
}
/*-------------------------------------------------
logerror - log to the debugger and any other
OSD-defined output streams
-------------------------------------------------*/
template <typename Format, typename... Params>
inline void running_machine::logerror(Format &&fmt, Params &&... args) const
{
// process only if there is a target
if (!m_logerror_list.empty())
{
g_profiler.start(PROFILER_LOGERROR);
// dump to the buffer
m_string_buffer.clear();
m_string_buffer.seekp(0);
util::stream_format(m_string_buffer, std::forward<Format>(fmt), std::forward<Params>(args)...);
m_string_buffer.put('\0');
// log to all callbacks
char const *const str(&m_string_buffer.vec()[0]);
for (auto &cb : m_logerror_list)
(cb->m_func)(*this, str);
g_profiler.stop();
}
}
#endif // __MACHINE_IPP__