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
|
class adv_dumper
|
||||||
{
|
{
|
||||||
public:
|
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.
|
* Register a dumper.
|
||||||
*
|
*
|
||||||
|
@ -42,11 +49,12 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual std::set<std::string> list_submodes() throw(std::bad_alloc) = 0;
|
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.
|
* 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.
|
* Get human-readable name for this dumper.
|
||||||
*
|
*
|
||||||
|
|
|
@ -66,12 +66,22 @@ namespace
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(auto j : b) {
|
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"
|
messages << "P " << x << "\t" << j << "\t"
|
||||||
<< i->modename(j) << std::endl;
|
<< 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"
|
messages << "F " << x << "\t" << j << "\t"
|
||||||
<< i->modename(j) << std::endl;
|
<< 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;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +116,11 @@ adv_dumper::adv_dumper(const std::string& id) throw(std::bad_alloc)
|
||||||
dumpers()[d_id] = this;
|
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,
|
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 roffset, uint32_t goffset, uint32_t boffset, uint32_t lgap, uint32_t tgap, uint32_t rgap,
|
||||||
uint32_t bgap, void(*fn)())
|
uint32_t bgap, void(*fn)())
|
||||||
|
|
|
@ -114,13 +114,29 @@ void dumper_menu::on_select(wxCommandEvent& e)
|
||||||
if(i.second.start_wxids.count(id)) {
|
if(i.second.start_wxids.count(id)) {
|
||||||
//Execute start of dump operation.
|
//Execute start of dump operation.
|
||||||
std::string mode = i.second.start_wxids[id];
|
std::string mode = i.second.start_wxids[id];
|
||||||
bool prefixed = t->wants_prefix(mode);
|
unsigned d = t->mode_details(mode);
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
wxFileDialog* d = new wxFileDialog(pwin, towxstring(prefixed ? std::string("Choose prefix") :
|
if((d & adv_dumper::target_type_mask) == adv_dumper::target_type_file) {
|
||||||
std::string("Choose file")), wxT("."));
|
wxFileDialog* d = new wxFileDialog(pwin, wxT("Choose file"), wxT("."));
|
||||||
if(d->ShowModal() == wxID_OK)
|
if(d->ShowModal() == wxID_OK)
|
||||||
prefix = tostdstring(d->GetFilename());
|
prefix = tostdstring(d->GetPath());
|
||||||
d->Destroy();
|
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 == "")
|
if(prefix == "")
|
||||||
return;
|
return;
|
||||||
runemufn([t, mode, prefix, &error_str]() {
|
runemufn([t, mode, prefix, &error_str]() {
|
||||||
|
|
|
@ -101,6 +101,20 @@ namespace
|
||||||
return *_dumper;
|
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,
|
adv_dumper& get_dumper(const std::vector<std::string>& cmdline, std::string& mode, std::string& prefix,
|
||||||
uint64_t& length)
|
uint64_t& length)
|
||||||
{
|
{
|
||||||
|
@ -170,18 +184,17 @@ namespace
|
||||||
adv_dumper& _dumper = locate_dumper(dumper);
|
adv_dumper& _dumper = locate_dumper(dumper);
|
||||||
std::set<std::string> modes = _dumper.list_submodes();
|
std::set<std::string> modes = _dumper.list_submodes();
|
||||||
if(modes.empty()) {
|
if(modes.empty()) {
|
||||||
if(_dumper.wants_prefix(""))
|
unsigned d = _dumper.mode_details("");
|
||||||
std::cout << "No modes available for " << dumper << " (multi)" << std::endl;
|
std::cout << "No modes available for " << dumper << " (" << format_details(d) << ")"
|
||||||
else
|
<< std::endl;
|
||||||
std::cout << "No modes available for " << dumper << " (single)" << std::endl;
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
std::cout << "Modes available for " << dumper << ":" << std::endl;
|
std::cout << "Modes available for " << dumper << ":" << std::endl;
|
||||||
for(auto i : modes)
|
for(auto i : modes) {
|
||||||
if(_dumper.wants_prefix(i))
|
unsigned d = _dumper.mode_details(i);
|
||||||
std::cout << i << "\tmulti\t" << _dumper.modename(i) << std::endl;
|
std::cout << i << "\t" << _dumper.modename(i) << "\t(" << format_details(d) << ")"
|
||||||
else
|
<< std::endl;
|
||||||
std::cout << i << "\tsingle\t" << _dumper.modename(i) << std::endl;
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
adv_dumper& _dumper = locate_dumper(dumper);
|
adv_dumper& _dumper = locate_dumper(dumper);
|
||||||
|
|
|
@ -280,9 +280,9 @@ namespace
|
||||||
return x;
|
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)
|
std::string name() throw(std::bad_alloc)
|
||||||
|
|
|
@ -318,9 +318,9 @@ namespace
|
||||||
return x;
|
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)
|
std::string name() throw(std::bad_alloc)
|
||||||
|
|
|
@ -142,9 +142,9 @@ namespace
|
||||||
return x;
|
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)
|
std::string name() throw(std::bad_alloc)
|
||||||
|
|
|
@ -134,9 +134,9 @@ namespace
|
||||||
return x;
|
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)
|
std::string name() throw(std::bad_alloc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue