Cleaning up paths a bit. Need to de-globalize.
This commit is contained in:
parent
8c0614b202
commit
95e2ea11eb
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
#include "xenia/debug/ui/application.h"
|
#include "xenia/debug/ui/application.h"
|
||||||
|
|
||||||
#include "el/message_handler.h"
|
|
||||||
#include "el/util/metrics.h"
|
|
||||||
#include "el/util/timer.h"
|
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/platform.h"
|
#include "xenia/base/platform.h"
|
||||||
|
@ -78,32 +75,3 @@ void Application::Quit() {
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
} // namespace debug
|
} // namespace debug
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
// This doesn't really belong here (it belongs in tb_system_[linux/windows].cpp.
|
|
||||||
// This is here since the proper implementations has not yet been done.
|
|
||||||
void el::util::RescheduleTimer(uint64_t fire_time) {
|
|
||||||
if (fire_time == el::MessageHandler::kNotSoon) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t now = el::util::GetTimeMS();
|
|
||||||
uint64_t delay_millis = fire_time >= now ? fire_time - now : 0;
|
|
||||||
xe::debug::ui::Application::current()->loop()->PostDelayed([]() {
|
|
||||||
uint64_t next_fire_time = el::MessageHandler::GetNextMessageFireTime();
|
|
||||||
uint64_t now = el::util::GetTimeMS();
|
|
||||||
if (now < next_fire_time) {
|
|
||||||
// We timed out *before* we were supposed to (the OS is not playing nice).
|
|
||||||
// Calling ProcessMessages now won't achieve a thing so force a reschedule
|
|
||||||
// of the platform timer again with the same time.
|
|
||||||
// ReschedulePlatformTimer(next_fire_time, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
el::MessageHandler::ProcessMessages();
|
|
||||||
|
|
||||||
// If we still have things to do (because we didn't process all messages,
|
|
||||||
// or because there are new messages), we need to rescedule, so call
|
|
||||||
// RescheduleTimer.
|
|
||||||
el::util::RescheduleTimer(el::MessageHandler::GetNextMessageFireTime());
|
|
||||||
}, delay_millis);
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,7 +11,14 @@
|
||||||
|
|
||||||
#include "el/animation_manager.h"
|
#include "el/animation_manager.h"
|
||||||
#include "el/elemental_forms.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/message_handler.h"
|
||||||
#include "el/text/font_manager.h"
|
#include "el/text/font_manager.h"
|
||||||
|
#include "el/util/metrics.h"
|
||||||
|
#include "el/util/string_table.h"
|
||||||
|
#include "el/util/timer.h"
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
#include "xenia/base/clock.h"
|
#include "xenia/base/clock.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
|
@ -29,6 +36,8 @@ constexpr double kDoubleClickDistance = 5;
|
||||||
|
|
||||||
constexpr int32_t kMouseWheelDetent = 120;
|
constexpr int32_t kMouseWheelDetent = 120;
|
||||||
|
|
||||||
|
Loop* elemental_loop_ = nullptr;
|
||||||
|
|
||||||
class RootElement : public el::Element {
|
class RootElement : public el::Element {
|
||||||
public:
|
public:
|
||||||
RootElement(ElementalControl* owner) : owner_(owner) {}
|
RootElement(ElementalControl* owner) : owner_(owner) {}
|
||||||
|
@ -38,26 +47,39 @@ class RootElement : public el::Element {
|
||||||
ElementalControl* owner_ = nullptr;
|
ElementalControl* owner_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ElementalControl::InitializeElemental(el::graphics::Renderer* renderer) {
|
bool ElementalControl::InitializeElemental(Loop* loop,
|
||||||
|
el::graphics::Renderer* renderer) {
|
||||||
static bool has_initialized = false;
|
static bool has_initialized = false;
|
||||||
if (has_initialized) {
|
if (has_initialized) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
has_initialized = true;
|
has_initialized = true;
|
||||||
|
|
||||||
if (!el::Initialize(
|
// Need to pass off the Loop we want Elemental to use.
|
||||||
renderer,
|
// TODO(benvanik): give the callback to elemental instead.
|
||||||
"third_party/turbobadger/resources/language/lng_en.tb.txt")) {
|
elemental_loop_ = loop;
|
||||||
|
|
||||||
|
if (!el::Initialize(renderer)) {
|
||||||
XELOGE("Failed to initialize turbobadger core");
|
XELOGE("Failed to initialize turbobadger core");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the default skin, and override skin that contains the graphics
|
el::io::FileManager::RegisterFileSystem(
|
||||||
// specific to the demo.
|
std::make_unique<el::io::PosixFileSystem>(
|
||||||
if (!el::Skin::get()->Load(
|
"third_party/elemental-forms/resources/"));
|
||||||
"third_party/elemental-forms/resources/default_skin/skin.tb.txt",
|
el::io::FileManager::RegisterFileSystem(
|
||||||
"third_party/elemental-forms/testbed/resources/skin/skin.tb.txt")) {
|
std::make_unique<el::io::PosixFileSystem>(
|
||||||
XELOGE("Failed to load turbobadger skin");
|
"third_party/elemental-forms/testbed/resources/"));
|
||||||
|
auto embedded_file_system = std::make_unique<el::io::EmbeddedFileSystem>();
|
||||||
|
// 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");
|
||||||
|
|
||||||
|
// Load the default skin. Hosting controls may load additional skins later.
|
||||||
|
if (!LoadSkin("default_skin/skin.tb.txt")) {
|
||||||
|
XELOGE("Failed to load default skin");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,14 +100,10 @@ bool ElementalControl::InitializeElemental(el::graphics::Renderer* renderer) {
|
||||||
|
|
||||||
// Add fonts we can use to the font manager.
|
// Add fonts we can use to the font manager.
|
||||||
#if defined(EL_FONT_RENDERER_STB) || defined(EL_FONT_RENDERER_FREETYPE)
|
#if defined(EL_FONT_RENDERER_STB) || defined(EL_FONT_RENDERER_FREETYPE)
|
||||||
font_manager->AddFontInfo("third_party/elemental-forms/resources/vera.ttf",
|
font_manager->AddFontInfo("fonts/vera.ttf", "Default");
|
||||||
"Default");
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef EL_FONT_RENDERER_TBBF
|
#ifdef EL_FONT_RENDERER_TBBF
|
||||||
font_manager->AddFontInfo(
|
font_manager->AddFontInfo("fonts/segoe_white_with_shadow.tb.txt", "Default");
|
||||||
"third_party/elemental-forms/resources/default_font/"
|
|
||||||
"segoe_white_with_shadow.tb.txt",
|
|
||||||
"Default");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the default font description for elements to one of the fonts we just
|
// Set the default font description for elements to one of the fonts we just
|
||||||
|
@ -101,7 +119,8 @@ bool ElementalControl::InitializeElemental(el::graphics::Renderer* renderer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementalControl::ElementalControl(Loop* loop, uint32_t flags) : super(flags) {}
|
ElementalControl::ElementalControl(Loop* loop, uint32_t flags)
|
||||||
|
: super(flags), loop_(loop) {}
|
||||||
|
|
||||||
ElementalControl::~ElementalControl() = default;
|
ElementalControl::~ElementalControl() = default;
|
||||||
|
|
||||||
|
@ -115,8 +134,8 @@ bool ElementalControl::Create() {
|
||||||
|
|
||||||
// Initialize elemental.
|
// Initialize elemental.
|
||||||
// TODO(benvanik): once? Do we care about multiple controls?
|
// TODO(benvanik): once? Do we care about multiple controls?
|
||||||
if (!InitializeElemental(renderer_.get())) {
|
if (!InitializeElemental(loop_, renderer_.get())) {
|
||||||
XELOGE("Unable to initialize turbobadger");
|
XELOGE("Unable to initialize elemental-forms");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +156,14 @@ bool ElementalControl::Create() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ElementalControl::LoadLanguage(std::string filename) {
|
||||||
|
return el::util::StringTable::get()->Load(filename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ElementalControl::LoadSkin(std::string filename) {
|
||||||
|
return el::Skin::get()->Load(filename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void ElementalControl::Destroy() {
|
void ElementalControl::Destroy() {
|
||||||
el::Shutdown();
|
el::Shutdown();
|
||||||
super::Destroy();
|
super::Destroy();
|
||||||
|
@ -476,3 +503,32 @@ void ElementalControl::OnMouseWheel(MouseEvent& e) {
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
|
// This doesn't really belong here (it belongs in tb_system_[linux/windows].cpp.
|
||||||
|
// This is here since the proper implementations has not yet been done.
|
||||||
|
void el::util::RescheduleTimer(uint64_t fire_time) {
|
||||||
|
if (fire_time == el::MessageHandler::kNotSoon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t now = el::util::GetTimeMS();
|
||||||
|
uint64_t delay_millis = fire_time >= now ? fire_time - now : 0;
|
||||||
|
xe::ui::elemental_loop_->PostDelayed([]() {
|
||||||
|
uint64_t next_fire_time = el::MessageHandler::GetNextMessageFireTime();
|
||||||
|
uint64_t now = el::util::GetTimeMS();
|
||||||
|
if (now < next_fire_time) {
|
||||||
|
// We timed out *before* we were supposed to (the OS is not playing nice).
|
||||||
|
// Calling ProcessMessages now won't achieve a thing so force a reschedule
|
||||||
|
// of the platform timer again with the same time.
|
||||||
|
// ReschedulePlatformTimer(next_fire_time, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
el::MessageHandler::ProcessMessages();
|
||||||
|
|
||||||
|
// If we still have things to do (because we didn't process all messages,
|
||||||
|
// or because there are new messages), we need to rescedule, so call
|
||||||
|
// RescheduleTimer.
|
||||||
|
el::util::RescheduleTimer(el::MessageHandler::GetNextMessageFireTime());
|
||||||
|
}, delay_millis);
|
||||||
|
}
|
||||||
|
|
|
@ -29,10 +29,13 @@ class ElementalControl : public PlatformControl {
|
||||||
el::graphics::Renderer* renderer() const { return renderer_.get(); }
|
el::graphics::Renderer* renderer() const { return renderer_.get(); }
|
||||||
el::Element* root_element() const { return root_element_.get(); }
|
el::Element* root_element() const { return root_element_.get(); }
|
||||||
|
|
||||||
|
bool LoadLanguage(std::string filename);
|
||||||
|
bool LoadSkin(std::string filename);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using super = PlatformControl;
|
using super = PlatformControl;
|
||||||
|
|
||||||
bool InitializeElemental(el::graphics::Renderer* renderer);
|
bool InitializeElemental(Loop* loop, el::graphics::Renderer* renderer);
|
||||||
virtual std::unique_ptr<el::graphics::Renderer> CreateRenderer() = 0;
|
virtual std::unique_ptr<el::graphics::Renderer> CreateRenderer() = 0;
|
||||||
|
|
||||||
bool Create() override;
|
bool Create() override;
|
||||||
|
@ -56,6 +59,7 @@ class ElementalControl : public PlatformControl {
|
||||||
void OnMouseUp(MouseEvent& e) override;
|
void OnMouseUp(MouseEvent& e) override;
|
||||||
void OnMouseWheel(MouseEvent& e) override;
|
void OnMouseWheel(MouseEvent& e) override;
|
||||||
|
|
||||||
|
Loop* loop_ = nullptr;
|
||||||
std::unique_ptr<el::graphics::Renderer> renderer_;
|
std::unique_ptr<el::graphics::Renderer> renderer_;
|
||||||
std::unique_ptr<el::Element> root_element_;
|
std::unique_ptr<el::Element> root_element_;
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b7322a960063620938d76156c0ce4a4328788e71
|
Subproject commit 17b41976c4277b702d8ec2f16e849d75d69cec71
|
Loading…
Reference in New Issue