treballant en ServiceMenu
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "service_menu.h"
|
||||
#include <iostream>
|
||||
#include "screen.h"
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
// Singleton
|
||||
ServiceMenu *ServiceMenu::instance_ = nullptr;
|
||||
@@ -13,71 +14,20 @@ void ServiceMenu::destroy() { delete ServiceMenu::instance_; }
|
||||
// Obtiene la instancia
|
||||
ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
|
||||
|
||||
// Constructor
|
||||
ServiceMenu::ServiceMenu() {
|
||||
// Inicializa los valores por defecto del menú de servicio
|
||||
is_active = false;
|
||||
selected_option = 0;
|
||||
options = {"Test de Sonido", "Test de Video", "Contadores", "Salir"};
|
||||
void ServiceMenu::toggle()
|
||||
{
|
||||
enabled_ = !enabled_;
|
||||
}
|
||||
|
||||
void ServiceMenu::show() {
|
||||
is_active = true;
|
||||
while (is_active) {
|
||||
render();
|
||||
handle_input();
|
||||
void ServiceMenu::render()
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
SDL_FRect rect = {10.0f, 10.0f, 100.0f, 100.0f};
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &rect);
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceMenu::render() {
|
||||
std::cout << "=== MENÚ DE SERVICIO ===" << std::endl;
|
||||
for (size_t i = 0; i < options.size(); ++i) {
|
||||
if (i == selected_option)
|
||||
std::cout << "> ";
|
||||
else
|
||||
std::cout << " ";
|
||||
std::cout << options[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceMenu::handle_input() {
|
||||
char input;
|
||||
std::cin >> input;
|
||||
switch (input) {
|
||||
case 'w':
|
||||
if (selected_option > 0) selected_option--;
|
||||
break;
|
||||
case 's':
|
||||
if (selected_option < options.size() - 1) selected_option++;
|
||||
break;
|
||||
case '\n':
|
||||
case '\r':
|
||||
case 'e':
|
||||
execute_option(selected_option);
|
||||
break;
|
||||
case 'q':
|
||||
is_active = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceMenu::execute_option(size_t option) {
|
||||
switch (option) {
|
||||
case 0:
|
||||
std::cout << "Ejecutando test de sonido..." << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Ejecutando test de video..." << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Mostrando contadores..." << std::endl;
|
||||
break;
|
||||
case 3:
|
||||
is_active = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
void ServiceMenu::update()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user