Split cases for prefix and special for dumper targets
This commit is contained in:
parent
b00ccb2731
commit
1974362569
8 changed files with 79 additions and 27 deletions
|
@ -10,6 +10,13 @@
|
|||
class adv_dumper
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Detail flags.
|
||||
*/
|
||||
static unsigned target_type_mask;
|
||||
static unsigned target_type_file;
|
||||
static unsigned target_type_prefix;
|
||||
static unsigned target_type_special;
|
||||
/**
|
||||
* Register a dumper.
|
||||
*
|
||||
|
@ -42,11 +49,12 @@ public:
|
|||
*/
|
||||
virtual std::set<std::string> list_submodes() throw(std::bad_alloc) = 0;
|
||||
/**
|
||||
* Does this dumper want a prefix?
|
||||
* Get mode details
|
||||
*
|
||||
* parameter mode: The submode.
|
||||
* Returns: Mode details flags
|
||||
*/
|
||||
virtual bool wants_prefix(const std::string& mode) throw() = 0;
|
||||
virtual unsigned mode_details(const std::string& mode) throw() = 0;
|
||||
/**
|
||||
* Get human-readable name for this dumper.
|
||||
*
|
||||
|
|
|
@ -66,12 +66,22 @@ namespace
|
|||
return;
|
||||
}
|
||||
for(auto j : b) {
|
||||
if(i->wants_prefix(j))
|
||||
unsigned d = i->mode_details(j);
|
||||
if((d & adv_dumper::target_type_mask) ==
|
||||
adv_dumper::target_type_prefix)
|
||||
messages << "P " << x << "\t" << j << "\t"
|
||||
<< i->modename(j) << std::endl;
|
||||
else
|
||||
else if((d & adv_dumper::target_type_mask) ==
|
||||
adv_dumper::target_type_file)
|
||||
messages << "F " << x << "\t" << j << "\t"
|
||||
<< i->modename(j) << std::endl;
|
||||
else if((d & adv_dumper::target_type_mask) ==
|
||||
adv_dumper::target_type_special)
|
||||
messages << "S " << x << "\t" << j << "\t"
|
||||
<< i->modename(j) << std::endl;
|
||||
else
|
||||
messages << "U " << x << "\t" << j << "\t"
|
||||
<< i->modename(j) << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -106,6 +116,11 @@ adv_dumper::adv_dumper(const std::string& id) throw(std::bad_alloc)
|
|||
dumpers()[d_id] = this;
|
||||
}
|
||||
|
||||
unsigned adv_dumper::target_type_mask = 3;
|
||||
unsigned adv_dumper::target_type_file = 0;
|
||||
unsigned adv_dumper::target_type_prefix = 1;
|
||||
unsigned adv_dumper::target_type_special = 2;
|
||||
|
||||
template<bool X> void render_video_hud(struct screen<X>& target, struct lcscreen& source, uint32_t hscl, uint32_t vscl,
|
||||
uint32_t roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap, uint32_t rgap,
|
||||
uint32_t bgap, void(*fn)())
|
||||
|
|
|
@ -114,13 +114,29 @@ void dumper_menu::on_select(wxCommandEvent& e)
|
|||
if(i.second.start_wxids.count(id)) {
|
||||
//Execute start of dump operation.
|
||||
std::string mode = i.second.start_wxids[id];
|
||||
bool prefixed = t->wants_prefix(mode);
|
||||
unsigned d = t->mode_details(mode);
|
||||
std::string prefix;
|
||||
wxFileDialog* d = new wxFileDialog(pwin, towxstring(prefixed ? std::string("Choose prefix") :
|
||||
std::string("Choose file")), wxT("."));
|
||||
if(d->ShowModal() == wxID_OK)
|
||||
prefix = tostdstring(d->GetFilename());
|
||||
d->Destroy();
|
||||
if((d & adv_dumper::target_type_mask) == adv_dumper::target_type_file) {
|
||||
wxFileDialog* d = new wxFileDialog(pwin, wxT("Choose file"), wxT("."));
|
||||
if(d->ShowModal() == wxID_OK)
|
||||
prefix = tostdstring(d->GetPath());
|
||||
d->Destroy();
|
||||
} else if((d & adv_dumper::target_type_mask) == adv_dumper::target_type_prefix) {
|
||||
wxFileDialog* d = new wxFileDialog(pwin, wxT("Choose prefix"), wxT("."));
|
||||
if(d->ShowModal() == wxID_OK)
|
||||
prefix = tostdstring(d->GetPath());
|
||||
d->Destroy();
|
||||
} else if((d & adv_dumper::target_type_mask) == adv_dumper::target_type_special) {
|
||||
try {
|
||||
prefix = pick_text(pwin, "Choose target", "Enter target to dump to", "");
|
||||
} catch(...) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
wxMessageBox(wxT("Unsupported target type"), _T("Dumper error"), wxICON_EXCLAMATION |
|
||||
wxOK, pwin);
|
||||
return;
|
||||
}
|
||||
if(prefix == "")
|
||||
return;
|
||||
runemufn([t, mode, prefix, &error_str]() {
|
||||
|
|
|
@ -101,6 +101,20 @@ namespace
|
|||
return *_dumper;
|
||||
}
|
||||
|
||||
std::string format_details(unsigned detail)
|
||||
{
|
||||
std::string r;
|
||||
if((detail & adv_dumper::target_type_mask) == adv_dumper::target_type_file)
|
||||
r = r + "TARGET_FILE";
|
||||
else if((detail & adv_dumper::target_type_mask) == adv_dumper::target_type_prefix)
|
||||
r = r + "TARGET_PREFIX";
|
||||
else if((detail & adv_dumper::target_type_mask) == adv_dumper::target_type_special)
|
||||
r = r + "TARGET_SPECIAL";
|
||||
else
|
||||
r = r + "TARGET_UNKNOWN";
|
||||
return r;
|
||||
}
|
||||
|
||||
adv_dumper& get_dumper(const std::vector<std::string>& cmdline, std::string& mode, std::string& prefix,
|
||||
uint64_t& length)
|
||||
{
|
||||
|
@ -170,18 +184,17 @@ namespace
|
|||
adv_dumper& _dumper = locate_dumper(dumper);
|
||||
std::set<std::string> modes = _dumper.list_submodes();
|
||||
if(modes.empty()) {
|
||||
if(_dumper.wants_prefix(""))
|
||||
std::cout << "No modes available for " << dumper << " (multi)" << std::endl;
|
||||
else
|
||||
std::cout << "No modes available for " << dumper << " (single)" << std::endl;
|
||||
unsigned d = _dumper.mode_details("");
|
||||
std::cout << "No modes available for " << dumper << " (" << format_details(d) << ")"
|
||||
<< std::endl;
|
||||
exit(0);
|
||||
}
|
||||
std::cout << "Modes available for " << dumper << ":" << std::endl;
|
||||
for(auto i : modes)
|
||||
if(_dumper.wants_prefix(i))
|
||||
std::cout << i << "\tmulti\t" << _dumper.modename(i) << std::endl;
|
||||
else
|
||||
std::cout << i << "\tsingle\t" << _dumper.modename(i) << std::endl;
|
||||
for(auto i : modes) {
|
||||
unsigned d = _dumper.mode_details(i);
|
||||
std::cout << i << "\t" << _dumper.modename(i) << "\t(" << format_details(d) << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
adv_dumper& _dumper = locate_dumper(dumper);
|
||||
|
|
|
@ -280,9 +280,9 @@ namespace
|
|||
return x;
|
||||
}
|
||||
|
||||
bool wants_prefix(const std::string& mode) throw()
|
||||
unsigned mode_details(const std::string& mode) throw()
|
||||
{
|
||||
return true;
|
||||
return target_type_prefix;
|
||||
}
|
||||
|
||||
std::string name() throw(std::bad_alloc)
|
||||
|
|
|
@ -318,9 +318,9 @@ namespace
|
|||
return x;
|
||||
}
|
||||
|
||||
bool wants_prefix(const std::string& mode) throw()
|
||||
unsigned mode_details(const std::string& mode) throw()
|
||||
{
|
||||
return false;
|
||||
return target_type_file;
|
||||
}
|
||||
|
||||
std::string name() throw(std::bad_alloc)
|
||||
|
|
|
@ -142,9 +142,9 @@ namespace
|
|||
return x;
|
||||
}
|
||||
|
||||
bool wants_prefix(const std::string& mode) throw()
|
||||
unsigned mode_details(const std::string& mode) throw()
|
||||
{
|
||||
return true;
|
||||
return IS_TCP(strhash(mode)) ? target_type_special : target_type_prefix;
|
||||
}
|
||||
|
||||
std::string name() throw(std::bad_alloc)
|
||||
|
|
|
@ -134,9 +134,9 @@ namespace
|
|||
return x;
|
||||
}
|
||||
|
||||
bool wants_prefix(const std::string& mode) throw()
|
||||
unsigned mode_details(const std::string& mode) throw()
|
||||
{
|
||||
return (mode != "ss");
|
||||
return (mode != "ss") ? target_type_prefix : target_type_file;
|
||||
}
|
||||
|
||||
std::string name() throw(std::bad_alloc)
|
||||
|
|
Loading…
Add table
Reference in a new issue