App skeleton.
This commit is contained in:
parent
1bae2ef10b
commit
88d01e8375
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "xenia/debug/ui/application.h"
|
||||||
|
|
||||||
|
#include "xenia/base/logging.h"
|
||||||
|
#include "xenia/base/platform.h"
|
||||||
|
#include "xenia/base/threading.h"
|
||||||
|
#include "xenia/debug/ui/main_window.h"
|
||||||
|
#include "xenia/profiling.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace debug {
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
Application::Application() {}
|
||||||
|
|
||||||
|
Application::~Application() = default;
|
||||||
|
|
||||||
|
std::unique_ptr<Application> Application::Create() {
|
||||||
|
std::unique_ptr<Application> app(new Application());
|
||||||
|
|
||||||
|
xe::threading::Fence fence;
|
||||||
|
app->loop()->Post([&app, &fence]() {
|
||||||
|
xe::threading::set_name("Win32 Loop");
|
||||||
|
xe::Profiler::ThreadEnter("Win32 Loop");
|
||||||
|
|
||||||
|
if (!app->Initialize()) {
|
||||||
|
XEFATAL("Failed to initialize application");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fence.Signal();
|
||||||
|
});
|
||||||
|
fence.Wait();
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Application::Initialize() {
|
||||||
|
main_window_ = std::make_unique<MainWindow>(this);
|
||||||
|
if (!main_window_->Initialize()) {
|
||||||
|
XELOGE("Unable to initialize main window");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::Quit() {
|
||||||
|
loop_.Quit();
|
||||||
|
|
||||||
|
// TODO(benvanik): proper exit.
|
||||||
|
XELOGI("User-initiated death!");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ui
|
||||||
|
} // namespace debug
|
||||||
|
} // namespace xe
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XENIA_DEBUG_UI_APPLICATION_H_
|
||||||
|
#define XENIA_DEBUG_UI_APPLICATION_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "xenia/ui/platform.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace debug {
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
class Application {
|
||||||
|
public:
|
||||||
|
~Application();
|
||||||
|
|
||||||
|
static std::unique_ptr<Application> Create();
|
||||||
|
|
||||||
|
xe::ui::Loop* loop() { return &loop_; }
|
||||||
|
MainWindow* main_window() const { return main_window_.get(); }
|
||||||
|
|
||||||
|
void Quit();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Application();
|
||||||
|
|
||||||
|
bool Initialize();
|
||||||
|
|
||||||
|
xe::ui::PlatformLoop loop_;
|
||||||
|
std::unique_ptr<MainWindow> main_window_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ui
|
||||||
|
} // namespace debug
|
||||||
|
} // namespace xe
|
||||||
|
|
||||||
|
#endif // XENIA_DEBUG_UI_APPLICATION_H_
|
|
@ -13,7 +13,6 @@
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/platform.h"
|
#include "xenia/base/platform.h"
|
||||||
#include "xenia/base/threading.h"
|
#include "xenia/base/threading.h"
|
||||||
#include "xenia/profiling.h"
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace debug {
|
namespace debug {
|
||||||
|
@ -32,33 +31,13 @@ enum Commands {
|
||||||
|
|
||||||
const std::wstring kBaseTitle = L"xenia debugger";
|
const std::wstring kBaseTitle = L"xenia debugger";
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow(Application* app)
|
||||||
: PlatformWindow(&loop_, kBaseTitle), main_menu_(MenuItem::Type::kNormal) {}
|
: PlatformWindow(app->loop(), kBaseTitle),
|
||||||
|
app_(app),
|
||||||
|
main_menu_(MenuItem::Type::kNormal) {}
|
||||||
|
|
||||||
MainWindow::~MainWindow() = default;
|
MainWindow::~MainWindow() = default;
|
||||||
|
|
||||||
std::unique_ptr<MainWindow> MainWindow::Create() {
|
|
||||||
std::unique_ptr<MainWindow> main_window(new MainWindow());
|
|
||||||
|
|
||||||
xe::threading::Fence fence;
|
|
||||||
|
|
||||||
main_window->loop()->Post([&main_window, &fence]() {
|
|
||||||
xe::threading::set_name("Win32 Loop");
|
|
||||||
xe::Profiler::ThreadEnter("Win32 Loop");
|
|
||||||
|
|
||||||
if (!main_window->Initialize()) {
|
|
||||||
XEFATAL("Failed to initialize main window");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fence.Signal();
|
|
||||||
});
|
|
||||||
|
|
||||||
fence.Wait();
|
|
||||||
|
|
||||||
return main_window;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWindow::Initialize() {
|
bool MainWindow::Initialize() {
|
||||||
if (!PlatformWindow::Initialize()) {
|
if (!PlatformWindow::Initialize()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -117,13 +96,7 @@ bool MainWindow::Initialize() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnClose() {
|
void MainWindow::OnClose() { app_->Quit(); }
|
||||||
loop_.Quit();
|
|
||||||
|
|
||||||
// TODO(benvanik): proper exit.
|
|
||||||
XELOGI("User-initiated death!");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::OnCommand(int id) {
|
void MainWindow::OnCommand(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "xenia/debug/ui/application.h"
|
||||||
#include "xenia/ui/gl/wgl_control.h"
|
#include "xenia/ui/gl/wgl_control.h"
|
||||||
#include "xenia/ui/platform.h"
|
#include "xenia/ui/platform.h"
|
||||||
#include "xenia/ui/window.h"
|
#include "xenia/ui/window.h"
|
||||||
|
@ -22,19 +23,18 @@ namespace ui {
|
||||||
|
|
||||||
class MainWindow : public xe::ui::PlatformWindow {
|
class MainWindow : public xe::ui::PlatformWindow {
|
||||||
public:
|
public:
|
||||||
|
MainWindow(Application* app);
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
static std::unique_ptr<MainWindow> Create();
|
Application* app() const { return app_; }
|
||||||
|
|
||||||
private:
|
|
||||||
explicit MainWindow();
|
|
||||||
|
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
|
|
||||||
|
private:
|
||||||
void OnClose() override;
|
void OnClose() override;
|
||||||
void OnCommand(int id) override;
|
void OnCommand(int id) override;
|
||||||
|
|
||||||
xe::ui::PlatformLoop loop_;
|
Application* app_ = nullptr;
|
||||||
xe::ui::PlatformMenu main_menu_;
|
xe::ui::PlatformMenu main_menu_;
|
||||||
std::unique_ptr<xe::ui::gl::WGLControl> control_;
|
std::unique_ptr<xe::ui::gl::WGLControl> control_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,15 +12,15 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "xenia/base/main.h"
|
#include "xenia/base/main.h"
|
||||||
#include "xenia/debug/ui/main_window.h"
|
#include "xenia/debug/ui/application.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace debug {
|
namespace debug {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
int main(std::vector<std::wstring>& args) {
|
int main(std::vector<std::wstring>& args) {
|
||||||
auto main_window = MainWindow::Create();
|
auto app = Application::Create();
|
||||||
main_window->loop()->AwaitQuit();
|
app->loop()->AwaitQuit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,12 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\base\main.h" />
|
<ClInclude Include="..\..\base\main.h" />
|
||||||
|
<ClInclude Include="application.h" />
|
||||||
<ClInclude Include="main_window.h" />
|
<ClInclude Include="main_window.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\base\main_win.cc" />
|
<ClCompile Include="..\..\base\main_win.cc" />
|
||||||
|
<ClCompile Include="application.cc" />
|
||||||
<ClCompile Include="main_window.cc" />
|
<ClCompile Include="main_window.cc" />
|
||||||
<ClCompile Include="xe-debug-ui.cc" />
|
<ClCompile Include="xe-debug-ui.cc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
<ClInclude Include="main_window.h">
|
<ClInclude Include="main_window.h">
|
||||||
<Filter>src\xenia\debug\ui</Filter>
|
<Filter>src\xenia\debug\ui</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="application.h">
|
||||||
|
<Filter>src\xenia\debug\ui</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\base\main_win.cc">
|
<ClCompile Include="..\..\base\main_win.cc">
|
||||||
|
@ -35,5 +38,8 @@
|
||||||
<ClCompile Include="main_window.cc">
|
<ClCompile Include="main_window.cc">
|
||||||
<Filter>src\xenia\debug\ui</Filter>
|
<Filter>src\xenia\debug\ui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="application.cc">
|
||||||
|
<Filter>src\xenia\debug\ui</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue