//--------------------------------------------------------------------------------------
// Copyright (C) 2008 http://shift.delblanco.es
//--------------------------------------------------------------------------------------
// SHIFT Videogame is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
//--------------------------------------------------------------------------------------
// GUI.cpp
//--------------------------------------------------------------------------------------
#include "dxstdafx.h"

#include <string>
#include "GUI.h"
#include "Menu.h"
#include "Settings.h"

//--------------------------------------------------------------------------------------
// Espacio de nombres
//--------------------------------------------------------------------------------------
using namespace std;

//--------------------------------------------------------------------------------------
// Variables Globales
//--------------------------------------------------------------------------------------
CGUI              *g_GUI;            // Instancia para el GUI
extern CMenu      *g_Menu;           // Instancia externa para el menú 3D (Menu.cpp)
extern CSettings  *g_Settings;       // Instancia externa para las opciones (Settings.cpp)
extern bool       g_bCreated;        // Para saber si se creó el dispositivo (Main.cpp)
extern float      g_TimeGame;        // Tiempo de juego (Game.cpp)

//--------------------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------------------
CGUI::CGUI()
{
    // Inicializamos punteros
    m_pDevice = NULL;
    m_pFont = NULL;
    m_pTextSprite = NULL;
    m_pGUI = NULL;

    // Inicializamos el vector de índices de comboboxes
    for(int i = 0 ; i < GUI_MAX_ITEMS_COMBOBOX ; i++)
        m_piIndex[i] = i;

    // Inicializamos variables
    m_iType = 0;
    m_iTypeGame = 0;
    m_iTypeArena = 0;
    m_iTypeVehicle = 0;
    m_iArena = 0;
    m_iVehicle = 0;
    m_inumArenas = 0;
    m_inumVehicles = 0;

    m_bInit = false;
    m_bIsServer = true;
    m_bStadistics = false;
    m_bPaused = false;
    m_bGamming = false;
}

//--------------------------------------------------------------------------------------
// Destructor
//--------------------------------------------------------------------------------------
CGUI::~CGUI()
{
    Release();
}

//--------------------------------------------------------------------------------------
// Inicia el GUI ante un CreateDevice
//--------------------------------------------------------------------------------------
bool CGUI::initialize()
{
    // Salimos si ya se ha inicializado
    if(m_bInit) return false;
    m_bInit = true;

    // Tomamos el dispositivo
    m_pDevice = DXUTGetD3DDevice();
    assert(m_pDevice != NULL);
    m_pDevice->AddRef();

    // Inicializamos el GUI
    m_pGUI = new CDXUTDialog();
    if(!m_pGUI) return false;
    m_aCtrls.clear();

    // Inicializamos la fuente de texto
    if( FAILED(D3DXCreateFont( m_pDevice, 14, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, 
                               OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, 
                               L"Arial", &m_pFont ) ) ) return false;

    // Inicializamos los parametros basicos por defecto
    m_pGUI->SetCallback( OnGUIEvent );

    // Tomamos la resolución actual
    m_uHeight = DXUTGetPresentParameters().BackBufferHeight;
    m_uWidth = DXUTGetPresentParameters().BackBufferWidth;
    m_uMidW = m_uWidth/2;
    m_uMidH = m_uHeight/2;

    // Creamos las fuentes
    m_pGUI->SetFont(GUI_FONT_MENU, L"Arial", 16, FW_BOLD);
    m_pGUI->SetFont(GUI_FONT_TITLE, L"Arial", 120, FW_EXTRABOLD);
    m_pGUI->SetFont(GUI_FONT_WARNING, L"Arial", 90, FW_EXTRABOLD);
    m_pGUI->SetFont(GUI_FONT_CREDITS, L"Arial", 14, FW_BOLD);
    m_pGUI->SetFont(GUI_FONT_INFO, L"Arial", 20, FW_BOLD);
    m_pGUI->SetFont(GUI_FONT_INFO_2, L"Arial", 16, FW_BOLD);
    m_pGUI->SetFont(GUI_FONT_TITLE_2, L"Arial", 90, FW_EXTRABOLD);
    m_pGUI->SetFont(GUI_FONT_COUNTER, L"Courier New", 80, FW_EXTRABOLD);
    m_pGUI->SetFont(GUI_FONT_DESCRIPTION, L"Arial", 15, FW_SEMIBOLD);
    m_pGUI->SetFont(GUI_FONT_MAP, L"Arial", 25, FW_EXTRABOLD);

    //----------------------------------------------------------------------------------
    // Creamos el texto de los créditos (esquinas superior e inferior derecha)
    m_pGUI->AddListBox(GUI_LISTBOX_CREDITS_UP, -50,             0, m_uWidth + 100, 20, 0);
    m_aCtrls.push_back(m_pGUI->GetListBox(GUI_LISTBOX_CREDITS_UP));

    m_pGUI->AddListBox(GUI_LISTBOX_CREDITS_DW, -50, m_uWidth - 20, m_uWidth + 100, 20, 0);
    m_aCtrls.push_back(m_pGUI->GetListBox(GUI_LISTBOX_CREDITS_DW));

    //----------------------------------------------------------------------------------
    // Elementos varios que se utilizan en diferentes tipos de GUI
    m_pGUI->AddStatic(GUI_STATIC_TITULO_2, L"", m_uMidW - 400, 30, 800, 200);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_TITULO_2));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 200, 200, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_CENTER|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_TITLE_2;

    m_pGUI->AddStatic(GUI_STATIC_INFO, L"", m_uMidW - 400, 120, 800, 100);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_INFO));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_CENTER|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO;

    m_pGUI->AddStatic(GUI_STATIC_INFO_2, L"", m_uMidW - 400, 150, 800, 40);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_INFO_2));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_CENTER|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO;

    m_pGUI->AddButton(GUI_BTN_ACCEPT, L"OK", m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20), GUI_BTN_W_2, GUI_BTN_H_2);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_ACCEPT));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddButton(GUI_BTN_CANCEL, L"Cancel", m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20), GUI_BTN_W_2, GUI_BTN_H_2);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_CANCEL));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddStatic(GUI_STATIC_COUNTER, L"", m_uMidW - 100, m_uMidH + 80, 200, 150);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_COUNTER));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(70, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_CENTER|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_COUNTER;

    m_pGUI->AddStatic(GUI_STATIC_INFO_2, L"", m_uMidW - 400, 150, 800, 40);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_INFO_2));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_CENTER|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO;

    m_pGUI->AddStatic(GUI_STATIC_RANK, L"", m_uMidW - 400, m_uMidH - 150, 500, 300);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_RANK));
    m_aCtrls.back()->SetTextColor( D3DCOLOR_ARGB( 90, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO;

	//----------------------------------------------------------------------------------
    // Creamos GUI de avisos (GUI_TYPE_WARNING)
    m_pGUI->AddStatic(GUI_STATIC_WARNING, L"", m_uMidW - 400, m_uMidH - 150, 800, 300);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_WARNING));
    m_aCtrls.back()->SetTextColor( D3DCOLOR_ARGB( 60, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_CENTER|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_WARNING;

    //----------------------------------------------------------------------------------
    // Creamos GUI del menú inicial (GUI_TYPE_MENU_INIT)
    m_pGUI->AddStatic(GUI_STATIC_TITULO, L"SHIFT", m_uMidW - 400, 20, 800, 200);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_TITULO));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB( 80, 200, 200, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_CENTER|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_TITLE;

    m_pGUI->AddButton(GUI_BTN_NEWGAME, L"New Game", m_uMidW - GUI_BTN_W/2, m_uMidH + GUI_BTN_H_SPACE, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_NEWGAME));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddButton(GUI_BTN_SETT, L"Options", m_uMidW - GUI_BTN_W/2, m_uMidH, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_SETT));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddButton(GUI_BTN_EXIT, L"Exit", m_uMidW - GUI_BTN_W/2, m_uMidH - GUI_BTN_H_SPACE, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_EXIT));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    //----------------------------------------------------------------------------------
    // Creamos GUI de opciones (GUI_TYPE_SETT)
    // Texto común
    m_pGUI->AddStatic(GUI_STATIC_SETT, L"", m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI - 12, GUI_SETT_W, 500);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_SETT));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(120, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;

    m_pGUI->AddButton(GUI_BTN_SETT_DISPLAY, L"Display options", m_uMidW - GUI_BTN_W/2, m_uMidH - GUI_BTN_H_SPACE, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_SETT_DISPLAY));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddButton(GUI_BTN_SETT_SOUND, L"Sound Options", m_uMidW - GUI_BTN_W/2, m_uMidH, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_SETT_SOUND));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddButton(GUI_BTN_SETT_GAME, L"Game Options", m_uMidW - GUI_BTN_W/2, m_uMidH + GUI_BTN_H_SPACE, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_SETT_GAME));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    //----------------------------------------------------------------------------------
    // Creamos GUI de opciones de video (GUI_TYPE_SETT_DISPLAY)
    m_pGUI->AddComboBox(GUI_CMBBX_SETT_QUALITY, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0, GUI_SETT_W, GUI_SETT_H);
    m_pGUI->GetComboBox(GUI_CMBBX_SETT_QUALITY)->SetDropHeight(50);
    m_aCtrls.push_back(m_pGUI->GetComboBox(GUI_CMBBX_SETT_QUALITY));

    m_pGUI->AddComboBox(GUI_CMBBX_SETT_WINFULL, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*1, GUI_SETT_W, GUI_SETT_H);
    m_pGUI->GetComboBox(GUI_CMBBX_SETT_WINFULL)->SetDropHeight(20);
    m_aCtrls.push_back(m_pGUI->GetComboBox(GUI_CMBBX_SETT_WINFULL));

    m_pGUI->AddComboBox(GUI_CMBBX_SETT_STADISTICS, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*2, GUI_SETT_W, GUI_SETT_H);
    m_pGUI->GetComboBox(GUI_CMBBX_SETT_STADISTICS)->SetDropHeight(20);
    m_aCtrls.push_back(m_pGUI->GetComboBox(GUI_CMBBX_SETT_STADISTICS));

    m_pGUI->AddComboBox(GUI_CMBBX_SETT_RESOLUTION, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*4, GUI_SETT_W, GUI_SETT_H);
    m_pGUI->GetComboBox(GUI_CMBBX_SETT_RESOLUTION)->SetDropHeight(50);
    m_aCtrls.push_back(m_pGUI->GetComboBox(GUI_CMBBX_SETT_RESOLUTION));

    m_pGUI->AddComboBox(GUI_CMBBX_SETT_FILTER, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*5, GUI_SETT_W, GUI_SETT_H);
    m_pGUI->GetComboBox(GUI_CMBBX_SETT_FILTER)->SetDropHeight(35);
    m_aCtrls.push_back(m_pGUI->GetComboBox(GUI_CMBBX_SETT_FILTER));

    m_pGUI->AddComboBox(GUI_CMBBX_SETT_MIPMAPPING, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*6, GUI_SETT_W, GUI_SETT_H);
    m_pGUI->GetComboBox(GUI_CMBBX_SETT_MIPMAPPING)->SetDropHeight(20);
    m_aCtrls.push_back(m_pGUI->GetComboBox(GUI_CMBBX_SETT_MIPMAPPING));

    //----------------------------------------------------------------------------------
    // Creamos GUI de opciones de sonido (GUI_TYPE_SETT_SOUND)
    m_pGUI->AddSlider(GUI_SLIDER_SETT_MUSIC, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0 + 5, 200, 20, 1, 100, 20);
    m_aCtrls.push_back(m_pGUI->GetSlider(GUI_SLIDER_SETT_MUSIC));

    m_pGUI->AddSlider(GUI_SLIDER_SETT_EFFECTS, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*2 + 5, 200, 20, 1, 100, 20);
    m_aCtrls.push_back(m_pGUI->GetSlider(GUI_SLIDER_SETT_EFFECTS));

    //----------------------------------------------------------------------------------
    // Creamos GUI de opciones de juego (GUI_TYPE_SETT_GAME)
    m_pGUI->AddEditBox(GUI_EDITBOX_SETT_NAME, L"", m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0 + 5, GUI_SETT_W, 30);
    m_aCtrls.push_back(m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME));

    m_pGUI->AddEditBox(GUI_EDITBOX_SETT_SERVER, L"", m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*2 + 5, GUI_SETT_W, 30);
    m_aCtrls.push_back(m_pGUI->GetEditBox(GUI_EDITBOX_SETT_SERVER));

    m_pGUI->AddSlider(GUI_SLIDER_SETT_MULTI_1, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*4 + 5, 200, 20, 1, 100, 20);
    m_aCtrls.push_back(m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_1));

    m_pGUI->AddSlider(GUI_SLIDER_SETT_MULTI_2, m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*6 + 5, 200, 20, 1, 100, 20);
    m_aCtrls.push_back(m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_2));

    //----------------------------------------------------------------------------------
    // Creamos GUI de nuevo juego (GUI_TYPE_NEW_GAME)
    m_pGUI->AddButton(GUI_BTN_MONOPLAYER, L"Monoplayer Game", m_uMidW - GUI_BTN_W/2, m_uMidH - GUI_BTN_H_SPACE, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_MONOPLAYER));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddButton(GUI_BTN_MULTIPLAYER, L"Multiplayer Game", m_uMidW - GUI_BTN_W/2, m_uMidH, GUI_BTN_W, GUI_BTN_H);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_MULTIPLAYER));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    //----------------------------------------------------------------------------------
    // Creamos GUI de seleccionar la IP del servidor o serlo (GUI_TYPE_SELECT_SERVER)
    m_pGUI->AddRadioButton(GUI_RADIO_SERVER_1, GUI_RADIO_SERVER, L"Connect to a existing game (CLIENT)", m_uMidW - 120, m_uMidH - 90, 300, 20);
    m_aCtrls.push_back(m_pGUI->GetRadioButton(GUI_RADIO_SERVER_1));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddRadioButton(GUI_RADIO_SERVER_2, GUI_RADIO_SERVER, L"Create a new game (SERVER)", m_uMidW - 120, m_uMidH - 60, 300, 20);
    m_aCtrls.push_back(m_pGUI->GetRadioButton(GUI_RADIO_SERVER_2));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    //----------------------------------------------------------------------------------
    // Creamos GUI de esperar por clientes (GUI_TYPE_WAIT_CLIENTS)
    m_pGUI->AddListBox(GUI_LISTBOX_CLIENTES, m_uMidW - 250, m_uMidH - m_uHeight/4 + 25, 120, m_uMidH, 0);
    m_aCtrls.push_back(m_pGUI->GetListBox(GUI_LISTBOX_CLIENTES));

    m_pGUI->AddListBox(GUI_LISTBOX_CHAT, m_uMidW - 110, m_uMidH - m_uHeight/4 + 25, 360, m_uMidH, 0);
    m_aCtrls.push_back(m_pGUI->GetListBox(GUI_LISTBOX_CHAT));

    m_pGUI->AddEditBox(GUI_EDITBOX_CHAT, L"", m_uMidW - 110, m_uMidH + m_uHeight/4 + 35, 360, 30);
    m_aCtrls.push_back(m_pGUI->GetEditBox(GUI_EDITBOX_CHAT));

    //----------------------------------------------------------------------------------
    // Creamos GUI de nuevo juego multijugador (GUI_TYPE_NEW_MULTI)
    m_pGUI->AddRadioButton(GUI_RADIO_MULTI_1, GUI_RADIO_MULTI, L"Objective Counter", m_uMidW - 60, m_uMidH - 100, 200, 20);
    m_aCtrls.push_back(m_pGUI->GetRadioButton(GUI_RADIO_MULTI_1));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddRadioButton(GUI_RADIO_MULTI_2, GUI_RADIO_MULTI, L"Death Match", m_uMidW - 60, m_uMidH - 70, 200, 20);
    m_aCtrls.push_back(m_pGUI->GetRadioButton(GUI_RADIO_MULTI_2));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    m_pGUI->AddRadioButton(GUI_RADIO_MULTI_3, GUI_RADIO_MULTI, L"Last Car Alive", m_uMidW - 60, m_uMidH - 40, 200, 20);
    m_aCtrls.push_back(m_pGUI->GetRadioButton(GUI_RADIO_MULTI_3));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MENU;
    m_aCtrls.back()->GetElement(1)->iFont = GUI_FONT_MENU;

    //----------------------------------------------------------------------------------
    // Creamos GUI de seleccionar la arena (GUI_TYPE_SELECT_ARENA)
    // Creamos GUI de seleccionar el vehículo (GUI_TYPE_SELECT_VEHICLE)
    m_pGUI->AddButton(GUI_BTN_SELECT_PRIOR, L"<<", m_uMidW, m_uHeight - 100, 50, GUI_BTN_H_3);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_SELECT_PRIOR));

    m_pGUI->AddButton(GUI_BTN_SELECT_NEXT, L">>", m_uMidW + GUI_BTN_W_3 + 5, m_uHeight - 100, 50, GUI_BTN_H_3);
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_SELECT_NEXT));

    m_pGUI->AddListBox(GUI_LISTBOX_SELECT_ARENA, 50, m_uMidH - m_uMidH/2 + 25, 200, m_uMidH/2);
    m_aCtrls.push_back(m_pGUI->GetListBox(GUI_LISTBOX_SELECT_ARENA));

    m_pGUI->AddListBox(GUI_LISTBOX_SELECT_VEHICLE, 50, m_uMidH - m_uMidH/2 + 25, 200, m_uMidH/2);
    m_aCtrls.push_back(m_pGUI->GetListBox(GUI_LISTBOX_SELECT_VEHICLE));

    m_pGUI->AddStatic(GUI_STATIC_ARENA_INFO, L"", 50, m_uMidH + 35, 400, 200);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_ARENA_INFO));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(120, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_DESCRIPTION;

    m_pGUI->AddStatic(GUI_STATIC_ARENA_MINFO, L"", 100, 100, 400, 200);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_ARENA_MINFO));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_DESCRIPTION;

    m_pGUI->AddStatic(GUI_STATIC_VEHICLE_INFO, L"", 50, m_uMidH + 35, 400, 200);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_VEHICLE_INFO));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(120, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_DESCRIPTION;

    m_pGUI->AddStatic(GUI_STATIC_VEHICLE_MINFO, L"", 100, 100, 400, 200);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_VEHICLE_MINFO));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(80, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_DESCRIPTION;

    m_pGUI->AddStatic(GUI_STATIC_GAME_INFO, L"", m_uMidW - 200, m_uMidH - 35, 400, 200);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_GAME_INFO));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(100, 255, 255, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_DESCRIPTION;

    //----------------------------------------------------------------------------------
    // Creamos GUI del interfaz de juego (GUI_TYPE_INTERFAZ_GAME)
    m_pGUI->AddButton(GUI_BTN_GAME_PAUSE, L"Pause (P)", m_uWidth - (GUI_BTN_W_3 + 5), m_uHeight - 70, GUI_BTN_W_3, GUI_BTN_H_3, L'P');
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_GAME_PAUSE));

    m_pGUI->AddStatic(GUI_STATIC_INFO_3a, L"", 5, 25, 400, 20);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_INFO_3a));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(150, 220, 220, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO_2;

    m_pGUI->AddStatic(GUI_STATIC_INFO_3b, L"", 5, 40, 400, 20);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_INFO_3b));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(150, 220, 220, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO_2;

    m_pGUI->AddStatic(GUI_STATIC_INFO_3c, L"", 5, 55, 400, 20);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_INFO_3c));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(150, 220, 220, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO_2;

    m_pGUI->AddStatic(GUI_STATIC_INFO_3d, L"", 5, 70, 400, 20);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_INFO_3d));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(100, 220, 220, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_INFO_2;

    //----------------------------------------------------------------------------------
    // Elementos para el mini-mapa
    m_pGUI->AddEditBox(GUI_EDITBOX_MAP, L"", 0, m_uHeight - 20 - 60, 60, 60);
    m_aCtrls.push_back(m_pGUI->GetEditBox(GUI_EDITBOX_MAP));

    m_pGUI->AddStatic(GUI_STATIC_MAP1, L".", -100, -100, 20, 20);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_MAP1));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(100, 0, 0, 0));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MAP;

    m_pGUI->AddStatic(GUI_STATIC_MAP2, L".", -100, -100, 20, 20);
    m_aCtrls.push_back(m_pGUI->GetStatic(GUI_STATIC_MAP2));
    m_aCtrls.back()->SetTextColor(D3DCOLOR_ARGB(100, 0, 0, 255));
    m_aCtrls.back()->GetElement(0)->dwTextFormat = DT_LEFT|DT_TOP;
    m_aCtrls.back()->GetElement(0)->iFont = GUI_FONT_MAP;

	//----------------------------------------------------------------------------------
    // Creamos GUI del menú durante el juego (GUI_TYPE_PAUSE_GAME)
    m_pGUI->AddButton(GUI_BTN_GAME_OPTIONS, L"Options (O)", m_uWidth - GUI_BTN_W_3, m_uHeight - 100, GUI_BTN_W_3, GUI_BTN_H_3, L'O');
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_GAME_OPTIONS));

    m_pGUI->AddButton(GUI_BTN_GAME_EXIT, L"Exit (X)", m_uWidth - GUI_BTN_W_3, m_uHeight - 80, GUI_BTN_W_3, GUI_BTN_H_3, L'X');
    m_aCtrls.push_back(m_pGUI->GetButton(GUI_BTN_GAME_EXIT));

    return 1;
}

//--------------------------------------------------------------------------------------
// Renderiza el GUI ante un FrameRender
//--------------------------------------------------------------------------------------
void CGUI::render()
{
    // Salimos si no se ha inicializado
    if(!m_bInit) return;

    // Renderizamos el GUI
    m_pGUI->OnRender(DXUTGetElapsedTime());

    // Imprimimos la versión del programa
    CDXUTTextHelper txtVersion(m_pFont, m_pTextSprite, 14);
    txtVersion.Begin();
    txtVersion.SetInsertionPos(m_uWidth - 125, 3);
    txtVersion.SetForegroundColor(D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.5f));
	txtVersion.DrawTextLine(L"SHIFT Videogame v1.0");
    txtVersion.End();

    // Imprimimos la versión del programa
    CDXUTTextHelper txtURL(m_pFont, m_pTextSprite, 14);
    txtURL.Begin();
    txtURL.SetInsertionPos(m_uWidth - 132, m_uHeight - 16);
    txtURL.SetForegroundColor(D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.5f));
	txtURL.DrawTextLine(L"http://shift.delblanco.es");
    txtURL.End();

    // Imprimimos las estadísticas
    if(m_bStadistics)
    {
        CDXUTTextHelper txtStadistics(m_pFont, m_pTextSprite, 14);
        txtStadistics.Begin();
        txtStadistics.SetInsertionPos(5, 3);
        txtStadistics.SetForegroundColor(D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.5f));
        txtStadistics.DrawTextLine(DXUTGetFrameStats());
        txtStadistics.End();
    }

}

//--------------------------------------------------------------------------------------
// Actualiza el GUI ante un FrameMove
//--------------------------------------------------------------------------------------
void CGUI::update()
{
    // No es necesario realizar ninguna tarea de actualización
}

//--------------------------------------------------------------------------------------
// Restaura objetos ante un ResetDevice
//--------------------------------------------------------------------------------------
void CGUI::restore()
{
    // Salimos si no se ha inicializado
    if(!m_bInit) return;

    // Restauramos el texto
    m_pFont->OnResetDevice();

    // Creamos el sprite para cuando hay varias líneas de texto
    D3DXCreateSprite(m_pDevice, &m_pTextSprite);
}

//--------------------------------------------------------------------------------------
// Libera objetos ante un LostDevice
//--------------------------------------------------------------------------------------
void CGUI::free()
{
    // Salimos si no se ha inicializado
    if(!m_bInit) return;

    // Liberamos el texto
    m_pFont->OnLostDevice();
    SAFE_RELEASE(m_pTextSprite);

    // Tomamos la resolución actual
    m_uHeight = DXUTGetPresentParameters().BackBufferHeight;
    m_uWidth = DXUTGetPresentParameters().BackBufferWidth;
    m_uMidW = m_uWidth/2;
    m_uMidH = m_uHeight/2;

    // Modificamos los objetos
    setTypeGUI(m_iType);
}

//--------------------------------------------------------------------------------------
// Libera el GUI
//--------------------------------------------------------------------------------------
void CGUI::Release()
{
    // Salimos si no se ha inicializado
    if(!m_bInit) return;
    m_bInit = false;

    // Liberamos el dispositivo
    SAFE_RELEASE(m_pDevice);

    // Liberamos otras estructuras
    SAFE_RELEASE(m_pFont);
    SAFE_RELEASE(m_pTextSprite);
    SAFE_DELETE(m_pGUI);
}

//--------------------------------------------------------------------------------------
// Para inicializar algunas variables y elementos de la configuración del juego
//--------------------------------------------------------------------------------------
void CGUI::iniGameConfig(void)
{
    // Inicializamos algunas veriables de juego por defecto
    m_iTypeGame=0;
    m_iTypeArena=0;
    m_iTypeVehicle=0;
    m_bIsServer = true;

    // Inicializamos radio controles por defecto
    m_pGUI->GetRadioButton(GUI_RADIO_SERVER_1)->SetChecked(true);
    m_pGUI->GetRadioButton(GUI_RADIO_MULTI_1)->SetChecked(true);

    // Cargamos los controles de juego con la configuración por defecto
    g_Settings->RefreshControls(GUI_TYPE_SETT_GAME);
}

//--------------------------------------------------------------------------------------
// Función para ocultar todos los elementos del GUI
//--------------------------------------------------------------------------------------
void CGUI::HideAll(void)
{
    // Recorremos la lista de componentes del GUI y ocultamos todos ellos
    for(vector<CDXUTControl *>::iterator itr = m_aCtrls.begin() ; itr != m_aCtrls.end() ; itr++)
        (*itr)->m_bVisible = false;
}

//--------------------------------------------------------------------------------------
// Establece la arena con el índice dado, cargando todas antes si fuese necesario
//--------------------------------------------------------------------------------------
bool CGUI::setArena(int dIndex)
{
    // Comprobamos si ya tenemos cargada la arena, entonces no cargamos nada
    if( (dIndex == m_iArena || (dIndex < 0 && m_inumArenas)) &&
        (g_Menu->getMArena()) )
    {
        g_Menu->setTypeMenu(MENU_TYPE_SELECT_ARENA, NULL);
        return true;
    }

    // En otro caso tomamos la nueva arena
    if(dIndex >= 0)
        m_iArena = dIndex;

    // Comprobamos si aún no hemos listado el directorio
    CDXUTListBox *pListBox = m_pGUI->GetListBox(GUI_LISTBOX_SELECT_ARENA);
    if(!m_inumArenas)
    {
        // Preparamos la órden de búsqueda OBJARENA_DIR + "*.xml"
        basic_string<wchar_t> Search = OBJARENA_DIR + (basic_string<wchar_t>)L"*.xml";

        // Cargamos los nombres de los ficheros del directorio
        WIN32_FIND_DATA pFile;
        HANDLE pHandle = INVALID_HANDLE_VALUE;
        DWORD dwError;

        // Cargamos los nombres de los ficheros en el GUI
        pHandle = FindFirstFile(Search.c_str(), &pFile);
        if (pHandle == INVALID_HANDLE_VALUE) return false;
        pListBox->RemoveAllItems();
		basic_string<wchar_t> Text = pFile.cFileName;
        pListBox->AddItem(Text.substr(0,Text.size()-4).c_str(), getIndex(0));
        m_inumArenas = 1;
        while(FindNextFile(pHandle, &pFile) != 0)
        {
			basic_string<wchar_t> Text = pFile.cFileName;
            pListBox->AddItem(Text.substr(0,Text.size()-4).c_str(), getIndex(m_inumArenas));
            m_inumArenas++;
        }

        dwError = GetLastError();
        FindClose(pHandle);
        if (dwError != ERROR_NO_MORE_FILES) return false;
    }

    // Si hay items cargados mostramos/actualizamos el menú
    if(!g_Menu->setTypeMenu(MENU_TYPE_SELECT_ARENA, pListBox->GetItem(m_iArena)->strText))
        return false;

	// Vamos a mostrar información relativa a la arena
    WCHAR value[MAX_STRING+1];
    C3DObjArena *Arena = g_Menu->getMArena();
    _snwprintf(value, MAX_STRING, L"NAME...\n  %s\nDESCRIPTION...\n  %s", Arena->getName(), Arena->getDescription());
    setText(value, GUI_STATIC_ARENA_INFO);
	setText(Arena->getRankTxt(), GUI_STATIC_ARENA_MINFO);

    // Se selecciona el item en el ListBox
    pListBox->SelectItem(m_iArena);
    return true;
}

