summaryrefslogtreecommitdiffstats
path: root/src/profile.cpp
diff options
context:
space:
mode:
authoradiblol <adiblol@1tbps.org>2012-03-08 19:32:05 +0100
committeradiblol <adiblol@1tbps.org>2012-03-08 19:32:05 +0100
commita4c804b49ec872b71bd5a0167c3ad45704a3cc30 (patch)
tree8c931235247d662ca46a99695beb328fdfc8e8a8 /src/profile.cpp
downloadcolobot-a4c804b49ec872b71bd5a0167c3ad45704a3cc30.tar.gz
colobot-a4c804b49ec872b71bd5a0167c3ad45704a3cc30.tar.bz2
colobot-a4c804b49ec872b71bd5a0167c3ad45704a3cc30.zip
Initial commit, Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
Diffstat (limited to 'src/profile.cpp')
-rw-r--r--src/profile.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/profile.cpp b/src/profile.cpp
new file mode 100644
index 0000000..b869bc2
--- /dev/null
+++ b/src/profile.cpp
@@ -0,0 +1,100 @@
+// profile.cpp
+
+#define STRICT
+#define D3D_OVERLOADS
+
+#include <stdio.h>
+#include <d3d.h>
+#include <stdlib.h>
+
+#include "language.h"
+#include "struct.h"
+#include "profile.h"
+
+
+
+static char g_filename[100];
+
+
+
+BOOL InitCurrentDirectory()
+{
+#if _SCHOOL
+ _fullpath(g_filename, "ceebot.ini", 100);
+#else
+ _fullpath(g_filename, "colobot.ini", 100);
+#endif
+ return TRUE;
+}
+
+
+BOOL SetProfileString(char* section, char* key, char* string)
+{
+ WritePrivateProfileString(section, key, string, g_filename);
+ return TRUE;
+}
+
+BOOL GetProfileString(char* section, char* key, char* buffer, int max)
+{
+ int nb;
+
+ nb = GetPrivateProfileString(section, key, "", buffer, max, g_filename);
+ if ( nb == 0 )
+ {
+ buffer[0] = 0;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+BOOL SetProfileInt(char* section, char* key, int value)
+{
+ char s[20];
+
+ sprintf(s, "%d", value);
+ WritePrivateProfileString(section, key, s, g_filename);
+ return TRUE;
+}
+
+BOOL GetProfileInt(char* section, char* key, int &value)
+{
+ char s[20];
+ int nb;
+
+ nb = GetPrivateProfileString(section, key, "", s, 20, g_filename);
+ if ( nb == 0 )
+ {
+ value = 0;
+ return FALSE;
+ }
+ sscanf(s, "%d", &value);
+ return TRUE;
+}
+
+
+BOOL SetProfileFloat(char* section, char* key, float value)
+{
+ char s[20];
+
+ sprintf(s, "%.2f", value);
+ WritePrivateProfileString(section, key, s, g_filename);
+ return TRUE;
+}
+
+BOOL GetProfileFloat(char* section, char* key, float &value)
+{
+ char s[20];
+ int nb;
+
+ nb = GetPrivateProfileString(section, key, "", s, 20, g_filename);
+ if ( nb == 0 )
+ {
+ value = 0.0f;
+ return FALSE;
+ }
+ sscanf(s, "%f", &value);
+ return TRUE;
+}
+
+