ReactOS 0.4.15-dev-7924-g5949c20
settings.c File Reference
#include <stdlib.h>
#include <windows.h>
#include <tchar.h>
#include "globals.h"
#include "message.h"
#include "matrix.h"
Include dependency graph for settings.c:

Go to the source code of this file.

Functions

void LoadSettings ()
 
void SaveSettings ()
 

Variables

TCHAR g_szMessages [MAX_MESSAGES][MAXMSG_LENGTH]
 
int g_nNumMessages = 0
 
int g_nMessageSpeed = 5
 
TCHAR g_szFontName [512] = _T("Arial")
 
int g_nMatrixSpeed = 10
 
int g_nDensity = 32
 
int g_nFontSize = 12
 
BOOL g_fRandomizeMessages = FALSE
 
BOOL g_fFontBold = TRUE
 
BOOL g_fScreenSaving = FALSE
 
HFONT g_hFont
 

Function Documentation

◆ LoadSettings()

void LoadSettings ( void  Dlg)

Definition at line 27 of file settings.c.

28{
29 HKEY hkey;
30 LONG value;
31 ULONG len;
32 TCHAR *hugechar = malloc(4096);
33 TCHAR *hptr = hugechar;
34
35 if(hugechar == 0)
36 return;
37
38 ZeroMemory(hugechar, 4096);
39
40 RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Catch22\\Matrix Screen Saver"), 0,
41 _T(""), 0, KEY_READ, NULL, &hkey, NULL);
42
43 len = sizeof value;
44 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("MessageSpeed"), 0, 0, (BYTE *)&value, &len))
45 {
48 }
49
50 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("MatrixSpeed"), 0, 0, (BYTE *)&value, &len))
51 {
52 if(value >= SPEED_MIN && value <= SPEED_MAX)
54 }
55
56 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Density"), 0, 0, (BYTE *)&value, &len))
57 {
60 }
61
62 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("FontSize"), 0, 0, (BYTE *)&value, &len))
63 {
64 if(value >= FONT_MIN && value <= FONT_MAX)
66 }
67
68 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("FontBold"), 0, 0, (BYTE *)&value, &len))
69 g_fFontBold = (value == 0 ? FALSE : TRUE);
70
71 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Randomize"), 0, 0, (BYTE *)&value, &len))
73
74 len = 512;
75 if(RegQueryValueEx(hkey, _T("FontName"), 0, 0, (BYTE *)g_szFontName, &len) != ERROR_SUCCESS)
76 lstrcpy(g_szFontName, _T("Arial"));
77
78 len = 4096;
79
80 if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Messages"), 0, 0 , (BYTE *)hugechar, &len))
81 {
82 while(len > 0 && *hptr && _istascii(*hptr))
83 {
84 if(lstrlen(hptr) > 0)
85 {
88 hptr += lstrlen(hptr) + 1;
89 }
90 }
91 }
92 else
93 {
94 /* built-in coded message for first run */
95 lstrcpyn(g_szMessages[0], _T("ReactOS"), MAXMSG_LENGTH);
97 }
98
99 RegCloseKey(hkey);
100 free(hugechar);
101}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLenum GLsizei len
Definition: glext.h:6722
#define _istascii
Definition: tchar.h:738
#define MAXMSG_LENGTH
Definition: globals.h:25
#define FONT_MAX
Definition: globals.h:33
#define DENSITY_MAX
Definition: globals.h:11
#define DENSITY_MIN
Definition: globals.h:12
#define FONT_MIN
Definition: globals.h:32
#define MSGSPEED_MIN
Definition: globals.h:28
#define SPEED_MAX
Definition: globals.h:20
#define SPEED_MIN
Definition: globals.h:21
#define MSGSPEED_MAX
Definition: globals.h:27
int g_nNumMessages
Definition: settings.c:14
BOOL g_fRandomizeMessages
Definition: settings.c:21
TCHAR g_szMessages[MAX_MESSAGES][MAXMSG_LENGTH]
Definition: settings.c:13
int g_nMatrixSpeed
Definition: settings.c:18
BOOL g_fFontBold
Definition: settings.c:22
int g_nFontSize
Definition: settings.c:20
int g_nMessageSpeed
Definition: settings.c:15
TCHAR g_szFontName[512]
Definition: settings.c:16
int g_nDensity
Definition: settings.c:19
#define KEY_READ
Definition: nt_native.h:1023
long LONG
Definition: pedump.c:60
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
#define _T(x)
Definition: vfdio.h:22
#define lstrcpyn
Definition: winbase.h:3875
#define ZeroMemory
Definition: winbase.h:1712
#define lstrcpy
Definition: winbase.h:3874
#define lstrlen
Definition: winbase.h:3876
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegCreateKeyEx
Definition: winreg.h:501
#define RegQueryValueEx
Definition: winreg.h:524
char TCHAR
Definition: xmlstorage.h:189
unsigned char BYTE
Definition: xxhash.c:193

