Jeck - Fix for issue 580. StyleManager initialization was causing an infinite loop. Also started documentation for OptionItem.

This commit is contained in:
wagic.jeck
2011-02-01 19:11:43 +00:00
parent ea285e673e
commit 8c18d155b8
4 changed files with 67 additions and 21 deletions
+62 -18
View File
@@ -1,6 +1,9 @@
#ifndef _OPTION_ITEM_H_ #ifndef _OPTION_ITEM_H_
#define _OPTION_ITEM_H_ #define _OPTION_ITEM_H_
/**
@file OptionItem.h
Includes classes and functionality related to the options menu.
*/
#include <JGui.h> #include <JGui.h>
#include <vector> #include <vector>
#include <string> #include <string>
@@ -20,18 +23,32 @@ using std::string;
#define PATH_MAX 4096 #define PATH_MAX 4096
#endif #endif
/**
@defgroup WGuiOptions Options Gui
@ingroup WGui
@{
*/
/**
The base class for all option menu items.
*/
class OptionItem: public WGuiItem class OptionItem: public WGuiItem
{ {
public: public:
OptionItem(int _id, string _displayValue); OptionItem(int _id, string _displayValue);
virtual ~OptionItem() {}; virtual ~OptionItem() {};
//Accessors /**
Returns the index into ::options used to store and retrieve this option.
*/
virtual int getId() virtual int getId()
{ {
return id; return id;
} }
/**
Changes the index into ::options used to store and retrieve this option.
*/
virtual void setId(int _id) virtual void setId(int _id)
{ {
id = _id; id = _id;
@@ -41,13 +58,18 @@ protected:
int id; int id;
}; };
/**
A numeric option item. Can be decorated with WDecoEnum to provide a string representation of the numeric values.
*/
class OptionInteger: public OptionItem class OptionInteger: public OptionItem
{ {
public: public:
int value; //Current value. int value; ///< Current value the option is displaying.
int defValue; //Default value. int defValue; ///< Default value for the option.
string strDefault; //What to call the default value. string strDefault; ///< What to call the default value in the menu.
int maxValue, increment, minValue; int maxValue; ///< Maximum value of the option.
int minValue; ///< Minimum value of the option.
int increment; ///< Amount to increment the option by when clicked.
OptionInteger(int _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "", int _minValue = 0); OptionInteger(int _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "", int _minValue = 0);
@@ -73,11 +95,14 @@ public:
}; };
/**
An option represented as one of a set of strings.
*/
class OptionSelect: public OptionItem class OptionSelect: public OptionItem
{ {
public: public:
size_t value; size_t value; ///< Currently selected option, an index into selections.
vector<string> selections; vector<string> selections; ///< Vector containing all possible values.
virtual void addSelection(string s); virtual void addSelection(string s);
OptionSelect(int _id, string _displayValue) : OptionSelect(int _id, string _displayValue) :
@@ -109,9 +134,12 @@ public:
} }
; ;
protected: protected:
size_t prior_value; size_t prior_value; ///< The prior selected value, in case a change is cancelled.
}; };
/**
An option representing possible languages. Automatically loads the list of possibilities from the lang/ folder.
*/
class OptionLanguage: public OptionSelect class OptionLanguage: public OptionSelect
{ {
public: public:
@@ -130,9 +158,12 @@ public:
virtual bool Selectable(); virtual bool Selectable();
virtual void setData(); virtual void setData();
protected: protected:
vector<string> actual_data; vector<string> actual_data; ///< An array containing the actual value we set the option to, rather than the display value in selections.
}; };
/**
An option representing possible theme substyles. Automatically loads the list of possibilities from the current theme.
*/
class OptionThemeStyle: public OptionSelect class OptionThemeStyle: public OptionSelect
{ {
public: public:
@@ -142,20 +173,25 @@ public:
OptionThemeStyle(string _displayValue); OptionThemeStyle(string _displayValue);
}; };
/**
An option allowing the user to choose a directory, provided it contains a certain file.
*/
class OptionDirectory: public OptionSelect class OptionDirectory: public OptionSelect
{ {
public: public:
virtual void Reload(); virtual void Reload();
OptionDirectory(string root, int id, string displayValue, const string type); OptionDirectory(string root, int id, string displayValue, const string type);
protected: protected:
const string root; const string root; ///< The root directory to search for subdirectories.
const string type; const string type; ///< The file to check for in a useable subdirectory.
}; };
/**
An option allowing the player to choose a theme directory. Requires that the theme directory contains a preview.png.
*/
class OptionTheme: public OptionDirectory class OptionTheme: public OptionDirectory
{ {
private: private:
static const string DIRTESTER; static const string DIRTESTER; ///< A particular file to look for when building the list of possible directories.
public: public:
OptionTheme(OptionThemeStyle * style = NULL); OptionTheme(OptionThemeStyle * style = NULL);
JQuadPtr getImage(); JQuadPtr getImage();
@@ -166,15 +202,18 @@ public:
virtual bool Visible(); virtual bool Visible();
protected: protected:
OptionThemeStyle * ts; OptionThemeStyle * ts; ///< The current theme style.
string author; string author; ///< The theme author
bool bChecked; bool bChecked; ///< Whether or not the theme has been checked for metadata
}; };
/**
An option allowing the player to choose a profile directory. Requires that the profile directory contains a collection.dat.
*/
class OptionProfile: public OptionDirectory class OptionProfile: public OptionDirectory
{ {
private: private:
static const string DIRTESTER; static const string DIRTESTER; ///< A particular file to look for when building the list of possible directories.
public: public:
OptionProfile(GameApp * _app, JGuiListener * jgl); OptionProfile(GameApp * _app, JGuiListener * jgl);
virtual void addSelection(string s); virtual void addSelection(string s);
@@ -203,6 +242,9 @@ private:
size_t initialValue; size_t initialValue;
}; };
/**
An option allowing the player to bind a key to a specific interaction.
*/
class OptionKey: public WGuiItem, public KeybGrabber class OptionKey: public WGuiItem, public KeybGrabber
{ {
public: public:
@@ -223,4 +265,6 @@ protected:
GameStateOptions* g; GameStateOptions* g;
SimpleMenu* btnMenu; SimpleMenu* btnMenu;
}; };
/**@} This comment used by Doxyyen. */
#endif #endif
+3 -1
View File
@@ -490,8 +490,10 @@ GameSettings::GameSettings()
WStyle * GameSettings::getStyle() WStyle * GameSettings::getStyle()
{ {
if (!styleMan) if (!styleMan){
styleMan = new StyleManager(); styleMan = new StyleManager();
styleMan->determineActive(NULL,NULL);
}
return styleMan->get(); return styleMan->get();
} }
+1
View File
@@ -548,6 +548,7 @@ void OptionTheme::confirmChange(bool confirmed)
{ {
setData(); setData();
options.getStyleMan()->loadRules(); options.getStyleMan()->loadRules();
options.getStyleMan()->determineActive(NULL, NULL);
if (ts) if (ts)
ts->Reload(); ts->Reload();
-1
View File
@@ -104,7 +104,6 @@ void StyleManager::loadRules()
} }
} }
determineActive(NULL, NULL);
return; return;
} }