xXNiKkI_DownXx

Breso BugBase Menu

May 3rd, 2023 (edited)
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.64 KB | None | 0 0
  1. //Largura e altura do mod
  2. float ModLargura = 320;
  3. float ModAltura = 500;
  4. float tamanhoFonte = 0.8f;
  5. float transparenciaMod = 0.8f;
  6.  
  7. int menuAtual = 0;                  //Index do menu atual
  8. int menuAnterior = 0;               //Index do menu atual
  9. int contadorOpcoes = 0;             //Armazena quantas opcoes tem o menu atual
  10. int opcaoSelecionada = 0;           //Armazena a opcao que ta selecionada no momento, no menu
  11.  
  12. float varTestes = 0.8f;
  13. int timer = 0;
  14.  
  15.  
  16. float bordaRedonda = 0.0;
  17. float ajustefino2 = 0.0;
  18.  
  19.  
  20. static ImVec4 CorTopo = ImVec4(0.2f, 1.0f, 0.2f, 0.8f);
  21. float testes[100];
  22.  
  23.  
  24. namespace BRESO
  25. {
  26. #define IsKeyPressed(key) GetAsyncKeyState(key) & 0x8000
  27.     enum Menus
  28.     {
  29.         fechado,
  30.         Principal,
  31.         Config,
  32.         Config2,
  33.     };
  34.  
  35.     void Vazio() {}
  36.  
  37.     bool Timer(int tempo = 50)
  38.     {
  39.         if (timer >= tempo)
  40.         {
  41.             timer = 0;
  42.             return true;
  43.         }
  44.         timer++;
  45.         return false;
  46.     }
  47.  
  48.     void Controles()
  49.     {
  50.         if (IsKeyPressed(VK_INSERT))
  51.         {
  52.             //Abrir o menu
  53.             if (Timer())
  54.             {
  55.                 if (menuAtual == 0)
  56.                     menuAtual = 1;
  57.                 else
  58.                     menuAtual = 0;
  59.             }
  60.         }
  61.         //if (IsKeyPressed(VK_UP))
  62.         //{
  63.         //    if (Timer(30))
  64.         //    {
  65.         //        if (opcaoSelecionada == 1)
  66.         //            opcaoSelecionada = contadorOpcoes;
  67.         //        else
  68.         //            opcaoSelecionada--;
  69.         //    }
  70.         //}
  71.         //if (IsKeyPressed(VK_DOWN))
  72.         //{
  73.         //    if (Timer(30))
  74.         //    {
  75.         //        if (opcaoSelecionada == contadorOpcoes)
  76.         //            opcaoSelecionada = 1;
  77.         //        else
  78.         //            opcaoSelecionada++;
  79.         //    }
  80.         //}
  81.     }
  82.  
  83.  
  84.      
  85.  
  86.     template<typename Func>
  87.     void addOption(const char* Texto, Func function, int indexOpcao = 0)
  88.     {
  89.         contadorOpcoes++;
  90.         ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.06f, 0.06f, 0.06f, 0.0));
  91.         ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  92.         ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  93.         ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0, 0.0)); // alinhar texto do botão à esquerda
  94.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 2.0));
  95.         if (ImGui::Button(Texto, ImVec2(ImGui::GetWindowContentRegionWidth(), 25))) {
  96.             function();
  97.         }
  98.         ImGui::PopStyleVar(2);
  99.         ImGui::PopStyleColor(3);
  100.  
  101.     }
  102.  
  103.  
  104.  
  105.     template<typename Func>
  106.     void addBool(const char* Texto, bool* boleta, Func function, int indexOpcao = 0)
  107.     {
  108.         contadorOpcoes++;
  109.         if (*boleta)
  110.         {
  111.             ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0, 1.0, 0.0, CorTopo.w));
  112.             ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  113.             ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.0, 1.0, 0.0, CorTopo.w));
  114.         }
  115.         else
  116.         {
  117.             ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(1.2, 0.2, 0.2, CorTopo.w));
  118.             ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  119.             ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(1.0, 0.0, 0.0, CorTopo.w));
  120.         }
  121.         char buffer[5000];
  122.         snprintf(buffer, 5000, "  %s", Texto);
  123.  
  124.         ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0, 0.0)); // alinhar texto do botão à esquerda
  125.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0,2.0));
  126.          
  127.         ImGui::Text(buffer);
  128.         ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetFontSize() - ImGui::GetStyle().FramePadding.x - 17.000);
  129.  
  130.         char buffer2[5000];
  131.         snprintf(buffer2, 5000, "##%s", Texto);
  132.  
  133.         ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.0f);
  134.         if (boleta)
  135.         {
  136.             if (ImGui::Checkbox(buffer2, boleta)) {
  137.                 function();
  138.             }
  139.         }
  140.         else
  141.         {
  142.             if (ImGui::Checkbox(buffer2, boleta)) {
  143.                 function();
  144.             }
  145.         }
  146.         ImGui::PopStyleVar(3);
  147.         ImGui::PopStyleColor(3);
  148.         //-----------------------------------------------------------
  149.  
  150.         // ..
  151.  
  152.     }
  153.  
  154.     void addBreak()
  155.     {
  156.         contadorOpcoes++;
  157.         ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.06f, 0.06f, 0.06f, 0.0));
  158.         ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  159.         ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  160.         //ImGui::PushStyleVar(ImGuiStyleVar_FrameBgTextAlign, ImVec2(0.0, 0.5)); // alinhar texto do botão à esquerda
  161.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0,2.0));
  162.         ImGui::Separator();
  163.         ImGui::PopStyleVar(1);
  164.         ImGui::PopStyleColor(3);
  165.  
  166.     }
  167.  
  168.     template<typename Func>
  169.     void addFloat_Drag(const char* Texto, float* variavel, float min, float max, float velocidade, Func function, int indexOpcao = 0)
  170.     {
  171.         ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.06f, 0.06f, 0.06f, 0.0));
  172.         ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  173.         ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  174.         //ImGui::PushStyleVar(ImGuiStyleVar_FrameBgTextAlign, ImVec2(0.0, 0.5)); // alinhar texto do botão à esquerda
  175.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 2.0));
  176.         if (ImGui::DragFloat(Texto, variavel, velocidade, min, max)) {
  177.             function();
  178.         }
  179.         ImGui::PopStyleVar(1);
  180.         ImGui::PopStyleColor(3);
  181.  
  182.     }
  183.  
  184.     template<typename Func>
  185.     void addFloat_Input(const char* Texto, float* variavel, float min, float max, float velocidade, Func function, int indexOpcao = 0)
  186.     {
  187.         contadorOpcoes++;
  188.  
  189.         ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.06f, 0.06f, 0.06f, 0.0));
  190.         ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  191.         ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  192.         ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  193.         ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.06f, 0.06f, 0.06f, 0.0f));
  194.         ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  195.         ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  196.         //ImGui::PushStyleVar(ImGuiStyleVar_FrameBgTextAlign, ImVec2(0.0, 0.5)); // alinhar texto do botão à esquerda
  197.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 2.0));
  198.         if (ImGui::InputFloat(Texto, variavel, velocidade)) {
  199.             function();
  200.         }
  201.         float a = *variavel;
  202.         if (*variavel > max)
  203.             *variavel = max;
  204.         else if (*variavel <= min)
  205.             *variavel = min;
  206.         ImGui::PopStyleVar(1);
  207.         ImGui::PopStyleColor(7);
  208.  
  209.     }
  210.  
  211.     template<typename Func>
  212.     void addSubMenu(const char* Texto, int MenuAtual, int MenuIndex, Func function = Vazio())
  213.     {
  214.         contadorOpcoes++;
  215.         ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.06f, 0.06f, 0.06f, 0.0));
  216.         ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  217.         ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  218.         ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0, 0.0)); // alinhar texto do botão à esquerda
  219.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 2.0));
  220.         if (ImGui::Button(Texto, ImVec2(ImGui::GetWindowContentRegionWidth(), 25))) {
  221.             function();
  222.             menuAnterior = MenuAtual;
  223.             menuAtual = MenuIndex;
  224.         }
  225.         ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetFontSize() - ImGui::GetStyle().FramePadding.x - 8.0);
  226.         ImGui::Text(">>");
  227.         ImGui::PopStyleVar(2);
  228.         ImGui::PopStyleColor(3);
  229.  
  230.     }
  231.  
  232.  
  233.     template<typename Func>
  234.     void Menu(const char* Titulo, Func function)
  235.     {
  236.         ImGui::SetNextWindowBgAlpha(transparenciaMod);
  237.         ImGuiStyle& style = ImGui::GetStyle();
  238.  
  239.         //style.WindowPadding.x = -4.0;
  240.         //style.WindowPadding.y = 23.0;
  241.         style.WindowRounding = bordaRedonda;
  242.         ImGui::SetNextWindowSize(ImVec2(ModLargura, ModAltura)); // definir tamanho da janela
  243.         ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(-4.0, 1.0));
  244.         ImGui::Begin(Titulo, nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar);
  245.         {
  246.             ImGui::SetWindowFontScale(tamanhoFonte);
  247.             ImGui::SetCursorPos(ImVec2((ImGui::GetWindowWidth() - ImGui::GetWindowContentRegionWidth()) / 2, 0)); // centralizar botão no topo
  248.             ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.5, 0.5)); // alinhar texto do botão à esquerda
  249.             ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  250.             ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  251.             ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  252.             ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.06f, 0.06f, 0.06f, 1.0));
  253.  
  254.            
  255.            
  256.        
  257.  
  258.             if (ImGui::Button(Titulo, ImVec2(ImGui::GetWindowContentRegionWidth(), 50))) {
  259.             }
  260.             ImGui::PopStyleColor(4);
  261.             ImGui::PopStyleVar();  
  262.  
  263.             ImGui::BeginChild("##");
  264.             {
  265.                 function();
  266.             }
  267.             ImGui::EndChild();
  268.         }
  269.         ImGui::PopStyleVar();
  270.         ImGui::End();
  271.         contadorOpcoes = 0;
  272.     }
  273.  
  274.  
  275.  
  276.     template<typename Func>
  277.     void addColor(const char* Texto, ImVec4* corVariavel, Func function, int indexOpcao = 0)
  278.     {
  279.         contadorOpcoes++;
  280.         ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0, 0.0, 0.0, CorTopo.w));
  281.         ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  282.         ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.0, 1.0, 0.0, CorTopo.w));
  283.  
  284.         ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0, 0.0)); // alinhar texto do botão à esquerda
  285.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 2.0));
  286.  
  287.         char buffer[5000];
  288.         snprintf(buffer, 5000, "  %s", Texto);
  289.  
  290.  
  291.  
  292.  
  293.         ImGui::Text(buffer);
  294.         ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetFontSize() - ImGui::GetStyle().FramePadding.x - 15.000);
  295.  
  296.         char buffer2[5000];
  297.         snprintf(buffer2, 5000, "##%s", Texto);
  298.         if (ImGui::ColorEdit4(buffer2, (float*)corVariavel, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel))
  299.         {
  300.             function();
  301.         }
  302.  
  303.         ImGui::PopStyleVar(2);
  304.         ImGui::PopStyleColor(3);
  305.         //-----------------------------------------------------------
  306.  
  307.         // ..
  308.  
  309.  
  310.  
  311.     }
  312.  
  313.     template<typename Func>
  314.     void addArray(const char* TextoBotao, const char* descricaoCombo, int* itemAtual, const char* const Array[], Func function, int indexOpcao = 0)
  315.     {
  316.         contadorOpcoes++;
  317.         ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.06f, 0.06f, 0.06f, 0.0));
  318.         ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  319.         ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  320.         ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  321.         ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  322.         ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  323.         ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  324.         ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(CorTopo.x, CorTopo.y, CorTopo.z, CorTopo.w));
  325.         ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(-1.400, 34.000)); // alinhar texto do botão à esquerda
  326.         ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6.000, 5.000));
  327.  
  328.         ImGui::Text(descricaoCombo);
  329.         ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetFontSize() - ImGui::GetStyle().FramePadding.x - 70.000);
  330.         ImGui::SameLine();
  331.         ImGui::SetNextItemWidth(180.000);
  332.         ImGui::Combo(" ", itemAtual, Array, sizeof(Array));
  333.         ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetFontSize() - ImGui::GetStyle().FramePadding.x - 70.000);
  334.  
  335.         ImGui::SetNextItemWidth(5.000);
  336.         if (ImGui::Button(TextoBotao))
  337.         {
  338.             function();
  339.  
  340.         }
  341.  
  342.         ImGui::PopStyleVar(2);
  343.         ImGui::PopStyleColor(8);
  344.  
  345.     }
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352. }
  353.  
  354.  
Add Comment
Please, Sign In to add comment