/*
	Rogue Trader.
	Copyright (c) 2007, Darragh Coy.
	All rights reserved.
	Original work(s), source code & author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in source and binary forms, with or without modification, are permitted 
	provided that the following conditions are met:

		* 	Redistributions of source code must retain the above copyright notice, this list of 
			conditions and the following disclaimer.
		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
		* 	The use of any third party libraries, modules or data files provided with the source 
			form of the program must follow and respect the individual licensing terms of these 
			components. You do not have permission to modify or circumvent the licensing terms for 
			provided third party components unless the third party licenses specifically allow this. 
			If you do not agree to the terms of provided third party components then you do not have 
			permission to use them in your derived work(s).
		* 	The terms of this license do not apply to separate (but related) distributions if supplied 
			by the author(s), only to the contents of this source distribution, derived works, and the 
			binaries produced by either modified or unmodified versions of the source code. The terms 
			of this license do not also apply to any third party libraries or components provided with 
			the source distribution. Such third party elements are licensed under their own separate 
			agreements.

	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef GUISCREEN_INGAMEMENU_H
#define GUISCREEN_INGAMEMENU_H

//##############################################################################
// Foward references
//##############################################################################

class GuiButton;
class GuiLabel;
class GuiVariableLabel;
class GuiImage;
class GuiHRule;
class GLFontManager;
class GuiGalaxyMap;
class GuiStarInfo;
class GuiMarketInfo;
class GuiCargoInfo;
class GuiShipInfo;
class GuiPlayerInfo;

//##############################################################################
// Stuff that cannot be forward referenced
//##############################################################################

#include "Game.h"
#include "GuiScreen.h"
#include "GuiPanel.h"

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   GuiScreen_InGameMenu
// Purpose:      In game menu GUI screen.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class GuiScreen_InGameMenu : public GuiScreen
{

 public:

        //----------------------------------------------------------------------
        // Functions
        //----------------------------------------------------------------------

        // Constructor: needs pointer to a game

        GuiScreen_InGameMenu( Game * game );

        // Destructor:

        ~GuiScreen_InGameMenu();

        // Make one of the panels visible and the others invisible:

        void setCurrentPanel_map()
        {
            // Disable and make all other panels invisble

            panelShipInfo->setVisible(false);
            panelCargoInfo->setVisible(false);
            panelCommanderInfo->setVisible(false);

            panelShipInfo->setEnabled(false);
            panelCargoInfo->setEnabled(false);
            panelCommanderInfo->setEnabled(false);

            // Make this panel visible

            panelMap->setVisible(true);
            panelMap->setEnabled(true);
        }

        void setCurrentPanel_cargoInfo()
        {
            // Disable and make all other panels invisble

            panelMap->setEnabled(false);
            panelShipInfo->setVisible(false);
            panelCommanderInfo->setVisible(false);

            panelMap->setVisible(false);
            panelShipInfo->setEnabled(false);
            panelCommanderInfo->setEnabled(false);

            // Make this panel visible

            panelCargoInfo->setVisible(true);
            panelCargoInfo->setEnabled(true);
        }

        void setCurrentPanel_shipInfo()
        {
            // Disable and make all other panels invisble

            panelMap->setEnabled(false);
            panelCargoInfo->setVisible(false);
            panelCommanderInfo->setVisible(false);

            panelMap->setVisible(false);
            panelCargoInfo->setEnabled(false);
            panelCommanderInfo->setEnabled(false);

            // Make this panel visible

            panelShipInfo->setVisible(true);
            panelShipInfo->setEnabled(true);
        }

        void setCurrentPanel_commanderInfo()
        {
            // Disable and make all other panels invisble

            panelMap->setEnabled(false);
            panelCargoInfo->setVisible(false);
            panelShipInfo->setVisible(false);

            panelMap->setVisible(false);
            panelCargoInfo->setEnabled(false);
            panelShipInfo->setEnabled(false);

            // Make this panel visible

            panelCommanderInfo->setVisible(true);
            panelCommanderInfo->setEnabled(true);
        }

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

 private:

        //----------------------------------------------------------------------
        // The separate panels for the screen: only one is shown at a time
        //----------------------------------------------------------------------

        GuiPanel * panelMap;
        GuiPanel * panelCargoInfo;
        GuiPanel * panelShipInfo;
        GuiPanel * panelCommanderInfo;

        //----------------------------------------------------------------------
        // Event listener class definitions:
        //----------------------------------------------------------------------

        class EventMap : public GLWindowEventListener
        {
            public:

            // Constructor: takes guiscreen the listener belongs to and game object

            EventMap( GuiScreen_InGameMenu * screen ) : guiScreen(screen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)                 

            // Implements button released event

            void mouseReleased
            (
                int x ,
                int y ,
                GLWindow::MouseButton button
            )
            {
                // Abort if not the lmb

                if ( button != GLWindow::MOUSE_BUTTON_LEFT ) return;

                // Make map panel visibile and all others invisible

                guiScreen->setCurrentPanel_map();
            }
            
            // Restore this to normal
            
            #pragma warning(default:4100)              

            // GuiScreen the listener belgons to

            GuiScreen_InGameMenu * guiScreen;

            // Game object

            Game * game;
        };

        //======================================================================

        class EventCargoInfo : public GLWindowEventListener
        {
            public:

            // Constructor: takes guiscreen the listener belongs to and game object

            EventCargoInfo( GuiScreen_InGameMenu * screen ) : guiScreen(screen) {;}            
           
            // No unreferenced param warning
            
            #pragma warning(disable:4100)            

            // Implements button released event

            void mouseReleased
            (
                int x ,
                int y ,
                GLWindow::MouseButton button
            )
            {
                // Abort if not the lmb

                if ( button != GLWindow::MOUSE_BUTTON_LEFT ) return;

                // Make cargo info panel visibile and all others invisible

                guiScreen->setCurrentPanel_cargoInfo();
            }
            
            // Restore this to normal
            
            #pragma warning(default:4100)            

            // GuiScreen the listener belgons to

            GuiScreen_InGameMenu * guiScreen;
        };


        //======================================================================

        class EventShipInfo : public GLWindowEventListener
        {
            public:

            // Constructor: takes guiscreen the listener belongs to and game object

            EventShipInfo( GuiScreen_InGameMenu * screen ) : guiScreen(screen) {;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)            

            // Implements button released event

            void mouseReleased
            (
                int x ,
                int y ,
                GLWindow::MouseButton button
            )
            {
                // Abort if not the lmb

                if ( button != GLWindow::MOUSE_BUTTON_LEFT ) return;

                // Make ship info panel visibile and all others invisible

                guiScreen->setCurrentPanel_shipInfo();
            }
            
            // Restore this to normal
            
            #pragma warning(default:4100)            

            // Game object

            GuiScreen_InGameMenu * guiScreen;
        };

        //======================================================================

        class EventCommanderInfo : public GLWindowEventListener
        {
            public:

            // Constructor: takes guiscreen the listener belongs to and game object

            EventCommanderInfo( GuiScreen_InGameMenu * screen ) : guiScreen(screen) {;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)                

            // Implements button released event

            void mouseReleased
            (
                int x ,
                int y ,
                GLWindow::MouseButton button
            )
            {
                // Abort if not the lmb

                if ( button != GLWindow::MOUSE_BUTTON_LEFT ) return;

                // Make commander info panel visibile and all others invisible

                guiScreen->setCurrentPanel_commanderInfo();
            }
            
            // Restore this to normal
            
            #pragma warning(default:4100)             

            // GuiScreen the listener belgons to

            GuiScreen_InGameMenu * guiScreen;
        };

        //======================================================================

        class EventReturn : public GLWindowEventListener
        {
            public:

            // Constructor: takes guiscreen the listener belongs

            EventReturn( GuiScreen_InGameMenu * screen ) : guiScreen(screen) {;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)              

            // Implements button released event

            void mouseReleased
            (
                int x ,
                int y ,
                GLWindow::MouseButton button
            )
            {
                // Abort if not the lmb

                if ( button != GLWindow::MOUSE_BUTTON_LEFT ) return;

                // Exit the gui screen this widget belongs to

                guiScreen->exit();
            }

            // Restore this to normal
            
            #pragma warning(default:4100)     

            // GuiScreen the listener belgons to

            GuiScreen_InGameMenu * guiScreen;
        };

        //======================================================================

        class EventQuit : public GLWindowEventListener
        {
            public:

            // Constructor: takes guiscreen the listener belongs to and game object

            EventQuit( GuiScreen_InGameMenu * screen , Game * game ) : guiScreen(screen) , game(game) {;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)                

            // Implements button released event

            void mouseReleased
            (
                int x ,
                int y ,
                GLWindow::MouseButton button
            )
            {
                // Abort if not the lmb

                if ( button != GLWindow::MOUSE_BUTTON_LEFT ) return;

                // Confirm with te user do s/he want to quit:

                if (
                        GuiScreen::showQuestionDialog
                        (
                            "Confirm quit" ,
                            "Any unsaved progress will be lost." ,
                            "Are you sure you want to quit the game ?"
                        )
                    )
                {
                    // Tell the game to stop running:

                    game->stop();

                    // Exit the gui screen this widget belongs to

                    guiScreen->exit();
                }
            }

            // Restore this to normal
            
            #pragma warning(default:4100)     

            // GuiScreen the listener belgons to

            GuiScreen_InGameMenu * guiScreen;

            // Game object

            Game * game;
        };

        //----------------------------------------------------------------------
        // Actual event listener objects:
        //----------------------------------------------------------------------

        EventMap            * eventMap;
        EventShipInfo       * eventShipInfo;
        EventCargoInfo      * eventCargoInfo;
        EventCommanderInfo  * eventCommanderInfo;
        EventReturn         * eventReturn;
        EventQuit           * eventQuit;

}; // end of: class GuiScreen_Startup{}

//##############################################################################
// C++ Includes
//##############################################################################

#include "GuiButton.h"
#include "GuiLabel.h"
#include "GuiVariableLabel.h"
#include "GuiImage.h"
#include "GuiHRule.h"
#include "GLFontManager.h"
#include "GuiGalaxyMap.h"
#include "GuiStarInfo.h"
#include "GuiMarketInfo.h"
#include "GuiCargoInfo.h"
#include "GuiShipInfo.h"
#include "GuiPlayerInfo.h"

#endif  // ifndef GUISCREEN_INGAMEMENU_H

