Jump to content
  • Advertisement
Sign in to follow this  
Xeta

Game settings problem

This topic is 5390 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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<int>(), which would then convert the void-ptr to an int, and return it...

Is this anywhere near what you're looking for?

Share this post


Link to post
Share on other sites
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<string, BaseSetting>" instance. The string is for the name of the setting/variable and the BaseSetting (which will be used with for example "Setting<int>" 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 <string, BaseSetting>" 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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!