//--------------------------------------------------------------------------------------
// Establece el vehículo con el índice dado, cargando todos antes si fuese necesario
//--------------------------------------------------------------------------------------
bool CGUI::setVehicle(int dIndex)
{
    // Comprobamos si ya tenemos cargado el vehículo, entonces no cargamos nada
    if( (dIndex == m_iVehicle || (dIndex < 0 && m_inumVehicles)) &&
        (g_Menu->getMVehicle()) )
    {
        g_Menu->setTypeMenu(MENU_TYPE_SELECT_VEHICLE, NULL);
        return true;
    }

    // En otro caso tomamos la nueva arena
    if(dIndex >= 0)
        m_iVehicle = dIndex;

    // Comprobamos si aún no hemos listado el directorio
    CDXUTListBox *pListBox = m_pGUI->GetListBox(GUI_LISTBOX_SELECT_VEHICLE);
    if(!m_inumVehicles)
    {
        // Preparamos la órden de búsqueda OBJVEHICLE_DIR + "*.xml"
        basic_string<wchar_t> Search = OBJVEHICLE_DIR + (basic_string<wchar_t>)L"*.xml";

        // Cargamos los nombres de los ficheros del directorio
        WIN32_FIND_DATA pFile;
        HANDLE pHandle = INVALID_HANDLE_VALUE;
        DWORD dwError;

        // Cargamos los nombres de los ficheros en el GUI
        pHandle = FindFirstFile(Search.c_str(), &pFile);
        if (pHandle == INVALID_HANDLE_VALUE) return false;
        pListBox->RemoveAllItems();
		basic_string<wchar_t> Text = pFile.cFileName;
        pListBox->AddItem(Text.substr(0,Text.size()-4).c_str(), getIndex(0));
        m_inumVehicles = 1;
        while(FindNextFile(pHandle, &pFile) != 0)
        {
			basic_string<wchar_t> Text = pFile.cFileName;
            pListBox->AddItem(Text.substr(0,Text.size()-4).c_str(), getIndex(m_inumVehicles));
            m_inumVehicles++;
        }

        dwError = GetLastError();
        FindClose(pHandle);
        if (dwError != ERROR_NO_MORE_FILES) return false;
    }

    // Si hay items cargados mostramos/actualizamos el menú
    if(!g_Menu->setTypeMenu(MENU_TYPE_SELECT_VEHICLE, pListBox->GetItem(m_iVehicle)->strText))
        return false;

    // Mostramos las características propias del vehículo
    WCHAR value[MAX_STRING+1];
    C3DObjVehicle *Vehicle = g_Menu->getMVehicle();
    _snwprintf(value, MAX_STRING, L"NAME...\n  %s\nDESCRIPTION...\n  %s", Vehicle->getName(), Vehicle->getDescription());
    setText(value, GUI_STATIC_VEHICLE_INFO);
    _snwprintf(value, MAX_STRING, L"FEATURES...\n  Capacity  %.1f\n  Health     %.1f\n  Speed     %.1f\n  Accel.      %.1f",
        Vehicle->getMaxCapacity(),
        Vehicle->getMaxHealth(),
        Vehicle->getMaxSpeed(),
        Vehicle->getMaxAcceleration());
	setText(value, GUI_STATIC_VEHICLE_MINFO);

    // Se selecciona el item en el ListBox
    pListBox->SelectItem(m_iVehicle);
    return true;
}

//--------------------------------------------------------------------------------------
// Para cambiar el marcador indicado con el número indicado
//--------------------------------------------------------------------------------------
void CGUI::setMarcador(int num, int marcador)
{
    // Ponemos el número dado en el componente STATIC indicado
    WCHAR texto[10];
    _itow(num, texto, 10);
    m_pGUI->GetStatic(marcador)->SetText(texto);
}

//--------------------------------------------------------------------------------------
// Para cambiar el texto del aviso
//--------------------------------------------------------------------------------------
void CGUI::setText(LPCWSTR txt, int m_iType)
{
    // Ponemos el texto dado en el componente STATIC indicado
    m_pGUI->GetStatic(m_iType)->SetText(txt);
}

//--------------------------------------------------------------------------------------
// Para lanzar un evento
//--------------------------------------------------------------------------------------
void CGUI::throwEvent(int ID)
{
    // Para externamente provocar eventos del GUI, como por ejemplo pulsar un botón
    OnGUIEvent(0, ID, NULL);
}

//--------------------------------------------------------------------------------------
// Para cambiar el tipo de GUI
//--------------------------------------------------------------------------------------
void CGUI::setTypeGUI(int dType)
{
    // Tomamos el nuevo tipo
    m_ioldType = m_iType;
    m_iType = dType;

    // Ocultamos todos los elementos
    if(m_ioldType != m_iType) HideAll();

    // Elementos fijos en todos los tipos de GUI
    m_pGUI->GetListBox(GUI_LISTBOX_CREDITS_UP)->SetSize(m_uWidth + 100, 20);
    m_pGUI->GetListBox(GUI_LISTBOX_CREDITS_DW)->SetSize(m_uWidth + 100, 20);
    m_pGUI->GetListBox(GUI_LISTBOX_CREDITS_DW)->SetLocation(-50, m_uHeight - 20);
    m_pGUI->GetListBox(GUI_LISTBOX_CREDITS_UP)->m_bVisible = true;
    m_pGUI->GetListBox(GUI_LISTBOX_CREDITS_DW)->m_bVisible = true;

    // Elementos propios del tipo de GUI
    switch(m_iType)    
    {
    //----------------------------------------------------------------------------------
    case GUI_TYPE_MENU_INIT:
        m_bGamming = false;

        m_pGUI->GetStatic(GUI_STATIC_TITULO)->SetLocation(m_uMidW - 400, 20);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 120);
        setText(L"... select an option ...", GUI_STATIC_INFO);

        m_pGUI->GetButton(GUI_BTN_NEWGAME)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH - GUI_BTN_H_SPACE);
        m_pGUI->GetButton(GUI_BTN_SETT)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH);
        m_pGUI->GetButton(GUI_BTN_EXIT)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH + GUI_BTN_H_SPACE);
        m_pGUI->GetButton(GUI_BTN_NEWGAME)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_SETT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_EXIT)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_TITULO)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_SETT:
        if(!m_bGamming)
        {
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
            setText(L"OPTIONS", GUI_STATIC_TITULO_2);
            m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
            setText(L"... select available options ...", GUI_STATIC_INFO);
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
            m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        }
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW - GUI_BTN_W_2/2, m_uHeight - (GUI_BTN_H_2 + 20));

        m_pGUI->GetButton(GUI_BTN_SETT_DISPLAY)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH - GUI_BTN_H_SPACE);
        m_pGUI->GetButton(GUI_BTN_SETT_SOUND)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH);
        m_pGUI->GetButton(GUI_BTN_SETT_GAME)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH + GUI_BTN_H_SPACE);
        m_pGUI->GetButton(GUI_BTN_SETT_DISPLAY)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_SETT_SOUND)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_SETT_GAME)->m_bVisible = true;

        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_SETT_DISPLAY:
    {
        int selQLT;

        if(!m_bGamming)
        {
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
            m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
            setText(L"... display options ...", GUI_STATIC_INFO);
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
            m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        }
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetStatic(GUI_STATIC_SETT)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI - 10);
        setText(L"Device Quality\n\nWindowed or FullScreen\n\nDevice Stadistics\n\n\n\nResolution\n\nTexture Filter\n\nMipmapping", GUI_STATIC_SETT);

        m_pGUI->GetComboBox(GUI_CMBBX_SETT_QUALITY)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0);
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_WINFULL)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*1);
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_STADISTICS)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*2);
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_RESOLUTION)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*4);
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_FILTER)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*5);
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_MIPMAPPING)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*6);

        // Activamos o no varios de los controles respecto del resto
        selQLT = *((int *)(m_pGUI->GetComboBox(GUI_CMBBX_SETT_QUALITY)->GetSelectedData()));
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_RESOLUTION)->SetEnabled(selQLT==0);
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_FILTER)->SetEnabled(selQLT==0);
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_MIPMAPPING)->SetEnabled(selQLT==0);

        m_pGUI->GetComboBox(GUI_CMBBX_SETT_QUALITY)->m_bVisible = true;
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_WINFULL)->m_bVisible = true;
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_STADISTICS)->m_bVisible = true;
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_RESOLUTION)->m_bVisible = true;
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_FILTER)->m_bVisible = true;
        m_pGUI->GetComboBox(GUI_CMBBX_SETT_MIPMAPPING)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_SETT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    }
    //----------------------------------------------------------------------------------
    case GUI_TYPE_SETT_SOUND:
        if(!m_bGamming)
        {
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
            m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
            setText(L"... sound options ...", GUI_STATIC_INFO);
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
            m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        }
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetStatic(GUI_STATIC_SETT)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI - 10);

