adding new list items for maps, for noggitWindow
This commit is contained in:
@@ -27,7 +27,14 @@ namespace Noggit::Project
|
||||
{
|
||||
enum class ProjectVersion
|
||||
{
|
||||
VANILLA,
|
||||
BC,
|
||||
WOTLK,
|
||||
CATA,
|
||||
PANDARIA,
|
||||
WOD,
|
||||
LEGION,
|
||||
BFA,
|
||||
SL
|
||||
};
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ PresetEditorWidget::PresetEditorWidget(std::shared_ptr<Project::NoggitProject> p
|
||||
|
||||
count++;
|
||||
}
|
||||
_project->ClientDatabase->UnloadTable("map");
|
||||
|
||||
|
||||
// Handle minimap widget
|
||||
ui->minimapWidget->draw_boundaries(true);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtWidgets/QStackedWidget>
|
||||
|
||||
#include <noggit/ui//windows/noggitWindow/widgets/MapListItem.hpp>
|
||||
#include <QtNetwork/QTcpSocket>
|
||||
#include <sstream>
|
||||
#include <QSysInfo>
|
||||
@@ -66,7 +66,7 @@ namespace Noggit::Ui
|
||||
setWindowTitle (QString::fromStdString (title.str()));
|
||||
setWindowIcon (QIcon (":/icon"));
|
||||
|
||||
if(project->ProjectVersion == Project::ProjectVersion::WOTLK)
|
||||
if(project->ProjectVersion == Project::ProjectVersion::WOTLK)
|
||||
{
|
||||
OpenDBs(project->ClientData);
|
||||
}
|
||||
@@ -223,39 +223,21 @@ namespace Noggit::Ui
|
||||
|
||||
auto layout (new QHBoxLayout (widget));
|
||||
layout->setAlignment(Qt::AlignLeft);
|
||||
|
||||
QListWidget* bookmarks_table (new QListWidget (widget));
|
||||
_continents_table = new QListWidget (widget);
|
||||
_dungeons_table = new QListWidget (widget);
|
||||
_raids_table = new QListWidget (widget);
|
||||
_battlegrounds_table = new QListWidget (widget);
|
||||
_arenas_table = new QListWidget (widget);
|
||||
_scenarios_table = new QListWidget(widget);
|
||||
|
||||
std::array<QListWidget*, 6> type_to_table
|
||||
{{_continents_table, _dungeons_table, _raids_table, _battlegrounds_table, _arenas_table, _scenarios_table}};
|
||||
|
||||
for (auto& table : type_to_table)
|
||||
{
|
||||
QObject::connect ( table, &QListWidget::itemClicked
|
||||
QObject::connect (_continents_table, &QListWidget::itemClicked
|
||||
, [this] (QListWidgetItem* item)
|
||||
{
|
||||
loadMap (item->data (Qt::UserRole).toInt());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
QTabWidget* entry_points_tabs (new QTabWidget (widget));
|
||||
entry_points_tabs->setMaximumWidth(600);
|
||||
|
||||
entry_points_tabs->addTab (_continents_table, "Continents");
|
||||
entry_points_tabs->addTab (_dungeons_table, "Dungeons");
|
||||
entry_points_tabs->addTab (_raids_table, "Raids");
|
||||
entry_points_tabs->addTab (_battlegrounds_table, "Battlegrounds");
|
||||
entry_points_tabs->addTab (_arenas_table, "Arenas");
|
||||
entry_points_tabs->addTab (_scenarios_table, "Scenarios");
|
||||
entry_points_tabs->addTab (_continents_table, "Maps");
|
||||
entry_points_tabs->addTab (bookmarks_table, "Bookmarks");
|
||||
|
||||
entry_points_tabs->setFixedWidth(300);
|
||||
layout->addWidget (entry_points_tabs);
|
||||
|
||||
build_map_lists();
|
||||
@@ -334,13 +316,7 @@ namespace Noggit::Ui
|
||||
|
||||
void Noggit::Ui::NoggitWindow::build_map_lists()
|
||||
{
|
||||
std::array<QListWidget*, 6> type_to_table
|
||||
{{_continents_table, _dungeons_table, _raids_table, _battlegrounds_table, _arenas_table, _scenarios_table}};
|
||||
|
||||
for (auto& table : type_to_table)
|
||||
{
|
||||
table->clear();
|
||||
}
|
||||
_continents_table->clear();
|
||||
|
||||
const auto& table = std::string("Map");
|
||||
auto mapTable = _project->ClientDatabase->LoadTable(table);
|
||||
@@ -357,27 +333,18 @@ namespace Noggit::Ui
|
||||
if (e.areaType < 0 || e.areaType > 5 || !World::IsEditableWorld(record))
|
||||
continue;
|
||||
|
||||
auto item = new QListWidgetItem(QString::number(e.mapID) + " - " + QString::fromUtf8(e.name.c_str()), type_to_table[e.areaType]);
|
||||
if (e.expansion == 0)
|
||||
item->setIcon(QIcon(":/icon-classic"));
|
||||
if (e.expansion == 1)
|
||||
item->setIcon(QIcon(":/icon-burning"));
|
||||
if (e.expansion == 2)
|
||||
item->setIcon(QIcon(":/icon-wrath"));
|
||||
if (e.expansion == 3)
|
||||
item->setIcon(QIcon(":/icon-cata"));
|
||||
if (e.expansion == 4)
|
||||
item->setIcon(QIcon(":/icon-panda"));
|
||||
if (e.expansion == 5)
|
||||
item->setIcon(QIcon(":/icon-warlords"));
|
||||
if (e.expansion == 6)
|
||||
item->setIcon(QIcon(":/icon-legion"));
|
||||
if (e.expansion == 7)
|
||||
item->setIcon(QIcon(":/icon-battle"));
|
||||
if (e.expansion == 8)
|
||||
item->setIcon(QIcon(":/icon-shadow"));
|
||||
auto item = new QListWidgetItem(_continents_table);
|
||||
auto mapListData = Noggit::Ui::Widget::MapListData();
|
||||
mapListData.MapName = QString::fromUtf8(e.name.c_str());
|
||||
mapListData.MapId = e.mapID;
|
||||
mapListData.MapTypeId = e.areaType;
|
||||
mapListData.ExpansionId = e.expansion;
|
||||
|
||||
auto mapListItem = new Noggit::Ui::Widget::MapListItem(mapListData, _continents_table);
|
||||
|
||||
item->setSizeHint(mapListItem->minimumSizeHint());
|
||||
item->setData(Qt::UserRole, QVariant(e.mapID));
|
||||
_continents_table->setItemWidget(item, mapListItem);
|
||||
}
|
||||
_project->ClientDatabase->UnloadTable(table);
|
||||
}
|
||||
|
||||
98
src/noggit/ui/windows/noggitWindow/widgets/MapListItem.cpp
Normal file
98
src/noggit/ui/windows/noggitWindow/widgets/MapListItem.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
#include <noggit/ui/windows/noggitWindow/widgets/MapListItem.hpp>
|
||||
|
||||
namespace Noggit::Ui::Widget
|
||||
{
|
||||
MapListItem::MapListItem(const MapListData& data, QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
auto layout = QGridLayout();
|
||||
|
||||
QIcon icon;
|
||||
if (data.ExpansionId == 0)
|
||||
icon = QIcon(":/icon-classic");
|
||||
if (data.ExpansionId == 1)
|
||||
icon = QIcon(":/icon-burning");
|
||||
if (data.ExpansionId == 2)
|
||||
icon = QIcon(":/icon-wrath");
|
||||
if (data.ExpansionId == 3)
|
||||
icon = QIcon(":/icon-cata");
|
||||
if (data.ExpansionId == 4)
|
||||
icon = QIcon(":/icon-panda");
|
||||
if (data.ExpansionId == 5)
|
||||
icon = QIcon(":/icon-warlords");
|
||||
if (data.ExpansionId == 6)
|
||||
icon = QIcon(":/icon-legion");
|
||||
if (data.ExpansionId == 7)
|
||||
icon = QIcon(":/icon-battle");
|
||||
if (data.ExpansionId == 8)
|
||||
icon = QIcon(":/icon-shadow");
|
||||
|
||||
project_version_icon = new QLabel("", parent);
|
||||
project_version_icon->setPixmap(icon.pixmap(QSize(32, 32)));
|
||||
project_version_icon->setGeometry(0, 0, 32, 32);
|
||||
project_version_icon->setObjectName("project-icon-label");
|
||||
project_version_icon->setStyleSheet("QLabel#project-icon-label { font-size: 12px; padding: 0px;}");
|
||||
|
||||
auto projectName = toCamelCase(QString(data.MapName));
|
||||
project_name_label = new QLabel(projectName, parent);
|
||||
project_name_label->setGeometry(32, 0, 300, 20);
|
||||
project_name_label->setObjectName("project-title-label");
|
||||
project_name_label->setStyleSheet("QLabel#project-title-label { font-size: 12px; }");
|
||||
|
||||
project_directory_label = new QLabel(QString::number(data.MapId), parent);
|
||||
project_directory_label->setGeometry(32, 15, 300, 20);
|
||||
project_directory_label->setObjectName("project-information");
|
||||
project_directory_label->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
||||
|
||||
auto directoryEffect = new QGraphicsOpacityEffect(this);
|
||||
directoryEffect->setOpacity(0.5);
|
||||
|
||||
auto instanceType = QString("Unknown");
|
||||
if(data.MapTypeId == 0)
|
||||
instanceType = QString("Continent");
|
||||
if(data.MapTypeId == 1)
|
||||
instanceType = QString("Dungeon");
|
||||
if(data.MapTypeId == 2)
|
||||
instanceType = QString("Raid");
|
||||
if(data.MapTypeId == 3)
|
||||
instanceType = QString("Battleground");
|
||||
if(data.MapTypeId == 4)
|
||||
instanceType = QString("Arena");
|
||||
if(data.MapTypeId == 5)
|
||||
instanceType = QString("Scenario");
|
||||
|
||||
project_directory_label->setGraphicsEffect(directoryEffect);
|
||||
project_directory_label->setAutoFillBackground(true);
|
||||
|
||||
project_last_edited_label = new QLabel( instanceType,this);
|
||||
project_last_edited_label->setGeometry(150, 15, 125, 20);
|
||||
project_last_edited_label->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||
project_last_edited_label->setObjectName("project-information");
|
||||
project_last_edited_label->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
||||
|
||||
auto lastEditedEffect = new QGraphicsOpacityEffect(this);
|
||||
lastEditedEffect->setOpacity(0.5);
|
||||
|
||||
project_last_edited_label->setGraphicsEffect(lastEditedEffect);
|
||||
project_last_edited_label->setAutoFillBackground(true);
|
||||
|
||||
layout.addWidget(project_version_icon);
|
||||
layout.addWidget(project_name_label);
|
||||
layout.addWidget(project_directory_label);
|
||||
layout.addWidget(project_last_edited_label);
|
||||
setLayout(layout.layout());
|
||||
}
|
||||
|
||||
QSize MapListItem::minimumSizeHint() const
|
||||
{
|
||||
return QSize(300, 32);
|
||||
}
|
||||
|
||||
QString MapListItem::toCamelCase(const QString& s)
|
||||
{
|
||||
QStringList parts = s.split(' ', QString::SkipEmptyParts);
|
||||
for (int i = 0; i < parts.size(); ++i)
|
||||
parts[i].replace(0, 1, parts[i][0].toUpper());
|
||||
|
||||
return parts.join(" ");
|
||||
}
|
||||
}
|
||||
40
src/noggit/ui/windows/noggitWindow/widgets/MapListItem.hpp
Normal file
40
src/noggit/ui/windows/noggitWindow/widgets/MapListItem.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef NOGGIT_WIGDET_MAP_LIST_ITEM_HPP
|
||||
#define NOGGIT_WIGDET_MAP_LIST_ITEM_HPP
|
||||
|
||||
#include <QMenuBar>
|
||||
#include <QAction>
|
||||
#include <qgraphicseffect.h>
|
||||
#include <QGridLayout>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <noggit/project/ApplicationProject.h>
|
||||
|
||||
namespace Noggit::Ui::Widget
|
||||
{
|
||||
struct MapListData
|
||||
{
|
||||
QString MapName;
|
||||
int MapId;
|
||||
int MapTypeId;
|
||||
int ExpansionId;
|
||||
};
|
||||
|
||||
class MapListItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QLabel* project_version_icon;
|
||||
QLabel* project_name_label;
|
||||
QLabel* project_directory_label;
|
||||
QLabel* project_version_label;
|
||||
QLabel* project_last_edited_label;
|
||||
int _maxWidth;
|
||||
public:
|
||||
MapListItem(const MapListData& data, QWidget* parent);
|
||||
QSize minimumSizeHint() const override;
|
||||
private:
|
||||
QString toCamelCase(const QString& s);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //NOGGIT_WIGDET_MAP_LIST_ITEM_HPP
|
||||
0
src/noggit/ui/windows/noggitWindow/widgets/_w.hpp
Normal file
0
src/noggit/ui/windows/noggitWindow/widgets/_w.hpp
Normal file
@@ -8,7 +8,7 @@ NoggitProjectCreationDialog::NoggitProjectCreationDialog(ProjectInformation& pro
|
||||
, ui(new ::Ui::NoggitProjectCreationDialog)
|
||||
, _projectInformation(projectInformation)
|
||||
{
|
||||
setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
||||
setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user