Main window, empty GPU files.
This commit is contained in:
@@ -10,30 +10,68 @@
|
||||
#include <xenia/ui/main_window.h>
|
||||
|
||||
#include <poly/logging.h>
|
||||
#include <poly/threading.h>
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
||||
MainWindow::MainWindow() : PlatformWindow(L"xenia") {}
|
||||
MainWindow::MainWindow(Emulator* emulator)
|
||||
: PlatformWindow(L"xenia"), emulator_(emulator) {}
|
||||
|
||||
MainWindow::~MainWindow() {}
|
||||
MainWindow::~MainWindow() = default;
|
||||
|
||||
void MainWindow::Start() {
|
||||
loop_.Post([this]() {
|
||||
poly::threading::Fence fence;
|
||||
|
||||
loop_.Post([&]() {
|
||||
if (!Initialize()) {
|
||||
PFATAL("Failed to initialize main window");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fence.Signal();
|
||||
});
|
||||
|
||||
fence.Wait();
|
||||
}
|
||||
|
||||
bool MainWindow::Initialize() {
|
||||
if (!Window::Initialize()) {
|
||||
if (!PlatformWindow::Initialize()) {
|
||||
return false;
|
||||
}
|
||||
//
|
||||
Resize(1280, 720);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::OnClose() {
|
||||
loop_.Quit();
|
||||
|
||||
// TODO(benvanik): proper exit.
|
||||
PLOGI("User-initiated death!");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
X_STATUS MainWindow::LaunchPath(std::wstring path) {
|
||||
X_STATUS result;
|
||||
|
||||
// Launch based on file type.
|
||||
// This is a silly guess based on file extension.
|
||||
// NOTE: this blocks!
|
||||
auto file_system_type = emulator_->file_system()->InferType(path);
|
||||
switch (file_system_type) {
|
||||
case kernel::fs::FileSystemType::STFS_TITLE:
|
||||
result = emulator_->LaunchSTFSTitle(path);
|
||||
break;
|
||||
case kernel::fs::FileSystemType::XEX_FILE:
|
||||
result = emulator_->LaunchXexFile(path);
|
||||
break;
|
||||
case kernel::fs::FileSystemType::DISC_IMAGE:
|
||||
result = emulator_->LaunchDiscImage(path);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace xe
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define XENIA_UI_MAIN_WINDOW_H_
|
||||
|
||||
#include <poly/ui/window.h>
|
||||
#include <xenia/emulator.h>
|
||||
|
||||
// TODO(benvanik): only on windows.
|
||||
#include <poly/ui/win32/win32_loop.h>
|
||||
@@ -24,16 +25,22 @@ using PlatformWindow = poly::ui::win32::Win32Window;
|
||||
|
||||
class MainWindow : public PlatformWindow {
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow();
|
||||
explicit MainWindow(Emulator* emulator);
|
||||
~MainWindow() override;
|
||||
|
||||
Emulator* emulator() const { return emulator_; }
|
||||
PlatformLoop* loop() { return &loop_; }
|
||||
|
||||
void Start();
|
||||
|
||||
X_STATUS LaunchPath(std::wstring path);
|
||||
|
||||
private:
|
||||
bool Initialize();
|
||||
|
||||
void OnClose() override;
|
||||
|
||||
Emulator* emulator_;
|
||||
PlatformLoop loop_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user