/* TODO: Descomentar para música
        setText(L"Music volume\n\n\n\nEffects volume", GUI_STATIC_SETT);
        m_pGUI->GetSlider(GUI_SLIDER_SETT_MUSIC)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0 + 5);
        m_pGUI->GetSlider(GUI_SLIDER_SETT_EFFECTS)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*2 + 5);
        m_pGUI->GetStatic(GUI_STATIC_COUNTER)->SetLocation(m_uMidW - 100, m_uMidH + 80);
        setText(L"", GUI_STATIC_COUNTER);
        m_pGUI->GetSlider(GUI_SLIDER_SETT_MUSIC)->m_bVisible = true;
*/
/* TODO: Comentar para música */
        setText(L"Sound volume", GUI_STATIC_SETT);
        m_pGUI->GetSlider(GUI_SLIDER_SETT_EFFECTS)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0 + 5);
		m_pGUI->GetStatic(GUI_STATIC_COUNTER)->SetLocation(m_uMidW - 100, GUI_SETT_H_INI + GUI_SETT_H_SEP*0 + 20);
/* TODO: Comentar para música */

        m_pGUI->GetSlider(GUI_SLIDER_SETT_EFFECTS)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_COUNTER)->m_bVisible = true;
        setMarcador(m_pGUI->GetSlider(GUI_SLIDER_SETT_EFFECTS)->GetValue(), GUI_STATIC_COUNTER);

        m_pGUI->GetStatic(GUI_STATIC_SETT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_SETT_GAME:
        if(!m_bGamming)
        {
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
            m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
            setText(L"... game options ...", GUI_STATIC_INFO);
            m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
            m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        }
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetStatic(GUI_STATIC_SETT)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI - 10);

