aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2016-12-29 02:48:02 +0100
committerDavid Skoland <davidskoland@gmail.com>2016-12-29 02:48:02 +0100
commitedf37fba4949ec902644c5e5937fa62e66c323c9 (patch)
treee1a42603231ad14245a958c6a72099f9f932c455
parent78c5e1563d32a19470c595769598167e6a38dcb4 (diff)
Added file and path function files + started working on the lobby
-rw-r--r--Attorney_Online_remake.pro8
-rw-r--r--lobby.cpp16
-rw-r--r--lobby.h7
-rw-r--r--main.cpp1
-rw-r--r--path_functions.cpp15
-rw-r--r--path_functions.h9
-rw-r--r--text_file_functions.cpp29
-rw-r--r--text_file_functions.h9
8 files changed, 91 insertions, 3 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index a88a0516..176ebb57 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -13,6 +13,10 @@ TEMPLATE = app
SOURCES += main.cpp\
- lobby.cpp
+ lobby.cpp \
+ text_file_functions.cpp \
+ path_functions.cpp
-HEADERS += lobby.h
+HEADERS += lobby.h \
+ text_file_functions.h \
+ path_functions.h
diff --git a/lobby.cpp b/lobby.cpp
index 8fa65013..fec063d2 100644
--- a/lobby.cpp
+++ b/lobby.cpp
@@ -1,8 +1,22 @@
+#include <QDebug>
+
+#include "path_functions.h"
+
#include "lobby.h"
Lobby::Lobby(QWidget *parent) : QMainWindow(parent)
{
- //this->resize();
+ this->resize(517, 666);
+ ui_background = new QLabel(this);
+}
+
+void Lobby::set_theme_images()
+{
+ QString theme_path = get_theme_path();
+
+ ui_background->move(0, 0);
+ ui_background->resize(517, 666);
+ ui_background->setPixmap(theme_path + "lobbybackground.png");
}
Lobby::~Lobby()
diff --git a/lobby.h b/lobby.h
index 310ac9c5..7a4df7b4 100644
--- a/lobby.h
+++ b/lobby.h
@@ -2,6 +2,7 @@
#define LOBBY_H
#include <QMainWindow>
+#include <QLabel>
class Lobby : public QMainWindow
{
@@ -9,7 +10,13 @@ class Lobby : public QMainWindow
public:
Lobby(QWidget *parent = nullptr);
+
+ void set_theme_images();
+
~Lobby();
+
+private:
+ QLabel *ui_background;
};
#endif // LOBBY_H
diff --git a/main.cpp b/main.cpp
index 9a058dc6..bbb10bb9 100644
--- a/main.cpp
+++ b/main.cpp
@@ -6,6 +6,7 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Lobby w;
+ w.set_theme_images();
w.show();
return a.exec();
diff --git a/path_functions.cpp b/path_functions.cpp
new file mode 100644
index 00000000..8766656b
--- /dev/null
+++ b/path_functions.cpp
@@ -0,0 +1,15 @@
+#include <QDir>
+
+#include "text_file_functions.h"
+
+#include "path_functions.h"
+
+QString get_base_path(){
+ return (QDir::currentPath() + "/base/");
+}
+
+QString get_theme_path(){
+ return get_base_path() + "themes/" + get_user_theme() + "/";
+}
+
+
diff --git a/path_functions.h b/path_functions.h
new file mode 100644
index 00000000..3912c17a
--- /dev/null
+++ b/path_functions.h
@@ -0,0 +1,9 @@
+#ifndef PATH_FUNCTIONS_H
+#define PATH_FUNCTIONS_H
+
+#include <QString>
+
+QString get_base_path();
+QString get_theme_path();
+
+#endif // PATH_FUNCTIONS_H
diff --git a/text_file_functions.cpp b/text_file_functions.cpp
new file mode 100644
index 00000000..336b76c4
--- /dev/null
+++ b/text_file_functions.cpp
@@ -0,0 +1,29 @@
+#include <QTextStream>
+#include <QStringList>
+
+#include "path_functions.h"
+
+#include "text_file_functions.h"
+
+QString get_user_theme(){
+ QFile config_file(get_base_path() + "config.ini");
+ if (!config_file.open(QIODevice::ReadOnly))
+ return "default";
+
+ QTextStream in(&config_file);
+
+ while(!in.atEnd())
+ {
+ QString line = in.readLine();
+
+ if (line.startsWith("theme"))
+ {
+ QStringList line_elements = line.split("=");
+
+ if (line_elements.size() > 1)
+ return line_elements.at(1).trimmed();
+ }
+ }
+
+ return "default";
+}
diff --git a/text_file_functions.h b/text_file_functions.h
new file mode 100644
index 00000000..99abe089
--- /dev/null
+++ b/text_file_functions.h
@@ -0,0 +1,9 @@
+#ifndef TEXT_FILE_FUNCTIONS_H
+#define TEXT_FILE_FUNCTIONS_H
+
+#include <QString>
+#include <QFile>
+
+QString get_user_theme();
+
+#endif // TEXT_FILE_FUNCTIONS_H