Trace Viewer: Display a file picker if the user doesn't supply a file on the command line.
This commit is contained in:
parent
e471767f4c
commit
f50e2ab10c
|
@ -19,6 +19,7 @@
|
||||||
#include "xenia/gpu/gl4/gl4_command_processor.h"
|
#include "xenia/gpu/gl4/gl4_command_processor.h"
|
||||||
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
||||||
#include "xenia/gpu/gl4/gl4_shader.h"
|
#include "xenia/gpu/gl4/gl4_shader.h"
|
||||||
|
#include "xenia/ui/file_picker.h"
|
||||||
|
|
||||||
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.");
|
DEFINE_string(target_trace_file, "", "Specifies the trace file to load.");
|
||||||
|
|
||||||
|
@ -69,21 +70,40 @@ class GL4TraceViewer : public TraceViewer {
|
||||||
|
|
||||||
int trace_viewer_main(const std::vector<std::wstring>& args) {
|
int trace_viewer_main(const std::vector<std::wstring>& args) {
|
||||||
// Grab path from the flag or unnamed argument.
|
// Grab path from the flag or unnamed argument.
|
||||||
if (FLAGS_target_trace_file.empty() && args.size() < 2) {
|
|
||||||
xe::FatalError("No trace file specified");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring path;
|
std::wstring path;
|
||||||
if (!FLAGS_target_trace_file.empty()) {
|
if (!FLAGS_target_trace_file.empty()) {
|
||||||
// Passed as a named argument.
|
// Passed as a named argument.
|
||||||
// TODO(benvanik): find something better than gflags that supports
|
// TODO(benvanik): find something better than gflags that supports
|
||||||
// unicode.
|
// unicode.
|
||||||
path = xe::to_wstring(FLAGS_target_trace_file);
|
path = xe::to_wstring(FLAGS_target_trace_file);
|
||||||
} else {
|
} else if (args.size() >= 2) {
|
||||||
// Passed as an unnamed argument.
|
// Passed as an unnamed argument.
|
||||||
path = args[1];
|
path = args[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no path passed, ask the user.
|
||||||
|
if (path.empty()) {
|
||||||
|
auto file_picker = xe::ui::FilePicker::Create();
|
||||||
|
file_picker->set_mode(ui::FilePicker::Mode::kOpen);
|
||||||
|
file_picker->set_type(ui::FilePicker::Type::kFile);
|
||||||
|
file_picker->set_multi_selection(false);
|
||||||
|
file_picker->set_title(L"Select Trace File");
|
||||||
|
file_picker->set_extensions({
|
||||||
|
{L"Supported Files", L"*.*"}, {L"All Files (*.*)", L"*.*"},
|
||||||
|
});
|
||||||
|
if (file_picker->Show()) {
|
||||||
|
auto selected_files = file_picker->selected_files();
|
||||||
|
if (!selected_files.empty()) {
|
||||||
|
path = selected_files[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.empty()) {
|
||||||
|
xe::FatalError("No trace file specified");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize the path and make absolute.
|
// Normalize the path and make absolute.
|
||||||
auto abs_path = xe::to_absolute_path(path);
|
auto abs_path = xe::to_absolute_path(path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue