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