Clean up instance usage in editor-voicesub.cpp

This commit is contained in:
Ilari Liusvaara 2014-06-09 18:43:19 +03:00
parent a2f4ba6dfd
commit c3982c8902
3 changed files with 16 additions and 3 deletions

View file

@ -136,5 +136,9 @@ std::string UI_get_project_otherpath(emulator_instance& inst);
* Get moviepath of current project.
*/
std::string UI_get_project_moviepath(emulator_instance& inst);
/**
* Is in project context?
*/
bool UI_in_project_context(emulator_instance& inst);
#endif

View file

@ -270,3 +270,12 @@ std::string UI_get_project_moviepath(emulator_instance& inst)
});
return path;
}
bool UI_in_project_context(emulator_instance& inst)
{
bool pc;
lsnes_instance.iqueue->run([&inst, &pc]() {
pc = (inst.project->get() != NULL);
});
return pc;
}

View file

@ -291,7 +291,7 @@ void wxeditor_voicesub::on_change_gain(wxCommandEvent& e)
void wxeditor_voicesub::on_load(wxCommandEvent& e)
{
if(inst.project->get() != NULL)
if(UI_in_project_context(inst))
return;
try {
std::string filename;
@ -310,7 +310,7 @@ void wxeditor_voicesub::on_load(wxCommandEvent& e)
void wxeditor_voicesub::on_unload(wxCommandEvent& e)
{
if(inst.project->get() != NULL)
if(UI_in_project_context(inst))
return;
inst.commentary->unload_collection();
}
@ -331,7 +331,7 @@ void wxeditor_voicesub::refresh()
if(closing)
return;
bool cflag = inst.commentary->collection_loaded();
bool pflag = (inst.project->get() != NULL);
bool pflag = UI_in_project_context(inst);
unloadbutton->Enable(cflag && !pflag);
loadbutton->Enable(!pflag);
exportsbutton->Enable(cflag);