-
Notifications
You must be signed in to change notification settings - Fork 2
/
gamemacro.cpp
68 lines (41 loc) · 1.5 KB
/
gamemacro.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
#include "gamemacro.h"
#include <QDebug>
GameMacro::GameMacro() {
}
bool GameMacro::parseMacro(const QString& macroString) {
int idIndex = macroString.indexOf(" ");
if (idIndex <= 0)
return false;
QString id = macroString.mid(0, idIndex);
this->id = id.toInt();
int nameIndex = macroString.indexOf(" ", idIndex + 1);
if (nameIndex <= 0)
return false;
name = macroString.mid(idIndex + 1, nameIndex - (idIndex + 1));
this->setText(name);
qDebug() << "detected macro: " << name;
int iconIndex = macroString.indexOf(" ", nameIndex + 1);
if (iconIndex <= 0)
return false;
icon = macroString.mid(nameIndex + 1, iconIndex - (nameIndex + 1));
qDebug() << "icon: " << icon;
int colorIndex = macroString.indexOf(" ", iconIndex + 1);
if (colorIndex <= 0)
return false;
color = macroString.mid(iconIndex + 1, colorIndex - (iconIndex + 1));
qDebug() << "color: " << color;
/* int contentsIndex = macroString.indexOf(" ", colorIndex + 1);
if (contentsIndex <= 0)
return false;*/
contents = macroString.mid(colorIndex + 1);
qDebug() << "contents: " << contents;
qDebug() << "serialized: " << toString();
return true;
//names.append(name);
}
QString GameMacro::toString() {
QString str;
QTextStream stream(&str);
stream << id << " " << name << " " << icon << " " << color << " " << contents;
return str;
}