2004-06-19 15:46:11 +02:00
|
|
|
// $Id: wxconfig.cpp,v 1.3 2004/06/19 13:46:11 philip Exp $
|
2004-06-17 21:32:04 +02:00
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
2004-06-19 14:56:09 +02:00
|
|
|
#include "wx/config.h"
|
|
|
|
#include "wx/filename.h"
|
|
|
|
|
2004-06-17 21:32:04 +02:00
|
|
|
#include "wxconfig.h"
|
|
|
|
|
2004-06-19 15:46:11 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
const wxString PathSep = wxT("\\");
|
|
|
|
#else
|
|
|
|
const wxString PathSep = wxT("/");
|
|
|
|
#endif
|
|
|
|
|
2004-06-17 21:32:04 +02:00
|
|
|
void ConfigInit()
|
|
|
|
{
|
|
|
|
wxConfig* cfg = new wxConfig(wxT("WFG Font Builder"));
|
|
|
|
wxConfig::Set(cfg);
|
|
|
|
|
|
|
|
// Default paths, for the first time program is run:
|
|
|
|
|
|
|
|
// Get "x:\wherever\etc\binaries\"
|
2004-06-19 15:46:11 +02:00
|
|
|
wxFileName cwd = wxFileName::GetCwd()+PathSep;
|
2004-06-17 21:32:04 +02:00
|
|
|
cwd.RemoveDir((int)cwd.GetDirCount()-1);
|
|
|
|
|
2004-06-19 15:46:11 +02:00
|
|
|
#define DIR(a) dir.AppendDir(wxT(a))
|
|
|
|
|
|
|
|
cwd.AppendDir(wxT("data"));
|
2004-06-17 21:32:04 +02:00
|
|
|
if (!ConfigGet(wxT("FSF path")))
|
|
|
|
{
|
2004-06-19 15:46:11 +02:00
|
|
|
wxFileName dir = cwd;
|
|
|
|
DIR("tools"); DIR("fontbuilder"); DIR("settings");
|
2004-06-17 21:32:04 +02:00
|
|
|
ConfigSet(wxT("FSF path"), dir.GetPath(wxPATH_GET_VOLUME));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ConfigGet(wxT("FNT path")))
|
|
|
|
{
|
2004-06-19 15:46:11 +02:00
|
|
|
wxFileName dir = cwd;
|
|
|
|
DIR("mods"); DIR("official"); DIR("fonts");
|
2004-06-17 21:32:04 +02:00
|
|
|
ConfigSet(wxT("FNT path"), dir.GetPath(wxPATH_GET_VOLUME));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ConfigGet(wxT("Charset path")))
|
|
|
|
{
|
2004-06-19 15:46:11 +02:00
|
|
|
wxFileName dir = cwd;
|
|
|
|
DIR("tools"); DIR("fontbuilder"); DIR("charsets");
|
2004-06-17 21:32:04 +02:00
|
|
|
ConfigSet(wxT("Charset path"), dir.GetPath(wxPATH_GET_VOLUME));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString ConfigGet(wxString key)
|
|
|
|
{
|
|
|
|
wxConfig* cfg = (wxConfig*) wxConfig::Get();
|
|
|
|
wxString ret;
|
|
|
|
cfg->Read(key, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigSet(wxString key, wxString value)
|
|
|
|
{
|
|
|
|
wxConfig* cfg = (wxConfig*) wxConfig::Get();
|
|
|
|
cfg->Write(key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigDestroy()
|
|
|
|
{
|
|
|
|
delete wxConfig::Get();
|
|
|
|
}
|
|
|
|
|