From 277ccd8e32931fdf0af00a50146b41e62bfc8e88 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 4 Dec 2015 15:05:07 -1000 Subject: [PATCH 1/3] Update hecl --- hecl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hecl b/hecl index 95406a7a0..251479e85 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 95406a7a05b215c4d8c369fc93d85997e7e54b5a +Subproject commit 251479e852f802196ad8ab95084e140e5977de7c From fd5814e209bfe9204ae8800ce0b720a85a4b905a Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 4 Dec 2015 15:13:40 -1000 Subject: [PATCH 2/3] Update hecl --- hecl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hecl b/hecl index 251479e85..3761749c6 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 251479e852f802196ad8ab95084e140e5977de7c +Subproject commit 3761749c6cd811e2fc46fb57db1bf6954477e94e From 1dca105792779b7f268efaff482efdeffdd4fe36 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 5 Dec 2015 15:27:02 -1000 Subject: [PATCH 3/3] Submodule updates and initial locale files --- Editor/CMakeLists.txt | 6 ++- Editor/ViewManager.cpp | 84 ++++++++++++++++++++++++++++++++++++ Editor/ViewManager.hpp | 34 +++++++++++++++ Editor/locale/CMakeLists.txt | 6 +++ Editor/locale/en_GB.yaml | 3 ++ Editor/locale/en_US.yaml | 3 ++ Editor/locale/locale.cpp | 58 +++++++++++++++++++++++++ Editor/locale/locale.hpp | 15 +++++++ Editor/main.cpp | 46 ++++---------------- hecl | 2 +- libSpecter | 2 +- 11 files changed, 219 insertions(+), 40 deletions(-) create mode 100644 Editor/ViewManager.cpp create mode 100644 Editor/ViewManager.hpp create mode 100644 Editor/locale/CMakeLists.txt create mode 100644 Editor/locale/en_GB.yaml create mode 100644 Editor/locale/en_US.yaml create mode 100644 Editor/locale/locale.cpp create mode 100644 Editor/locale/locale.hpp diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 4d43604bd..34a7b1719 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -1,7 +1,11 @@ +add_subdirectory(locale) + add_executable(rude WIN32 - main.cpp) + main.cpp + ViewManager.hpp ViewManager.cpp) target_link_libraries(rude + RudeLocales RuntimeCommonCharacter RuntimeCommonInput RuntimeCommon diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp new file mode 100644 index 000000000..f1b5b83e3 --- /dev/null +++ b/Editor/ViewManager.cpp @@ -0,0 +1,84 @@ +#include "ViewManager.hpp" + +namespace RUDE +{ + +void ViewManager::SetupRootView() +{ + m_rootView.reset(new Specter::RootView(*this, m_viewResources, m_mainWindow.get())); + Specter::SplitView* splitView = new Specter::SplitView(m_viewResources, *m_rootView, Specter::SplitView::Axis::Horizontal); + m_rootView->setContentView(std::unique_ptr(splitView)); + + m_test1 = m_cvarManager.newCVar("hello_button", "Help for Hello Button", false, + HECL::CVar::EFlags::Archive | HECL::CVar::EFlags::Editor); + Specter::Space* space1 = new Specter::Space(m_viewResources, *splitView, Specter::Toolbar::Position::Top); + space1->toolbar().push_back(std::make_unique(m_viewResources, space1->toolbar(), + std::make_unique(m_test1), "Hello Button")); + Specter::MultiLineTextView* textView1 = new Specter::MultiLineTextView(m_viewResources, *space1, m_viewResources.m_heading18); + space1->setContentView(std::unique_ptr(textView1)); + + m_test2 = m_cvarManager.newCVar("hello_button_jp", "Help for Japanese Hello Button", false, + HECL::CVar::EFlags::Archive | HECL::CVar::EFlags::Editor); + Specter::Space* space2 = new Specter::Space(m_viewResources, *splitView, Specter::Toolbar::Position::Bottom); + space2->toolbar().push_back(std::make_unique(m_viewResources, space2->toolbar(), + std::make_unique(m_test2), "こんにちはボタン")); + Specter::MultiLineTextView* textView2 = new Specter::MultiLineTextView(m_viewResources, *space2, m_viewResources.m_heading18); + space2->setContentView(std::unique_ptr(textView2)); + + splitView->setContentView(0, std::unique_ptr(space1)); + splitView->setContentView(1, std::unique_ptr(space2)); + + textView1->typesetGlyphs("Hello, World!\n\n", m_viewResources.themeData().uiText()); + textView2->typesetGlyphs("こんにちは世界!\n\n", m_viewResources.themeData().uiText()); + + textView1->setBackground(m_viewResources.themeData().viewportBackground()); + textView2->setBackground(m_viewResources.themeData().viewportBackground()); + m_rootView->setBackground(Zeus::CColor::skGrey); +} + +void ViewManager::init(boo::IApplication* app) +{ + m_mainWindow = std::unique_ptr(app->newWindow(_S("RUDE"))); + m_mainWindow->showWindow(); + m_mainWindow->setWaitCursor(true); + + unsigned dpi = m_mainWindow->getVirtualPixelFactor() * 72; + m_cvDPI = m_cvarManager.newCVar("ed_dpi", "User-selected UI DPI", + int(dpi), HECL::CVar::EFlags::Editor | HECL::CVar::EFlags::Archive); + + boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory(); + m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), dpi); + SetupRootView(); + + m_mainWindow->setWaitCursor(false); +} + +bool ViewManager::proc() +{ + boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue(); + if (m_rootView->isDestroyed()) + return false; + + if (m_cvDPI->isModified()) + { + unsigned dpi = m_cvDPI->toInteger(); + m_viewResources.resetDPI(dpi); + m_rootView->resetResources(m_viewResources); + m_cvDPI->clearModified(); + } + + m_rootView->dispatchEvents(); + m_rootView->draw(gfxQ); + gfxQ->execute(); + m_mainWindow->waitForRetrace(); + + return true; +} + +void ViewManager::stop() +{ + m_mainWindow->getCommandQueue()->stopRenderer(); +} + +} + diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp new file mode 100644 index 000000000..d06e3b63f --- /dev/null +++ b/Editor/ViewManager.hpp @@ -0,0 +1,34 @@ +#ifndef RUDE_VIEW_MANAGER_HPP +#define RUDE_VIEW_MANAGER_HPP + +#include +#include + +namespace RUDE +{ + +class ViewManager : Specter::IViewManager +{ + HECL::CVarManager& m_cvarManager; + Specter::FontCache m_fontCache; + Specter::ViewResources m_viewResources; + std::unique_ptr m_mainWindow; + std::unique_ptr m_rootView; + + HECL::CVar* m_cvDPI; + HECL::CVar* m_test1; + HECL::CVar* m_test2; + + void SetupRootView(); +public: + ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr) + : m_cvarManager(cvarMgr), m_fontCache(fileMgr) {} + + void init(boo::IApplication* app); + bool proc(); + void stop(); +}; + +} + +#endif // RUDE_VIEW_MANAGER_HPP diff --git a/Editor/locale/CMakeLists.txt b/Editor/locale/CMakeLists.txt new file mode 100644 index 000000000..964fbb441 --- /dev/null +++ b/Editor/locale/CMakeLists.txt @@ -0,0 +1,6 @@ +bintoc(en_US.c en_US.yaml L_en_US) +bintoc(en_GB.c en_GB.yaml L_en_GB) +add_library(RudeLocales + en_US.yaml en_US.c + en_GB.yaml en_GB.c + locale.hpp locale.cpp) diff --git a/Editor/locale/en_GB.yaml b/Editor/locale/en_GB.yaml new file mode 100644 index 000000000..8cebe7992 --- /dev/null +++ b/Editor/locale/en_GB.yaml @@ -0,0 +1,3 @@ +en_GB: + controls: + color: "Colour" diff --git a/Editor/locale/en_US.yaml b/Editor/locale/en_US.yaml new file mode 100644 index 000000000..0ed8c2ac8 --- /dev/null +++ b/Editor/locale/en_US.yaml @@ -0,0 +1,3 @@ +en_US: + controls: + color: "Color" diff --git a/Editor/locale/locale.cpp b/Editor/locale/locale.cpp new file mode 100644 index 000000000..86f25db43 --- /dev/null +++ b/Editor/locale/locale.cpp @@ -0,0 +1,58 @@ +#include "locale.hpp" +#include + +extern "C" const uint8_t L_en_US[]; +extern "C" size_t L_en_US_SZ; + +extern "C" const uint8_t L_en_GB[]; +extern "C" size_t L_en_GB_SZ; + +namespace RUDE +{ + +static const Specter::Locale Locales[] = +{ + {"en_US", "US English", L_en_US, L_en_US_SZ}, + {"en_GB", "British English", L_en_GB, L_en_GB_SZ} +}; + +std::vector> ListLocales() +{ + constexpr size_t localeCount = std::extent::value; + std::vector> ret; + ret.reserve(localeCount); + for (size_t i=0 ; i::value; + for (size_t i=0 ; i::value; + for (size_t i=0 ; i + +namespace RUDE +{ + +std::vector> ListLocales(); +const Specter::Locale* LookupLocale(const std::string& name); +const Specter::Locale* SystemLocaleOrEnglish(); + +} + +#endif // RUDE_LOCALE_HPP diff --git a/Editor/main.cpp b/Editor/main.cpp index 93b4cf40e..bf22749cc 100644 --- a/Editor/main.cpp +++ b/Editor/main.cpp @@ -4,58 +4,32 @@ #include #include #include +#include "ViewManager.hpp" namespace RUDE { struct Application : boo::IApplicationCallback { HECL::Runtime::FileStoreManager m_fileMgr; - Specter::FontCache m_fontCache; - boo::IWindow* m_mainWindow; - Specter::ViewResources m_viewResources; - std::unique_ptr m_rootView; HECL::CVarManager m_cvarManager; + ViewManager m_viewManager; + bool m_running = true; Application() : m_fileMgr(_S("rude")), - m_fontCache(m_fileMgr), - m_cvarManager(m_fileMgr) {} + m_cvarManager(m_fileMgr), + m_viewManager(m_fileMgr, m_cvarManager) {} int appMain(boo::IApplication* app) { - m_mainWindow = app->newWindow(_S("RUDE")); - m_mainWindow->showWindow(); - m_mainWindow->setWaitCursor(true); - - unsigned dpi = m_mainWindow->getVirtualPixelFactor() * 72; - HECL::CVar* cvDPI = m_cvarManager.newCVar("ed_dpi", "User-selected UI DPI", - int(dpi), HECL::CVar::EFlags::Editor | HECL::CVar::EFlags::Archive); - - boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory(); - m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), dpi); - m_rootView.reset(new Specter::RootView(m_viewResources, m_mainWindow)); - - m_mainWindow->setWaitCursor(false); - boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue(); + m_viewManager.init(app); while (m_running) { - if (m_rootView->isDestroyed()) + if (!m_viewManager.proc()) break; - if (cvDPI->isModified()) - { - dpi = cvDPI->toInteger(); - m_viewResources.resetDPI(dpi); - m_rootView->resetResources(m_viewResources); - cvDPI->clearModified(); - } - m_rootView->dispatchEvents(); - m_rootView->draw(gfxQ); - gfxQ->execute(); - m_mainWindow->waitForRetrace(); } - - gfxQ->stopRenderer(); + m_viewManager.stop(); m_cvarManager.serialize(); return 0; } @@ -67,8 +41,6 @@ struct Application : boo::IApplicationCallback { } - - }; } @@ -81,7 +53,7 @@ int main(int argc, const boo::SystemChar** argv) { LogVisor::RegisterConsoleLogger(); RUDE::Application appCb; - int ret = ApplicationRun(boo::IApplication::EPlatformType::Auto, + int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, appCb, _S("rude"), _S("RUDE"), argc, argv, false); printf("IM DYING!!\n"); return ret; diff --git a/hecl b/hecl index 95406a7a0..1ab67752d 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 95406a7a05b215c4d8c369fc93d85997e7e54b5a +Subproject commit 1ab67752dfc85f610d26eda6160c474fcb892ead diff --git a/libSpecter b/libSpecter index 49cebf59c..1f555a7b8 160000 --- a/libSpecter +++ b/libSpecter @@ -1 +1 @@ -Subproject commit 49cebf59c89b74b83ade6c48d3212a0a8ff67e02 +Subproject commit 1f555a7b83f35f208bf79b606f8441e0528fc6f3