2 #include <wx/statline.h>
4 #include <wx/control.h>
5 #include <wx/combobox.h>
6 #include <wx/radiobut.h>
7 #include <wx/spinctrl.h>
9 #include "platform/wxwidgets/menu_tracelog.hpp"
10 #include "platform/wxwidgets/platform.hpp"
11 #include "platform/wxwidgets/loadsave.hpp"
12 #include "core/debug.hpp"
13 #include "core/dispatch.hpp"
14 #include "core/instance.hpp"
15 #include "core/project.hpp"
16 #include "core/moviedata.hpp"
17 #include "core/rom.hpp"
18 #include "core/ui-services.hpp"
21 tracelog_menu::tracelog_menu(wxWindow
* win
, emulator_instance
& _inst
, int wxid_low
, int wxid_high
)
26 wxid_range_low
= wxid_low
;
27 wxid_range_high
= wxid_high
;
28 win
->Connect(wxid_low
, wxid_high
, wxEVT_COMMAND_MENU_SELECTED
,
29 wxCommandEventHandler(tracelog_menu::on_select
), NULL
, this);
30 inst
.dbg
->set_tracelog_change_cb([this]() { runuifun([this]() { this->update(); }); });
31 corechange
.set(inst
.dispatch
->core_change
, [this]() { runuifun([this]() { this->update(); }); });
34 tracelog_menu::~tracelog_menu()
38 void tracelog_menu::on_select(wxCommandEvent
& e
)
41 int id
= e
.GetId() - wxid_range_low
;
42 if(id
< 0 || id
> wxid_range_high
- wxid_range_low
) return;
44 if(!cpunames
.count(rid
))
47 wxeditor_tracelog_display(pwin
, inst
, rid
, cpunames
[rid
]);
49 bool ch
= items
[rid
]->IsChecked();
52 std::string filename
= choose_file_save(pwin
, "Save " + cpunames
[rid
] + " Trace",
53 UI_get_project_moviepath(inst
), filetype_trace
, "");
54 inst
.dbg
->tracelog(rid
, filename
);
55 } catch(canceled_exception
& e
) {
58 inst
.dbg
->tracelog(rid
, "");
64 void tracelog_menu::update()
67 auto _items
= inst
.rom
->get_trace_cpus();
72 for(auto i
: _items
) {
73 items
.push_back(AppendCheckItem(wxid_range_low
+ 2 * id
, towxstring(i
+ " (to file)...")));
75 items
[id
]->Check(inst
.dbg
->is_tracelogging(id
));
78 items
.push_back(AppendSeparator());
80 for(auto i
: _items
) {
81 items
.push_back(Append(wxid_range_low
+ 2 * id
+ 1, towxstring(i
+ " (to window)...")));
84 if(disabler_fn
) disabler_fn(!_items
.empty());
87 bool tracelog_menu::any_enabled()
89 return !items
.empty();