From 6b52f2682e2d10177e0f4933c05e46859b3b3863 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Tue, 7 Jul 2015 22:16:18 -0700 Subject: [PATCH] Fixing elemental input and using embedded resources. --- .gitignore | 1 + src/xenia/debug/ui/resources.rc | 5 +++ src/xenia/debug/ui/xe-debug-ui.vcxproj | 6 +++ .../debug/ui/xe-debug-ui.vcxproj.filters | 5 +++ src/xenia/ui/elemental_control.cc | 41 ++++++++++++------- src/xenia/ui/elemental_control.h | 3 +- third_party/elemental-forms | 2 +- 7 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 src/xenia/debug/ui/resources.rc diff --git a/.gitignore b/.gitignore index 4a0ad784a..07dcdca2e 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ obj/ *.py[co] .coverage *.o +*.aps # ============================================================================== # Logs and dumps diff --git a/src/xenia/debug/ui/resources.rc b/src/xenia/debug/ui/resources.rc new file mode 100644 index 000000000..c8e765beb --- /dev/null +++ b/src/xenia/debug/ui/resources.rc @@ -0,0 +1,5 @@ +//{{NO_DEPENDENCIES}} + +#include "third_party\\elemental-forms\\resources.rc" + +//IDR_xe_debug_ui_resources_skin_bg_tile_png RCDATA ".\\resources\\skin\\bg_tile.png" diff --git a/src/xenia/debug/ui/xe-debug-ui.vcxproj b/src/xenia/debug/ui/xe-debug-ui.vcxproj index 1a45bb185..85779cd4e 100644 --- a/src/xenia/debug/ui/xe-debug-ui.vcxproj +++ b/src/xenia/debug/ui/xe-debug-ui.vcxproj @@ -84,6 +84,12 @@ + + + $(SolutionDir)third_party/elemental-forms;$(SolutionDir);. + $(SolutionDir)third_party/elemental-forms;$(SolutionDir);. + + diff --git a/src/xenia/debug/ui/xe-debug-ui.vcxproj.filters b/src/xenia/debug/ui/xe-debug-ui.vcxproj.filters index eabdda76d..bb91f41c8 100644 --- a/src/xenia/debug/ui/xe-debug-ui.vcxproj.filters +++ b/src/xenia/debug/ui/xe-debug-ui.vcxproj.filters @@ -45,4 +45,9 @@ src\xenia\debug\ui + + + src\xenia\debug\ui + + \ No newline at end of file diff --git a/src/xenia/ui/elemental_control.cc b/src/xenia/ui/elemental_control.cc index c17f350bd..bfa4688b9 100644 --- a/src/xenia/ui/elemental_control.cc +++ b/src/xenia/ui/elemental_control.cc @@ -10,10 +10,11 @@ #include "xenia/ui/elemental_control.h" #include "el/animation_manager.h" +#include "el/util/debug.h" #include "el/elemental_forms.h" -#include "el/io/embedded_file_system.h" #include "el/io/file_manager.h" #include "el/io/posix_file_system.h" +#include "el/io/win32_res_file_system.h" #include "el/message_handler.h" #include "el/text/font_manager.h" #include "el/util/metrics.h" @@ -60,19 +61,15 @@ bool ElementalControl::InitializeElemental(Loop* loop, elemental_loop_ = loop; if (!el::Initialize(renderer)) { - XELOGE("Failed to initialize turbobadger core"); + XELOGE("Failed to initialize elemental core"); return false; } el::io::FileManager::RegisterFileSystem( - std::make_unique( - "third_party/elemental-forms/resources/")); + std::make_unique("IDR_default_resources_")); el::io::FileManager::RegisterFileSystem( std::make_unique( "third_party/elemental-forms/testbed/resources/")); - auto embedded_file_system = std::make_unique(); - // TODO(benvanik): bin2c stuff. - el::io::FileManager::RegisterFileSystem(std::move(embedded_file_system)); // Load default translations. el::util::StringTable::get()->Load("default_language/language_en.tb.txt"); @@ -151,7 +148,7 @@ bool ElementalControl::Create() { auto message_window = new el::MessageWindow(root_element(), TBIDC("")); message_window->Show("Title", "Hello!"); - // el::ShowDebugInfoSettingsWindow(root_element()); + el::util::ShowDebugInfoSettingsWindow(root_element()); return true; } @@ -253,12 +250,13 @@ el::ModifierKeys ElementalControl::GetModifierKeys() { return modifiers; } -void ElementalControl::OnKeyPress(KeyEvent& e, bool is_down) { +void ElementalControl::OnKeyPress(KeyEvent& e, bool is_down, bool is_char) { if (!root_element()) { return; } auto special_key = el::SpecialKey::kUndefined; - switch (e.key_code()) { + if (!is_char) { + switch (e.key_code()) { case 38: special_key = el::SpecialKey::kUp; break; @@ -359,12 +357,19 @@ void ElementalControl::OnKeyPress(KeyEvent& e, bool is_down) { case 91: modifier_super_pressed_ = is_down; break; + } } if (!CheckShortcutKey(e, special_key, is_down)) { - e.set_handled(root_element()->InvokeKey( - special_key != el::SpecialKey::kUndefined ? e.key_code() : 0, - special_key, GetModifierKeys(), is_down)); + int key_code = 0; + if (is_char) { + key_code = e.key_code(); + if (key_code < 32 || (key_code > 126 && key_code < 160)) { + key_code = 0; + } + } + e.set_handled(root_element()->InvokeKey(key_code, special_key, + GetModifierKeys(), is_down)); } } @@ -423,12 +428,18 @@ bool ElementalControl::CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key, void ElementalControl::OnKeyDown(KeyEvent& e) { super::OnKeyDown(e); - OnKeyPress(e, true); + OnKeyPress(e, true, false); } void ElementalControl::OnKeyUp(KeyEvent& e) { super::OnKeyUp(e); - OnKeyPress(e, false); + OnKeyPress(e, false, false); +} + +void ElementalControl::OnKeyChar(KeyEvent& e) { + super::OnKeyChar(e); + OnKeyPress(e, true, true); + OnKeyPress(e, false, true); } void ElementalControl::OnMouseDown(MouseEvent& e) { diff --git a/src/xenia/ui/elemental_control.h b/src/xenia/ui/elemental_control.h index f61569e0c..93c43fd76 100644 --- a/src/xenia/ui/elemental_control.h +++ b/src/xenia/ui/elemental_control.h @@ -49,10 +49,11 @@ class ElementalControl : public PlatformControl { el::ModifierKeys GetModifierKeys(); - void OnKeyPress(KeyEvent& e, bool is_down); + void OnKeyPress(KeyEvent& e, bool is_down, bool is_char); bool CheckShortcutKey(KeyEvent& e, el::SpecialKey special_key, bool is_down); void OnKeyDown(KeyEvent& e) override; void OnKeyUp(KeyEvent& e) override; + void OnKeyChar(KeyEvent& e) override; void OnMouseDown(MouseEvent& e) override; void OnMouseMove(MouseEvent& e) override; diff --git a/third_party/elemental-forms b/third_party/elemental-forms index 17b41976c..30adbc89f 160000 --- a/third_party/elemental-forms +++ b/third_party/elemental-forms @@ -1 +1 @@ -Subproject commit 17b41976c4277b702d8ec2f16e849d75d69cec71 +Subproject commit 30adbc89f338caa80693dc6ab48a503f0ef3728f