// File: 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
subq $0x1a0, %rsp            # imm = 0x1A0
callq 0x18610
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x4(%rbp)
callq 0x18620
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x8(%rbp)
testb $0x1, 0x20bcba(%rip)    # 0x2265b8
jne 0x1a91e
leaq -0x30(%rbp), %rdi
callq 0x67b7d
leaq 0x20bc80(%rip), %rdi    # 0x226590
leaq -0x30(%rbp), %rsi
movl $0x28, %edx
callq 0x96e0
leaq 0x20bc9b(%rip), %rax    # 0x2265c0
movq %rax, -0x38(%rbp)
leaq 0x20bc90(%rip), %rdi    # 0x2265c0
callq 0x1b2b0
movq %rax, -0x40(%rbp)
leaq 0x20bc80(%rip), %rdi    # 0x2265c0
callq 0x1b2e0
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1b310
testb $0x1, %al
jne 0x1a95f
jmp 0x1ae06
leaq -0x40(%rbp), %rdi
callq 0x1b350
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x1ab8e
movq -0x50(%rbp), %rsi
addq $0x18, %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x93b0
movq -0x170(%rbp), %rdi
callq 0x1a3c0
movq %rax, -0x168(%rbp)
jmp 0x1a9a6
leaq -0x78(%rbp), %rdi
callq 0x9530
movq -0x168(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cvtsi2ssl 0x4(%rax), %xmm0
cvtsi2ssl 0x8(%rax), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x88(%rbp)
movq -0x50(%rbp), %rax
movss -0x4(%rbp), %xmm2
movss 0x4(%rax), %xmm0
movss 0xc(%rax), %xmm1
movss -0x8(%rbp), %xmm3
mulss %xmm3, %xmm1
movss -0x88(%rbp), %xmm3
mulss %xmm3, %xmm1
movss 0x8ac98(%rip), %xmm3    # 0xa569c
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x8c(%rbp)
movq -0x50(%rbp), %rax
movss -0x8(%rbp), %xmm2
movss 0x8(%rax), %xmm0
movss 0x10(%rax), %xmm1
mulss %xmm2, %xmm1
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x90(%rbp)
movq -0x58(%rbp), %rax
movl 0x10(%rax), %ecx
movl %ecx, -0xa0(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0xb0(%rbp)
movl $0x0, -0xc0(%rbp)
movl $0x0, -0xbc(%rbp)
movq -0x58(%rbp), %rax
cvtsi2ssl 0x4(%rax), %xmm0
movss %xmm0, -0xb8(%rbp)
movq -0x58(%rbp), %rax
cvtsi2ssl 0x8(%rax), %xmm0
movss %xmm0, -0xb4(%rbp)
movss -0x8c(%rbp), %xmm0
movss %xmm0, -0xd0(%rbp)
movss -0x90(%rbp), %xmm0
movss %xmm0, -0xcc(%rbp)
movq -0x50(%rbp), %rax
movss 0xc(%rax), %xmm0
movss -0x8(%rbp), %xmm1
mulss %xmm1, %xmm0
movss -0x88(%rbp), %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0xc8(%rbp)
movq -0x50(%rbp), %rax
movss 0x10(%rax), %xmm0
movss -0x8(%rbp), %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0xc4(%rbp)
movl $0x0, -0xd8(%rbp)
movl $0x0, -0xd4(%rbp)
movb $-0x1, -0xdc(%rbp)
movb $-0x1, -0xdb(%rbp)
movb $-0x1, -0xda(%rbp)
movb $-0x1, -0xd9(%rbp)
movsd -0xc0(%rbp), %xmm0
movsd -0xb8(%rbp), %xmm1
movsd -0xd0(%rbp), %xmm2
movsd -0xc8(%rbp), %xmm3
movsd -0xd8(%rbp), %xmm4
movl -0xdc(%rbp), %edi
movl -0xa0(%rbp), %ecx
movq %rsp, %rax
movl %ecx, 0x10(%rax)
movups -0xb0(%rbp), %xmm5
movups %xmm5, (%rax)
xorps %xmm5, %xmm5
callq 0x835b3
jmp 0x1adf6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x9530
jmp 0x1ae1b
movq -0x50(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1aba4
movq -0x50(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x1ad88
movq -0x50(%rbp), %rax
movss 0x4(%rax), %xmm0
mulss -0x4(%rbp), %xmm0
movss %xmm0, -0xe4(%rbp)
movq -0x50(%rbp), %rax
movss 0x8(%rax), %xmm0
mulss -0x8(%rbp), %xmm0
movss %xmm0, -0xe0(%rbp)
movq -0x50(%rbp), %rax
movss 0x10(%rax), %xmm0
mulss -0x8(%rbp), %xmm0
movss 0x8aab2(%rip), %xmm1    # 0xa5698
divss %xmm1, %xmm0
movss %xmm0, -0xe8(%rbp)
movq -0x50(%rbp), %rax
movss 0xc(%rax), %xmm0
mulss -0x8(%rbp), %xmm0
movss 0x8aa90(%rip), %xmm1    # 0xa5698
divss %xmm1, %xmm0
movss %xmm0, -0xec(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x1aceb
movq 0x20b988(%rip), %rax    # 0x2265b0
movq %rax, -0x100(%rbp)
movups 0x20b96a(%rip), %xmm0   # 0x2265a0
movaps %xmm0, -0x110(%rbp)
movups 0x20b94c(%rip), %xmm0   # 0x226590
movaps %xmm0, -0x120(%rbp)
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
callq 0x9360
movq %rax, %rdi
movss -0xe8(%rbp), %xmm0
movss -0xec(%rbp), %xmm1
movq -0x100(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movaps -0x120(%rbp), %xmm2
movaps -0x110(%rbp), %xmm3
movups %xmm3, 0x10(%rax)
movups %xmm2, (%rax)
callq 0x696c8
movlpd %xmm0, -0xf4(%rbp)
movss -0xf4(%rbp), %xmm1
movss 0x8a35d(%rip), %xmm0    # 0xa5008
divss %xmm0, %xmm1
movss -0xe4(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0xe4(%rbp)
movss -0xf0(%rbp), %xmm1
movss 0x8a335(%rip), %xmm0    # 0xa5008
divss %xmm0, %xmm1
movss -0xe0(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0xe0(%rbp)
movq 0x20b8be(%rip), %rax    # 0x2265b0
movq %rax, -0x130(%rbp)
movups 0x20b8a0(%rip), %xmm0   # 0x2265a0
movaps %xmm0, -0x140(%rbp)
movups 0x20b882(%rip), %xmm0   # 0x226590
movaps %xmm0, -0x150(%rbp)
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
callq 0x9360
movq %rax, %rdi
movq -0xe4(%rbp), %rax
movq %rax, -0x158(%rbp)
movss -0xe8(%rbp), %xmm1
movss -0xec(%rbp), %xmm2
movq -0x50(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x15c(%rbp)
movsd -0x158(%rbp), %xmm0
movl -0x15c(%rbp), %esi
movq -0x130(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x150(%rbp), %xmm3
movups -0x140(%rbp), %xmm4
movups %xmm4, 0x10(%rax)
movups %xmm3, (%rax)
callq 0x690a7
jmp 0x1adf4
movq -0x50(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x1adf2
movq -0x50(%rbp), %rax
movss 0x4(%rax), %xmm0
mulss -0x4(%rbp), %xmm0
cvttss2si %xmm0, %edi
movq -0x50(%rbp), %rax
movss 0x8(%rax), %xmm0
mulss -0x8(%rbp), %xmm0
cvttss2si %xmm0, %esi
movq -0x50(%rbp), %rax
movss 0xc(%rax), %xmm0
mulss -0x4(%rbp), %xmm0
cvttss2si %xmm0, %edx
movq -0x50(%rbp), %rax
movss 0x10(%rax), %xmm0
mulss -0x8(%rbp), %xmm0
cvttss2si %xmm0, %ecx
movq -0x50(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x160(%rbp)
movl -0x160(%rbp), %r8d
callq 0x56227
jmp 0x1adf4
jmp 0x1adf6
jmp 0x1adf8
leaq -0x40(%rbp), %rdi
callq 0x1b370
jmp 0x1a949
leaq 0x20b7b3(%rip), %rdi    # 0x2265c0
callq 0x1b390
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x9f50
nopw %cs:(%rax,%rax)
nop