/* TODO: Descomentar para multijugador
        setText(L"Default player's name\n\n\n\nDefault server's name\n\n\n\nDefault objetives to win\n\n\n\nDefault deaths to win", GUI_STATIC_SETT);
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0 + 5);
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_SERVER)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*2 + 5);
        m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_1)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*4 + 5);
        m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_2)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*6 + 5);

        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->m_bVisible = true;
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_SERVER)->m_bVisible = true;
        m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_1)->m_bVisible = true;
        m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_2)->m_bVisible = true;

		m_pGUI->GetStatic(GUI_STATIC_COUNTER)->SetLocation(m_uMidW - 100, GUI_SETT_H_INI + GUI_SETT_H_SEP*4 + 20);
		setText(L"--", GUI_STATIC_COUNTER);
        m_pGUI->GetStatic(GUI_STATIC_COUNTER)->m_bVisible = true;
*/
/* TODO: Comentar para multijugador */
		setText(L"Default player's name\n\n\n\nControls\n  - CURSORS .... to drive\n  - ESPACE ....... to use handbrake\n  - CONTROL .... to launch rockets\n  - C .................. to change camera view\n  - P .................. to pause", GUI_STATIC_SETT);
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->SetLocation(m_uMidW - GUI_SETT_W/2, GUI_SETT_H_INI + GUI_SETT_H_SEP*0 + 5);
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->m_bVisible = true;
/* TODO: Comentar para multijugador */

        m_pGUI->GetStatic(GUI_STATIC_SETT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
/* TODO: Descomentar para multijugador
    //----------------------------------------------------------------------------------
    case GUI_TYPE_NEW_GAME:
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
        setText(L"NEW GAME", GUI_STATIC_TITULO_2);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
        setText(L"... select multiplayer or monoplayer game ...", GUI_STATIC_INFO);
        m_pGUI->GetButton(GUI_BTN_MONOPLAYER)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH - GUI_BTN_H_SPACE);
        m_pGUI->GetButton(GUI_BTN_MULTIPLAYER)->SetLocation(m_uMidW - GUI_BTN_W/2, m_uMidH);
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - GUI_BTN_W_2/2, m_uHeight - (GUI_BTN_H_2 + 20));

        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->SetLocation(m_uMidW - 100, m_uMidH + 110);
        m_pGUI->GetStatic(GUI_STATIC_INFO_2)->SetLocation(m_uMidW - 400, m_uMidH + 85);
        setText(L"... player's name ...", GUI_STATIC_INFO_2);
        m_pGUI->GetStatic(GUI_STATIC_INFO_2)->m_bVisible = true;
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_MONOPLAYER)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_MULTIPLAYER)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_SELECT_SERVER:
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
        setText(L"... multiplayer - client or server ...", GUI_STATIC_INFO);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));

        m_pGUI->GetRadioButton(GUI_RADIO_SERVER_1)->SetLocation(m_uMidW - 120, m_uMidH - 90);
        m_pGUI->GetRadioButton(GUI_RADIO_SERVER_2)->SetLocation(m_uMidW - 120, m_uMidH - 60);

        // Activamos los controles propios si es servidor o cliente
        if(m_pGUI->GetRadioButton(GUI_RADIO_SERVER_1)->GetChecked())
        {
            setText(L"... server's IP ...", GUI_STATIC_INFO_2);
            m_pGUI->GetStatic(GUI_STATIC_INFO_2)->SetLocation(m_uMidW - 400, m_uMidH + 10);
            m_pGUI->GetEditBox(GUI_EDITBOX_SETT_SERVER)->SetLocation(m_uMidW - 100, m_uMidH + 35);
            m_pGUI->GetStatic(GUI_STATIC_INFO_2)->m_bVisible = true;
            m_pGUI->GetEditBox(GUI_EDITBOX_SETT_SERVER)->m_bVisible = true;
        }

        m_pGUI->GetRadioButton(GUI_RADIO_SERVER_1)->m_bVisible = true;
        m_pGUI->GetRadioButton(GUI_RADIO_SERVER_2)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_WAIT_CLIENTS:
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
        setText(L"... multiplayer - wait clients ...", GUI_STATIC_INFO);

        m_pGUI->GetListBox(GUI_LISTBOX_CLIENTES)->SetLocation(m_uMidW - 250, m_uMidH - m_uHeight/4 + 25);
        m_pGUI->GetListBox(GUI_LISTBOX_CLIENTES)->SetSize(120, m_uMidH);
        m_pGUI->GetListBox(GUI_LISTBOX_CHAT)->SetLocation(m_uMidW - 110, m_uMidH - m_uHeight/4 + 25);
        m_pGUI->GetListBox(GUI_LISTBOX_CHAT)->SetSize(360, m_uMidH);
        m_pGUI->GetEditBox(GUI_EDITBOX_CHAT)->SetLocation(m_uMidW - 110, m_uMidH + m_uHeight/4 + 35);

        m_pGUI->GetListBox(GUI_LISTBOX_CLIENTES)->m_bVisible = true;
        m_pGUI->GetListBox(GUI_LISTBOX_CHAT)->m_bVisible = true;
        m_pGUI->GetEditBox(GUI_EDITBOX_CHAT)->m_bVisible = true;

        // El servidor podrá iniciar o terminar la partida
        if(m_bIsServer)
        {
            m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
            m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));
            m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        }
        // Los clientes sólo podrán abandonar el salón de chat
        else
            m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - GUI_BTN_W_2/2, m_uHeight - (GUI_BTN_H_2 + 20));

        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_NEW_MULTI:
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
        setText(L"... multiplayer - select game's type and configure it ...", GUI_STATIC_INFO);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));

        m_pGUI->GetRadioButton(GUI_RADIO_MULTI_1)->SetLocation(m_uMidW - 60, m_uMidH - 100);
        m_pGUI->GetRadioButton(GUI_RADIO_MULTI_2)->SetLocation(m_uMidW - 60, m_uMidH - 70);
        m_pGUI->GetRadioButton(GUI_RADIO_MULTI_3)->SetLocation(m_uMidW - 60, m_uMidH - 40);
        m_pGUI->GetRadioButton(GUI_RADIO_MULTI_1)->m_bVisible = true;
        m_pGUI->GetRadioButton(GUI_RADIO_MULTI_2)->m_bVisible = true;
        m_pGUI->GetRadioButton(GUI_RADIO_MULTI_3)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_INFO_2)->SetLocation(m_uMidW - 400, m_uMidH + 10);
        m_pGUI->GetStatic(GUI_STATIC_COUNTER)->SetLocation(m_uMidW - 100, m_uMidH + 80);

        // Activamos los controles propios del tipo de juego seleccionado
        switch(m_iTypeGame)
        {
        case GAME_MULTI_1:
            setText(L"... number of objetives to win ...", GUI_STATIC_INFO_2);
            setMarcador(m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_1)->GetValue(), GUI_STATIC_COUNTER);
            m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_1)->SetLocation(m_uMidW - 100, m_uMidH + 50);
            m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_1)->m_bVisible = true;
            break;
        case GAME_MULTI_2:
            setText(L"... number of deaths to win ...", GUI_STATIC_INFO_2);
            setMarcador(m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_2)->GetValue(), GUI_STATIC_COUNTER);
            m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_2)->SetLocation(m_uMidW - 100, m_uMidH + 50);
            m_pGUI->GetSlider(GUI_SLIDER_SETT_MULTI_2)->m_bVisible = true;
            break;
        case GAME_MULTI_3:
            setText(L"", GUI_STATIC_INFO_2);
            setText(L"", GUI_STATIC_COUNTER);
            break;
        }
        m_pGUI->GetStatic(GUI_STATIC_INFO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_COUNTER)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
*/
    //----------------------------------------------------------------------------------
    case GUI_TYPE_SELECT_ARENA:
/* TODO: Comentar para multijugador */
    case GUI_TYPE_NEW_GAME:
        setText(L"NEW GAME", GUI_STATIC_TITULO_2);
		m_iTypeGame = GAME_MONO_1;
/* TODO: Comentar para multijugador */
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
/* TODO: Para activar el GUI multijugador, descomentar este bloque *//*
        switch(m_iTypeGame)
        {
        case GAME_MONO_1:  setText(L"... monoplayer - regresive time counter - select arena ...", GUI_STATIC_INFO); break;
        case GAME_MULTI_1: setText(L"... multiplayer - objective counter - select arena ...", GUI_STATIC_INFO); break;
        case GAME_MULTI_2: setText(L"... multiplayer - death match - select arena ...", GUI_STATIC_INFO); break;
        case GAME_MULTI_3: setText(L"... multiplayer - last car alive - select arena ...", GUI_STATIC_INFO); break;
        }
*/
/* TODO: Para activar el GUI multijugador, borrar esta línea */setText(L"... select the arena ...", GUI_STATIC_INFO);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));

        m_pGUI->GetButton(GUI_BTN_SELECT_PRIOR)->SetLocation(m_uMidW, m_uHeight - 100);
        m_pGUI->GetButton(GUI_BTN_SELECT_NEXT)->SetLocation(m_uMidW + GUI_BTN_W_3 + 5, m_uHeight - 100);
        m_pGUI->GetListBox(GUI_LISTBOX_SELECT_ARENA)->SetLocation(50, m_uMidH - m_uMidH/2 + 25);
        m_pGUI->GetListBox(GUI_LISTBOX_SELECT_ARENA)->SetSize(200, m_uMidH/2);
        m_pGUI->GetStatic(GUI_STATIC_ARENA_INFO)->SetLocation(50, m_uMidH + 35);
        m_pGUI->GetStatic(GUI_STATIC_ARENA_MINFO)->SetLocation(50, m_uMidH + 95);

        m_pGUI->GetButton(GUI_BTN_SELECT_PRIOR)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_SELECT_NEXT)->m_bVisible = true;
        m_pGUI->GetListBox(GUI_LISTBOX_SELECT_ARENA)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_ARENA_INFO)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_ARENA_MINFO)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_SELECT_VEHICLE:
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uMidW - 400, 30);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, 105);
/* TODO: Para activar el GUI multijugador, descomentar este bloque *//*
        switch(m_iTypeGame)
        {
        case GAME_MONO_1:  setText(L"... monoplayer - regresive time counter - select a vehicle ...", GUI_STATIC_INFO); break;
        case GAME_MULTI_1: setText(L"... multiplayer - objective counter - select a vehicle ...", GUI_STATIC_INFO); break;
        case GAME_MULTI_2: setText(L"... multiplayer - death match - select a vehicle ...", GUI_STATIC_INFO); break;
        case GAME_MULTI_3: setText(L"... multiplayer - last car alive - select a vehicle ...", GUI_STATIC_INFO); break;
        }
*/
/* TODO: Para activar el GUI multijugador, borrar esta línea */setText(L"... select the vehicle ...", GUI_STATIC_INFO);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uHeight - (GUI_BTN_H_2 + 20));
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uHeight - (GUI_BTN_H_2 + 20));

        m_pGUI->GetButton(GUI_BTN_SELECT_PRIOR)->SetLocation(m_uMidW, m_uHeight - 100);
        m_pGUI->GetButton(GUI_BTN_SELECT_NEXT)->SetLocation(m_uMidW + GUI_BTN_W_3 + 5, m_uHeight - 100);
        m_pGUI->GetListBox(GUI_LISTBOX_SELECT_VEHICLE)->SetLocation(50, m_uMidH - m_uMidH/2 + 25);
        m_pGUI->GetListBox(GUI_LISTBOX_SELECT_VEHICLE)->SetSize(200, m_uMidH/2);
        m_pGUI->GetStatic(GUI_STATIC_VEHICLE_INFO)->SetLocation(50, m_uMidH + 35);
        m_pGUI->GetStatic(GUI_STATIC_VEHICLE_MINFO)->SetLocation(50, m_uMidH + 95);

        m_pGUI->GetButton(GUI_BTN_SELECT_PRIOR)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_SELECT_NEXT)->m_bVisible = true;
        m_pGUI->GetListBox(GUI_LISTBOX_SELECT_VEHICLE)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_VEHICLE_INFO)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_VEHICLE_MINFO)->m_bVisible = true;

        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_INTERFAZ_PREGAME:
	{
		TCHAR txt[MAX_STRING+1];

        m_bPaused = true;
        m_bGamming = false;

        m_pGUI->GetStatic(GUI_STATIC_WARNING)->SetLocation(m_uMidW - 400, m_uMidH - 160);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, m_uMidH - 80);
        m_pGUI->GetStatic(GUI_STATIC_GAME_INFO)->SetLocation(m_uMidW - 130, m_uMidH + 30);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW - GUI_BTN_W_2/2, m_uMidH + 150);

		g_GUI->setText(g_Menu->getMGame()->getArena()->getName(), GUI_STATIC_WARNING);
		wsprintf(txt, L"Capture all the %d blue objectives in time\nand without damaging the vehicle\n\n You'll start with %d seconds and\n%d seconds more per objective", (int)(g_Menu->getMGame()->getArena()->getNumObj()), (int)(g_Menu->getMGame()->getArena()->getTimeIni()), (int)(g_Menu->getMGame()->getArena()->getTimeObj()));
		g_GUI->setText(txt, GUI_STATIC_INFO);
		g_GUI->setText(L"  - CURSORS .... to drive\n  - ESPACE ....... to use handbrake\n  - CONTROL .... to launch rockets\n  - C .................. to change camera view\n  - P .................. to pause", GUI_STATIC_GAME_INFO);

		m_pGUI->GetStatic(GUI_STATIC_WARNING)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_GAME_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        break;
	}
    //----------------------------------------------------------------------------------
    case GUI_TYPE_INTERFAZ_GAME:
	{
        m_bPaused = false;
        m_bGamming = true;

        // Guardamos la configuración por defecto con los controles de juego
        g_Settings->RefreshData(GUI_TYPE_SETT_GAME);

        m_pGUI->GetButton(GUI_BTN_GAME_PAUSE)->SetLocation(m_uWidth - GUI_BTN_W_3, m_uHeight - 50);
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->SetLocation(m_uWidth-450, 10);
		int size = (int)(g_Menu->getMGame()->getArena()->getSize());
		m_pGUI->GetEditBox(GUI_EDITBOX_MAP)->SetSize(size+6, size+6);
		m_pGUI->GetEditBox(GUI_EDITBOX_MAP)->SetLocation(-2, m_uHeight - 24 - size);
        m_pGUI->GetStatic(GUI_STATIC_MAP1)->SetLocation(-100, -100);
        m_pGUI->GetStatic(GUI_STATIC_MAP2)->SetLocation(-100, -100);

        m_pGUI->GetButton(GUI_BTN_GAME_PAUSE)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_TITULO_2)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO_3a)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO_3b)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO_3c)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO_3d)->m_bVisible = true;
		m_pGUI->GetEditBox(GUI_EDITBOX_MAP)->m_bVisible = true;
		m_pGUI->GetStatic(GUI_STATIC_MAP1)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_MAP2)->m_bVisible = true;
        break;
	}
    //----------------------------------------------------------------------------------
    case GUI_TYPE_PAUSE_GAME:
        m_bPaused = true;

		m_pGUI->GetStatic(GUI_STATIC_WARNING)->SetLocation(m_uMidW - 400, m_uMidH - 120);
        m_pGUI->GetButton(GUI_BTN_GAME_PAUSE)->SetLocation(m_uWidth - GUI_BTN_W_3, m_uHeight - 50);
        m_pGUI->GetButton(GUI_BTN_GAME_OPTIONS)->SetLocation(m_uWidth - GUI_BTN_W_3, m_uHeight - 100);
        m_pGUI->GetButton(GUI_BTN_GAME_EXIT)->SetLocation(m_uWidth - GUI_BTN_W_3, m_uHeight - 80);

		g_GUI->setText(L"PAUSED", GUI_STATIC_WARNING);

		m_pGUI->GetStatic(GUI_STATIC_WARNING)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_GAME_PAUSE)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_GAME_OPTIONS)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_GAME_EXIT)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_WARNING:
        m_pGUI->GetStatic(GUI_STATIC_WARNING)->SetLocation(m_uMidW - 400, m_uMidH - 80);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, m_uMidH);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uMidH + 70);
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uMidH + 70);

		g_GUI->setText(L"SURE?", GUI_STATIC_WARNING);
		g_GUI->setText(L"... you'll miss the current game ...\n\nare you sure?", GUI_STATIC_INFO);

		m_pGUI->GetStatic(GUI_STATIC_WARNING)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_WARNING_WIN:
	{
		TCHAR txt[MAX_STRING+1];

        m_pGUI->GetStatic(GUI_STATIC_WARNING)->SetLocation(m_uMidW - 400, m_uMidH - 120);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, m_uMidH - 40);
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->SetLocation(m_uMidW - GUI_SETT_W/2, m_uMidH + 40);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW - GUI_BTN_W_2/2, m_uMidH + 100);

		g_GUI->setText(L"YOU WIN", GUI_STATIC_WARNING);
		wsprintf(txt, L"Congratulations %s\n... all objectives have been caught in %d seconds ...\n\n... write your name ...", g_Settings->getData()->m_awNomPlayer, (int)(g_TimeGame));
		g_GUI->setText(txt, GUI_STATIC_INFO);

		m_pGUI->GetStatic(GUI_STATIC_WARNING)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetEditBox(GUI_EDITBOX_SETT_NAME)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        break;
	}
    //----------------------------------------------------------------------------------
    case GUI_TYPE_WARNING_RANK:
        m_pGUI->GetStatic(GUI_STATIC_WARNING)->SetLocation(m_uMidW - 400, m_uMidH - 120);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, m_uMidH + 110);
        m_pGUI->GetStatic(GUI_STATIC_RANK)->SetLocation(m_uMidW - 170, m_uMidH - 20);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uMidH + 150);
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uMidH + 150);

		// Insertamos el nuevo elemento del ranking
		Rank R;
		wcscpy(R.m_Player, g_GUI->getGUI()->GetEditBox(GUI_EDITBOX_SETT_NAME)->GetText());
		wcscpy(R.m_Vehicle, g_Menu->getMGame()->getLocalPlayer()->getVehicle()->getName());
		R.m_Time = g_TimeGame;
		g_Menu->getMGame()->getArena()->addRanking(R);

		g_GUI->setText(L"RANKING", GUI_STATIC_WARNING);
		g_GUI->setText(g_Menu->getMGame()->getArena()->getRankTxt(), GUI_STATIC_RANK);
		g_GUI->setText(L"play again?", GUI_STATIC_INFO);

		m_pGUI->GetStatic(GUI_STATIC_WARNING)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_RANK)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
    //----------------------------------------------------------------------------------
    case GUI_TYPE_WARNING_LOST:
	{
		TCHAR txt[MAX_STRING+1];

        m_pGUI->GetStatic(GUI_STATIC_WARNING)->SetLocation(m_uMidW - 400, m_uMidH - 80);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, m_uMidH);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uMidH + 90);
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uMidH + 90);

		g_GUI->setText(L"YOU LOSE", GUI_STATIC_WARNING);
		wsprintf(txt, L"... the time is out ...\n... after %d seconds and %d of %d objectives ...\n\nplay again?",
			(int)(g_TimeGame),
			(int)(g_Menu->getMGame()->getObjectives()),
			(int)(g_Menu->getMGame()->getArena()->getNumObj()) );
		g_GUI->setText(txt, GUI_STATIC_INFO);
		
		m_pGUI->GetStatic(GUI_STATIC_WARNING)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
	}
    //----------------------------------------------------------------------------------
    case GUI_TYPE_WARNING_DIE:
	{
		TCHAR txt[MAX_STRING+1];

        m_pGUI->GetStatic(GUI_STATIC_WARNING)->SetLocation(m_uMidW - 400, m_uMidH - 80);
        m_pGUI->GetStatic(GUI_STATIC_INFO)->SetLocation(m_uMidW - 400, m_uMidH);
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->SetLocation(m_uMidW + GUI_BTN_W_SPACE, m_uMidH + 90);
        m_pGUI->GetButton(GUI_BTN_CANCEL)->SetLocation(m_uMidW - (GUI_BTN_W_2 + GUI_BTN_W_SPACE), m_uMidH + 90);

		g_GUI->setText(L"YOU LOSE", GUI_STATIC_WARNING);
		wsprintf(txt, L"... your vehicle is damaged ...\n... after %d seconds and %d of %d objectives ...\n\nplay again?",
			(int)(g_TimeGame),
			(int)(g_Menu->getMGame()->getObjectives()),
			(int)(g_Menu->getMGame()->getArena()->getNumObj()) );
		g_GUI->setText(txt, GUI_STATIC_INFO);

		m_pGUI->GetStatic(GUI_STATIC_WARNING)->m_bVisible = true;
        m_pGUI->GetStatic(GUI_STATIC_INFO)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_ACCEPT)->m_bVisible = true;
        m_pGUI->GetButton(GUI_BTN_CANCEL)->m_bVisible = true;
        break;
	}
    //----------------------------------------------------------------------------------
    }
}

