Skip to main content
gamedev.net
🔒 Locked

Game settings problem

Started by Xeta Oct 13, 2004 at 10:31 AM 2 replies 500+ views
Original Post
Xeta
Xeta
Hi... I am implementing a SettingsManager, based on the Enginuity engine. But I have (obviously) a problem. (Im not going to use settings with multiple values.) The "BaseSetting" (dator) class, is not a template so that there is no need to choose a specific variable type when creating a Settingsmap or list. It only includes some virtual functions for operator overloading and such. The derived class "Setting" has all those things to calculate from variable to string (for lets say, priting them on screen in text form) and vice versa. Just like Enginuity. This works fine one way... I can create different settings and put them in my SettingsManagers map, i can also return them as strings for viewing and give them new values. But i cant use my Settings directly in places where they are needed, like "video_width" should be used when creating the D3D COM object. That create function calls for an int. But i cant just put my SettingsManager (its a singleton by the way) map settingslist directly there cause it cant return as an int (because the main BaseSetting (dator) class dosen't know the variabletype, i cant create virtual functions for returning it. I dont know if I missed something obvious here (I'm quite new att the programming thing). But if anyone knows a sollution, please help me :) Oh and by the way, when you overload the '=' operator on class "whatever". Does it imply both on whatever = somethingelse and somethingelse = whatever ? And sorry if there are any spelling errors, my english is not the best. \\Xeta
_Phalanx_
_Phalanx_
Im guessing since you have like 60 veiws and no replys, most people probly dont know what this settings manager is your talking about, (i dont) plz explain it.
stein
stein
I'm not quite sure how you're using these classes...

Is it like class VideoWidth : public BaseSetting?

If yes, then you could just go:

((VideoWidth*)pBaseSettingWhichIsAVideoWidth)->Get(), which would then return an int, as declared in VideoWidth.

If the actual value is store in BaseSetting on the other hand, then you could make a templated Get-function...

Then you could do:

pBaseSettingWhichIsAVideoWidth->Get(), which would then convert the void-ptr to an int, and return it...

Is this anywhere near what you're looking for?
| Stein Nygård - http://steinware.dk |
Xeta
Xeta
Hi again, thanks for the replys. Im sorry for being unclear.

I want to have Settings Manager to have a list of all essensial game-related variables. I want them all in one place (in a std::map) just so they can be easily accessable. And to sometime in the future letting the game-user change thease variables in-game with a console.

'BaseSetting' is a normal class. 'Setting' is a template (typename T) which inherits from 'BaseSetting'.
Then i have a third calss called 'SettingManager' which was a "std::map" instance. The string is for the name of the setting/variable and the BaseSetting (which will be used with for example "Setting" later) contains the actual variable. 'SettingManager' also has functions for registering new variables and changing them.

Now, with the 'SettingManager' i can store new settings(variables) of different types and change them. (When changing a value for a variable it always asks for a String, and then the 'Setting' class automaticly changes it into its 'typename T', like an int or something). But the problem is that i want to be able to use the Settings Manager where the relevant variables are used.
For exampel in a fuction that draws a player in its current possition:

// i have some 'void DrawPlayer(int x, int y)' fuction.
// 'settingList' is the "map " I wrote
// about before. 'SettingManager' is the actions Settings
// Manager class that contains the settingmap.

DrawPlayer(SettingManager->settingList["playerX"], SettingManager->settingList["playerY"]);

'playerX' and 'playerY' are the Setting names, in the setting map. The 'video_width' i wrote about before was the same, its a setting name for the settingmap and not its own class (sorry for the confusion).

So now, the problem is that "settingList["playerX"]" cannot return as a 'int' value because the setting map is created with just 'BaseSetting' and doesn't know the variable typename. Is tere any other system or something i can do to get around this?

\\Xeta

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.