// File: /workspace/github_cpp_makefile_star2_O3/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 0x2f8a1
leaq 0x8f962(%rip), %rdx     # 0x99140
movl $0x23f, %edi            # imm = 0x23F
movl $0x6e, %esi
callq 0x2d5d9
leaq 0x8f96c(%rip), %rsi     # 0x99160
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0x5bb89
movl 0x10(%rbx), %eax
movl %eax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
movl $0x2, %edi
callq 0x770af
callq 0x2d6f9
testb %al, %al
je 0x9829
xorl %r15d, %r15d
jmp 0x9d50
movl $0x3, %r13d
movl $0xff00bfff, %ebx       # imm = 0xFF00BFFF
leaq 0x8f9af(%rip), %r14     # 0x991ea
xorl %edi, %edi
callq 0x303ac
movl %eax, %r12d
callq 0x304eb
movsd 0x8f7be(%rip), %xmm1    # 0x99010
movsd 0x8f7c6(%rip), %xmm2    # 0x99020
callq 0x4b7f5
testb %r12b, %al
jne 0x9872
movl $0x107, %edi            # imm = 0x107
callq 0x2ff6c
testb %al, %al
je 0x987d
xorl %eax, %eax
testl %r13d, %r13d
setg %al
subl %eax, %r13d
callq 0x304eb
movsd 0x8f7a6(%rip), %xmm1    # 0x99030
movsd 0x8f78e(%rip), %xmm2    # 0x99020
callq 0x4b7f5
testb %r12b, %al
jne 0x98aa
movl $0x106, %edi            # imm = 0x106
callq 0x2ff6c
testb %al, %al
je 0x98b6
xorl %eax, %eax
cmpl $0x3, %r13d
setl %al
addl %eax, %r13d
callq 0x304eb
movsd 0x8f77d(%rip), %xmm1    # 0x99040
movsd 0x8f755(%rip), %xmm2    # 0x99020
callq 0x4b7f5
andb %r12b, %al
cmpb $0x1, %al
jne 0x98ec
movl 0xcdf3b(%rip), %eax     # 0xd7818
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
subl %ecx, %eax
movl %eax, 0xcdf2c(%rip)     # 0xd7818
callq 0x304eb
movsd 0x8f757(%rip), %xmm1    # 0x99050
movsd 0x8f71f(%rip), %xmm2    # 0x99020
callq 0x4b7f5
andb %r12b, %al
cmpb $0x1, %al
jne 0x9923
movl 0xcdf05(%rip), %eax     # 0xd7818
xorl %ecx, %ecx
cmpl $0x2, %eax
setl %cl
addl %eax, %ecx
movl %ecx, 0xcdef5(%rip)     # 0xd7818
callq 0x304eb
movsd 0x8f730(%rip), %xmm1    # 0x99060
movsd 0x8f738(%rip), %xmm2    # 0x99070
callq 0x4b7f5
andb %r12b, %al
cmpb $0x1, %al
jne 0x994b
xorb $0x1, 0xd04b6(%rip)     # 0xd9e01
callq 0x304eb
movsd 0x8f728(%rip), %xmm1    # 0x99080
movsd 0x8f730(%rip), %xmm2    # 0x99090
callq 0x4b7f5
movb $0x1, %r15b
testb %r12b, %al
jne 0x9d50
movl $0x101, %edi            # imm = 0x101
callq 0x2ff6c
testb %al, %al
jne 0x9d50
leal -0x1(%r13), %eax
cmpl $0x2, %eax
ja 0x99a4
movl %eax, %eax
leaq 0x8f857(%rip), %rcx     # 0x991ec
movl (%rcx,%rax,4), %ecx
leaq 0x8f859(%rip), %rdx     # 0x991f8
movl (%rdx,%rax,4), %eax
jmp 0x99ae
movl $0x1c2, %eax            # imm = 0x1C2
movl $0x320, %ecx            # imm = 0x320
movl %ecx, 0xcde5c(%rip)     # 0xd7810
movl %eax, 0xcde5a(%rip)     # 0xd7814
callq 0x2da5e
movl $0xff3c2d23, %edi       # imm = 0xFF3C2D23
callq 0x2da29
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x8f7a1(%rip), %rdi     # 0x9918b
movaps 0x8f6af(%rip), %xmm0    # 0x990a0
movss 0x8f737(%rip), %xmm1    # 0x99130
movss 0x8f733(%rip), %xmm2    # 0x99134
movl $0xfff5f5f5, %esi       # imm = 0xFFF5F5F5
callq 0x5d06b
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 0xcdde7(%rip), %esi     # 0xd7810
movl 0xcdde5(%rip), %edx     # 0xd7814
xorl %r15d, %r15d
leaq 0x8f75e(%rip), %rdi     # 0x99197
xorl %eax, %eax
callq 0x5d446
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 0x8f64b(%rip), %xmm0    # 0x990b0
movss 0x8f6cb(%rip), %xmm1    # 0x99138
movss 0x8f6c7(%rip), %xmm2    # 0x9913c
movl $0xff00bfff, %esi       # imm = 0xFF00BFFF
callq 0x5d06b
movl 0xcdd93(%rip), %eax     # 0xd7818
cmpl $0x1, %eax
leaq 0x8f720(%rip), %r12     # 0x991af
leaq 0x8f712(%rip), %rcx     # 0x991a8
cmoveq %rcx, %r12
cmpl $0x2, %eax
leaq 0x8f6fd(%rip), %rax     # 0x991a1
cmoveq %rax, %r12
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x8f6ed(%rip), %rdi     # 0x991b6
movsd 0x8f5ef(%rip), %xmm0    # 0x990c0
movss 0x8f657(%rip), %xmm1    # 0x99130
movss 0x8f653(%rip), %xmm2    # 0x99134
movl $0xfff5f5f5, %esi       # imm = 0xFFF5F5F5
callq 0x5d06b
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r12, %rdi
movsd 0x8f5c0(%rip), %xmm0    # 0x990d0
movss 0x8f620(%rip), %xmm1    # 0x99138
movss 0x8f61c(%rip), %xmm2    # 0x9913c
movl $0xff00bfff, %esi       # imm = 0xFF00BFFF
callq 0x5d06b
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x8f675(%rip), %rdi     # 0x991c0
movsd 0x8f58d(%rip), %xmm0    # 0x990e0
movss 0x8f5d5(%rip), %xmm1    # 0x99130
movss 0x8f5d1(%rip), %xmm2    # 0x99134
movl $0xfff5f5f5, %esi       # imm = 0xFFF5F5F5
callq 0x5d06b
cmpb $0x0, 0xd028d(%rip)     # 0xd9e01
leaq 0x8f65b(%rip), %rdi     # 0x991d6
leaq 0x8f649(%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 0x8f548(%rip), %xmm0    # 0x990f0
movss 0x8f588(%rip), %xmm1    # 0x99138
movss 0x8f584(%rip), %xmm2    # 0x9913c
movl $0xff00bfff, %esi       # imm = 0xFF00BFFF
callq 0x5d06b
movsd 0x8f4b6(%rip), %xmm0    # 0x99080
movsd 0x8f4be(%rip), %xmm1    # 0x99090
movl $0xff00bfff, %edi       # imm = 0xFF00BFFF
callq 0x4a725
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 0x8f5e1(%rip), %rdi     # 0x991e1
movsd 0x8f4f8(%rip), %xmm0    # 0x99100
movss 0x8f520(%rip), %xmm1    # 0x99130
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5d06b
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 0x8f5a2(%rip), %r12     # 0x991e8
movq %r12, %rdi
movsd 0x8f3bf(%rip), %xmm0    # 0x99010
movss 0x8f4df(%rip), %xmm1    # 0x99138
movss 0x8f4db(%rip), %xmm2    # 0x9913c
callq 0x5d06b
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 0x8f479(%rip), %xmm0    # 0x99110
movss 0x8f499(%rip), %xmm1    # 0x99138
movss 0x8f495(%rip), %xmm2    # 0x9913c
callq 0x5d06b
cmpl $0x0, 0xcdb65(%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 %r12, %rdi
movsd 0x8f360(%rip), %xmm0    # 0x99040
movss 0x8f450(%rip), %xmm1    # 0x99138
movss 0x8f44c(%rip), %xmm2    # 0x9913c
callq 0x5d06b
cmpl $0x2, 0xcdb1c(%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 0x8f3f7(%rip), %xmm0    # 0x99120
movss 0x8f407(%rip), %xmm1    # 0x99138
movss 0x8f403(%rip), %xmm2    # 0x9913c
callq 0x5d06b
callq 0x2db26
callq 0x2d6f9
testb %al, %al
je 0x983b
callq 0x2d695
movl %r15d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop