// File: /workspace/github_cpp_makefile_star2_O1/KellerMartins[P]PDS2-Pacman/source/main.cpp
// Function: OpenConfigWindow()
bool OpenConfigWindow(){ 
    #ifdef NDEBUG
    SetTraceLog(0);
    #endif
    
    SetConfigFlags(FLAG_MSAA_4X_HINT);
    InitWindow(575, 110, "Opções | Pacman Remake - PDS2");
    
    Font font = LoadFont("assets/interface/metropolis/Metropolis.fnt");
    SetTextureFilter(font.texture, FILTER_TRILINEAR);

    int resolution = 3;
    while(1){
        if(WindowShouldClose()){
            //Fecha a janela
            CloseWindow();
            return false;
        }

        //Define os retângulos dos botões da janela
        Rectangle play = { 430, 10, 135, 90 };
        Rectangle fullscr = { 175, 75, 240, 27 };
        Rectangle previousRes = { 175, 5, 20, 30 };
        Rectangle nextRes = { 405, 5, 20, 30 };
        Rectangle previousQual = { 175, 40, 20, 30 };
        Rectangle nextQual = { 405, 40, 20, 30 };

        bool clicked = IsMouseButtonPressed(MOUSE_LEFT_BUTTON);

        //Checa se clicou em um deles ou apertou a tecla correspondente ao comando
        if((CheckCollisionPointRec(GetMousePosition(), previousRes) && clicked) ||  IsKeyReleased(KEY_LEFT))
            resolution -= resolution-1>=0? 1:0;
        
        if((CheckCollisionPointRec(GetMousePosition(), nextRes) && clicked) ||  IsKeyReleased(KEY_RIGHT))
            resolution += resolution+1<=3? 1:0;

        if(CheckCollisionPointRec(GetMousePosition(), previousQual) && clicked)
            quality = (RenderManager::BlurQuality) (quality-1>=0? quality-1:quality);
        
        if(CheckCollisionPointRec(GetMousePosition(), nextQual) && clicked)
            quality = (RenderManager::BlurQuality) (quality+1<=2? quality+1:quality);
        
        if(CheckCollisionPointRec(GetMousePosition(), fullscr) && clicked)
            fullscreen = !fullscreen;
        
        if((CheckCollisionPointRec(GetMousePosition(), play) && clicked) ||  IsKeyReleased(KEY_ENTER))
            break; //Termina o loop da tela de configuraçoes
        
        //Define a resolução a ser usada
        switch(resolution){
            case 3:
                width = 1920;
                height = 1080;
            break;
            case 2:
                width = 1366;
                height = 768;
            break;
            case 1:
                width = 1280;
                height = 720;
            break;
            case 0:
            default:
                width = 800;
                height = 450;
            break;
        }
        
        //> Renderização
        BeginDrawing();

        //Define a cor de fundo
        Color settingsCol = {255,191,0,255};
        ClearBackground({35,45,60,255});
        //Renderiza o texto
        DrawTextEx(font,"Resolução", (Vector2){5,5}, 30, 1, RAYWHITE); 
        DrawTextEx(font,FormatText("%4d x %4d",width,height),(Vector2){195, 5}, 33,2, settingsCol); 

        const char* qualityString = quality==2 ?" Alta " : (quality==1? "Média" : "Baixa ");
        DrawTextEx(font,"Qualidade", (Vector2){5,40}, 30, 1, RAYWHITE); 
        DrawTextEx(font, qualityString, (Vector2){255, 40}, 33, 2, settingsCol); 

        DrawTextEx(font,"Tela cheia", (Vector2){5, 75}, 30, 1, RAYWHITE); 
        DrawTextEx(font, fullscreen? "   Ativado" : "Desativado", (Vector2){205, 75}, 33, 2, settingsCol); 
        
        //Renderiza o botão de jogar
        DrawRectangleRec(play, {255,191,0,255});
        DrawTextEx(font, "Jogar!",(Vector2){455, 40}, 30, 0, WHITE); 
        
        //Renderiza as setas de resolução
        DrawTextEx(font,"<",(Vector2){175, 5}, 33, 2, resolution>0? settingsCol : (Color)DARKGRAY); 
        DrawTextEx(font,">",(Vector2){403, 5}, 33, 2, resolution<3? settingsCol : (Color)DARKGRAY);

        //Renderiza as setas de qualidade
        DrawTextEx(font,"<",(Vector2){175, 40}, 33, 2, quality>0? settingsCol : (Color)DARKGRAY); 
        DrawTextEx(font,">",(Vector2){403, 40}, 33, 2, quality<2? settingsCol : (Color)DARKGRAY);
           
        EndDrawing();
    }
    //Fecha a janela de configurações
    CloseWindow();

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl $0x20, %edi
callq 0x2f81d
leaq 0x8f962(%rip), %rdx     # 0x99140
movl $0x23f, %edi            # imm = 0x23F
movl $0x6e, %esi
callq 0x2d555
leaq 0x8f96c(%rip), %rsi     # 0x99160
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0x5bb05
movl 0x10(%rbx), %eax
movl %eax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
movl $0x2, %edi
callq 0x7702b
callq 0x2d675
movl %eax, %r15d
testb %al, %al
jne 0x9d4c
movl $0x3, %r13d
movl $0xff00bfff, %ebx       # imm = 0xFF00BFFF
leaq 0x8f9b0(%rip), %r14     # 0x991ea
xorl %edi, %edi
callq 0x30328
movl %eax, %r12d
callq 0x30467
movsd 0x8f7bf(%rip), %xmm1    # 0x99010
movsd 0x8f7c7(%rip), %xmm2    # 0x99020
callq 0x4b771
testb %r12b, %al
jne 0x9871
movl $0x107, %edi            # imm = 0x107
callq 0x2fee8
testb %al, %al
je 0x987c
xorl %eax, %eax
testl %r13d, %r13d
setg %al
subl %eax, %r13d
callq 0x30467
movsd 0x8f7a7(%rip), %xmm1    # 0x99030
movsd 0x8f78f(%rip), %xmm2    # 0x99020
callq 0x4b771
testb %r12b, %al
jne 0x98a9
movl $0x106, %edi            # imm = 0x106
callq 0x2fee8
testb %al, %al
je 0x98b5
xorl %eax, %eax
cmpl $0x3, %r13d
setl %al
addl %eax, %r13d
callq 0x30467
movsd 0x8f77e(%rip), %xmm1    # 0x99040
movsd 0x8f756(%rip), %xmm2    # 0x99020
callq 0x4b771
andb %r12b, %al
cmpb $0x1, %al
jne 0x98eb
movl 0xcdf3c(%rip), %eax     # 0xd7818
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
subl %ecx, %eax
movl %eax, 0xcdf2d(%rip)     # 0xd7818
callq 0x30467
movsd 0x8f758(%rip), %xmm1    # 0x99050
movsd 0x8f720(%rip), %xmm2    # 0x99020
callq 0x4b771
andb %r12b, %al
cmpb $0x1, %al
jne 0x9922
movl 0xcdf06(%rip), %eax     # 0xd7818
xorl %ecx, %ecx
cmpl $0x2, %eax
setl %cl
addl %eax, %ecx
movl %ecx, 0xcdef6(%rip)     # 0xd7818
callq 0x30467
movsd 0x8f731(%rip), %xmm1    # 0x99060
movsd 0x8f739(%rip), %xmm2    # 0x99070
callq 0x4b771
andb %r12b, %al
cmpb $0x1, %al
jne 0x994a
xorb $0x1, 0xd04b7(%rip)     # 0xd9e01
callq 0x30467
movsd 0x8f729(%rip), %xmm1    # 0x99080
movsd 0x8f731(%rip), %xmm2    # 0x99090
callq 0x4b771
testb %r12b, %al
jne 0x9d4c
movl $0x101, %edi            # imm = 0x101
callq 0x2fee8
testb %al, %al
jne 0x9d4c
leal -0x1(%r13), %eax
cmpl $0x2, %eax
ja 0x99a0
movl %eax, %eax
leaq 0x8f85b(%rip), %rcx     # 0x991ec
movl (%rcx,%rax,4), %ecx
leaq 0x8f85d(%rip), %rdx     # 0x991f8
movl (%rdx,%rax,4), %eax
jmp 0x99aa
movl $0x1c2, %eax            # imm = 0x1C2
movl $0x320, %ecx            # imm = 0x320
movl %ecx, 0xcde60(%rip)     # 0xd7810
movl %eax, 0xcde5e(%rip)     # 0xd7814
callq 0x2d9da
movl $0xff3c2d23, %edi       # imm = 0xFF3C2D23
callq 0x2d9a5
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x8f7a5(%rip), %rdi     # 0x9918b
movaps 0x8f6b3(%rip), %xmm0    # 0x990a0
movss 0x8f73b(%rip), %xmm1    # 0x99130
movss 0x8f737(%rip), %xmm2    # 0x99134
movl $0xfff5f5f5, %esi       # imm = 0xFFF5F5F5
callq 0x5cfe7
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movaps %xmm1, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movl 0xcddeb(%rip), %esi     # 0xd7810
movl 0xcdde9(%rip), %edx     # 0xd7814
leaq 0x8f765(%rip), %rdi     # 0x99197
xorl %eax, %eax
callq 0x5d3c2
movq -0x60(%rbp), %rcx
movq %rcx, 0x20(%rsp)
movaps -0x80(%rbp), %xmm0
movaps -0x70(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rax, %rdi
movsd 0x8f652(%rip), %xmm0    # 0x990b0
movss 0x8f6d2(%rip), %xmm1    # 0x99138
movss 0x8f6ce(%rip), %xmm2    # 0x9913c
movl $0xff00bfff, %esi       # imm = 0xFF00BFFF
callq 0x5cfe7
movl 0xcdd9a(%rip), %eax     # 0xd7818
cmpl $0x1, %eax
leaq 0x8f727(%rip), %r15     # 0x991af
leaq 0x8f719(%rip), %rcx     # 0x991a8
cmoveq %rcx, %r15
cmpl $0x2, %eax
leaq 0x8f704(%rip), %rax     # 0x991a1
cmoveq %rax, %r15
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x8f6f4(%rip), %rdi     # 0x991b6
movsd 0x8f5f6(%rip), %xmm0    # 0x990c0
movss 0x8f65e(%rip), %xmm1    # 0x99130
movss 0x8f65a(%rip), %xmm2    # 0x99134
movl $0xfff5f5f5, %esi       # imm = 0xFFF5F5F5
callq 0x5cfe7
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movsd 0x8f5c7(%rip), %xmm0    # 0x990d0
movss 0x8f627(%rip), %xmm1    # 0x99138
movss 0x8f623(%rip), %xmm2    # 0x9913c
movl $0xff00bfff, %esi       # imm = 0xFF00BFFF
callq 0x5cfe7
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x8f67c(%rip), %rdi     # 0x991c0
movsd 0x8f594(%rip), %xmm0    # 0x990e0
movss 0x8f5dc(%rip), %xmm1    # 0x99130
movss 0x8f5d8(%rip), %xmm2    # 0x99134
movl $0xfff5f5f5, %esi       # imm = 0xFFF5F5F5
callq 0x5cfe7
cmpb $0x0, 0xd0294(%rip)     # 0xd9e01
leaq 0x8f662(%rip), %rdi     # 0x991d6
leaq 0x8f650(%rip), %rax     # 0x991cb
cmovneq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movsd 0x8f54f(%rip), %xmm0    # 0x990f0
movss 0x8f58f(%rip), %xmm1    # 0x99138
movss 0x8f58b(%rip), %xmm2    # 0x9913c
movl $0xff00bfff, %esi       # imm = 0xFF00BFFF
callq 0x5cfe7
movsd 0x8f4bd(%rip), %xmm0    # 0x99080
movsd 0x8f4c5(%rip), %xmm1    # 0x99090
movl $0xff00bfff, %edi       # imm = 0xFF00BFFF
callq 0x4a6a1
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
xorps %xmm2, %xmm2
leaq 0x8f5e8(%rip), %rdi     # 0x991e1
movsd 0x8f4ff(%rip), %xmm0    # 0x99100
movss 0x8f527(%rip), %xmm1    # 0x99130
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5cfe7
testl %r13d, %r13d
movl $0xff505050, %esi       # imm = 0xFF505050
cmovgl %ebx, %esi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x8f5a9(%rip), %r15     # 0x991e8
movq %r15, %rdi
movsd 0x8f3c6(%rip), %xmm0    # 0x99010
movss 0x8f4e6(%rip), %xmm1    # 0x99138
movss 0x8f4e2(%rip), %xmm2    # 0x9913c
callq 0x5cfe7
cmpl $0x3, %r13d
movl $0xff505050, %esi       # imm = 0xFF505050
cmovll %ebx, %esi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
movsd 0x8f480(%rip), %xmm0    # 0x99110
movss 0x8f4a0(%rip), %xmm1    # 0x99138
movss 0x8f49c(%rip), %xmm2    # 0x9913c
callq 0x5cfe7
cmpl $0x0, 0xcdb6c(%rip)     # 0xd7818
movl $0xff505050, %esi       # imm = 0xFF505050
cmovgl %ebx, %esi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movsd 0x8f367(%rip), %xmm0    # 0x99040
movss 0x8f457(%rip), %xmm1    # 0x99138
movss 0x8f453(%rip), %xmm2    # 0x9913c
callq 0x5cfe7
cmpl $0x2, 0xcdb23(%rip)     # 0xd7818
movl $0xff505050, %esi       # imm = 0xFF505050
cmovll %ebx, %esi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
movsd 0x8f3fe(%rip), %xmm0    # 0x99120
movss 0x8f40e(%rip), %xmm1    # 0x99138
movss 0x8f40a(%rip), %xmm2    # 0x9913c
callq 0x5cfe7
callq 0x2daa2
callq 0x2d675
movl %eax, %r15d
testb %al, %al
je 0x983a
callq 0x2d611
notb %r15b
andb $0x1, %r15b
movl %r15d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)