diff --git a/editor/editor.vcproj b/editor/editor.vcproj index 110ccfd..b6e19c2 100644 --- a/editor/editor.vcproj +++ b/editor/editor.vcproj @@ -60,7 +60,7 @@ /> + + diff --git a/editor/inifile.cpp b/editor/inifile.cpp new file mode 100644 index 0000000..d504eec --- /dev/null +++ b/editor/inifile.cpp @@ -0,0 +1,4 @@ +#include "inifile.h" + +std::string IniFile::filename; +std::string IniFile::section; \ No newline at end of file diff --git a/editor/inifile.h b/editor/inifile.h new file mode 100644 index 0000000..75d01c0 --- /dev/null +++ b/editor/inifile.h @@ -0,0 +1,62 @@ +#pragma once + +#include +#include + +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); + } +}; diff --git a/editor/rocket.ini b/editor/rocket.ini new file mode 100644 index 0000000..26dfbb5 --- /dev/null +++ b/editor/rocket.ini @@ -0,0 +1,3 @@ +[GUI] +fontHeight = 14 +fontWidth = 5 \ No newline at end of file diff --git a/editor/syncdocument.h b/editor/syncdocument.h index 4fd8110..6ffba88 100644 --- a/editor/syncdocument.h +++ b/editor/syncdocument.h @@ -6,6 +6,7 @@ #include "../sync/network.h" #include "../sync/data.h" +#include "inifile.h" #include #include diff --git a/editor/trackview.cpp b/editor/trackview.cpp index e7b962e..d985725 100644 --- a/editor/trackview.cpp +++ b/editor/trackview.cpp @@ -10,8 +10,8 @@ static const TCHAR *trackViewWindowClassName = _T("TrackView"); static const int topMarginHeight = 20; static const int leftMarginWidth = 60; -static const int fontHeight = 16; -static const int fontWidth = 6; +static int fontHeight = 16; +static int fontWidth = 6; static const int trackWidth = fontWidth * 16; static DWORD darken(DWORD col, float amt) @@ -21,6 +21,16 @@ static DWORD darken(DWORD col, float amt) 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; scrollPosY = 0; windowWidth = -1; diff --git a/synctracker2.sln b/synctracker2.sln index 2c729fa..74ebcd2 100644 --- a/synctracker2.sln +++ b/synctracker2.sln @@ -1,12 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "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 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_editor", "editor\editor.vcproj", "{76B44BC8-8BB4-4B6E-B2FA-7738C9E7F80B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_player", "sync_player.vcproj", "{5866042C-7FCB-4DB1-BAAD-44DF6567511F}" EndProject @@ -26,14 +21,6 @@ Global {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.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.Build.0 = Debug Client|Win32 {5866042C-7FCB-4DB1-BAAD-44DF6567511F}.Debug|Win32.ActiveCfg = Debug|Win32