36 lines
730 B
C++
36 lines
730 B
C++
#include "utils.h"
|
|
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
|
|
|
|
int Utils::read1stLineOfFile(QString fileName) {
|
|
QFile f(fileName);
|
|
if (f.exists()) {
|
|
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
QTextStream in(&f);
|
|
in.setCodec("UTF-8");
|
|
while(!in.atEnd()) {
|
|
return in.readLine().toInt();
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
QString Utils::zoneName(quint8 i) {
|
|
static constexpr char const *zName[] = {
|
|
"",
|
|
"purple",
|
|
"blue",
|
|
"yellow",
|
|
"green",
|
|
"yellow (mars)",
|
|
"green (mars)"
|
|
};
|
|
if (i < (sizeof(zName)/sizeof(char const *))) {
|
|
return zName[i];
|
|
}
|
|
return "N/A";
|
|
}
|