# Stage 1.7
- Added File to Memory and FastHashMomory - Add Protection that only one app can exist - Add a Trace exist Variable as GetTraceRef automatically creates a trace - Outsource the LI::Rect to its own header - Add a CurrentScreen func - Use Rect for uv (to manually set all corners) - Rect still supports to use vec4 for uv - Add tex3ds Spritesheet support - Add T3X Loader to Texture (if single tex) - Integrate an autounload into Texture as in case of spritesheet the Tex needs to be unloaded manually - Safe some performance in texture loading by combining the Loops (best thing ive ever found) - Use the Momory Hash to only render one error icon into the TTF Texture - Also Try loading the whole 16-Bit range - Use GPU_A8 format for TTF rendering to save 24Bits per pixel and use the same Rendermode as System Font - Simplify Quad Command by using modern vec api - Integrate Text aligning - Fix FPS displayed twice in Performance overlay - UI7 DrawList now has its own AST system - TODO: do the same layering for the objects as Text uses - Map Drawcommands with a bool that declares either bottom or top screen was active - Add first basic Manu functions - Fix Typos in Theme - Add a basic UI7 Context Handler ## Extra - Added JetBrainsMono font in Test app ## Bugs: - Performance Overlay Freezes 3ds hardware and crashes Citra with Vulkan when System Font is used - UI7 Menu scrolling is as scruffed as back in RenderD7 0.9.5
This commit is contained in:
@ -21,6 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/common/strings.hpp>
|
||||
#include <pd/ui7/drawlist.hpp>
|
||||
|
||||
namespace PD {
|
||||
@ -31,11 +32,12 @@ void DrawList::AddRectangle(vec2 pos, vec2 szs, const UI7Color& clr) {
|
||||
}
|
||||
auto rect = ren->CreateRect(pos, szs, 0.f);
|
||||
auto cmd = LI::Command::New();
|
||||
ren->SetupCommand(cmd);
|
||||
ren->UseTex();
|
||||
ren->SetupCommand(cmd);
|
||||
cmd->Layer(layer);
|
||||
ren->QuadCommand(cmd, rect, vec4(0.f, 1.f, 1.f, 0.f), clr);
|
||||
commands.push_back(cmd);
|
||||
commands.push_back(
|
||||
std::make_pair(ren->CurrentScreen() == Screen::Bottom, cmd));
|
||||
}
|
||||
|
||||
void DrawList::AddTriangle(vec2 pos0, vec2 pos1, vec2 pos2,
|
||||
@ -44,41 +46,82 @@ void DrawList::AddTriangle(vec2 pos0, vec2 pos1, vec2 pos2,
|
||||
return;
|
||||
}
|
||||
auto cmd = LI::Command::New();
|
||||
ren->SetupCommand(cmd);
|
||||
ren->UseTex();
|
||||
ren->SetupCommand(cmd);
|
||||
cmd->Layer(layer);
|
||||
ren->TriangleCommand(cmd, pos0, pos1, pos2, clr);
|
||||
commands.push_back(cmd);
|
||||
commands.push_back(
|
||||
std::make_pair(ren->CurrentScreen() == Screen::Bottom, cmd));
|
||||
}
|
||||
|
||||
void DrawList::AddText(vec2 pos, const std::string& text, const UI7Color& clr,
|
||||
LITextFlags flags, vec2 box) {
|
||||
u32 id = Strings::FastHash(text);
|
||||
auto e = static_text.find(id);
|
||||
if (e == static_text.end()) {
|
||||
static_text[id] = LI::Renderer::StaticText::New();
|
||||
e = static_text.find(id);
|
||||
}
|
||||
if (!e->second->IsSetup()) {
|
||||
e->second->Setup(&(*ren), pos, clr, text, flags, box);
|
||||
}
|
||||
e->second->SetPos(pos);
|
||||
e->second->SetColor(clr);
|
||||
e->second->SetLayer(base + layer);
|
||||
e->second->Draw();
|
||||
|
||||
////// STILL LEAVING THE OLD CODE BELOW AS IT IS MAYBE NEEDED //////
|
||||
////// IF STATIC TEXT SYSTEM SHOULD HAVE AN DISABLE OPTION //////
|
||||
|
||||
// Dont create a Command here as TextCommand has autosetup
|
||||
// cause it needs to generate multiple commands if
|
||||
// Font uses multiple textures
|
||||
ren->TextCommand(commands, pos, clr, text, flags, box);
|
||||
// Oh and Handle Layer management here as well
|
||||
// int l = ren->Layer();
|
||||
// ren->Layer(layer);
|
||||
// std::vector<LI::Command::Ref> cmds;
|
||||
// ren->TextCommand(cmds, pos, clr, text, flags, box);
|
||||
// ren->Layer(l);
|
||||
// for (auto c : cmds) {
|
||||
// commands.push_back(
|
||||
// std::make_pair(ren->CurrentScreen() == Screen::Bottom, c));
|
||||
// }
|
||||
}
|
||||
|
||||
void DrawList::AddImage(vec2 pos, Texture::Ref img) {
|
||||
if (!ren->InBox(pos, img->GetSize(), ren->GetViewport())) {
|
||||
void DrawList::AddImage(vec2 pos, Texture::Ref img, vec2 size) {
|
||||
size = size == 0.f ? img->GetSize() : size;
|
||||
if (!ren->InBox(pos, size, ren->GetViewport())) {
|
||||
return;
|
||||
}
|
||||
auto rect = ren->CreateRect(pos, img->GetSize(), 0.f);
|
||||
auto rect = ren->CreateRect(pos, size, 0.f);
|
||||
auto cmd = LI::Command::New();
|
||||
ren->SetupCommand(cmd);
|
||||
ren->UseTex(img);
|
||||
ren->SetupCommand(cmd);
|
||||
cmd->Layer(layer);
|
||||
ren->QuadCommand(cmd, rect, vec4(0.f, 1.f, 1.f, 0.f), 0xffffffff);
|
||||
commands.push_back(cmd);
|
||||
ren->QuadCommand(cmd, rect, img->GetUV(), 0xffffffff);
|
||||
commands.push_back(
|
||||
std::make_pair(ren->CurrentScreen() == Screen::Bottom, cmd));
|
||||
}
|
||||
|
||||
void DrawList::Clear() { commands.clear(); }
|
||||
|
||||
void DrawList::Process() {
|
||||
// UI7 Commands Use LI7 as default feature
|
||||
ren->OptiCommandList(commands);
|
||||
for (auto command : commands) {
|
||||
ren->PushCommand(command);
|
||||
command.second->Layer(command.second->Layer() + base);
|
||||
ren->OnScreen(command.first ? Screen::Bottom : Screen::Top);
|
||||
ren->PushCommand(command.second);
|
||||
}
|
||||
commands.clear();
|
||||
layer = 0;
|
||||
std::vector<u32> rem;
|
||||
for (auto it : static_text) {
|
||||
if (!it.second->Used()) {
|
||||
rem.push_back(it.first);
|
||||
}
|
||||
it.second->SetUnused();
|
||||
}
|
||||
for (auto& it : rem) {
|
||||
static_text.erase(it);
|
||||
}
|
||||
}
|
||||
} // namespace UI7
|
||||
|
331
source/ui7/menu.cpp
Normal file
331
source/ui7/menu.cpp
Normal file
@ -0,0 +1,331 @@
|
||||
#include <pd/common/sys.hpp>
|
||||
#include <pd/common/timetrace.hpp>
|
||||
#include <pd/ui7/menu.hpp>
|
||||
|
||||
//////////////////////////////
|
||||
//////// OBJECT SETUP ////////
|
||||
////// Setup Variables ///////
|
||||
///////// Move Cursor ////////
|
||||
//// Check Scrolling State ///
|
||||
/////// Handle Controls //////
|
||||
////////// Render ////////////
|
||||
//////////////////////////////
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
void UI7::Menu::Label(const std::string& label) {
|
||||
vec2 size = this->back->GetRenderer()->GetTextDimensions(label);
|
||||
vec2 pos = Cursor();
|
||||
CursorMove(size - vec2(0, 4)); // Fix to make gap not to large
|
||||
|
||||
if (HandleScrolling(pos, size)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// To Draw a Label above the head bar you should
|
||||
/// use the m->GetFrontList() instead
|
||||
|
||||
main->AddText(pos, label, linked_theme->Get(UI7Color_Text), 0,
|
||||
vec2(view_area.z(), 20));
|
||||
}
|
||||
|
||||
bool UI7::Menu::Button(const std::string& label) {
|
||||
bool ret = false;
|
||||
auto tszs = this->back->GetRenderer()->GetTextDimensions(label);
|
||||
vec2 size = tszs + vec2(8, 4);
|
||||
vec2 pos = Cursor();
|
||||
UI7Color clr = UI7Color_Button;
|
||||
CursorMove(size);
|
||||
/////// SCROLLING HANDLER HERE ////////
|
||||
if (HandleScrolling(pos, size)) {
|
||||
return false;
|
||||
}
|
||||
/// CONTROLS ///
|
||||
if (has_touch) {
|
||||
if (inp->IsHeld(inp->Touch) &&
|
||||
LI::Renderer::InBox(inp->TouchPos(), vec4(pos, size))) {
|
||||
clr = UI7Color_ButtonHovered;
|
||||
}
|
||||
if (inp->IsUp(inp->Touch) &&
|
||||
LI::Renderer::InBox(inp->TouchPosLast(), vec4(pos, size))) {
|
||||
clr = UI7Color_ButtonActive;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
/// Rendering ///
|
||||
main->AddRectangle(pos, size, linked_theme->Get(clr));
|
||||
main->AddText(pos + size * 0.5 - tszs * 0.5, label,
|
||||
linked_theme->Get(UI7Color_Text));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void UI7::Menu::Checkbox(const std::string& label, bool& v) {
|
||||
vec2 pos = Cursor();
|
||||
vec2 tdim = front->ren->GetTextDimensions(label);
|
||||
vec2 cbs(18);
|
||||
vec2 size = cbs + vec2(tdim.x() + 5, 0);
|
||||
CursorMove(size);
|
||||
|
||||
if (HandleScrolling(pos, size)) {
|
||||
return;
|
||||
}
|
||||
|
||||
UI7Color cbbg = UI7Color_FrameBackground;
|
||||
|
||||
if (has_touch) {
|
||||
if (inp->IsHeld(inp->Touch) &&
|
||||
LI::Renderer::InBox(inp->TouchPos(), vec4(pos, size))) {
|
||||
cbbg = UI7Color_FrameBackgroundHovered;
|
||||
}
|
||||
if (inp->IsUp(inp->Touch) &&
|
||||
LI::Renderer::InBox(inp->TouchPosLast(), vec4(pos, size))) {
|
||||
cbbg = UI7Color_FrameBackgroundHovered;
|
||||
v = !v;
|
||||
}
|
||||
}
|
||||
|
||||
main->AddRectangle(pos, cbs, linked_theme->Get(cbbg));
|
||||
if (v) {
|
||||
main->AddRectangle(pos + 2, cbs - 4, linked_theme->Get(UI7Color_Checkmark));
|
||||
}
|
||||
main->AddText(pos + vec2(cbs.x() + 5, cbs.y() * 0.5 - tdim.y() * 0.5), label,
|
||||
linked_theme->Get(UI7Color_Text));
|
||||
}
|
||||
|
||||
void UI7::Menu::Image(Texture::Ref img, vec2 size) {
|
||||
/// Variable Setup Stage ///
|
||||
size = size == 0.f ? img->GetSize() : size;
|
||||
vec2 pos = Cursor();
|
||||
CursorMove(size);
|
||||
/// Scrolling Handler ///
|
||||
if (HandleScrolling(pos, size)) {
|
||||
return;
|
||||
}
|
||||
/// Rendering Stage ///
|
||||
main->AddImage(pos, img, size);
|
||||
}
|
||||
|
||||
void UI7::Menu::DebugLabels() {
|
||||
std::stringstream s;
|
||||
s << "Name: " << name << " [";
|
||||
s << std::hex << std::setw(8) << std::setfill('0') << id;
|
||||
s << std::dec << "]";
|
||||
this->Label(s.str());
|
||||
this->Label(
|
||||
"Pre: " +
|
||||
Strings::FormatNanos(
|
||||
Sys::GetTraceRef("MPRE_" + name)->GetProtocol()->GetAverage()));
|
||||
this->Label(
|
||||
"Post: " +
|
||||
Strings::FormatNanos(
|
||||
Sys::GetTraceRef("MPOS_" + name)->GetProtocol()->GetAverage()));
|
||||
this->Label(
|
||||
"Update: " +
|
||||
Strings::FormatNanos(
|
||||
Sys::GetTraceRef("MUPT_" + name)->GetProtocol()->GetAverage()));
|
||||
this->Label(
|
||||
"MUser: " +
|
||||
Strings::FormatNanos(
|
||||
Sys::GetTraceRef("MUSR_" + name)->GetProtocol()->GetAverage()));
|
||||
}
|
||||
|
||||
void UI7::Menu::Update(float delta) {
|
||||
TT::Scope st("MUPT_" + name);
|
||||
this->back->BaseLayer(30);
|
||||
this->back->Process();
|
||||
this->main->BaseLayer(40);
|
||||
this->main->Process();
|
||||
this->front->BaseLayer(50);
|
||||
this->front->Process();
|
||||
}
|
||||
|
||||
void UI7::Menu::CursorMove(const vec2& size) {
|
||||
last_size = size;
|
||||
slcursor = cursor + vec2(size[0] + 5, 0);
|
||||
if (bslpos[1]) {
|
||||
cursor = vec2(5, cursor[1] + bslpos[1] + 5);
|
||||
bslpos = vec2();
|
||||
} else {
|
||||
cursor = vec2(5, cursor[1] + size[1] + 5);
|
||||
}
|
||||
max = vec2(slcursor[0], cursor[1]);
|
||||
}
|
||||
|
||||
void UI7::Menu::PreHandler(UI7MenuFlags flags) {
|
||||
TT::Scope st("MPRE_" + name);
|
||||
TT::Beg("MUSR_" + name);
|
||||
Cursor(vec2(5, 5));
|
||||
this->flags = flags;
|
||||
this->scrolling[0] = flags & UI7MenuFlags_HzScrolling;
|
||||
this->scrolling[1] = flags & UI7MenuFlags_VtScrolling;
|
||||
has_touch = main->GetRenderer()->CurrentScreen() == Screen::Bottom;
|
||||
if (!(flags & UI7MenuFlags_NoBackground)) {
|
||||
back->AddRectangle(0, view_area.zw(), UI7Color_Background);
|
||||
}
|
||||
if (!(flags & UI7MenuFlags_NoTitlebar)) {
|
||||
tbh = front->GetRenderer()->TextScale() * 30.f;
|
||||
front->AddRectangle(0, vec2(view_area.z(), tbh),
|
||||
linked_theme->Get(UI7Color_Header));
|
||||
vec2 tpos(5, tbh * 0.5 - front->ren->GetTextDimensions(name).y() * 0.5);
|
||||
LITextFlags tflags = LITextFlags_None;
|
||||
if (flags & UI7MenuFlags_CenterTitle) {
|
||||
tpos = 0;
|
||||
tflags = LITextFlags_AlignMid;
|
||||
}
|
||||
front->AddText(tpos, this->name, linked_theme->Get(UI7Color_Text), tflags,
|
||||
vec2(view_area.z(), tbh));
|
||||
Cursor(vec2(5, tbh + 5));
|
||||
}
|
||||
}
|
||||
|
||||
void UI7::Menu::PostHandler() {
|
||||
TT::Scope st("MPOS_" + name);
|
||||
if (scrolling[1]) {
|
||||
scroll_allowed[1] = (max[1] > 235);
|
||||
scrollbar[1] = scroll_allowed[1];
|
||||
|
||||
if (scrollbar[1]) {
|
||||
/// Setup Some Variables hare [they are self described]
|
||||
int screen_w = view_area.z();
|
||||
int tsp = 5 + tbh;
|
||||
int slider_w = 4;
|
||||
int szs = view_area.w() - tsp - 5;
|
||||
/// Actually dont have a Horizontal bar yet
|
||||
if (scrollbar[0]) szs -= slider_w - 2;
|
||||
int lslider_h = 20; // Dont go less heigt for the drag
|
||||
float slider_h = (szs - 4) * (float(szs - 4) / max[1]);
|
||||
/// Visual Slider Height (How it looks in the end)
|
||||
int vslider_h = std::clamp(slider_h, float(lslider_h), float(szs - 4));
|
||||
|
||||
/// Check if we overscroll to the bottom and Auto scroll back...
|
||||
/// Probably schould use Tween ENgine here
|
||||
if (scrolling_off[1] > max[1] - view_area[3] && max[1] != 0.f &&
|
||||
max[1] >= view_area[3] - 5) {
|
||||
scrolling_off[1] -= 3.f;
|
||||
if (scrolling_off[1] < max[1] - view_area[3]) {
|
||||
scrolling_off[1] = max[1] - view_area[3];
|
||||
}
|
||||
}
|
||||
|
||||
/// Do the Same as above just for Overscroll back to the top
|
||||
if (scrolling_off[1] < 0) {
|
||||
scrolling_off[1] += 3.f;
|
||||
if (scrolling_off[1] > 0) {
|
||||
scrolling_off[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Dont overscroll to much
|
||||
if (scrolling_off[1] < -40 ||
|
||||
scrolling_off[1] > max[1] - view_area[3] + 40) {
|
||||
scroll_mod[1] = 0.f;
|
||||
}
|
||||
|
||||
/// The pain :(
|
||||
if (has_touch) {
|
||||
vec2 tpos = inp->TouchPos();
|
||||
if (inp->IsDown(inp->Touch)) {
|
||||
mouse = tpos;
|
||||
} else if (inp->IsUp(inp->Touch)) {
|
||||
mouse = vec2();
|
||||
}
|
||||
if (inp->IsHeld(inp->Touch)) {
|
||||
if (!front->ren->InBox(tpos, vec4(view_area[2] - 13, tbh + 5, 8,
|
||||
view_area[3] - tbh - 10))) {
|
||||
if (scrolling_off[1] < max[1] - view_area[3] + 40 &&
|
||||
scrolling_off[1] > -40) {
|
||||
/// Cursor Mod
|
||||
float cm = mouse[1] - tpos[1];
|
||||
if (scroll_mod[1] <= 4.f && scroll_mod[1] >= -4.f && cm != 0) {
|
||||
scroll_mod[1] = cm;
|
||||
}
|
||||
}
|
||||
mouse = tpos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Effect
|
||||
if (scroll_mod[1] != 0) {
|
||||
scrolling_off[1] += scroll_mod[1];
|
||||
}
|
||||
if (scroll_mod[1] < 0.f) {
|
||||
scroll_mod[1] += 0.4f;
|
||||
if (scroll_mod[1] > 0.f) {
|
||||
scroll_mod[1] = 0;
|
||||
}
|
||||
}
|
||||
if (scroll_mod[1] > 0.f) {
|
||||
scroll_mod[1] -= 0.4f;
|
||||
if (scroll_mod[1] < 0.f) {
|
||||
scroll_mod[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int srpos =
|
||||
tsp + std::clamp(float(szs - vslider_h - 4) *
|
||||
(scrolling_off[1] / (max[1] - view_area[3])),
|
||||
0.f, float(szs - vslider_h - 4));
|
||||
|
||||
/// Rendering Stage
|
||||
front->AddRectangle(vec2(screen_w - 12, tsp), vec2(slider_w * 2, szs),
|
||||
linked_theme->Get(UI7Color_FrameBackground));
|
||||
front->AddRectangle(vec2(screen_w - 10, tsp + 2), vec2(slider_w, szs - 4),
|
||||
linked_theme->Get(UI7Color_FrameBackgroundHovered));
|
||||
front->AddRectangle(vec2(screen_w - 10, srpos + 2),
|
||||
vec2(slider_w, vslider_h),
|
||||
linked_theme->Get(UI7Color_Button));
|
||||
}
|
||||
}
|
||||
TT::End("MUSR_" + name);
|
||||
}
|
||||
|
||||
void UI7::Menu::SameLine() {
|
||||
bslpos = last_size;
|
||||
cursor = slcursor;
|
||||
}
|
||||
|
||||
void UI7::Menu::Separator() {
|
||||
vec2 pos = Cursor();
|
||||
vec2 size = vec2(view_area.z() - (scrollbar[1] ? 24 : 10), 1);
|
||||
CursorMove(size);
|
||||
if (HandleScrolling(pos, size)) {
|
||||
return;
|
||||
}
|
||||
main->AddRectangle(pos, size, linked_theme->Get(UI7Color_TextDead));
|
||||
}
|
||||
|
||||
void UI7::Menu::SeparatorText(const std::string& label) {
|
||||
vec2 size = vec2(view_area.z() - (scrollbar[1] ? 24 : 10), 1);
|
||||
vec2 tdim = this->back->GetRenderer()->GetTextDimensions(label);
|
||||
vec2 pos = Cursor();
|
||||
CursorMove(vec2(size.x(), tdim.y() - 4)); // Fix to make gap not to large
|
||||
|
||||
if (HandleScrolling(pos, size)) {
|
||||
return;
|
||||
}
|
||||
/// Label pos for better overview
|
||||
vec2 lpos = pos + vec2((view_area.z() - 10) * 0.5 - tdim.x() * 0.5, 0);
|
||||
main->AddRectangle(pos + vec2(0, tdim.y() * 0.5),
|
||||
vec2(lpos.x() - pos.x() - 5, size.y()),
|
||||
linked_theme->Get(UI7Color_TextDead));
|
||||
main->AddRectangle(pos + vec2(lpos.x() + tdim.x(), tdim.y() * 0.5),
|
||||
vec2(size.x() - (lpos.x() + tdim.x()), size.y()),
|
||||
linked_theme->Get(UI7Color_TextDead));
|
||||
main->AddText(lpos, label, linked_theme->Get(UI7Color_Text), 0,
|
||||
vec2(view_area.z(), 20));
|
||||
}
|
||||
|
||||
bool UI7::Menu::HandleScrolling(vec2& pos, const vec2& size) {
|
||||
if (scrolling[1]) {
|
||||
vec2 p = pos;
|
||||
pos -= vec2(0, scrolling_off.y());
|
||||
if (pos.y() > view_area.w() ||
|
||||
(pos.y() + size.y() < tbh - 5 && p.y() > tbh)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
@ -10,12 +10,12 @@ void Theme::Default(Theme& theme) {
|
||||
theme.Set(UI7Color_Button, Color("#111111FF"));
|
||||
theme.Set(UI7Color_ButtonDead, Color("#080808FF"));
|
||||
theme.Set(UI7Color_ButtonActive, Color("#2A2A2AFF"));
|
||||
theme.Set(UI7Color_ButtonDisabled, Color("#222222FF"));
|
||||
theme.Set(UI7Color_ButtonHovered, Color("#222222FF"));
|
||||
theme.Set(UI7Color_Header, Color("#111111FF"));
|
||||
theme.Set(UI7Color_Selector, Color("#222222FF"));
|
||||
theme.Set(UI7Color_Checkmark, Color("#2A2A2AFF"));
|
||||
theme.Set(UI7Color_FrameBackground, Color("#555555FF"));
|
||||
theme.Set(UI7Color_FragmeBackgroundHovered, Color("#777777FF"));
|
||||
theme.Set(UI7Color_FrameBackgroundHovered, Color("#777777FF"));
|
||||
theme.Set(UI7Color_Progressbar, Color("#00FF00FF"));
|
||||
theme.Set(UI7Color_ListEven, Color("#CCCCCCFF"));
|
||||
theme.Set(UI7Color_ListOdd, Color("#BBBBBBFF"));
|
||||
|
@ -0,0 +1,52 @@
|
||||
#include <pd/common/timetrace.hpp>
|
||||
#include <pd/ui7/ui7.hpp>
|
||||
|
||||
namespace PD {
|
||||
bool UI7::Context::BeginMenu(const ID& id, UI7MenuFlags flags) {
|
||||
Assert(!this->current, "You are already in another Menu!");
|
||||
Assert(std::find(amenus.begin(), amenus.end(), (u32)id) == amenus.end(),
|
||||
"Menu Name Already used or\nContext::Update not called!");
|
||||
auto menu = this->menus.find(id);
|
||||
if (menu == this->menus.end()) {
|
||||
this->menus[id] = Menu::New(id, &theme, inp);
|
||||
menu = this->menus.find(id);
|
||||
}
|
||||
this->current = menu->second;
|
||||
if (!this->current->BackList()) {
|
||||
this->current->BackList(DrawList::New(ren));
|
||||
}
|
||||
if (!this->current->MainList()) {
|
||||
this->current->MainList(DrawList::New(ren));
|
||||
}
|
||||
if (!this->current->FrontList()) {
|
||||
this->current->FrontList(DrawList::New(ren));
|
||||
}
|
||||
this->current->ViewArea(this->ren->GetViewport());
|
||||
this->current->PreHandler(flags);
|
||||
amenus.push_back(this->current->GetID());
|
||||
return true;
|
||||
}
|
||||
|
||||
UI7::Menu::Ref UI7::Context::GetCurrentMenu() {
|
||||
Assert(current != nullptr, "Not in a Menu!");
|
||||
return current;
|
||||
}
|
||||
|
||||
void UI7::Context::EndMenu() {
|
||||
this->current->PostHandler();
|
||||
this->current = nullptr;
|
||||
}
|
||||
|
||||
void UI7::Context::Update(float delta) {
|
||||
TT::Scope st("UI7_Update");
|
||||
Assert(current == nullptr, "Still in a Menu!");
|
||||
this->back->BaseLayer(10);
|
||||
this->back->Process();
|
||||
for (auto it : amenus) {
|
||||
menus[it]->Update(delta);
|
||||
}
|
||||
this->front->BaseLayer(60);
|
||||
this->front->Process();
|
||||
this->amenus.clear();
|
||||
}
|
||||
} // namespace PD
|
Reference in New Issue
Block a user