Removing dependencies on MainWindow.
This commit is contained in:
parent
4732378ba9
commit
9efccc5f4a
|
@ -403,6 +403,7 @@
|
||||||
<ClInclude Include="src\xenia\ui\loop.h" />
|
<ClInclude Include="src\xenia\ui\loop.h" />
|
||||||
<ClInclude Include="src\xenia\ui\main_window.h" />
|
<ClInclude Include="src\xenia\ui\main_window.h" />
|
||||||
<ClInclude Include="src\xenia\ui\menu_item.h" />
|
<ClInclude Include="src\xenia\ui\menu_item.h" />
|
||||||
|
<ClInclude Include="src\xenia\ui\platform.h" />
|
||||||
<ClInclude Include="src\xenia\ui\ui_event.h" />
|
<ClInclude Include="src\xenia\ui\ui_event.h" />
|
||||||
<ClInclude Include="src\xenia\ui\win32\win32_control.h" />
|
<ClInclude Include="src\xenia\ui\win32\win32_control.h" />
|
||||||
<ClInclude Include="src\xenia\ui\win32\win32_file_picker.h" />
|
<ClInclude Include="src\xenia\ui\win32\win32_file_picker.h" />
|
||||||
|
|
|
@ -1368,6 +1368,9 @@
|
||||||
<ClInclude Include="src\xenia\ui\gl\circular_buffer.h">
|
<ClInclude Include="src\xenia\ui\gl\circular_buffer.h">
|
||||||
<Filter>src\xenia\ui\gl</Filter>
|
<Filter>src\xenia\ui\gl</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\xenia\ui\platform.h">
|
||||||
|
<Filter>src\xenia\ui</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="src\xenia\cpu\hir\opcodes.inl">
|
<None Include="src\xenia\cpu\hir\opcodes.inl">
|
||||||
|
|
|
@ -70,7 +70,7 @@ Emulator::~Emulator() {
|
||||||
export_resolver_.reset();
|
export_resolver_.reset();
|
||||||
|
|
||||||
// Kill the window last, as until the graphics system/etc is dead it's needed.
|
// Kill the window last, as until the graphics system/etc is dead it's needed.
|
||||||
main_window_.reset();
|
display_window_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS Emulator::Setup() {
|
X_STATUS Emulator::Setup() {
|
||||||
|
@ -94,8 +94,7 @@ X_STATUS Emulator::Setup() {
|
||||||
SetProcessAffinityMask(process_handle, system_affinity_mask);
|
SetProcessAffinityMask(process_handle, system_affinity_mask);
|
||||||
|
|
||||||
// Create the main window. Other parts will hook into this.
|
// Create the main window. Other parts will hook into this.
|
||||||
main_window_ = std::make_unique<ui::MainWindow>(this);
|
display_window_ = ui::MainWindow::Create(this);
|
||||||
main_window_->Start();
|
|
||||||
|
|
||||||
// Create memory system first, as it is required for other systems.
|
// Create memory system first, as it is required for other systems.
|
||||||
memory_ = std::make_unique<Memory>();
|
memory_ = std::make_unique<Memory>();
|
||||||
|
@ -152,8 +151,8 @@ X_STATUS Emulator::Setup() {
|
||||||
if (!processor_->Setup()) {
|
if (!processor_->Setup()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = graphics_system_->Setup(processor_.get(), main_window_->loop(),
|
result = graphics_system_->Setup(processor_.get(), display_window_->loop(),
|
||||||
main_window_.get());
|
display_window_.get());
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "xenia/debug/debugger.h"
|
#include "xenia/debug/debugger.h"
|
||||||
#include "xenia/kernel/kernel_state.h"
|
#include "xenia/kernel/kernel_state.h"
|
||||||
#include "xenia/memory.h"
|
#include "xenia/memory.h"
|
||||||
#include "xenia/ui/main_window.h"
|
#include "xenia/ui/platform.h"
|
||||||
#include "xenia/vfs/virtual_file_system.h"
|
#include "xenia/vfs/virtual_file_system.h"
|
||||||
#include "xenia/xbox.h"
|
#include "xenia/xbox.h"
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class Emulator {
|
||||||
|
|
||||||
const std::wstring& command_line() const { return command_line_; }
|
const std::wstring& command_line() const { return command_line_; }
|
||||||
|
|
||||||
ui::MainWindow* main_window() const { return main_window_.get(); }
|
ui::PlatformWindow* display_window() const { return display_window_.get(); }
|
||||||
|
|
||||||
Memory* memory() const { return memory_.get(); }
|
Memory* memory() const { return memory_.get(); }
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class Emulator {
|
||||||
|
|
||||||
std::wstring command_line_;
|
std::wstring command_line_;
|
||||||
|
|
||||||
std::unique_ptr<ui::MainWindow> main_window_;
|
std::unique_ptr<ui::PlatformWindow> display_window_;
|
||||||
|
|
||||||
std::unique_ptr<Memory> memory_;
|
std::unique_ptr<Memory> memory_;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ GL4GraphicsSystem::GL4GraphicsSystem(Emulator* emulator)
|
||||||
GL4GraphicsSystem::~GL4GraphicsSystem() = default;
|
GL4GraphicsSystem::~GL4GraphicsSystem() = default;
|
||||||
|
|
||||||
X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
|
X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
|
||||||
ui::PlatformLoop* target_loop,
|
ui::Loop* target_loop,
|
||||||
ui::PlatformWindow* target_window) {
|
ui::PlatformWindow* target_window) {
|
||||||
auto result = GraphicsSystem::Setup(processor, target_loop, target_window);
|
auto result = GraphicsSystem::Setup(processor, target_loop, target_window);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ class GL4GraphicsSystem : public GraphicsSystem {
|
||||||
|
|
||||||
static std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
static std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||||
|
|
||||||
X_STATUS Setup(cpu::Processor* processor, ui::PlatformLoop* target_loop,
|
X_STATUS Setup(cpu::Processor* processor, ui::Loop* target_loop,
|
||||||
ui::PlatformWindow* target_window) override;
|
ui::PlatformWindow* target_window) override;
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
|
|
|
@ -38,19 +38,11 @@ std::unique_ptr<GraphicsSystem> GraphicsSystem::Create(Emulator* emulator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsSystem::GraphicsSystem(Emulator* emulator)
|
GraphicsSystem::GraphicsSystem(Emulator* emulator) : emulator_(emulator) {}
|
||||||
: emulator_(emulator),
|
|
||||||
memory_(nullptr),
|
|
||||||
processor_(nullptr),
|
|
||||||
target_loop_(nullptr),
|
|
||||||
target_window_(nullptr),
|
|
||||||
interrupt_callback_(0),
|
|
||||||
interrupt_callback_data_(0) {}
|
|
||||||
|
|
||||||
GraphicsSystem::~GraphicsSystem() = default;
|
GraphicsSystem::~GraphicsSystem() = default;
|
||||||
|
|
||||||
X_STATUS GraphicsSystem::Setup(cpu::Processor* processor,
|
X_STATUS GraphicsSystem::Setup(cpu::Processor* processor, ui::Loop* target_loop,
|
||||||
ui::PlatformLoop* target_loop,
|
|
||||||
ui::PlatformWindow* target_window) {
|
ui::PlatformWindow* target_window) {
|
||||||
processor_ = processor;
|
processor_ = processor;
|
||||||
memory_ = processor->memory();
|
memory_ = processor->memory();
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
#include "xenia/cpu/processor.h"
|
#include "xenia/cpu/processor.h"
|
||||||
#include "xenia/memory.h"
|
#include "xenia/memory.h"
|
||||||
#include "xenia/ui/main_window.h"
|
#include "xenia/ui/loop.h"
|
||||||
|
#include "xenia/ui/platform.h"
|
||||||
#include "xenia/xbox.h"
|
#include "xenia/xbox.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
@ -36,8 +37,7 @@ class GraphicsSystem {
|
||||||
Memory* memory() const { return memory_; }
|
Memory* memory() const { return memory_; }
|
||||||
cpu::Processor* processor() const { return processor_; }
|
cpu::Processor* processor() const { return processor_; }
|
||||||
|
|
||||||
virtual X_STATUS Setup(cpu::Processor* processor,
|
virtual X_STATUS Setup(cpu::Processor* processor, ui::Loop* target_loop,
|
||||||
ui::PlatformLoop* target_loop,
|
|
||||||
ui::PlatformWindow* target_window);
|
ui::PlatformWindow* target_window);
|
||||||
virtual void Shutdown();
|
virtual void Shutdown();
|
||||||
|
|
||||||
|
@ -64,14 +64,14 @@ class GraphicsSystem {
|
||||||
protected:
|
protected:
|
||||||
GraphicsSystem(Emulator* emulator);
|
GraphicsSystem(Emulator* emulator);
|
||||||
|
|
||||||
Emulator* emulator_;
|
Emulator* emulator_ = nullptr;
|
||||||
Memory* memory_;
|
Memory* memory_ = nullptr;
|
||||||
cpu::Processor* processor_;
|
cpu::Processor* processor_ = nullptr;
|
||||||
ui::PlatformLoop* target_loop_;
|
ui::Loop* target_loop_ = nullptr;
|
||||||
ui::PlatformWindow* target_window_;
|
ui::PlatformWindow* target_window_ = nullptr;
|
||||||
|
|
||||||
uint32_t interrupt_callback_;
|
uint32_t interrupt_callback_ = 0;
|
||||||
uint32_t interrupt_callback_data_;
|
uint32_t interrupt_callback_data_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gpu
|
} // namespace gpu
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "xenia/gpu/xenos.h"
|
#include "xenia/gpu/xenos.h"
|
||||||
#include "xenia/profiling.h"
|
#include "xenia/profiling.h"
|
||||||
#include "xenia/ui/gl/gl_context.h"
|
#include "xenia/ui/gl/gl_context.h"
|
||||||
#include "xenia/ui/main_window.h"
|
|
||||||
|
|
||||||
// HACK: until we have another impl, we just use gl4 directly.
|
// HACK: until we have another impl, we just use gl4 directly.
|
||||||
#include "xenia/gpu/gl4/command_processor.h"
|
#include "xenia/gpu/gl4/command_processor.h"
|
||||||
|
@ -843,7 +842,7 @@ class TracePlayer : public TraceReader {
|
||||||
int current_command_index_;
|
int current_command_index_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void DrawControllerUI(xe::ui::MainWindow* window, TracePlayer& player,
|
void DrawControllerUI(xe::ui::PlatformWindow* window, TracePlayer& player,
|
||||||
Memory* memory) {
|
Memory* memory) {
|
||||||
ImGui::SetNextWindowPos(ImVec2(5, 5), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(5, 5), ImGuiSetCond_FirstUseEver);
|
||||||
if (!ImGui::Begin("Controller", nullptr, ImVec2(340, 60))) {
|
if (!ImGui::Begin("Controller", nullptr, ImVec2(340, 60))) {
|
||||||
|
@ -884,7 +883,7 @@ void DrawControllerUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawCommandListUI(xe::ui::MainWindow* window, TracePlayer& player,
|
void DrawCommandListUI(xe::ui::PlatformWindow* window, TracePlayer& player,
|
||||||
Memory* memory) {
|
Memory* memory) {
|
||||||
ImGui::SetNextWindowPos(ImVec2(5, 70), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(5, 70), ImGuiSetCond_FirstUseEver);
|
||||||
if (!ImGui::Begin("Command List", nullptr, ImVec2(200, 640))) {
|
if (!ImGui::Begin("Command List", nullptr, ImVec2(200, 640))) {
|
||||||
|
@ -1028,7 +1027,7 @@ ShaderDisplayType DrawShaderTypeUI() {
|
||||||
return shader_display_type;
|
return shader_display_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawShaderUI(xe::ui::MainWindow* window, TracePlayer& player,
|
void DrawShaderUI(xe::ui::PlatformWindow* window, TracePlayer& player,
|
||||||
Memory* memory, gl4::GL4Shader* shader,
|
Memory* memory, gl4::GL4Shader* shader,
|
||||||
ShaderDisplayType display_type) {
|
ShaderDisplayType display_type) {
|
||||||
// Must be prepared for advanced display modes.
|
// Must be prepared for advanced display modes.
|
||||||
|
@ -1394,7 +1393,7 @@ static const char* kEndiannessNames[] = {
|
||||||
"unspecified endianness", "8-in-16", "8-in-32", "16-in-32",
|
"unspecified endianness", "8-in-16", "8-in-32", "16-in-32",
|
||||||
};
|
};
|
||||||
|
|
||||||
void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
void DrawStateUI(xe::ui::PlatformWindow* window, TracePlayer& player,
|
||||||
Memory* memory) {
|
Memory* memory) {
|
||||||
auto gs = static_cast<gl4::GL4GraphicsSystem*>(player.graphics_system());
|
auto gs = static_cast<gl4::GL4GraphicsSystem*>(player.graphics_system());
|
||||||
auto cp = gs->command_processor();
|
auto cp = gs->command_processor();
|
||||||
|
@ -2034,8 +2033,8 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawPacketDisassemblerUI(xe::ui::MainWindow* window, TracePlayer& player,
|
void DrawPacketDisassemblerUI(xe::ui::PlatformWindow* window,
|
||||||
Memory* memory) {
|
TracePlayer& player, Memory* memory) {
|
||||||
ImGui::SetNextWindowCollapsed(true, ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowCollapsed(true, ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowPos(ImVec2(float(window->width()) - 500 - 5, 5),
|
ImGui::SetNextWindowPos(ImVec2(float(window->width()) - 500 - 5, 5),
|
||||||
ImGuiSetCond_FirstUseEver);
|
ImGuiSetCond_FirstUseEver);
|
||||||
|
@ -2176,7 +2175,8 @@ void DrawPacketDisassemblerUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawUI(xe::ui::MainWindow* window, TracePlayer& player, Memory* memory) {
|
void DrawUI(xe::ui::PlatformWindow* window, TracePlayer& player,
|
||||||
|
Memory* memory) {
|
||||||
// ImGui::ShowTestWindow();
|
// ImGui::ShowTestWindow();
|
||||||
|
|
||||||
DrawControllerUI(window, player, memory);
|
DrawControllerUI(window, player, memory);
|
||||||
|
@ -2212,7 +2212,7 @@ int trace_viewer_main(std::vector<std::wstring>& args) {
|
||||||
// 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);
|
||||||
|
|
||||||
auto window = emulator->main_window();
|
auto window = emulator->display_window();
|
||||||
auto loop = window->loop();
|
auto loop = window->loop();
|
||||||
auto file_name = xe::find_name_from_path(path);
|
auto file_name = xe::find_name_from_path(path);
|
||||||
window->set_title(std::wstring(L"Xenia GPU Trace Viewer: ") + file_name);
|
window->set_title(std::wstring(L"Xenia GPU Trace Viewer: ") + file_name);
|
||||||
|
@ -2306,7 +2306,7 @@ int trace_viewer_main(std::vector<std::wstring>& args) {
|
||||||
graphics_system->RequestSwap();
|
graphics_system->RequestSwap();
|
||||||
|
|
||||||
// Wait until we are exited.
|
// Wait until we are exited.
|
||||||
emulator->main_window()->loop()->AwaitQuit();
|
emulator->display_window()->loop()->AwaitQuit();
|
||||||
|
|
||||||
ImImpl_Shutdown();
|
ImImpl_Shutdown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ SHIM_CALL XamShowMessageBoxUI_shim(PPCContext* ppc_context,
|
||||||
TASKDIALOGCONFIG config = {0};
|
TASKDIALOGCONFIG config = {0};
|
||||||
config.cbSize = sizeof(config);
|
config.cbSize = sizeof(config);
|
||||||
config.hInstance = GetModuleHandle(nullptr);
|
config.hInstance = GetModuleHandle(nullptr);
|
||||||
config.hwndParent = kernel_state->emulator()->main_window()->hwnd();
|
config.hwndParent = kernel_state->emulator()->display_window()->hwnd();
|
||||||
config.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | // esc to exit
|
config.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | // esc to exit
|
||||||
TDF_POSITION_RELATIVE_TO_WINDOW; // center in window
|
TDF_POSITION_RELATIVE_TO_WINDOW; // center in window
|
||||||
config.dwCommonButtons = 0;
|
config.dwCommonButtons = 0;
|
||||||
|
@ -120,7 +120,7 @@ SHIM_CALL XamShowDirtyDiscErrorUI_shim(PPCContext* ppc_context,
|
||||||
XELOGD("XamShowDirtyDiscErrorUI(%d)", user_index);
|
XELOGD("XamShowDirtyDiscErrorUI(%d)", user_index);
|
||||||
|
|
||||||
int button_pressed = 0;
|
int button_pressed = 0;
|
||||||
TaskDialog(kernel_state->emulator()->main_window()->hwnd(),
|
TaskDialog(kernel_state->emulator()->display_window()->hwnd(),
|
||||||
GetModuleHandle(nullptr), L"Disc Read Error",
|
GetModuleHandle(nullptr), L"Disc Read Error",
|
||||||
L"Game is claiming to be unable to read game data!", nullptr,
|
L"Game is claiming to be unable to read game data!", nullptr,
|
||||||
TDCBF_CLOSE_BUTTON, TD_ERROR_ICON, &button_pressed);
|
TDCBF_CLOSE_BUTTON, TD_ERROR_ICON, &button_pressed);
|
||||||
|
|
|
@ -42,21 +42,22 @@ enum Commands {
|
||||||
const std::wstring kBaseTitle = L"xenia";
|
const std::wstring kBaseTitle = L"xenia";
|
||||||
|
|
||||||
MainWindow::MainWindow(Emulator* emulator)
|
MainWindow::MainWindow(Emulator* emulator)
|
||||||
: PlatformWindow(kBaseTitle),
|
: PlatformWindow(&loop_, kBaseTitle),
|
||||||
emulator_(emulator),
|
emulator_(emulator),
|
||||||
main_menu_(MenuItem::Type::kNormal),
|
main_menu_(MenuItem::Type::kNormal) {}
|
||||||
fullscreen_(false) {}
|
|
||||||
|
|
||||||
MainWindow::~MainWindow() = default;
|
MainWindow::~MainWindow() = default;
|
||||||
|
|
||||||
void MainWindow::Start() {
|
std::unique_ptr<PlatformWindow> MainWindow::Create(Emulator* emulator) {
|
||||||
|
std::unique_ptr<MainWindow> main_window(new MainWindow(emulator));
|
||||||
|
|
||||||
xe::threading::Fence fence;
|
xe::threading::Fence fence;
|
||||||
|
|
||||||
loop_.Post([&]() {
|
main_window->loop()->Post([&main_window, &fence]() {
|
||||||
xe::threading::set_name("Win32 Loop");
|
xe::threading::set_name("Win32 Loop");
|
||||||
xe::Profiler::ThreadEnter("Win32 Loop");
|
xe::Profiler::ThreadEnter("Win32 Loop");
|
||||||
|
|
||||||
if (!Initialize()) {
|
if (!main_window->Initialize()) {
|
||||||
XEFATAL("Failed to initialize main window");
|
XEFATAL("Failed to initialize main window");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +66,8 @@ void MainWindow::Start() {
|
||||||
});
|
});
|
||||||
|
|
||||||
fence.Wait();
|
fence.Wait();
|
||||||
|
|
||||||
|
return std::unique_ptr<PlatformWindow>(main_window.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::Initialize() {
|
bool MainWindow::Initialize() {
|
||||||
|
@ -98,8 +101,8 @@ bool MainWindow::Initialize() {
|
||||||
} break;
|
} break;
|
||||||
case 0x1B: { // VK_ESCAPE
|
case 0x1B: { // VK_ESCAPE
|
||||||
// Allow users to escape fullscreen (but not enter it).
|
// Allow users to escape fullscreen (but not enter it).
|
||||||
if (fullscreen_) {
|
if (is_fullscreen()) {
|
||||||
ToggleFullscreen();
|
ToggleFullscreen(false);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -187,7 +190,7 @@ bool MainWindow::Initialize() {
|
||||||
}
|
}
|
||||||
main_menu_.AddChild(std::move(help_menu));
|
main_menu_.AddChild(std::move(help_menu));
|
||||||
|
|
||||||
SetMenu(&main_menu_);
|
set_menu(&main_menu_);
|
||||||
|
|
||||||
Resize(1280, 720);
|
Resize(1280, 720);
|
||||||
|
|
||||||
|
@ -204,11 +207,6 @@ void MainWindow::UpdateTitle() {
|
||||||
set_title(title);
|
set_title(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ToggleFullscreen() {
|
|
||||||
fullscreen_ = !fullscreen_;
|
|
||||||
SetFullscreen(fullscreen_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::OnClose() {
|
void MainWindow::OnClose() {
|
||||||
loop_.Quit();
|
loop_.Quit();
|
||||||
|
|
||||||
|
@ -250,7 +248,7 @@ void MainWindow::OnCommand(int id) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case IDC_WINDOW_FULLSCREEN: {
|
case IDC_WINDOW_FULLSCREEN: {
|
||||||
ToggleFullscreen();
|
ToggleFullscreen(!is_fullscreen());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case IDC_HELP_WEBSITE: {
|
case IDC_HELP_WEBSITE: {
|
||||||
|
|
|
@ -10,15 +10,10 @@
|
||||||
#ifndef XENIA_UI_MAIN_WINDOW_H_
|
#ifndef XENIA_UI_MAIN_WINDOW_H_
|
||||||
#define XENIA_UI_MAIN_WINDOW_H_
|
#define XENIA_UI_MAIN_WINDOW_H_
|
||||||
|
|
||||||
|
#include "xenia/ui/platform.h"
|
||||||
#include "xenia/ui/window.h"
|
#include "xenia/ui/window.h"
|
||||||
#include "xenia/xbox.h"
|
#include "xenia/xbox.h"
|
||||||
|
|
||||||
// TODO(benvanik): only on windows.
|
|
||||||
#include "xenia/ui/win32/win32_file_picker.h"
|
|
||||||
#include "xenia/ui/win32/win32_loop.h"
|
|
||||||
#include "xenia/ui/win32/win32_menu_item.h"
|
|
||||||
#include "xenia/ui/win32/win32_window.h"
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
class Emulator;
|
class Emulator;
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
@ -26,26 +21,20 @@ class Emulator;
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
using PlatformLoop = xe::ui::win32::Win32Loop;
|
|
||||||
using PlatformWindow = xe::ui::win32::Win32Window;
|
|
||||||
using PlatformMenu = xe::ui::win32::Win32MenuItem;
|
|
||||||
using PlatformFilePicker = xe::ui::win32::Win32FilePicker;
|
|
||||||
|
|
||||||
class MainWindow : public PlatformWindow {
|
class MainWindow : public PlatformWindow {
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(Emulator* emulator);
|
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
Emulator* emulator() const { return emulator_; }
|
static std::unique_ptr<PlatformWindow> Create(Emulator* emulator);
|
||||||
PlatformLoop* loop() { return &loop_; }
|
|
||||||
|
|
||||||
void Start();
|
Emulator* emulator() const { return emulator_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit MainWindow(Emulator* emulator);
|
||||||
|
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
|
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
void ToggleFullscreen();
|
|
||||||
|
|
||||||
void OnClose() override;
|
void OnClose() override;
|
||||||
void OnCommand(int id) override;
|
void OnCommand(int id) override;
|
||||||
|
@ -53,7 +42,6 @@ class MainWindow : public PlatformWindow {
|
||||||
Emulator* emulator_;
|
Emulator* emulator_;
|
||||||
PlatformLoop loop_;
|
PlatformLoop loop_;
|
||||||
PlatformMenu main_menu_;
|
PlatformMenu main_menu_;
|
||||||
bool fullscreen_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XENIA_UI_PLATFORM_H_
|
||||||
|
#define XENIA_UI_PLATFORM_H_
|
||||||
|
|
||||||
|
// TODO(benvanik): only on windows.
|
||||||
|
#include "xenia/ui/win32/win32_file_picker.h"
|
||||||
|
#include "xenia/ui/win32/win32_loop.h"
|
||||||
|
#include "xenia/ui/win32/win32_menu_item.h"
|
||||||
|
#include "xenia/ui/win32/win32_window.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace ui {
|
||||||
|
|
||||||
|
using PlatformFilePicker = xe::ui::win32::Win32FilePicker;
|
||||||
|
using PlatformLoop = xe::ui::win32::Win32Loop;
|
||||||
|
using PlatformMenu = xe::ui::win32::Win32MenuItem;
|
||||||
|
using PlatformWindow = xe::ui::win32::Win32Window;
|
||||||
|
|
||||||
|
} // namespace ui
|
||||||
|
} // namespace xe
|
||||||
|
|
||||||
|
#endif // XENIA_UI_PLATFORM_H_
|
|
@ -20,12 +20,10 @@ namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
namespace win32 {
|
namespace win32 {
|
||||||
|
|
||||||
Win32Window::Win32Window(const std::wstring& title)
|
Win32Window::Win32Window(Loop* loop, const std::wstring& title)
|
||||||
: Window(title), closing_(false), fullscreen_(false) {
|
: Window(loop, title) {}
|
||||||
menu_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Win32Window::~Win32Window() {}
|
Win32Window::~Win32Window() = default;
|
||||||
|
|
||||||
bool Win32Window::Initialize() {
|
bool Win32Window::Initialize() {
|
||||||
Create();
|
Create();
|
||||||
|
@ -160,8 +158,15 @@ void Win32Window::ResizeToFill(int32_t pad_left, int32_t pad_top,
|
||||||
// TODO(benvanik): fullscreen.
|
// TODO(benvanik): fullscreen.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::SetFullscreen(bool fullscreen) {
|
bool Win32Window::is_fullscreen() const {
|
||||||
fullscreen_ = fullscreen;
|
DWORD style = GetWindowLong(hwnd_, GWL_STYLE);
|
||||||
|
return (style & WS_OVERLAPPEDWINDOW) != WS_OVERLAPPEDWINDOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Win32Window::ToggleFullscreen(bool fullscreen) {
|
||||||
|
if (fullscreen == is_fullscreen()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD style = GetWindowLong(hwnd_, GWL_STYLE);
|
DWORD style = GetWindowLong(hwnd_, GWL_STYLE);
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
|
@ -200,7 +205,7 @@ void Win32Window::OnClose() {
|
||||||
void Win32Window::OnSetMenu(MenuItem* menu) {
|
void Win32Window::OnSetMenu(MenuItem* menu) {
|
||||||
Win32MenuItem* win_menu = reinterpret_cast<Win32MenuItem*>(menu);
|
Win32MenuItem* win_menu = reinterpret_cast<Win32MenuItem*>(menu);
|
||||||
// Don't actually set the menu if we're fullscreen. We'll do that later.
|
// Don't actually set the menu if we're fullscreen. We'll do that later.
|
||||||
if (win_menu && !fullscreen_) {
|
if (win_menu && !is_fullscreen()) {
|
||||||
::SetMenu(hwnd_, win_menu->handle());
|
::SetMenu(hwnd_, win_menu->handle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace win32 {
|
||||||
|
|
||||||
class Win32Window : public Window<Win32Control> {
|
class Win32Window : public Window<Win32Control> {
|
||||||
public:
|
public:
|
||||||
Win32Window(const std::wstring& title);
|
Win32Window(Loop* loop, const std::wstring& title);
|
||||||
~Win32Window() override;
|
~Win32Window() override;
|
||||||
|
|
||||||
bool Initialize() override;
|
bool Initialize() override;
|
||||||
|
@ -35,7 +35,8 @@ class Win32Window : public Window<Win32Control> {
|
||||||
void ResizeToFill(int32_t pad_left, int32_t pad_top, int32_t pad_right,
|
void ResizeToFill(int32_t pad_left, int32_t pad_top, int32_t pad_right,
|
||||||
int32_t pad_bottom) override;
|
int32_t pad_bottom) override;
|
||||||
|
|
||||||
void SetFullscreen(bool fullscreen) override;
|
bool is_fullscreen() const override;
|
||||||
|
void ToggleFullscreen(bool fullscreen) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Create() override;
|
bool Create() override;
|
||||||
|
@ -49,9 +50,8 @@ class Win32Window : public Window<Win32Control> {
|
||||||
private:
|
private:
|
||||||
void EnableMMCSS();
|
void EnableMMCSS();
|
||||||
|
|
||||||
bool closing_;
|
bool closing_ = false;
|
||||||
|
|
||||||
bool fullscreen_;
|
|
||||||
WINDOWPLACEMENT windowed_pos_;
|
WINDOWPLACEMENT windowed_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "xenia/base/delegate.h"
|
#include "xenia/base/delegate.h"
|
||||||
#include "xenia/ui/control.h"
|
#include "xenia/ui/control.h"
|
||||||
|
#include "xenia/ui/loop.h"
|
||||||
#include "xenia/ui/menu_item.h"
|
#include "xenia/ui/menu_item.h"
|
||||||
#include "xenia/ui/ui_event.h"
|
#include "xenia/ui/ui_event.h"
|
||||||
|
|
||||||
|
@ -27,6 +28,8 @@ class Window : public T {
|
||||||
|
|
||||||
virtual bool Initialize() { return true; }
|
virtual bool Initialize() { return true; }
|
||||||
|
|
||||||
|
Loop* loop() const { return loop_; }
|
||||||
|
|
||||||
const std::wstring& title() const { return title_; }
|
const std::wstring& title() const { return title_; }
|
||||||
virtual bool set_title(const std::wstring& title) {
|
virtual bool set_title(const std::wstring& title) {
|
||||||
if (title == title_) {
|
if (title == title_) {
|
||||||
|
@ -36,6 +39,15 @@ class Window : public T {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem* menu() const { return menu_; }
|
||||||
|
void set_menu(MenuItem* menu) {
|
||||||
|
if (menu == menu_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
menu_ = menu;
|
||||||
|
OnSetMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
void Close() {
|
void Close() {
|
||||||
auto e = UIEvent(this);
|
auto e = UIEvent(this);
|
||||||
on_closing(e);
|
on_closing(e);
|
||||||
|
@ -46,13 +58,8 @@ class Window : public T {
|
||||||
on_closed(e);
|
on_closed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetMenu(MenuItem* menu) {
|
virtual bool is_fullscreen() const { return false; }
|
||||||
menu_ = menu;
|
virtual void ToggleFullscreen(bool fullscreen) {}
|
||||||
|
|
||||||
OnSetMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void SetFullscreen(bool fullscreen) {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Delegate<UIEvent> on_shown;
|
Delegate<UIEvent> on_shown;
|
||||||
|
@ -61,7 +68,8 @@ class Window : public T {
|
||||||
Delegate<UIEvent> on_closed;
|
Delegate<UIEvent> on_closed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Window(const std::wstring& title) : T(0), title_(title) {}
|
Window(Loop* loop, const std::wstring& title)
|
||||||
|
: T(0), loop_(loop), title_(title) {}
|
||||||
|
|
||||||
void OnShow() {
|
void OnShow() {
|
||||||
if (is_visible_) {
|
if (is_visible_) {
|
||||||
|
@ -87,8 +95,9 @@ class Window : public T {
|
||||||
|
|
||||||
virtual void OnCommand(int id) {}
|
virtual void OnCommand(int id) {}
|
||||||
|
|
||||||
MenuItem* menu_;
|
Loop* loop_ = nullptr;
|
||||||
std::wstring title_;
|
std::wstring title_;
|
||||||
|
MenuItem* menu_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "xenia/kernel/kernel.h"
|
#include "xenia/kernel/kernel.h"
|
||||||
#include "xenia/profiling.h"
|
#include "xenia/profiling.h"
|
||||||
#include "xenia/ui/file_picker.h"
|
#include "xenia/ui/file_picker.h"
|
||||||
#include "xenia/ui/main_window.h"
|
|
||||||
|
|
||||||
DEFINE_string(target, "", "Specifies the target .xex or .iso to execute.");
|
DEFINE_string(target, "", "Specifies the target .xex or .iso to execute.");
|
||||||
|
|
||||||
|
@ -61,7 +60,7 @@ int xenia_main(std::vector<std::wstring>& args) {
|
||||||
//{ L"Content Package (*.xcp)", L"*.xcp" },
|
//{ L"Content Package (*.xcp)", L"*.xcp" },
|
||||||
{L"All Files (*.*)", L"*.*"},
|
{L"All Files (*.*)", L"*.*"},
|
||||||
});
|
});
|
||||||
if (file_picker.Show(emulator->main_window()->hwnd())) {
|
if (file_picker.Show(emulator->display_window()->hwnd())) {
|
||||||
auto selected_files = file_picker.selected_files();
|
auto selected_files = file_picker.selected_files();
|
||||||
if (!selected_files.empty()) {
|
if (!selected_files.empty()) {
|
||||||
path = selected_files[0];
|
path = selected_files[0];
|
||||||
|
@ -80,7 +79,7 @@ int xenia_main(std::vector<std::wstring>& args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait until we are exited.
|
// Wait until we are exited.
|
||||||
emulator->main_window()->loop()->AwaitQuit();
|
emulator->display_window()->loop()->AwaitQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
emulator.reset();
|
emulator.reset();
|
||||||
|
|
Loading…
Reference in New Issue