//--------------------------------------------------------------------------------------
// Handles the GUI events
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl )
{
    if(g_bCreated)
    switch( nControlID )
    {

    //----------------------------------------------------------------------------------
    case GUI_BTN_ACCEPT:
    //----------------------------------------------------------------------------------
        switch(g_GUI->getTypeGUI())
        {
        case GUI_TYPE_WARNING:
            g_Menu->setTypeMenu(MENU_TYPE_MENU);
            g_GUI->setTypeGUI(GUI_TYPE_MENU_INIT);
            break;
		case GUI_TYPE_WARNING_RANK:
        case GUI_TYPE_WARNING_LOST:
        case GUI_TYPE_WARNING_DIE:
            // Creamos el juego
            g_Menu->setTypeMenu(MENU_TYPE_GAME, g_GUI->getLocalPlayerName(), g_GUI->getTypeGame());
			g_Menu->update();
            // Mostramos la información de partida
            g_GUI->setTypeGUI(GUI_TYPE_INTERFAZ_PREGAME);
            g_Menu->setTypeMenu(MENU_TYPE_PREGAME);
            break;
        case GUI_TYPE_WARNING_WIN:
            g_GUI->setTypeGUI(GUI_TYPE_WARNING_RANK);
            break;
        case GUI_TYPE_SETT:
            if(g_GUI->getGamming())  g_GUI->setTypeGUI(GUI_TYPE_PAUSE_GAME);
            else                     g_GUI->setTypeGUI(GUI_TYPE_MENU_INIT);
            break;
        case GUI_TYPE_SETT_DISPLAY:
            g_Settings->RefreshData(GUI_TYPE_SETT_DISPLAY);
            g_Settings->Apply(GUI_TYPE_SETT_DISPLAY);
            g_GUI->setTypeGUI(GUI_TYPE_SETT);
            break;
        case GUI_TYPE_SETT_SOUND:
            g_Settings->RefreshData(GUI_TYPE_SETT_SOUND);
            g_Settings->Apply(GUI_TYPE_SETT_SOUND);
            g_GUI->setTypeGUI(GUI_TYPE_SETT);
            break;
        case GUI_TYPE_SETT_GAME:
            if(g_GUI->getGUI()->GetEditBox(GUI_EDITBOX_SETT_SERVER)->GetTextLength() == 0)
            {
                g_GUI->setText(L"INVALID SERVER'S NAME\ninsert a valid server's name to continue\n...press OK to return to the dialog...", GUI_STATIC_INFO);
                g_GUI->setTypeGUI(GUI_TYPE_WARNING);
            }
            else if(g_GUI->getGUI()->GetEditBox(GUI_EDITBOX_SETT_NAME)->GetTextLength() == 0)
            {
                g_GUI->setText(L"INVALID PLAYER'S NAME\ninsert a valid player's name to continue\n...press OK to return to the dialog...", GUI_STATIC_INFO);
                g_GUI->setTypeGUI(GUI_TYPE_WARNING);
            }
            else
            {
                g_Settings->RefreshData(GUI_TYPE_SETT_GAME);
                g_Settings->Apply(GUI_TYPE_SETT_GAME);
                g_GUI->setTypeGUI(GUI_TYPE_SETT);
            }
            break;
        case GUI_TYPE_SELECT_SERVER:
            g_GUI->setTypeGUI(GUI_TYPE_WAIT_CLIENTS);
            break;
        case GUI_TYPE_WAIT_CLIENTS:
            if(g_GUI->getIsServer())
                g_GUI->setTypeGUI(GUI_TYPE_NEW_MULTI);
            else if(g_GUI->setVehicle())
                g_GUI->setTypeGUI(GUI_TYPE_SELECT_VEHICLE);
            break;
        case GUI_TYPE_NEW_MULTI:
            if(g_GUI->setArena())
                g_GUI->setTypeGUI(GUI_TYPE_SELECT_ARENA);
            break;
        case GUI_TYPE_SELECT_ARENA:
            if(g_GUI->setVehicle())
                g_GUI->setTypeGUI(GUI_TYPE_SELECT_VEHICLE);
            break;
        case GUI_TYPE_SELECT_VEHICLE:
            // Creamos el juego
            g_Menu->setTypeMenu(MENU_TYPE_GAME, g_GUI->getLocalPlayerName(), g_GUI->getTypeGame());
			g_Menu->update();
            // Mostramos la información de partida
            g_GUI->setTypeGUI(GUI_TYPE_INTERFAZ_PREGAME);
            g_Menu->setTypeMenu(MENU_TYPE_PREGAME);
			g_Menu->update();
            break;
		case GUI_TYPE_INTERFAZ_PREGAME:
			// Sólo si ha pasado el tiempo inicial del menu
			if (g_Menu->getTotalTime() < MENU_INI_CAMERA) break;
			// Mostramos el juego
            g_GUI->setTypeGUI(GUI_TYPE_INTERFAZ_GAME);
            g_Menu->setTypeMenu(MENU_TYPE_GAME);
            break;
        case GUI_TYPE_PAUSE_GAME:
			// Sólo si ha pasado el tiempo inicial del menu
			if (g_Menu->getTotalTime() < MENU_INI_CAMERA) break;
			// Mostramos el juego
            g_GUI->setTypeGUI(GUI_TYPE_INTERFAZ_GAME);
            break;
        }
        break;

    //----------------------------------------------------------------------------------
    case GUI_BTN_CANCEL:
    //----------------------------------------------------------------------------------
        switch(g_GUI->getTypeGUI())
        {
        case GUI_TYPE_WARNING:
            g_GUI->setTypeGUI(g_GUI->getOldTypeGUI());
            break;
		case GUI_TYPE_WARNING_RANK:
        case GUI_TYPE_WARNING_LOST:
        case GUI_TYPE_WARNING_DIE:
            g_Menu->setTypeMenu(MENU_TYPE_MENU);
            g_GUI->setTypeGUI(GUI_TYPE_MENU_INIT);
            break;
        case GUI_TYPE_SETT_DISPLAY:    g_GUI->setTypeGUI(GUI_TYPE_SETT);break;
        case GUI_TYPE_SETT_SOUND:      g_GUI->setTypeGUI(GUI_TYPE_SETT);break;
        case GUI_TYPE_SETT_GAME:       g_GUI->setTypeGUI(GUI_TYPE_SETT);break;
        case GUI_TYPE_NEW_GAME:        g_GUI->setTypeGUI(GUI_TYPE_MENU_INIT);break;
        case GUI_TYPE_SELECT_SERVER:   g_GUI->setTypeGUI(GUI_TYPE_NEW_GAME);break;
        case GUI_TYPE_WAIT_CLIENTS:    g_GUI->setTypeGUI(GUI_TYPE_SELECT_SERVER);break;
        case GUI_TYPE_NEW_MULTI:       g_GUI->setTypeGUI(GUI_TYPE_WAIT_CLIENTS);break;
        case GUI_TYPE_SELECT_ARENA:
			g_Menu->getMArena()->setEnabled(false);
            switch(g_GUI->getTypeGame())
            {
            case GAME_MONO_1:
/* TODO: Para activar el GUI multijugador, descomentar este bloque *//*
                g_GUI->setTypeGUI(GUI_TYPE_NEW_GAME);break;
*/
/* TODO: Para activar el GUI multijugador, borrar esta línea */g_GUI->setTypeGUI(GUI_TYPE_NEW_GAME);g_GUI->setTypeGUI(GUI_TYPE_MENU_INIT);break;
            case GAME_MULTI_1:
            case GAME_MULTI_2:
            case GAME_MULTI_3:
                g_GUI->setTypeGUI(GUI_TYPE_NEW_MULTI);break;
            }
            g_Menu->setTypeMenu(MENU_TYPE_MENU);
            break;
        case GUI_TYPE_SELECT_VEHICLE:
            if(g_GUI->getIsServer())
            {
                if(g_GUI->setArena())
                    g_GUI->setTypeGUI(GUI_TYPE_SELECT_ARENA);
            }
            else
                g_GUI->setTypeGUI(GUI_TYPE_SELECT_SERVER);
            break;
        case GUI_TYPE_PAUSE_GAME:
			// Sólo si ha pasado el tiempo inicial del menu
			if (g_Menu->getTotalTime() < MENU_INI_CAMERA) break;
			// Mostramos el juego
			g_GUI->setTypeGUI(GUI_TYPE_INTERFAZ_GAME);
			break;
        }
        break;

    //----------------------------------------------------------------------------------
    case GUI_BTN_NEWGAME:
        // Inicializamos algunas variables y elementos de la configuración del juego
        g_GUI->iniGameConfig();
/* TODO: Para activar el GUI multijugador, descomentar este bloque *//*
        // Comenzamos el asistente del nuevo juego
        g_GUI->setTypeGUI(GUI_TYPE_NEW_GAME);
        break;
*/
/* TODO: Para activar el GUI multijugador, borrar esta línea */g_GUI->setTypeGUI(GUI_TYPE_NEW_GAME);g_GUI->setTypeGame(GAME_MONO_1);if(g_GUI->setArena())g_GUI->setTypeGUI(GUI_TYPE_SELECT_ARENA);break;
    case GUI_BTN_MONOPLAYER:
        g_GUI->setTypeGame(GAME_MONO_1);
        if(g_GUI->setArena())
            g_GUI->setTypeGUI(GUI_TYPE_SELECT_ARENA);
        break;
    case GUI_BTN_MULTIPLAYER:
        g_GUI->setTypeGame(GAME_MULTI_1);
        g_GUI->setTypeGUI(GUI_TYPE_SELECT_SERVER);
        break;

    case GUI_CMBBX_SETT_QUALITY:
    case GUI_CMBBX_SETT_WINFULL:
        g_GUI->setTypeGUI(g_GUI->getTypeGUI());
        break;

    case GUI_RADIO_SERVER_1:
        g_GUI->setIsServer(false);
        g_GUI->setTypeGUI(GUI_TYPE_SELECT_SERVER);
        break;
    case GUI_RADIO_SERVER_2:
        g_GUI->setIsServer(true);
        g_GUI->setTypeGUI(GUI_TYPE_SELECT_SERVER);
        break;
    case GUI_RADIO_MULTI_1:
        g_GUI->setTypeGame(GAME_MULTI_1);
        g_GUI->setTypeGUI(GUI_TYPE_NEW_MULTI);
        break;
    case GUI_RADIO_MULTI_2:
        g_GUI->setTypeGame(GAME_MULTI_2);
        g_GUI->setTypeGUI(GUI_TYPE_NEW_MULTI);
        break;
    case GUI_RADIO_MULTI_3:
        g_GUI->setTypeGame(GAME_MULTI_3);
        g_GUI->setTypeGUI(GUI_TYPE_NEW_MULTI);
        break;
    case GUI_SLIDER_SETT_MUSIC:
    case GUI_SLIDER_SETT_EFFECTS:
    case GUI_SLIDER_SETT_MULTI_1:
    case GUI_SLIDER_SETT_MULTI_2:
        g_GUI->setMaxCountGame(g_GUI->getGUI()->GetSlider(nControlID)->GetValue());
        g_GUI->setMarcador(g_GUI->getMaxCountGame(), GUI_STATIC_COUNTER);
        break;
    case GUI_BTN_GAME_PAUSE:
		// Sólo si ha pasado el tiempo inicial del menu
		if (g_Menu->getTotalTime() < MENU_INI_CAMERA) break;
		// Pausamos o mostramos el juego
        if(g_GUI->getPaused())
        {
            g_GUI->setTypeGUI(GUI_TYPE_INTERFAZ_GAME);
            g_Menu->setTypeMenu(MENU_TYPE_GAME);
        }
        else
        {
            g_GUI->setTypeGUI(GUI_TYPE_PAUSE_GAME);
            g_Menu->setTypeMenu(MENU_TYPE_PAUSE);
        }
        break;
    case GUI_BTN_GAME_OPTIONS:
        if(g_GUI->getTypeGUI() == GUI_TYPE_PAUSE_GAME)
            g_GUI->setTypeGUI(GUI_TYPE_SETT);
        break;
    case GUI_BTN_GAME_EXIT:
        if(g_GUI->getTypeGUI() == GUI_TYPE_PAUSE_GAME)
			g_GUI->setTypeGUI(GUI_TYPE_WARNING);
        break;

    //----------------------------------------------------------------------------------
    // Navegación por arenas y por coches en SELECT_ARENA y SELECT_VEHICLE
    case GUI_BTN_SELECT_NEXT:
        switch(g_GUI->getTypeGUI())
        {
        case GUI_TYPE_SELECT_ARENA:   g_GUI->nextArena();  break;
        case GUI_TYPE_SELECT_VEHICLE: g_GUI->nextVehicle(); break;
        }
        break;
    case GUI_BTN_SELECT_PRIOR:
        switch(g_GUI->getTypeGUI())
        {
        case GUI_TYPE_SELECT_ARENA:   g_GUI->priorArena();  break;
        case GUI_TYPE_SELECT_VEHICLE: g_GUI->priorVehicle(); break;
        }
        break;
    case GUI_LISTBOX_SELECT_ARENA:
        g_GUI->setArena(g_GUI->getGUI()->GetListBox(GUI_LISTBOX_SELECT_ARENA)->GetSelectedIndex());
        break;
    case GUI_LISTBOX_SELECT_VEHICLE:
        g_GUI->setVehicle(g_GUI->getGUI()->GetListBox(GUI_LISTBOX_SELECT_VEHICLE)->GetSelectedIndex());
        break;
    //----------------------------------------------------------------------------------
    case GUI_BTN_SETT:
        g_GUI->setTypeGUI(GUI_TYPE_SETT);
        break;
    case GUI_BTN_SETT_DISPLAY:
        g_Settings->RefreshControls(GUI_TYPE_SETT_DISPLAY);
        g_GUI->setTypeGUI(GUI_TYPE_SETT_DISPLAY);
        break;
    case GUI_BTN_SETT_SOUND:
        g_Settings->RefreshControls(GUI_TYPE_SETT_SOUND);
        g_GUI->setTypeGUI(GUI_TYPE_SETT_SOUND);
        break;
    case GUI_BTN_SETT_GAME:
        g_Settings->RefreshControls(GUI_TYPE_SETT_GAME);
        g_GUI->setTypeGUI(GUI_TYPE_SETT_GAME);
        break;
    //----------------------------------------------------------------------------------
    case GUI_BTN_EXIT:
        SendMessage( DXUTGetHWND(), WM_CLOSE, 0, 0 );
        break;
    }
}
