[1488] | 1 | #include <assert.h>
|
---|
| 2 | #define CHARBUF 250 ///< length of the buffer (one line to be saved to file)
|
---|
| 3 |
|
---|
| 4 | /// Boolean variables that will be displayed as GUI checkboxes.
|
---|
| 5 | typedef enum { bShowHelp, /*bAutoGenCubeMap, bUseCosTexture, */
|
---|
| 6 | bShowFireballs, bMultipleObjects, bConfineToRoom,
|
---|
| 7 | LAST_BOOL } bool_t;
|
---|
| 8 |
|
---|
| 9 | /// Numeric variables that will be displayed as GUI sliders.
|
---|
| 10 | typedef enum { iWhichMethod, iWhichMesh, fMeshScale,
|
---|
| 11 | iResolution, iShowCubeMap, fIntensity, iShininess,
|
---|
| 12 | LAST_NUMBER } number_t;
|
---|
| 13 |
|
---|
| 14 | /// Possible values for #iWhichMethod.
|
---|
| 15 | typedef enum {
|
---|
| 16 | DIFFUSE_SPECULAR_CLASSIC, ///< Classic environment mapping technique.
|
---|
| 17 | DIFFUSE_SPECULAR_LOCALIZED, ///< Our proposal.
|
---|
[1534] | 18 | DIFFUSE_SPECULAR_LOCALIZED_5TEX, ///< Our proposal, using 5 texel only.
|
---|
[1573] | 19 | DIFFUSE_SPECULAR_LOCALIZED_NEW, ///< Our proposal.
|
---|
| 20 | DIFFUSE_SPECULAR_LOCALIZED_P2P ///< Point to point form factor
|
---|
[1488] | 21 | } method_t;
|
---|
| 22 |
|
---|
| 23 | /// Parameter-manager buttons
|
---|
| 24 | typedef enum {
|
---|
| 25 | IDC_RESET_BUTTON = -3,
|
---|
| 26 | IDC_SAVE_BUTTON,
|
---|
| 27 | IDC_LOAD_BUTTON
|
---|
| 28 | } std_buttons_t;
|
---|
| 29 |
|
---|
| 30 | /// Conversion function (see Parameters::Add()).
|
---|
| 31 | /// E.g. to create a slider that produces exponential values.
|
---|
| 32 | typedef float (*CONVERTER)(float a);
|
---|
| 33 | /// Change callback function (see Parameters::Add()).
|
---|
| 34 | /// To be called when the respective parameter is modified.
|
---|
| 35 | typedef void (*ONCHANGE_CALLBACK)(void);
|
---|
| 36 |
|
---|
| 37 | /// Default conversion function (see #CONVERTER).
|
---|
| 38 | /// Does nothing but returning the value passed.
|
---|
| 39 | float noconvert(float a); // { return a; }
|
---|
| 40 | /// Default change callback function (see #ONCHANGE_CALLBACK).
|
---|
| 41 | /// Does nothing.
|
---|
| 42 | void OnChange(); // {}
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
| 45 | \brief Manages application parameters.
|
---|
| 46 | \brief Creates GUI controls (sliders, checkboxes) and hotkeys.
|
---|
| 47 |
|
---|
| 48 | \author Istvan Lazanyi, TU Budapest
|
---|
| 49 | \date 2006-04-26
|
---|
| 50 | */
|
---|
| 51 | class Parameters {
|
---|
| 52 | bool bparam[LAST_BOOL]; ///< current param value (boolean)
|
---|
| 53 | wchar_t bname[LAST_BOOL][CHARBUF]; ///< param name
|
---|
| 54 | int radiogroup[LAST_BOOL]; ///< for boolean params that are represented by a checkbox
|
---|
| 55 |
|
---|
| 56 | int param[LAST_NUMBER]; ///< current param value (numeric)
|
---|
| 57 | wchar_t name[LAST_NUMBER][CHARBUF]; ///< param name
|
---|
| 58 | int numsteps[LAST_NUMBER]; ///< number of possible steps for param
|
---|
| 59 | bool rotate[LAST_NUMBER]; ///< stores whether the slider can rotate around
|
---|
| 60 |
|
---|
| 61 | CONVERTER ffunc[LAST_NUMBER];
|
---|
| 62 | ONCHANGE_CALLBACK chfunc[LAST_NUMBER+3];
|
---|
| 63 | ONCHANGE_CALLBACK bchfunc[LAST_BOOL];
|
---|
| 64 |
|
---|
| 65 | CDXUTDialog* g_HUD;
|
---|
| 66 |
|
---|
| 67 | bool bSilent; ///< to avoid an endless loop due to a change
|
---|
| 68 | const static int CHARBUFFER_SIZE = 200;
|
---|
| 69 | enum { checkboxID0 = 1000, sliderID0 = 2000, staticID0 = 3000, upID0 = 4000, downID0 = 5000 };
|
---|
| 70 |
|
---|
| 71 | public:
|
---|
| 72 | void Setup( CDXUTDialog* g_HUD );
|
---|
| 73 | void Setup( CDXUTDialog* g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave = OnChange, ONCHANGE_CALLBACK OnLoad = OnChange);
|
---|
| 74 |
|
---|
| 75 | bool Get( bool_t i );
|
---|
| 76 | float Get( number_t i );
|
---|
| 77 | int GetInt( number_t i );
|
---|
| 78 |
|
---|
| 79 | void SetBool( bool_t ID, bool b );
|
---|
| 80 | void SetFloat( number_t ID, float v );
|
---|
| 81 | void SetInt( number_t ID, int v );
|
---|
| 82 |
|
---|
| 83 | void Add( bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
|
---|
| 84 | void Add( int radiogroupID, bool_t ID, char* label, char cHotKey = 0, ONCHANGE_CALLBACK bchf = OnChange );
|
---|
| 85 |
|
---|
| 86 | void Add( number_t ID, char* label, int num_steps);
|
---|
| 87 |
|
---|
| 88 | void Add( number_t ID, char* label, int num_steps,
|
---|
| 89 | CONVERTER ff, ONCHANGE_CALLBACK chf = OnChange );
|
---|
| 90 |
|
---|
| 91 | void Add( number_t ID, char* label, int num_steps, char cKeyDecr, char cKeyIncr = 0,
|
---|
| 92 | CONVERTER ff = noconvert, ONCHANGE_CALLBACK chf = OnChange );
|
---|
| 93 |
|
---|
| 94 | void SetEnabled( bool_t ID, bool bEnabled );
|
---|
| 95 | void SetEnabled( number_t ID, bool bEnabled );
|
---|
| 96 |
|
---|
| 97 | void UpdateFromHUD( int controlID );
|
---|
| 98 |
|
---|
| 99 | void SaveToFile( char* fileName );
|
---|
| 100 | void LoadFromFile( char* fileName );
|
---|
| 101 | }; |
---|