Skip to content

Commit

Permalink
moved files
Browse files Browse the repository at this point in the history
  • Loading branch information
godrin committed Jul 2, 2014
1 parent 31f7849 commit 7d2ff44
Show file tree
Hide file tree
Showing 71 changed files with 80 additions and 217 deletions.
15 changes: 13 additions & 2 deletions CMakeLists.txt
Expand Up @@ -38,6 +38,7 @@ link_libraries (
)
include_directories(${SDL_INCLUDE_DIR} ${RUBY_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_SOURCE_DIR}/lib/video
${CMAKE_CURRENT_SOURCE_DIR}/lib/gui
${CMAKE_CURRENT_SOURCE_DIR}/lib/generator
${CMAKE_CURRENT_SOURCE_DIR}/lib/sound
Expand Down Expand Up @@ -78,7 +79,13 @@ SET(CMAKE_SWIG_FLAGS "")
#set_target_properties(example PROPERTIES PREFIX "")


FILE(GLOB MYLIB_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} lib/*.cc lib/*.c lib/gui/*.cc lib/sound/*.cc
FILE(GLOB MYLIB_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
lib/*.cc
lib/*.c
lib/video/*.c
lib/video/*.cc
lib/gui/*.cc
lib/sound/*.cc
lib/3dengine/*.cc
lib/generator/*.cc
lib/game/*.cc
Expand All @@ -89,7 +96,11 @@ FILE(GLOB MYLIB_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} lib/*.cc lib/*.c li
lib/game/path/*.cc
lib/game/widgets/*.cc
)
FILE(GLOB MYLIB_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} lib/*.h lib/gui/*.h lib/sound/*.h
FILE(GLOB MYLIB_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
lib/*.h
lib/video/*.h
lib/gui/*.h
lib/sound/*.h
lib/3dengine/*.h
lib/game/*.h
lib/players/*.h
Expand Down
119 changes: 58 additions & 61 deletions lib/ag_config.cc
Expand Up @@ -2,46 +2,44 @@
#include "ag_xml.h"
#include "ag_fs.h"

// TODO: AGConfig should switch to a ruby-based configuration (maybe YAML)
// TODO: commenting should be possible !! (no overwriting)

AGConfig::AGConfig()
{
Document doc("config.xml");
{
Document doc("config.xml");

Node &root=doc.root();
AGString comment;
for(Node::iterator i=root.begin();i!=root.end();i++)
Node &root=doc.root();
AGString comment;
for(Node::iterator i=root.begin();i!=root.end();i++)
{
if((*i)->get("name")=="")
{
AGString c=(*i)->getContent();
if(c.substr(0,4)=="<!--")
{
if((*i)->get("name")=="")
{
AGString c=(*i)->getContent();
if(c.substr(0,4)=="<!--")
{
comment=c;
}
}
else
{
singleValue[(*i)->get("name")]=(*i)->get("value");
comments[(*i)->get("name")]=comment;
comment="";
}
comment=c;
}
// writeToDisc();
}
else
{
singleValue[(*i)->get("name")]=(*i)->get("value");
comments[(*i)->get("name")]=comment;
comment="";
}
}
}

AGString AGConfig::get(const AGString &pValue,const AGString &pDefault,const AGString &pComment)
{
AGString v=get(pValue);
if(v=="")
{
AGString v=get(pValue);
if(v=="")
{
comments[pValue]=pComment;
set(pValue,pDefault);
v=pDefault;
}
return v;
comments[pValue]=pComment;
set(pValue,pDefault);
v=pDefault;
}
return v;
}



Expand All @@ -55,49 +53,48 @@ AGString AGConfig::get(const AGString &pValue) const
}

void AGConfig::set(const AGString &pName,const AGString &pValue)
{
AGString old=singleValue[pName];
if(old!=pValue)
{
AGString old=singleValue[pName];
if(old!=pValue)
{
singleValue[pName]=pValue;
writeToDisc();
}
singleValue[pName]=pValue;
writeToDisc();
}
}

void AGConfig::writeToDisc()
{
Document doc;
Node &root=doc.root();
root.setName("config");
for(std::map<AGString,AGString>::const_iterator i=singleValue.begin();i!=singleValue.end();i++)
{
Document doc;
Node &root=doc.root();
root.setName("config");
for(std::map<AGString,AGString>::const_iterator i=singleValue.begin();i!=singleValue.end();i++)
{
if(comments[i->first]!="")
{
Node &n=root.addChild("");
n.setContent(AGString("\n")+comments[i->first]+"\n");
}

Node &n=root.addChild("option");
n.set("name",i->first);
n.set("value",i->second);
}
if(comments[i->first]!="")
{
Node &n=root.addChild("");
n.setContent(AGString("\n")+comments[i->first]+"\n");
}

saveFile("config.xml",doc.toString(true));
Node &n=root.addChild("option");
n.set("name",i->first);
n.set("value",i->second);
}

saveFile("config.xml",doc.toString(true));
}



AGConfig *gConfig=0;
AGConfig *getConfig()
{
if(!gConfig)
gConfig=new AGConfig;
return gConfig;
}
{
if(!gConfig)
gConfig=new AGConfig;
return gConfig;
}

void updateConfig()
{
checkedDelete(gConfig);
gConfig=0;
// getConfig();
}
{
checkedDelete(gConfig);
gConfig=0;
}
3 changes: 0 additions & 3 deletions lib/ag_config.h
Expand Up @@ -47,7 +47,4 @@ class AGEXPORT AGConfig
AGEXPORT AGConfig *getConfig();
AGEXPORT void updateConfig();


//#define EXPORT __declspec(dllexport)

#endif

0 comments on commit 7d2ff44

Please sign in to comment.