////////////////////////////////////////////////////////////////////////////////
// Declaration of configuration class for plab
// Copyright Björn Ganster
// Developed since 2007
////////////////////////////////////////////////////////////////////////////////

#ifndef plabConfig__H
#define plabConfig__H

#include "Color.h"
#include <vector>

#define MECH_SUB_DIR "mechs"

////////////////////////////////////////////////////////////////////////////////

class Config {
public:
   // Constructor
   Config();

   // Destructor
   ~Config();

   // Read configuration
   bool readFromFile (const PathChar* FileName);

   // Get settings
   Color& getViewerBackgroundColor();
   Color& getInactiveModeButtonColor();
   Color& getActiveModeButtonColor();
   Color& getTextColor();
   bool experimentalFeaturesEnabled() const;
   double getDouble(const BGCPString& key) const;

   // Add new pair of key and values
   void addKeyValuePair (const BGCPString& key, const BGCPString& value); 

   // Get keys and values
   BGCPString getValue (const BGCPString& key) const;
   const BGCPString& getValue (size_t i) const;
   const BGCPString& getKey (size_t i) const;

   // Find first line after given line that contains str
   int FindFirstKeyAfterLine (int line, const char* str);

   // Get number of key/value pairs
   size_t getKeyCount() const;

   // Change key/value pair
   void setKeyValuePair (size_t i, const BGCPString& key, const BGCPString& value);

   // Insert key/value pair
   void insertKeyValuePair (size_t i, const BGCPString& key, const BGCPString& value);

   // Queries
   bool hasKeyValuePair (const char* key, const char* value);
   int findValue (const char* value);

   // Functions to query how joystick axis are assigned to aerospace fighter movement
   int getRollAxis();
   int getPitchAxis();
   int getThrottleAxis();

   // Remove game from config
   void removeGame(const BGCPString& gameNameToRemove);

private:
   Color ViewerBackgroundColor, inactiveModeButtonColor, ActiveModeButtonColor,
         TextColor;
   BGCPString ConfigFN;
   std::vector <BGCPString> keys, values;
   bool m_experimentalFeaturesEnabled;

   void writeConfig();
};

////////////////////////////////////////////////////////////////////////////////
// Access config

Config* getConfig();
Config* createConfig();

bool experimentalFeaturesEnabled();

#endif
