// File: /workspace/github_cpp_makefile_star2_O1/KellerMartins[P]PDS2-Pacman/source/graphics/ui.cpp
// Function: UI::Render()
void Render(){
        float screenWidth = (float)RenderManager::GetWidth();
        float screenHeight = (float)RenderManager::GetHeight();

        if(!_loadedFont){
            _font = GetFontDefault();
        }

        for(UIElement& e : _elements){
            if(e.type == ElementType::UIImage){
                
                Texture2D& imageTex = GetImage(e.string);

                float aspectRatio = (float)imageTex.width/(float)imageTex.height;
                
                float positionX = e.x*screenWidth  - e.width*screenHeight*aspectRatio/2;
                float positionY = e.y*screenHeight - e.height*screenHeight/2;

                DrawTexturePro(imageTex, (Rectangle){0, 0, (float)imageTex.width, (float)imageTex.height}, 
                                         (Rectangle){positionX, positionY, e.width*screenHeight*aspectRatio, e.height*screenHeight}, 
                                         VECTOR2_ZERO, 0,WHITE);
            }
            else if(e.type == ElementType::UIText || e.type == ElementType::UITextCentered){
                
                Vector2 position;
                position.x = e.x*screenWidth;
                position.y = e.y*screenHeight;
                float fontSize = e.height*screenHeight/100;
                float spacing = e.width*screenHeight/100;

                if(e.type == ElementType::UITextCentered){
                    Vector2 textSize = MeasureTextEx(_font, e.string.c_str(), fontSize, spacing);
                    position.x -= textSize.x/2;
                    position.y -= textSize.y/2;

                }

                DrawTextEx(_font, e.string.c_str(), position, fontSize, spacing, e.colorTint);
            }else if(e.type == ElementType::UIRect){
                DrawRectangle(e.x*screenWidth, e.y*screenHeight, 
                              e.width*screenWidth, e.height*screenHeight, 
                              e.colorTint);
            }
        }

        _elements.clear();
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
callq 0xf6b7
movl %eax, %ebx
callq 0xf6c3
movl %eax, %r14d
cmpb $0x0, 0x204f1e(%rip)    # 0x215580
jne 0x10695
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
callq 0x5babd
movq 0x20(%r15), %rax
movq %rax, 0x204efa(%rip)    # 0x215578
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x204eda(%rip)   # 0x215568
movups %xmm0, 0x204ec3(%rip)   # 0x215558
movq 0x204eec(%rip), %r15    # 0x215588
movq 0x204eed(%rip), %r12    # 0x215590
cmpq %r12, %r15
je 0x10948
xorps %xmm0, %xmm0
cvtsi2ss %ebx, %xmm0
movss %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x48(%rbp), %r13
leaq -0x58(%rbp), %rbx
movl (%r15), %eax
cmpl $0x2, %eax
jb 0x107eb
cmpl $0x3, %eax
je 0x108b2
cmpl $0x2, %eax
jne 0x1093b
movq %r13, -0x58(%rbp)
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xcd26
movq %rbx, %rdi
callq 0x10190
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x10722
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8880
xorps %xmm0, %xmm0
cvtsi2ssl 0x4(%r14), %xmm0
xorps %xmm1, %xmm1
cvtsi2ssl 0x8(%r14), %xmm1
divss %xmm1, %xmm0
movss 0xc(%r15), %xmm1
movss -0x2c(%rbp), %xmm5
mulss %xmm5, %xmm1
mulss %xmm0, %xmm1
movss 0x89065(%rip), %xmm4    # 0x997b8
mulss %xmm4, %xmm1
movss 0x4(%r15), %xmm2
mulss -0x30(%rbp), %xmm2
addss %xmm1, %xmm2
movss 0x10(%r15), %xmm3
mulss %xmm5, %xmm3
mulss %xmm4, %xmm3
movss 0x8(%r15), %xmm4
mulss %xmm5, %xmm4
movl 0x10(%r14), %eax
movl %eax, -0x60(%rbp)
movups (%r14), %xmm1
movaps %xmm1, -0x70(%rbp)
xorps %xmm1, %xmm1
cvtsi2ssl 0x4(%r14), %xmm1
addss %xmm3, %xmm4
xorps %xmm3, %xmm3
cvtsi2ssl 0x8(%r14), %xmm3
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
unpcklps %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movss 0xc(%r15), %xmm3
mulss %xmm5, %xmm3
mulss %xmm0, %xmm3
movss 0x10(%r15), %xmm0
mulss %xmm5, %xmm0
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
movl -0x60(%rbp), %eax
movl %eax, 0x10(%rsp)
movaps -0x70(%rbp), %xmm0
movups %xmm0, (%rsp)
xorps %xmm0, %xmm0
xorps %xmm4, %xmm4
xorps %xmm5, %xmm5
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x774f3
jmp 0x1093b
movss 0x4(%r15), %xmm3
mulss -0x30(%rbp), %xmm3
movss 0x8(%r15), %xmm5
movss -0x2c(%rbp), %xmm0
mulss %xmm0, %xmm5
movss 0x10(%r15), %xmm2
mulss %xmm0, %xmm2
movss 0x88f9d(%rip), %xmm1    # 0x997b4
divss %xmm1, %xmm2
movss 0xc(%r15), %xmm4
mulss %xmm0, %xmm4
divss %xmm1, %xmm4
cmpl $0x1, %eax
jne 0x108ff
movq 0x18(%r15), %rdi
movq 0x204d3b(%rip), %rax    # 0x215578
movq %rax, 0x20(%rsp)
movups 0x204d1f(%rip), %xmm0   # 0x215568
movups %xmm0, 0x10(%rsp)
movups 0x204d03(%rip), %xmm0   # 0x215558
movups %xmm0, (%rsp)
movaps %xmm2, %xmm0
movaps %xmm4, %xmm1
movaps %xmm3, -0x90(%rbp)
movss %xmm2, -0x38(%rbp)
movss %xmm4, -0x34(%rbp)
movaps %xmm5, -0x80(%rbp)
callq 0x5d608
movss -0x34(%rbp), %xmm4
movaps -0x90(%rbp), %xmm3
movaps %xmm0, %xmm1
movss 0x88a64(%rip), %xmm2    # 0x992f4
mulss %xmm2, %xmm1
subss %xmm1, %xmm3
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss %xmm2, %xmm0
movss -0x38(%rbp), %xmm2
movaps -0x80(%rbp), %xmm1
subss %xmm0, %xmm1
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
jmp 0x10902
movss 0x4(%r15), %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
movss 0x8(%r15), %xmm0
movss -0x2c(%rbp), %xmm2
mulss %xmm2, %xmm0
cvttss2si %xmm0, %esi
movss 0xc(%r15), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
movss 0x10(%r15), %xmm0
mulss %xmm2, %xmm0
cvttss2si %xmm0, %ecx
movl 0x38(%r15), %r8d
callq 0x4a167
jmp 0x1093b
unpcklps %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
movq 0x18(%r15), %rdi
movl 0x38(%r15), %esi
movq 0x204c67(%rip), %rax    # 0x215578
movq %rax, 0x20(%rsp)
movups 0x204c4b(%rip), %xmm0   # 0x215568
movups %xmm0, 0x10(%rsp)
movups 0x204c2f(%rip), %xmm0   # 0x215558
movups %xmm0, (%rsp)
movaps %xmm3, %xmm0
movaps %xmm2, %xmm1
movaps %xmm4, %xmm2
callq 0x5cfe7
addq $0x40, %r15
cmpq %r12, %r15
jne 0x106cd
movq 0x204c39(%rip), %rsi    # 0x215588
leaq 0x204c32(%rip), %rdi    # 0x215588
callq 0x112a4
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x10985
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8880
movq %rbx, %rdi
callq 0x8ea0
nop