/*
	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_SPACESTATION_H
#define GUISCREEN_SPACESTATION_H

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

class GuiButton;
class GuiLabel;
class GuiImage;
class GuiHRule;
class GuiTrade_Buy;
class GuiTrade_Sell;
class GuiTrade_Status;
class GuiStarInfo;
class GuiMarketInfo;
class GuiRepair;
class GuiUpgrade;
class GuiBuyShip_Select;
class GuiBuyShip_Buy;
class GuiLoadGame;
class GuiSaveGame;
class GLFontManager;
class Game;

//##############################################################################
// These cannot be forward referenced
//##############################################################################

#include "GuiPanel.h"
#include "GuiScreen.h"
#include "GuiGalaxyMap.h"

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   GuiScreen_SpaceStation
// Purpose:      Gui screen which is displayed when the player gets into a spacestation.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class GuiScreen_SpaceStation : public GuiScreen
{

 public:

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

        // Constructor: needs pointer to a game

        GuiScreen_SpaceStation( Game * game );

        // Destructor:

        ~GuiScreen_SpaceStation();

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

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

            panelMap->setVisible(false);
            panelUpgrade->setVisible(false);
            panelRepair->setVisible(false);
            panelBuyShip->setVisible(false);
            panelLoad->setVisible(false);
            panelSave->setVisible(false);

            panelMap->setEnabled(false);
            panelUpgrade->setEnabled(false);
            panelRepair->setEnabled(false);
            panelBuyShip->setEnabled(false);
            panelLoad->setEnabled(false);
            panelSave->setEnabled(false);

            // Make this panel visible

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

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

            panelTrade->setVisible(false);
            panelUpgrade->setVisible(false);
            panelRepair->setVisible(false);
            panelBuyShip->setVisible(false);
            panelLoad->setVisible(false);
            panelSave->setVisible(false);

            panelTrade->setEnabled(false);
            panelUpgrade->setEnabled(false);
            panelRepair->setEnabled(false);
            panelBuyShip->setEnabled(false);
            panelLoad->setEnabled(false);
            panelSave->setEnabled(false);

            // Make this panel visible

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

            // Re-center the map on the players system:

            galacticMap->centerView();
        }

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

            panelTrade->setVisible(false);
            panelMap->setVisible(false);
            panelRepair->setVisible(false);
            panelBuyShip->setVisible(false);
            panelLoad->setVisible(false);
            panelSave->setVisible(false);

            panelTrade->setEnabled(false);
            panelMap->setEnabled(false);
            panelRepair->setEnabled(false);
            panelBuyShip->setEnabled(false);
            panelLoad->setEnabled(false);
            panelSave->setEnabled(false);

            // Make this panel visible

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

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

            panelTrade->setVisible(false);
            panelMap->setVisible(false);
            panelUpgrade->setVisible(false);
            panelBuyShip->setVisible(false);
            panelLoad->setVisible(false);
            panelSave->setVisible(false);

            panelTrade->setEnabled(false);
            panelMap->setEnabled(false);
            panelUpgrade->setEnabled(false);
            panelBuyShip->setEnabled(false);
            panelLoad->setEnabled(false);
            panelSave->setEnabled(false);

            // Make this panel visible

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

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

            panelTrade->setVisible(false);
            panelMap->setVisible(false);
            panelUpgrade->setVisible(false);
            panelRepair->setVisible(false);
            panelLoad->setVisible(false);
            panelSave->setVisible(false);

            panelTrade->setEnabled(false);
            panelMap->setEnabled(false);
            panelUpgrade->setEnabled(false);
            panelRepair->setEnabled(false);
            panelLoad->setEnabled(false);
            panelSave->setEnabled(false);

            // Make this panel visible

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

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

            panelTrade->setVisible(false);
            panelMap->setVisible(false);
            panelUpgrade->setVisible(false);
            panelBuyShip->setVisible(false);
            panelRepair->setVisible(false);
            panelSave->setVisible(false);

            panelTrade->setEnabled(false);
            panelMap->setEnabled(false);
            panelUpgrade->setEnabled(false);
            panelBuyShip->setEnabled(false);
            panelRepair->setEnabled(false);
            panelSave->setEnabled(false);

            // Make this panel visible

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

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

            panelTrade->setVisible(false);
            panelMap->setVisible(false);
            panelUpgrade->setVisible(false);
            panelBuyShip->setVisible(false);
            panelRepair->setVisible(false);
            panelLoad->setVisible(false);

            panelTrade->setEnabled(false);
            panelMap->setEnabled(false);
            panelUpgrade->setEnabled(false);
            panelBuyShip->setEnabled(false);
            panelRepair->setEnabled(false);
            panelLoad->setEnabled(false);

            // Make this panel visible

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

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

 private:

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

        GuiPanel * panelTrade;
        GuiPanel * panelMap;
        GuiPanel * panelUpgrade;
        GuiPanel * panelRepair;
        GuiPanel * panelBuyShip;
        GuiPanel * panelLoad;
        GuiPanel * panelSave;

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

        class EventTrade : public GLWindowEventListener
        {
            public:

            // Constructor

            EventTrade(GuiScreen_SpaceStation * guiScreen) : guiScreen(guiScreen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)

            // Implements button released event

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

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

                // Open up the trade panel

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        class EventMap : public GLWindowEventListener
        {
            public:

            // Constructor

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

            // Implements button released event

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

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

                // Open up the map panel

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        class EventUpgrade : public GLWindowEventListener
        {
            public:

            // Constructor

            EventUpgrade(GuiScreen_SpaceStation * guiScreen) : guiScreen(guiScreen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)                 

            // Implements button released event

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

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

                // Open up the upgrade ship panel

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        class EventRepair : public GLWindowEventListener
        {
            public:

            // Constructor

            EventRepair(GuiScreen_SpaceStation * guiScreen) : guiScreen(guiScreen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)                  

            // Implements button released event

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

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

                // Open up the repair ship panel

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        class EventBuyShip : public GLWindowEventListener
        {
            public:

            // Constructor

            EventBuyShip(GuiScreen_SpaceStation * guiScreen) : guiScreen(guiScreen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)                

            // Implements button released event

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

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

                // Open up the buy ship panel

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        class EventLoad : public GLWindowEventListener
        {
            public:

            // Constructor

            EventLoad(GuiScreen_SpaceStation * guiScreen) : guiScreen(guiScreen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)              

            // Implements button released event

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

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

                // Open up the load panel

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        class EventSave : public GLWindowEventListener
        {
            public:

            // Constructor

            EventSave(GuiScreen_SpaceStation * guiScreen) : guiScreen(guiScreen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)            

            // Implements button released event

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

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

                // Open up the save panel

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        class EventLaunch : public GLWindowEventListener
        {
            public:

            // Constructor

            EventLaunch(GuiScreen_SpaceStation * guiScreen) : guiScreen(guiScreen){;}
            
            // No unreferenced param warning
            
            #pragma warning(disable:4100)               

            // Implements button released event

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

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

                // Exit the gui screen:

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

            // GuiScreen the listener belgons to

            GuiScreen_SpaceStation * guiScreen;
        };

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

        EventTrade      * eventTrade;
        EventMap        * eventMap;
        EventUpgrade    * eventUpgrade;
        EventRepair     * eventRepair;
        EventBuyShip    * eventBuyShip;
        EventLoad       * eventLoad;
        EventSave       * eventSave;
        EventLaunch     * eventLaunch;

        // The galactic map widget:

        GuiGalaxyMap * galacticMap;

}; // end of: class GuiScreen_SpaceStation{}

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

#include "GuiButton.h"
#include "GuiLabel.h"
#include "GuiImage.h"
#include "GuiHRule.h"
#include "GuiTrade_Buy.h"
#include "GuiTrade_Sell.h"
#include "GuiTrade_Status.h"
#include "GuiStarInfo.h"
#include "GuiMarketInfo.h"
#include "GuiRepair.h"
#include "GuiUpgrade.h"
#include "GuiBuyShip_Select.h"
#include "GuiBuyShip_Buy.h"
#include "GuiLoadGame.h"
#include "GuiSaveGame.h"
#include "GLFontManager.h"
#include "Game.h"
#include "Ships.h"

#endif  // ifndef GUISCREEN_SPACESTATION_H