◆ SaveSettings()

void SaveSettings ( void  Dlg)

Definition at line 103 of file settings.c.

104{
105 HKEY hkey;
106 TCHAR *hugechar = malloc(4096 * sizeof(TCHAR));
107 TCHAR *msgptr = hugechar;
108 int totallen = 0;
109 int i,len;
110 LONG value;
111
112 if(hugechar == 0)
113 return;
114
115 ZeroMemory(hugechar, 4096 * sizeof(TCHAR));
116 msgptr = hugechar;
117
118 RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Catch22\\Matrix Screen Saver"), 0,
119 _T(""), 0, KEY_WRITE, NULL, &hkey, NULL);
120
122 RegSetValueEx(hkey, _T("MessageSpeed"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
123
125 RegSetValueEx(hkey, _T("MatrixSpeed"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
126
128 RegSetValueEx(hkey, _T("Density"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
129
131 RegSetValueEx(hkey, _T("FontSize"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
132
134 RegSetValueEx(hkey, _T("Randomize"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
135
137 RegSetValueEx(hkey, _T("FontBold"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
138
139 RegSetValueEx(hkey, _T("FontName"), 0, REG_SZ, (BYTE *)g_szFontName, lstrlen(g_szFontName) * sizeof(TCHAR));
140
141 for(i = 0; i < g_nNumMessages; i++)
142 {
144
145 if(len > 0 && totallen+len < 4096)
146 {
147 lstrcpyn(msgptr, g_szMessages[i], 4096-totallen);
148 totallen += len + 1;
149 msgptr += len + 1;
150 }
151 }
152
153 //*msgptr = _T('\0');
154 totallen++;
155
156 RegSetValueEx(hkey, _T("Messages"), 0, REG_MULTI_SZ, (BYTE *)hugechar, totallen * sizeof(TCHAR));
157 RegCloseKey(hkey);
158
159 free(hugechar);
160}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define REG_SZ
Definition: layer.c:22
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533

Variable Documentation

◆ g_fFontBold

BOOL g_fFontBold = TRUE

◆ g_fRandomizeMessages

BOOL g_fRandomizeMessages = FALSE

Definition at line 21 of file settings.c.

Referenced by ConfigDlgProc(), DoMatrixMessage(), LoadSettings(), and SaveSettings().

◆ g_fScreenSaving

BOOL g_fScreenSaving = FALSE

Definition at line 23 of file settings.c.

◆ g_hFont

HFONT g_hFont

Definition at line 25 of file settings.c.

Referenced by ConfigDlgProc(), SetMatrixMessage(), and SetMessageFont().

◆ g_nDensity

int g_nDensity = 32

Definition at line 19 of file settings.c.

Referenced by ConfigDlgProc(), LoadSettings(), and SaveSettings().

◆ g_nFontSize

int g_nFontSize = 12

◆ g_nMatrixSpeed

int g_nMatrixSpeed = 10

Definition at line 18 of file settings.c.

Referenced by ConfigDlgProc(), LoadSettings(), MatrixWndProc(), and SaveSettings().

◆ g_nMessageSpeed

int g_nMessageSpeed = 5

Definition at line 15 of file settings.c.

Referenced by ConfigDlgProc(), DoMatrixMessage(), LoadSettings(), MessageSpeed(), and SaveSettings().

◆ g_nNumMessages

int g_nNumMessages = 0

Definition at line 14 of file settings.c.

Referenced by ConfigDlgProc(), DoMatrixMessage(), LoadSettings(), and SaveSettings().

◆ g_szFontName

TCHAR g_szFontName[512] = _T("Arial")

◆ g_szMessages