added inifile support though filthy static class thingy.

This commit is contained in:
Egbert Teeselink 2008-02-27 10:05:32 +00:00 committed by Erik Faye-Lund
parent cd0e1275a2
commit da96ca4262
7 changed files with 89 additions and 18 deletions

View File

@ -60,7 +60,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib comctl32.lib " AdditionalDependencies="ws2_32.lib comctl32.lib comsupp.lib comsuppwd.lib"
LinkIncremental="2" LinkIncremental="2"
GenerateManifest="false" GenerateManifest="false"
GenerateDebugInformation="true" GenerateDebugInformation="true"
@ -186,6 +186,10 @@
> >
</File> </File>
<File <File
RelativePath=".\inifile.cpp"
>
</File>
<File
RelativePath="..\sync\network.cpp" RelativePath="..\sync\network.cpp"
> >
</File> </File>

4
editor/inifile.cpp Normal file
View File

@ -0,0 +1,4 @@
#include "inifile.h"
std::string IniFile::filename;
std::string IniFile::section;

62
editor/inifile.h Normal file
View File

@ -0,0 +1,62 @@
#pragma once
#include <string>
#include <windows.h>
class IniFile
{
protected:
static std::string filename;
static std::string section;
public:
static std::string getFullPath(std::string filename)
{
char fullpath[100];
char* dummy;
GetFullPathName(filename.c_str(), 100, fullpath, &dummy);
return std::string(fullpath);
}
static void load(std::string filename)
{
IniFile::filename = getFullPath(filename);
}
static void load(std::string filename, std::string section)
{
load(filename);
setSection(section);
}
static void setSection(std::string section)
{
IniFile::section = section;
}
static bool check()
{
char buf[10];
return (GetPrivateProfileSectionNames( buf, 10, filename.c_str() )) ? true : false;
}
static int get(std::string filename, std::string section, std::string key, int defaultValue=INT_MAX)
{
return GetPrivateProfileInt(section.c_str(), key.c_str(), defaultValue, filename.c_str());
}
static int get(std::string section, std::string key, int defaultValue=INT_MAX)
{
return get(filename, section, key, defaultValue);
}
static int get(std::string key, int defaultValue=INT_MAX)
{
return get(filename, section, key, defaultValue);
}
static void read(int &var, std::string filename, std::string section, std::string key)
{
var = get(filename, section, key, var);
}
static void read(int &var, std::string section, std::string key)
{
var = get(filename, section, key, var);
}
static void read(int &var, std::string key)
{
var = get(filename, section, key, var);
}
};

3
editor/rocket.ini Normal file
View File

@ -0,0 +1,3 @@
[GUI]
fontHeight = 14
fontWidth = 5

View File

@ -6,6 +6,7 @@
#include "../sync/network.h" #include "../sync/network.h"
#include "../sync/data.h" #include "../sync/data.h"
#include "inifile.h"
#include <stack> #include <stack>
#include <list> #include <list>

View File

@ -10,8 +10,8 @@ static const TCHAR *trackViewWindowClassName = _T("TrackView");
static const int topMarginHeight = 20; static const int topMarginHeight = 20;
static const int leftMarginWidth = 60; static const int leftMarginWidth = 60;
static const int fontHeight = 16; static int fontHeight = 16;
static const int fontWidth = 6; static int fontWidth = 6;
static const int trackWidth = fontWidth * 16; static const int trackWidth = fontWidth * 16;
static DWORD darken(DWORD col, float amt) static DWORD darken(DWORD col, float amt)
@ -21,6 +21,16 @@ static DWORD darken(DWORD col, float amt)
TrackView::TrackView() TrackView::TrackView()
{ {
IniFile::load("rocket.ini", "GUI");
if(IniFile::check())
{
//read directly into variables, using their current values
//as defaults in case the ini file or the keys are not found.
IniFile::read(fontHeight, "fontHeight");
IniFile::read(fontWidth, "fontWidth");
}
scrollPosX = 0; scrollPosX = 0;
scrollPosY = 0; scrollPosY = 0;
windowWidth = -1; windowWidth = -1;

View File

@ -1,12 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005 # Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "editor", "editor\editor.vcproj", "{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_editor", "editor\editor.vcproj", "{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_bass", "example_bass\example_bass.vcproj", "{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}"
ProjectSection(ProjectDependencies) = postProject
{5866042C-7FCB-4DB1-BAAD-44DF6567511F} = {5866042C-7FCB-4DB1-BAAD-44DF6567511F}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_player", "sync_player.vcproj", "{5866042C-7FCB-4DB1-BAAD-44DF6567511F}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_player", "sync_player.vcproj", "{5866042C-7FCB-4DB1-BAAD-44DF6567511F}"
EndProject EndProject
@ -26,14 +21,6 @@ Global
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release Client|Win32.Build.0 = Release|Win32 {76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release Client|Win32.Build.0 = Release|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release|Win32.ActiveCfg = Release|Win32 {76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release|Win32.ActiveCfg = Release|Win32
{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release|Win32.Build.0 = Release|Win32 {76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}.Release|Win32.Build.0 = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug Client|Win32.ActiveCfg = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug Client|Win32.Build.0 = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug|Win32.ActiveCfg = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Debug|Win32.Build.0 = Debug|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release Client|Win32.ActiveCfg = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release Client|Win32.Build.0 = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release|Win32.ActiveCfg = Release|Win32
{96D91AAD-2F45-4CC6-A923-96B80E1C3CE3}.Release|Win32.Build.0 = Release|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug Client|Win32.ActiveCfg = Debug Client|Win32 {5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug Client|Win32.ActiveCfg = Debug Client|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug Client|Win32.Build.0 = Debug Client|Win32 {5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug Client|Win32.Build.0 = Debug Client|Win32
{5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug|Win32.ActiveCfg = Debug|Win32 {5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug|Win32.ActiveCfg = Debug|Win32