About Store Forum Documentation Contact



Post Reply 
Save/Load Engine Settings
Author Message
Esenthel Online
Administrator

Post: #1
Save/Load Engine Settings
Small tutorial showing how to load a few basic engine settings:
Code:
/******************************************************************************/
void SaveSettings(TextData &data)
{
   data.getNode("Width"     ).value=S+D.x();
   data.getNode("Height"    ).value=S+D.y();
   data.getNode("Fullscreen").value=S+D.full();
}
void LoadSettings(TextData &data)
{
   int x=-1, y=-1, full=-1;
   if(TextNode *node  =data.findNode("Fullscreen"))full=node  .asInt();
   if(TextNode *width =data.findNode("Width"     ))x   =width .asInt();
   if(TextNode *height=data.findNode("Height"    ))y   =height.asInt();
   D.mode(x, y, full);
}
void SaveSettings(C Str &name="Settings.txt")
{
   TextData settings; SaveSettings(settings); settings.save(name);
}
void LoadSettings(C Str &name="Settings.txt")
{
   TextData settings; if(settings.load(name))LoadSettings(settings);
}
/******************************************************************************/
void InitPre()
{
   EE_INIT();
   App.flag|=APP_MAXIMIZABLE|APP_MINIMIZABLE|APP_RESIZABLE|APP_FULL_TOGGLE;
   LoadSettings();
}
bool Init()
{
   return true;
}
void Shut()
{
   SaveSettings();
}
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   return true;
}
void Draw()
{
   D.clear();
}
/******************************************************************************/
10-14-2013 06:02 AM
Find all posts by this user Quote this message in a reply
SamerK Offline
Member

Post: #2
RE: Save/Load Engine Settings
That's really useful, many thanks.
10-14-2013 01:59 PM
Find all posts by this user Quote this message in a reply
docrst Offline
Member

Post: #3
RE: Save/Load Engine Settings
wooohooo, it worked, thank you for the awesome post on how to fix the change!
I take back every thing I never said bad about you!
10-15-2013 03:22 AM
Visit this user's website Find all posts by this user Quote this message in a reply
docrst Offline
Member

Post: #4
RE: Save/Load Engine Settings
so now i have a blank - black client

/******************************************************************************/
void SetGuiSkin(int skin)
{
UID id;
switch(skin)
{
default: id=UID(1879466926, 1079990496, 2528492206, 1950274427); break;
case 1: id=UID(4199047452, 1270318192, 2111172003, 2181509925); break;
case 2: id=UID(2132192267, 1141018682, 3823891598, 1391707399); break;
case 3: id=UID(4124413388, 1292094117, 1050269881, 3048952337); break;
}
Gui.skin=skin;
GuiStyle &style=*GuiStyles(UID(1879466926, 1079990496, 2528492206, 1950274427)); // all gui objects in the Gui Editor have this style set, so instead of changing each gui object style to another, we can just load this style from another style
style.load(EncodeFileName(id));
Gui.style_window=style;
}
void SetGui()
{
Ms .cursor(UID(663015471, 1113822760, 3536750729, 3160006226));
Gui.kb_lit.zero();
Gui.image_win_bar=UID(1671466887, 1231605943, 3707119495, 2898284887);
Gui.ts_text.color =WHITE;
Gui.ts_text.shadow=255;
Gui.style_msg_box_region=&Gui.style_region;
Gui.style_region= *GuiStyles(UID(1255553995, 1182662655, 3307630495, 3075817986));
Gui.ts_list =*TextStyles(UID(236481518, 1159883855, 2763641477, 3459702660));
FontDefault = Fonts(UID(1701253065, 1174809470, 3221417129, 1213197705));

SetGuiSkin(Gui.skin);

SelectServer.create();
}
/******************************************************************************/
/******************************************************************************/
void SaveSettings(TextData &data)
{
data.getNode("Width" ).value=S+D.x();
data.getNode("Height" ).value=S+D.y();
data.getNode("Fullscreen").value=S+D.full();
}
void LoadSettings(TextData &data)
{
int x=-1, y=-1, full=-1;
if(TextNode *node =data.findNode("Fullscreen"))full=node .asInt();
if(TextNode *width =data.findNode("Width" ))x =width .asInt();
if(TextNode *height=data.findNode("Height" ))y =height.asInt();
D.mode(x, y, full);
}
void SaveSettings(C Str &name="Settings.txt")
{
TextData settings; SaveSettings(settings); settings.save(name);
}
void LoadSettings(C Str &name="Settings.txt")
{
TextData settings; if(settings.load(name))LoadSettings(settings);
}
/******************************************************************************/
void InitPre()
{
EE_INIT();
App.flag|=APP_MAXIMIZABLE|APP_MINIMIZABLE|APP_RESIZABLE|APP_FULL_TOGGLE;
LoadSettings();
}
bool Init()
{
return true;
}
void Shut()
{
SaveSettings();
}
bool Update()
{
if(Kb.bp(KB_ESC))return false;
return true;
}
void Draw()
{
D.clear();
}
/******************************************************************************/

when i just take out ConfigSave(); it works but nothing saves when I close the client and re open it.
(This post was last modified: 10-16-2013 03:27 AM by docrst.)
10-16-2013 03:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
gdalex Offline
Member

Post: #5
RE: Save/Load Engine Settings
I can't see your GUI functions being called in your main loop :/
If I am right, you are not sending any draw call, this is why nothing is drawn.

Please check the tutorial :
04 - Gui > 05 - Window Menu
To understand how drawing GUI works smile
10-16-2013 08:28 AM
Find all posts by this user Quote this message in a reply
docrst Offline
Member

Post: #6
RE: Save/Load Engine Settings
no help unless your a programmer.
10-17-2013 03:38 AM
Visit this user's website Find all posts by this user Quote this message in a reply
gdalex Offline
Member

Post: #7
RE: Save/Load Engine Settings
We agree.
There is nothing that you can create in EE (GUI, world, skeleton) that needs no programming/scripting skills to be tested
(This post was last modified: 12-14-2013 09:41 AM by gdalex.)
10-17-2013 07:45 AM
Find all posts by this user Quote this message in a reply
docrst Offline
Member

Post: #8
RE: Save/Load Engine Settings
why, there are allot of game systems that don't?
10-18-2013 03:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply