Browse Source

Modified fonts, partly implemented rusification tree structure

Ivan Arkhipov 5 years ago
parent
commit
92be07aced

+ 55 - 7
Legacy_v2.pro

@@ -28,6 +28,54 @@ DEFINES += QT_DEPRECATED_WARNINGS
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 
+# ================================================== #
+message(================QT INFO====================)
+message(Qt version: $$[QT_VERSION])
+message(Qt is installed in $$[QT_INSTALL_PREFIX])
+# ================================================== #
+
+message(==========BUILDING EXTERNAL RES============)
+win32 {
+    build_pass: CONFIG(debug, debug|release) {
+        DESTDIR = $$OUT_PWD/debug
+    }
+    else: build_pass {
+        DESTDIR = $$OUT_PWD/release
+    }
+}
+
+unix {
+    DESTDIR = $$OUT_PWD
+}
+
+guiRes.target = BuildResources
+exists($$DESTDIR/res) {
+    message("Directory $$DESTDIR/res already exists")
+} else {
+    guiRes.commands += $(MKDIR) \"$$DESTDIR/res\" $$escape_expand(\n\t)
+    }
+
+EXT_RES =                                                                   \
+    "$$PWD/backgrounds.qrc            -o $$DESTDIR/data01.gtr"     \
+    "$$PWD/common.qrc                 -o $$DESTDIR/data02.gtr"     \
+
+for (RES, EXT_RES) {
+    win32 {
+        message(rcc.exe -binary $${RES})
+        guiRes.commands += rcc.exe -binary $${RES} $$escape_expand(\n\t)
+    }
+    unix {
+        guiRes.commands += rcc -binary $${RES} $$escape_expand(\n\t)
+    }
+}
+
+QMAKE_EXTRA_TARGETS += guiRes
+PRE_TARGETDEPS += BuildResources
+
+# ================================================== #
+
+
+
 SOURCES += \
         src/main.cpp \
         gui/mainwindow.cpp \
@@ -39,8 +87,8 @@ SOURCES += \
     gui/settingswidget.cpp \
     gui/newswidget.cpp \
     gui/helpwidget.cpp \
-    src/rusificationtreeelement.cpp \
-    src/networkdownloader.cpp
+    src/networkdownloader.cpp \
+    src/rusificationtreeitem.cpp
 
 HEADERS += \
         gui/mainwindow.h \
@@ -52,8 +100,8 @@ HEADERS += \
     gui/settingswidget.h \
     gui/newswidget.h \
     gui/helpwidget.h \
-    include/rusificationtreeelement.h \
-    include/networkdownloader.h
+    include/networkdownloader.h \
+    include/rusificationtreeitem.h
 
 FORMS += \
         gui/mainwindow.ui \
@@ -63,9 +111,9 @@ FORMS += \
     gui/newswidget.ui \
     gui/helpwidget.ui
 
-RESOURCES += \
-    backgrounds.qrc \
-    common.qrc
+#RESOURCES += \
+#    backgrounds.qrc \
+#    common.qrc
 
 win32:RC_ICONS = $$PWD/assets/appicon.ico
 

+ 1 - 0
common.qrc

@@ -20,5 +20,6 @@
         <file>assets/buttons/question.png</file>
         <file>assets/appicon.ico</file>
         <file>assets/teksty-photo-normal.png</file>
+        <file>assets/fonts/title.TTF</file>
     </qresource>
 </RCC>

+ 1 - 6
gui/mainwindow.cpp

@@ -11,7 +11,6 @@
 #include <QMessageBox>
 #include <QDesktopWidget>
 #include <QtConcurrent/QtConcurrent>
-#include <QFontDatabase>
 
 MainWindow::MainWindow(LegacyApp *app, QWidget *parent) :
     QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint), app(app),
@@ -22,10 +21,6 @@ MainWindow::MainWindow(LegacyApp *app, QWidget *parent) :
 void MainWindow::Init() {
     ui->setupUi(this);
 
-    QResource::registerResource(QApplication::applicationDirPath() + "/res/data009.gtr");
-    QFontDatabase::addApplicationFont(":/assets/fonts/trajan.ttf");
-    QFontDatabase::addApplicationFont(":/assets/fonts/viking.ttf");
-
     status_frame = new StatusWidget(app, this);
     ui->content_layout->addWidget(status_frame);
 
@@ -116,7 +111,7 @@ void MainWindow::randomChangeBackground()
 
     QtConcurrent::run([this](){
         qDebug() << "Starting background update";
-        while (next_pixmap_opacity < 1) {
+        while (next_pixmap_opacity < 1 && qApp) {
             if (!qApp)
                 return;
 

+ 1 - 1
gui/mainwindow.h

@@ -91,7 +91,7 @@ private:
     QTimer fade_animation_timer;
     double next_pixmap_opacity;
 
-    const int MAX_PIXMAP_ID = 2;
+    const int MAX_PIXMAP_ID = 9;
 
     const size_t common_font_size = 15;
     const size_t title_font_size = 17;

+ 14 - 11
gui/mainwindow.ui

@@ -104,7 +104,7 @@
     <property name="styleSheet">
      <string notr="true">border-image:transparent;</string>
     </property>
-    <layout class="QHBoxLayout" name="horizontalLayout" stretch="6,9,11,7,6,0">
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="6,7,13,7,6,0">
      <property name="spacing">
       <number>10</number>
      </property>
@@ -139,7 +139,10 @@
        </property>
        <property name="font">
         <font>
-         <family>Trajan Pro 3</family>
+         <family>Constantia</family>
+         <pointsize>9</pointsize>
+         <weight>50</weight>
+         <bold>false</bold>
         </font>
        </property>
        <property name="mouseTracking">
@@ -152,7 +155,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>статус</string>
+        <string>  СТАТУС  </string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -181,7 +184,7 @@
        </property>
        <property name="font">
         <font>
-         <family>Trajan Pro 3</family>
+         <family>Constantia</family>
         </font>
        </property>
        <property name="mouseTracking">
@@ -191,7 +194,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>настройки</string>
+        <string>  НАСТРОЙКИ  </string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -220,7 +223,7 @@
        </property>
        <property name="font">
         <font>
-         <family>Trajan Pro 3</family>
+         <family>Constantia</family>
         </font>
        </property>
        <property name="mouseTracking">
@@ -230,7 +233,7 @@
         <string notr="true">color:rgb(255, 255, 255)</string>
        </property>
        <property name="text">
-        <string notr="true"> русификация </string>
+        <string notr="true">  РУСИФИКАЦИЯ  </string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -259,7 +262,7 @@
        </property>
        <property name="font">
         <font>
-         <family>Trajan Pro 3</family>
+         <family>Constantia</family>
         </font>
        </property>
        <property name="mouseTracking">
@@ -269,7 +272,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>новости</string>
+        <string> НОВОСТИ </string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>
@@ -298,7 +301,7 @@
        </property>
        <property name="font">
         <font>
-         <family>Trajan Pro 3</family>
+         <family>Constantia</family>
         </font>
        </property>
        <property name="mouseTracking">
@@ -311,7 +314,7 @@
         <string notr="true">color:rgb(255, 255, 255);</string>
        </property>
        <property name="text">
-        <string>помощь</string>
+        <string>  ПОМОЩЬ  </string>
        </property>
        <property name="scaledContents">
         <bool>true</bool>

+ 57 - 2
gui/rusificationwidget.cpp

@@ -1,6 +1,7 @@
 #include "gui\rusificationwidget.h"
 #include "ui_rusificationwidget.h"
 #include "legacyapp.h"
+#include "rusificationtreeitem.h"
 
 void doStuffWithEveryItemInMyTree( QTreeWidgetItem *item )
 {
@@ -9,16 +10,28 @@ void doStuffWithEveryItemInMyTree( QTreeWidgetItem *item )
         doStuffWithEveryItemInMyTree( item->child(i) );
 }
 
+RusificationTreeItem* findItemByName(RusificationTreeItem* item, QString name) {
+    if (item->name == name)
+        return item;
+
+    for (int i = 0; i < item->childCount(); i++) {
+        RusificationTreeItem* found_item = findItemByName((RusificationTreeItem*)item->child(i), name);
+        if (found_item)
+            return found_item;
+    }
+    return nullptr;
+}
+
 RusificationWidget::RusificationWidget(LegacyApp *_app, QWidget *parent) :
     QWidget(parent),
     ui(new Ui::RusificationWidget),
     app(_app)
 {
     ui->setupUi(this);
-    ui->treeWidget_title->expandAll();
+    setupTreeWidget();
+
     hideAllImportWidgets();
     ui->database_import_widget->show();
-    doStuffWithEveryItemInMyTree(ui->treeWidget_title->invisibleRootItem());
 
     ui_update_timer.setInterval(500);
     connect(&ui_update_timer, &QTimer::timeout, this, &RusificationWidget::updateUI);
@@ -30,6 +43,35 @@ RusificationWidget::~RusificationWidget()
     delete ui;
 }
 
+void RusificationWidget::setupTreeWidget()
+{
+    connect(ui->treeWidget_title, &QTreeWidget::itemEntered, this, &RusificationWidget::onHoveredTreeItemChanged);
+
+    QSettings patch_list(qApp->applicationDirPath() + "/legacy_patches.ini", QSettings::IniFormat);
+    patch_list.setIniCodec("UTF-8");
+    ui->treeWidget_title->setMouseTracking(true);
+
+    RusificationTreeItem *root_item = new RusificationTreeItem("rusification");
+    root_item->title = "Русификация";
+    root_item->setText(0, "Русификация");
+    root_item->description = "Русификация (описание)";
+    root_item->setFlags(Qt::ItemIsAutoTristate | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
+    ui->treeWidget_title->invisibleRootItem()->addChild(root_item);
+
+    foreach (const QString &group, patch_list.childGroups()) {
+        qDebug() << "Processing " << group << " patch item";
+
+        RusificationTreeItem *item = new RusificationTreeItem(group);
+        item->parseSettingsItem(patch_list);
+
+        RusificationTreeItem *parent_item = findItemByName(root_item, item->parent_name);
+        parent_item->addChild(item);
+    }
+
+    ui->treeWidget_title->expandAll();
+    doStuffWithEveryItemInMyTree(ui->treeWidget_title->invisibleRootItem());
+}
+
 void RusificationWidget::hideAllImportWidgets()
 {
     ui->database_import_widget->hide();
@@ -37,6 +79,12 @@ void RusificationWidget::hideAllImportWidgets()
     ui->textfragment_import_widget->hide();
 }
 
+void RusificationWidget::onHoveredTreeItemChanged(QTreeWidgetItem *item, int column)
+{
+    RusificationTreeItem *tree_item = (RusificationTreeItem*)(item);
+    ui->patch_hint->setText("Патч: " + tree_item->title + "\nОписание: " + tree_item->description);
+}
+
 void RusificationWidget::on_database_import_radiobutton_common_clicked()
 {
     hideAllImportWidgets();
@@ -65,4 +113,11 @@ void RusificationWidget::updateUI()
 
         ui->tabWidget_common->tabBar()->hide();
     }
+
+    //======= MANAGEMENT SECTION =======//
+    auto res = app->client_local_dat.GetIO().GetFilename();
+    if (res.result == LOTRO_DAT::SUCCESS)
+        ui->datfile_name_common->setText(QString::fromStdString(res.value));
+    else
+        ui->datfile_name_common->setText("(файл не инициализирован)");
 }

+ 5 - 0
gui/rusificationwidget.h

@@ -3,6 +3,7 @@
 
 #include <QWidget>
 #include <QTimer>
+#include <QTreeWidgetItem>
 
 namespace Ui {
 class RusificationWidget;
@@ -20,9 +21,13 @@ public:
     ~RusificationWidget();
 
 private:
+    void setupTreeWidget();
+
     void hideAllImportWidgets();
 
 private slots:
+    void onHoveredTreeItemChanged(QTreeWidgetItem *item, int column);
+
     void on_database_import_radiobutton_common_clicked();
 
     void on_file_import_radiobutton_common_clicked();

+ 50 - 119
gui/rusificationwidget.ui

@@ -159,13 +159,55 @@ background-color: rgba(30, 0, 0, 100);</string>
              <bool>true</bool>
             </property>
             <property name="styleSheet">
-             <string notr="true">border-radius: 20px;
+             <string notr="true">QTreeWidget{
+border-radius: 20px;
 color: rgb(255, 255, 255);
-background-color: rgba(255, 255, 255, 0);</string>
+background-color: rgba(255, 255, 255, 0);
+}
+QScrollBar:vertical {
+     border: 0px solid grey;
+     background: transparent;
+     width: 10px;
+     margin: 22px 0 22px 0;
+ }
+
+ QScrollBar::handle:vertical {
+	background-color: rgba(129, 129, 129, 150);	
+    min-height: 10px;
+	border-radius: 5px;
+ }
+ QScrollBar::add-line:vertical {
+     border: 0px solid grey;
+     background: transparent;
+     height: 1px;
+     subcontrol-position: bottom;
+     subcontrol-origin: margin;
+ }
+
+ QScrollBar::sub-line:vertical {
+     border: 0px solid grey;
+     background: transparent;
+     height: 1px;
+     subcontrol-position: top;
+     subcontrol-origin: margin;
+ }
+ QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
+     border: 0px;
+     width: 3px;
+     height: 3px;
+     background: transparent;
+ }
+
+ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
+     background: none;
+ }</string>
             </property>
             <property name="frameShape">
              <enum>QFrame::NoFrame</enum>
             </property>
+            <property name="verticalScrollBarPolicy">
+             <enum>Qt::ScrollBarAsNeeded</enum>
+            </property>
             <property name="editTriggers">
              <set>QAbstractItemView::EditKeyPressed</set>
             </property>
@@ -184,8 +226,11 @@ background-color: rgba(255, 255, 255, 0);</string>
             <property name="autoExpandDelay">
              <number>0</number>
             </property>
+            <property name="indentation">
+             <number>20</number>
+            </property>
             <property name="rootIsDecorated">
-             <bool>true</bool>
+             <bool>false</bool>
             </property>
             <property name="uniformRowHeights">
              <bool>false</bool>
@@ -229,120 +274,6 @@ background-color: rgba(255, 255, 255, 0);</string>
               </brush>
              </property>
             </column>
-            <item>
-             <property name="text">
-              <string>Русификация</string>
-             </property>
-             <item>
-              <property name="text">
-               <string>Тексты</string>
-              </property>
-              <property name="checkState">
-               <enum>PartiallyChecked</enum>
-              </property>
-              <item>
-               <property name="text">
-                <string>Шрифты</string>
-               </property>
-               <property name="checkState">
-                <enum>Checked</enum>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Предметы</string>
-               </property>
-               <property name="checkState">
-                <enum>Checked</enum>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Эмоции</string>
-               </property>
-               <property name="checkState">
-                <enum>Checked</enum>
-               </property>
-              </item>
-             </item>
-             <item>
-              <property name="text">
-               <string>Карты</string>
-              </property>
-              <property name="checkState">
-               <enum>Checked</enum>
-              </property>
-             </item>
-             <item>
-              <property name="text">
-               <string>Логотипы игры</string>
-              </property>
-             </item>
-             <item>
-              <property name="text">
-               <string>Озвучка персонажей</string>
-              </property>
-              <property name="checkState">
-               <enum>Checked</enum>
-              </property>
-             </item>
-             <item>
-              <property name="text">
-               <string>Заставочные экраны</string>
-              </property>
-              <property name="checkState">
-               <enum>Checked</enum>
-              </property>
-             </item>
-             <item>
-              <property name="text">
-               <string>Видеоролики</string>
-              </property>
-              <property name="checkState">
-               <enum>Checked</enum>
-              </property>
-              <item>
-               <property name="text">
-                <string>Вступительный</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Расовые</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Классовые</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Книга 1: Тени Ангмара</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Книга 2: Копи Мории</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Книга 3: Союзники Короля</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Книга 4: Мощь Саурона</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Чёрная Книга Мордора</string>
-               </property>
-              </item>
-             </item>
-            </item>
            </widget>
           </item>
          </layout>
@@ -414,7 +345,7 @@ color:rgb(255,255,255);
               </widget>
              </item>
              <item row="2" column="0">
-              <widget class="QTextBrowser" name="textBrowser">
+              <widget class="QTextBrowser" name="patch_hint">
                <property name="styleSheet">
                 <string notr="true">border-radius: 20px;
 background-color: rgba(30, 0, 0, 0);
@@ -1767,7 +1698,7 @@ background-color: none;</string>
            </widget>
           </item>
           <item>
-           <widget class="QLabel" name="folder_value_common_2">
+           <widget class="QLabel" name="datfile_name_common">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
               <horstretch>0</horstretch>

+ 4 - 7
gui/statuswidget.ui

@@ -76,7 +76,7 @@ background-color: rgba(30, 0, 0, 100);</string>
              <widget class="QLabel" name="label_4_common">
               <property name="font">
                <font>
-                <family>Trebuchet MS</family>
+                <family>Trajan Pro 3</family>
                 <pointsize>8</pointsize>
                 <weight>50</weight>
                 <bold>false</bold>
@@ -141,7 +141,7 @@ background-color: rgba(30, 0, 0, 100);</string>
              <widget class="QLabel" name="label_8_common">
               <property name="font">
                <font>
-                <family>Trebuchet MS</family>
+                <family>Trajan Pro 3</family>
                </font>
               </property>
               <property name="styleSheet">
@@ -200,7 +200,7 @@ background-color: rgba(30, 0, 0, 100);</string>
              <widget class="QLabel" name="label_2_common">
               <property name="font">
                <font>
-                <family>Trebuchet MS</family>
+                <family>Trajan Pro 3</family>
                 <pointsize>8</pointsize>
                 <weight>50</weight>
                 <bold>false</bold>
@@ -262,10 +262,7 @@ background-color: rgba(30, 0, 0, 100);</string>
              <widget class="QLabel" name="label_6_common">
               <property name="font">
                <font>
-                <family>Trebuchet MS</family>
-                <pointsize>8</pointsize>
-                <weight>50</weight>
-                <bold>false</bold>
+                <family>Trajan Pro 3</family>
                </font>
               </property>
               <property name="styleSheet">

+ 0 - 12
include/rusificationtreeelement.h

@@ -1,12 +0,0 @@
-#ifndef INCLUDEUSIFICATIONTREEELEMENT_H
-#define INCLUDEUSIFICATIONTREEELEMENT_H
-
-#include <QTreeWidgetItem>
-
-class RusificationTreeElement : public QTreeWidgetItem
-{
-public:
-    RusificationTreeElement();
-};
-
-#endif // INCLUDEUSIFICATIONTREEELEMENT_H

+ 24 - 0
include/rusificationtreeitem.h

@@ -0,0 +1,24 @@
+#ifndef INCLUDEUSIFICATIONTREEITEM_H
+#define INCLUDEUSIFICATIONTREEITEM_H
+
+#include <QTreeWidgetItem>
+#include <QSettings>
+
+struct RusificationTreeItem : public QTreeWidgetItem
+{
+
+public:
+    explicit RusificationTreeItem(QString name);
+    void parseSettingsItem(QSettings& patches_list);
+
+public:
+    QString name;
+    QString title;
+    QString description;
+    QString patchname;
+
+    QString parent_name;
+    std::vector<int> categories;
+};
+
+#endif // INCLUDEUSIFICATIONTREEITEM_H

+ 12 - 1
src/legacyapp.cpp

@@ -2,14 +2,25 @@
 #include "filesystem.h"
 
 #include <QtConcurrent/QtConcurrent>
+#include <QFontDatabase>
 
 LegacyApp::LegacyApp(QObject *parent) : QObject(parent), window(this),
     client_local_dat(), client_local_dat_busy(false),
     properties(qApp->applicationDirPath() + "/legacy_v2.ini", QSettings::IniFormat)
-{}
+{
+    properties.setIniCodec("UTF-8");
+}
 
 void LegacyApp::Init()
 {
+    QResource::registerResource(QApplication::applicationDirPath() + "/data01.gtr");
+    QResource::registerResource(QApplication::applicationDirPath() + "/data02.gtr");
+
+    QFontDatabase::addApplicationFont(":/assets/fonts/trajan.ttf");
+    QFontDatabase::addApplicationFont(":/assets/fonts/viking.ttf");
+    QFontDatabase::addApplicationFont(":/assets/fonts/title.ttf");
+
+
     window.Init();
     StartDatFilesInitialisation();
 }

+ 0 - 6
src/rusificationtreeelement.cpp

@@ -1,6 +0,0 @@
-#include "rusificationtreeelement.h"
-
-RusificationTreeElement::RusificationTreeElement()
-{
-
-}

+ 32 - 0
src/rusificationtreeitem.cpp

@@ -0,0 +1,32 @@
+#include "rusificationtreeitem.h"
+#include <QSettings>
+#include <QDebug>
+
+RusificationTreeItem::RusificationTreeItem(QString name): QTreeWidgetItem(1000), name(name)
+{
+}
+
+void RusificationTreeItem::parseSettingsItem(QSettings &patches_list)
+{
+    patches_list.beginGroup(name);
+    title = patches_list.value("title").toString();
+    description = patches_list.value("descr").toString();
+    patchname = patches_list.value("patchname").toString();
+    parent_name = patches_list.value("parent", "rusification").toString();
+
+    setText(0, title);
+
+    if (name.contains("patch")) {
+        QStringList categories_list = patches_list.value("id").toString().split('|');
+        for (QString category : categories_list)
+            categories.push_back(category.toInt());
+        setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
+    }
+
+    if (name.contains("group")) {
+        setFlags(Qt::ItemIsAutoTristate | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
+    }
+
+    qDebug() << title << description << parent_name;
+    patches_list.endGroup();
+}