Merge pull request #1077 from npwoods/more_miscellaneous_refactorings

More miscellaneous refactorings
This commit is contained in:
Vas Crabb 2016-07-11 11:16:37 +10:00 committed by GitHub
commit 2afcd53179
3 changed files with 37 additions and 16 deletions

View File

@ -549,6 +549,39 @@ std::string running_machine::get_statename(const char *option) const
return statename_str;
}
//-------------------------------------------------
// compose_saveload_filename - composes a filename
// for state loading/saving
//-------------------------------------------------
std::string running_machine::compose_saveload_filename(const char *filename, const char **searchpath)
{
std::string result;
// is this an absolute path?
if (osd_is_absolute_path(filename))
{
// if so, this is easy
if (searchpath != nullptr)
*searchpath = nullptr;
result = filename;
}
else
{
// this is a relative path; first specify the search path
if (searchpath != nullptr)
*searchpath = options().state_directory();
// take into account the statename option
const char *stateopt = options().state_name();
std::string statename = get_statename(stateopt);
result = string_format("%s%s%s.sta", statename, PATH_SEPARATOR, filename);
}
return result;
}
//-------------------------------------------------
// set_saveload_filename - specifies the filename
// for state loading/saving
@ -556,20 +589,8 @@ std::string running_machine::get_statename(const char *option) const
void running_machine::set_saveload_filename(const char *filename)
{
// free any existing request and allocate a copy of the requested name
if (osd_is_absolute_path(filename))
{
m_saveload_searchpath = nullptr;
m_saveload_pending_file.assign(filename);
}
else
{
m_saveload_searchpath = options().state_directory();
// take into account the statename option
const char *stateopt = options().state_name();
std::string statename = get_statename(stateopt);
m_saveload_pending_file = string_format("%s%s%s.sta", statename, PATH_SEPARATOR, filename);
}
// compose the save/load filename and persist it
m_saveload_pending_file = compose_saveload_filename(filename, &m_saveload_searchpath);
}

View File

@ -234,6 +234,7 @@ public:
void strlog(const char *str) const;
UINT32 rand();
const char *describe_context();
std::string compose_saveload_filename(const char *base_filename, const char **searchpath = nullptr);
// CPU information
cpu_device * firstcpu; // first CPU

View File

@ -45,12 +45,11 @@ public:
protected:
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
bool & m_ok;
private:
virtual void populate() override;
virtual void handle() override;
bool & m_ok;
device_image_interface * m_image;
std::string & m_current_directory;
std::string & m_current_file;