Skeleton debugger window.
This commit is contained in:
parent
9efccc5f4a
commit
1bae2ef10b
|
@ -0,0 +1,145 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* 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/main_window.h"
|
||||||
|
|
||||||
|
#include "xenia/base/clock.h"
|
||||||
|
#include "xenia/base/logging.h"
|
||||||
|
#include "xenia/base/platform.h"
|
||||||
|
#include "xenia/base/threading.h"
|
||||||
|
#include "xenia/profiling.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace debug {
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
using xe::ui::MenuItem;
|
||||||
|
using xe::ui::PlatformMenu;
|
||||||
|
using xe::ui::PlatformWindow;
|
||||||
|
|
||||||
|
enum Commands {
|
||||||
|
IDC_FILE_EXIT,
|
||||||
|
|
||||||
|
IDC_HELP_WEBSITE,
|
||||||
|
IDC_HELP_ABOUT,
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::wstring kBaseTitle = L"xenia debugger";
|
||||||
|
|
||||||
|
MainWindow::MainWindow()
|
||||||
|
: PlatformWindow(&loop_, kBaseTitle), main_menu_(MenuItem::Type::kNormal) {}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
if (!PlatformWindow::Initialize()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
on_key_down.AddListener([this](xe::ui::KeyEvent& e) {
|
||||||
|
bool handled = true;
|
||||||
|
switch (e.key_code()) {
|
||||||
|
case 0x1B: { // VK_ESCAPE
|
||||||
|
// Allow users to escape fullscreen (but not enter it).
|
||||||
|
if (is_fullscreen()) {
|
||||||
|
ToggleFullscreen(false);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case 0x70: { // VK_F1
|
||||||
|
OnCommand(Commands::IDC_HELP_WEBSITE);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default: { handled = false; } break;
|
||||||
|
}
|
||||||
|
e.set_handled(handled);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Main menu.
|
||||||
|
auto file_menu =
|
||||||
|
std::make_unique<PlatformMenu>(MenuItem::Type::kPopup, L"&File");
|
||||||
|
{
|
||||||
|
file_menu->AddChild(std::make_unique<PlatformMenu>(
|
||||||
|
MenuItem::Type::kString, Commands::IDC_FILE_EXIT, L"E&xit", L"Alt+F4"));
|
||||||
|
}
|
||||||
|
main_menu_.AddChild(std::move(file_menu));
|
||||||
|
|
||||||
|
// Help menu.
|
||||||
|
auto help_menu =
|
||||||
|
std::make_unique<PlatformMenu>(MenuItem::Type::kPopup, L"&Help");
|
||||||
|
{
|
||||||
|
help_menu->AddChild(std::make_unique<PlatformMenu>(
|
||||||
|
MenuItem::Type::kString, Commands::IDC_HELP_WEBSITE, L"&Website...",
|
||||||
|
L"F1"));
|
||||||
|
help_menu->AddChild(std::make_unique<PlatformMenu>(
|
||||||
|
MenuItem::Type::kString, Commands::IDC_HELP_ABOUT, L"&About..."));
|
||||||
|
}
|
||||||
|
main_menu_.AddChild(std::move(help_menu));
|
||||||
|
|
||||||
|
set_menu(&main_menu_);
|
||||||
|
|
||||||
|
// Setup the GL control that actually does the drawing.
|
||||||
|
// We run here in the loop and only touch it (and its context) on this
|
||||||
|
// thread. That means some sync-fu when we want to swap.
|
||||||
|
control_ = std::make_unique<xe::ui::gl::WGLControl>(loop());
|
||||||
|
AddChild(control_.get());
|
||||||
|
|
||||||
|
Resize(1440, 1200);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnClose() {
|
||||||
|
loop_.Quit();
|
||||||
|
|
||||||
|
// TODO(benvanik): proper exit.
|
||||||
|
XELOGI("User-initiated death!");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnCommand(int id) {
|
||||||
|
switch (id) {
|
||||||
|
case IDC_FILE_EXIT: {
|
||||||
|
Close();
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case IDC_HELP_WEBSITE: {
|
||||||
|
LaunchBrowser("http://xenia.jp");
|
||||||
|
} break;
|
||||||
|
case IDC_HELP_ABOUT: {
|
||||||
|
LaunchBrowser("http://xenia.jp/about/");
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ui
|
||||||
|
} // namespace debug
|
||||||
|
} // namespace xe
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* 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_MAIN_WINDOW_H_
|
||||||
|
#define XENIA_DEBUG_UI_MAIN_WINDOW_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "xenia/ui/gl/wgl_control.h"
|
||||||
|
#include "xenia/ui/platform.h"
|
||||||
|
#include "xenia/ui/window.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace debug {
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
class MainWindow : public xe::ui::PlatformWindow {
|
||||||
|
public:
|
||||||
|
~MainWindow() override;
|
||||||
|
|
||||||
|
static std::unique_ptr<MainWindow> Create();
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit MainWindow();
|
||||||
|
|
||||||
|
bool Initialize();
|
||||||
|
|
||||||
|
void OnClose() override;
|
||||||
|
void OnCommand(int id) override;
|
||||||
|
|
||||||
|
xe::ui::PlatformLoop loop_;
|
||||||
|
xe::ui::PlatformMenu main_menu_;
|
||||||
|
std::unique_ptr<xe::ui::gl::WGLControl> control_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ui
|
||||||
|
} // namespace debug
|
||||||
|
} // namespace xe
|
||||||
|
|
||||||
|
#endif // XENIA_DEBUG_UI_MAIN_WINDOW_H_
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* 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 <gflags/gflags.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "xenia/base/main.h"
|
||||||
|
#include "xenia/debug/ui/main_window.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace debug {
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
int main(std::vector<std::wstring>& args) {
|
||||||
|
auto main_window = MainWindow::Create();
|
||||||
|
main_window->loop()->AwaitQuit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ui
|
||||||
|
} // namespace debug
|
||||||
|
} // namespace xe
|
||||||
|
|
||||||
|
DEFINE_ENTRY_POINT(L"xe-debug-ui", L"xe-debug-ui ??", xe::debug::ui::main);
|
|
@ -52,8 +52,6 @@
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -66,10 +64,8 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -78,6 +74,13 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\base\main.h" />
|
||||||
|
<ClInclude Include="main_window.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\base\main_win.cc" />
|
||||||
|
<ClCompile Include="main_window.cc" />
|
||||||
|
<ClCompile Include="xe-debug-ui.cc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -10,5 +10,30 @@
|
||||||
<Filter Include="src\xenia\debug">
|
<Filter Include="src\xenia\debug">
|
||||||
<UniqueIdentifier>{1b70e26e-0024-410f-b27f-ceaba190d5a9}</UniqueIdentifier>
|
<UniqueIdentifier>{1b70e26e-0024-410f-b27f-ceaba190d5a9}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="src\xenia\debug\ui">
|
||||||
|
<UniqueIdentifier>{9b5a4bce-210a-4488-863a-9175f0543d00}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="src\xenia\base">
|
||||||
|
<UniqueIdentifier>{9a5724c2-5473-4d53-93b4-26531201f38d}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\base\main.h">
|
||||||
|
<Filter>src\xenia\base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="main_window.h">
|
||||||
|
<Filter>src\xenia\debug\ui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\base\main_win.cc">
|
||||||
|
<Filter>src\xenia\base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="xe-debug-ui.cc">
|
||||||
|
<Filter>src\xenia\debug\ui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="main_window.cc">
|
||||||
|
<Filter>src\xenia\debug\ui</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue