// File: /workspace/github_cpp_makefile_star2_O2/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 0xed34
movl %eax, %ebx
callq 0xed40
movl %eax, %r14d
cmpb $0x0, 0x204a11(%rip)    # 0x2145a0
jne 0xfbc2
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
callq 0x5af05
movq 0x20(%r15), %rax
movq %rax, 0x2049ed(%rip)    # 0x214598
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x2049cd(%rip)   # 0x214588
movups %xmm0, 0x2049b6(%rip)   # 0x214578
cvtsi2ss %ebx, %xmm0
movss %xmm0, -0x30(%rbp)
cvtsi2ss %r14d, %xmm0
movss %xmm0, -0x2c(%rbp)
movq 0x2049cc(%rip), %r12    # 0x2145a8
movq 0x2049cd(%rip), %r13    # 0x2145b0
leaq -0x90(%rbp), %rbx
pushq $-0x1
popq %r14
cmpq %r13, %r12
je 0xfe42
movl (%r12), %eax
cmpl $0x2, %eax
jb 0xfce3
cmpl $0x3, %eax
je 0xfda9
cmpl $0x2, %eax
jne 0xfe39
leaq 0x18(%r12), %rsi
movq %rbx, %rdi
callq 0x8ad0
movq %rbx, %rdi
callq 0xf7d0
movq %rax, %r15
movq %rbx, %rdi
callq 0x83a0
cvtsi2ssl 0x4(%r15), %xmm0
cvtsi2ssl 0x8(%r15), %xmm1
divss %xmm1, %xmm0
movss 0xc(%r12), %xmm3
movss -0x2c(%rbp), %xmm5
mulss %xmm5, %xmm3
mulss %xmm0, %xmm3
movaps %xmm3, %xmm0
movss 0x88b73(%rip), %xmm4    # 0x987d8
mulss %xmm4, %xmm0
movss 0x4(%r12), %xmm2
mulss -0x30(%rbp), %xmm2
addss %xmm0, %xmm2
movss 0x10(%r12), %xmm0
mulss %xmm5, %xmm0
movaps %xmm0, %xmm1
mulss %xmm4, %xmm1
movss 0x8(%r12), %xmm4
mulss %xmm5, %xmm4
addss %xmm1, %xmm4
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
movl 0x10(%r15), %eax
movl %eax, -0x40(%rbp)
movups (%r15), %xmm1
movaps %xmm1, -0x50(%rbp)
cvtsi2ssl 0x4(%r15), %xmm1
cvtsi2ssl 0x8(%r15), %xmm4
unpcklps %xmm4, %xmm1            # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movl -0x40(%rbp), %eax
movl %eax, 0x10(%rsp)
movaps -0x50(%rbp), %xmm4
movups %xmm4, (%rsp)
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
xorps %xmm0, %xmm0
xorps %xmm4, %xmm4
xorps %xmm5, %xmm5
movl %r14d, %edi
callq 0x7693b
jmp 0xfe39
movss 0x4(%r12), %xmm3
mulss -0x30(%rbp), %xmm3
movss 0x8(%r12), %xmm5
movss -0x2c(%rbp), %xmm0
mulss %xmm0, %xmm5
movss 0x10(%r12), %xmm2
mulss %xmm0, %xmm2
movss 0x88ac2(%rip), %xmm1    # 0x987d4
divss %xmm1, %xmm2
movss 0xc(%r12), %xmm4
mulss %xmm0, %xmm4
divss %xmm1, %xmm4
cmpl $0x1, %eax
jne 0xfdfb
movq 0x18(%r12), %rdi
movq 0x20485e(%rip), %rax    # 0x214598
movq %rax, 0x20(%rsp)
movups 0x204842(%rip), %xmm0   # 0x214588
movups %xmm0, 0x10(%rsp)
movups 0x204826(%rip), %xmm0   # 0x214578
movups %xmm0, (%rsp)
movaps %xmm2, %xmm0
movaps %xmm4, %xmm1
movaps %xmm3, -0x70(%rbp)
movss %xmm2, -0x38(%rbp)
movss %xmm4, -0x34(%rbp)
movaps %xmm5, -0x60(%rbp)
callq 0x5ca50
movss -0x34(%rbp), %xmm4
movaps -0x70(%rbp), %xmm3
movaps %xmm0, %xmm1
movss 0x8853d(%rip), %xmm2    # 0x982c4
mulss %xmm2, %xmm1
subss %xmm1, %xmm3
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss %xmm2, %xmm0
movss -0x38(%rbp), %xmm2
movaps -0x60(%rbp), %xmm1
subss %xmm0, %xmm1
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
jmp 0xfdfe
movss 0x4(%r12), %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
movss 0x8(%r12), %xmm0
movss -0x2c(%rbp), %xmm2
mulss %xmm2, %xmm0
cvttss2si %xmm0, %esi
movss 0xc(%r12), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
movss 0x10(%r12), %xmm0
mulss %xmm2, %xmm0
cvttss2si %xmm0, %ecx
movl 0x38(%r12), %r8d
callq 0x495af
jmp 0xfe39
unpcklps %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
movq 0x18(%r12), %rdi
movl 0x38(%r12), %esi
movq 0x204789(%rip), %rax    # 0x214598
movq %rax, 0x20(%rsp)
movups 0x20476d(%rip), %xmm0   # 0x214588
movups %xmm0, 0x10(%rsp)
movups 0x204751(%rip), %xmm0   # 0x214578
movups %xmm0, (%rsp)
movaps %xmm3, %xmm0
movaps %xmm2, %xmm1
movaps %xmm4, %xmm2
callq 0x5c42f
addq $0x40, %r12
jmp 0xfbee
leaq 0x20475f(%rip), %rdi    # 0x2145a8
callq 0x10038
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x83a0
movq %rbx, %rdi
callq 0x8ed0
nop