1
1
#include " ../include/Header.h"
2
2
#include " ../include/Config.h"
3
3
4
+ bool button_cleared = false ;
5
+
6
+ id::id (string in_ID) : ID(in_ID) {}
7
+ bool id::operator ==(const id& other) const { return ID == other.ID ; }
8
+ vector<id> ids;
9
+
4
10
void read_config (json& config, id* ID) {
5
11
if (config[config.begin ().key ()].contains (" profiles" )) {
6
12
ID->profiles .clear ();
@@ -12,6 +18,8 @@ void read_config(json& config, id* ID) {
12
18
button button1;
13
19
profile1.buttons .push_back (button1);
14
20
}
21
+ ID->profiles .push_back (profile1);
22
+ return ;
15
23
}
16
24
for (int i = 0 ; i < profile_count; i++) {
17
25
profile profile1;
@@ -21,11 +29,13 @@ void read_config(json& config, id* ID) {
21
29
if (profile_store.contains (" pages" )) {
22
30
int page_count = 0 ;
23
31
for (auto & page : profile_store[" pages" ]) if (page.is_object ()) page_count++;
24
- if (page_count == 0 )
32
+ if (page_count == 0 ) {
25
33
for (int a = 0 ; i < profile1.columns * profile1.rows ; i++) {
26
34
button button1;
27
35
profile1.buttons .push_back (button1);
28
36
}
37
+ continue ;
38
+ }
29
39
for (int j = 0 ; j < page_count; j++) {
30
40
json page_store = profile_store[" pages" ][to_string (j)];
31
41
if (page_store.contains (" buttons" )) {
@@ -81,7 +91,7 @@ void configure_id(id* id) {
81
91
read_config (config, id);
82
92
reader.close ();
83
93
cerr << " configured\n " ;
84
- send_config = true ;
94
+ id-> reconfigure = true ;
85
95
return ;
86
96
} catch (...) {
87
97
cerr << " invalid config!\n clearing...\n " ;
@@ -90,7 +100,7 @@ void configure_id(id* id) {
90
100
ofstream writer (nxsh_config);
91
101
writer << empty_config.dump (4 );
92
102
writer.close ();
93
- send_config = true ;
103
+ id-> reconfigure = true ;
94
104
}
95
105
}
96
106
reader.close ();
@@ -106,7 +116,7 @@ void configure_id(id* id) {
106
116
ofstream writer (nxsh_config);
107
117
writer << empty_config.dump (4 );
108
118
writer.close ();
109
- send_config = true ;
119
+ id-> reconfigure = true ;
110
120
}
111
121
112
122
void clear_button (int profile, int page, int button) {
@@ -129,10 +139,10 @@ void clear_button(int profile, int page, int button) {
129
139
writer.close ();
130
140
read_config (to_remove, &ids[selected_id]);
131
141
button_cleared = true ;
132
- send_config = true ;
142
+ ids[selected_id]. reconfigure = true ;
133
143
}
134
144
135
- void write_config (vector<string> args, int arg_size) {
145
+ void write_config (vector<string> args, size_t arg_size) {
136
146
string nxsh_config (getenv (" USERPROFILE" ));
137
147
nxsh_config += " \\ AppData\\ Roaming\\ NexusShell" ;
138
148
if (!exists (nxsh_config)) create_directory (nxsh_config);
0 commit comments