-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathctheme.cpp
95 lines (73 loc) · 1.85 KB
/
ctheme.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "ctheme.h"
#include <cstdlib>
#include <iostream>
#include <fstream>
extern CTheme *theme_list_head;
CTheme::CTheme( ) {
next = NULL;
}
int CTheme::readThemesFromConf( ) {
ifstream themeFile( "./resources/themes/themes.conf" );
string line;
CTheme *iter = theme_list_head;
string default_theme = "";
int index=0;
int current_theme;
while (themeFile.good( )) {
getline( themeFile, line );
if (line[0] == '#') { /* coment line, ignore */
continue;
}
/* the first non-comment line is the default/current theme */
if (default_theme == "") {
default_theme = line;
continue;
}
/* found one entry for a theme-description */
printf( "\nReading themes.conf file ..." );
if (theme_list_head == NULL) {
theme_list_head = new CTheme( );
iter = theme_list_head;
} else {
iter->next = new CTheme( );
iter = iter->next;
}
iter->themeName = line;
getline( themeFile, line );
iter->boardImage = line;
getline( themeFile, line );
iter->scorePanelImage = line;
getline( themeFile, line );
iter->fontImage = line;
getline( themeFile, line );
iter->backgroundMusic = line;
getline( themeFile, line );
iter->tiktikSound = line;
for (int z=0; z<3; z++) {
getline( themeFile, line );
iter->boardColor[z] = atof( line.c_str() );
}
for (int z=0; z<3; z++) {
getline( themeFile, line );
iter->bat1Color[z] = atof( line.c_str() );
}
for (int z=0; z<3; z++) {
getline( themeFile, line );
iter->bat2Color[z] = atof( line.c_str() );
}
for (int z=0; z<3; z++) {
getline( themeFile, line );
iter->puckColor[z] = atof( line.c_str() );
}
for (int z=0; z<3; z++) {
getline( themeFile, line );
iter->backgroundColor[z] = atof( line.c_str() );
}
if (iter->themeName == default_theme) {
current_theme = index;
}
index++;
iter->next = NULL;
}
return current_theme;
}