/
Metallist64
/
rbfx
Обзор
Документация
Войти
/
Metallist64
/
rbfx
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Source/Samples/114_AdvancedUI/AdvancedUI.h
110 строк
3 KB
Eugene Kozlov
Refactor RmlUI samples. Move basic styles to CoreData. Update defaults.
09 дек 2025, 17:46
09 дек 2025, 17:46
22fa4be
Код
Авторство
О чём код?
// // Copyright (c) 2008-2020 the Urho3D project. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #pragma once #include "Sample.h" #include <Urho3D/UI/Text3D.h> #include <Urho3D/RmlUI/RmlUIComponent.h> #include <RmlUi/Core.h> namespace Urho3D { class RmlUI; } class AdvancedUI; /// A 2D UI window, managed by main UI instance returned by GetSubsystem<RmlUI>(). class AdvancedUIWindow : public RmlUIComponent { URHO3D_OBJECT(AdvancedUIWindow, RmlUIComponent); public: explicit AdvancedUIWindow(Context* context); private: enum class PageIndex : unsigned { MainMenu = 0, LoadGame, }; AdvancedUI* GetSample() const; /// Implement RmlUIComponent /// @{ void Update(float timeStep) override; void OnDataModelInitialized() override; void OnDocumentPostLoad() override; /// @} void OnContinue(); void OnNewGame(); void OnLoadGame(); void OnDeleteGame(); void OnSettings(); void OnExit(); void GoBack(); /// UI state /// @{ PageIndex currentPage_{}; unsigned selectedGameIndex_{}; StringVector savedGames_; bool isGamePlayed_{}; /// @} unsigned nextGameIndex_{}; ea::string playedGameName_; }; /// A RmlUI demonstration. class AdvancedUI : public Sample { URHO3D_OBJECT(AdvancedUI, Sample); public: /// Construct. explicit AdvancedUI(Context* context); /// Setup after engine initialization and before running the main loop. void Start() override; /// Disable exit on Esc. bool IsEscapeEnabled() override { return false; } private: friend class AdvancedUIWindow; /// Initialize 3D scene. void InitScene(); /// Initialize UI subsystems, backbuffer and cube windows. void InitWindow(); /// Initialize currently played game. void InitGame(bool gamePlayed, const ea::string& text = EMPTY_STRING); /// Handle keys. void OnUpdate(StringHash, VariantMap&); /// Window which will be rendered into backbuffer. WeakPtr<AdvancedUIWindow> window_; /// 3D text that acts as indicator of played game. WeakPtr<Text3D> text3D_; };