diff --git a/src/noggit/application/ApplicationEntry.cpp b/src/noggit/application/ApplicationEntry.cpp index 00a51694..d7377215 100755 --- a/src/noggit/application/ApplicationEntry.cpp +++ b/src/noggit/application/ApplicationEntry.cpp @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) noggit->initalize(argc, argv, Command); auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit); - project_selection->show(); + // project_selection->show(); return q_application.exec(); } \ No newline at end of file diff --git a/src/noggit/application/NoggitApplication.cpp b/src/noggit/application/NoggitApplication.cpp index de5ba3dc..0fc1d82b 100755 --- a/src/noggit/application/NoggitApplication.cpp +++ b/src/noggit/application/NoggitApplication.cpp @@ -140,8 +140,6 @@ namespace Noggit::Application ); } LogError << "std::terminate: " << reason << std::endl; - - CloseLogging(); } bool NoggitApplication::GetCommand(int index) diff --git a/src/noggit/application/NoggitApplication.hpp b/src/noggit/application/NoggitApplication.hpp index 4ae1555b..062709c0 100755 --- a/src/noggit/application/NoggitApplication.hpp +++ b/src/noggit/application/NoggitApplication.hpp @@ -46,6 +46,7 @@ namespace Noggit::Application { } BlizzardArchive::ClientData* clientData() { return _client_data.get(); } + bool hasClientData() { return _client_data != nullptr; } void setClientData(std::shared_ptr data) { _client_data = data; } void initalize(int argc, char* argv[], std::vector Parser); diff --git a/src/noggit/ui/windows/noggitWindow/NoggitWindow.cpp b/src/noggit/ui/windows/noggitWindow/NoggitWindow.cpp index 722ff481..a92943b2 100755 --- a/src/noggit/ui/windows/noggitWindow/NoggitWindow.cpp +++ b/src/noggit/ui/windows/noggitWindow/NoggitWindow.cpp @@ -117,6 +117,16 @@ namespace Noggit::Ui::Windows } ); + auto proj_selec_action(file_menu->addAction("Exit to Project Selection")); + QObject::connect(proj_selec_action, &QAction::triggered, [this] + { + auto noggit = Noggit::Application::NoggitApplication::instance(); + auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit); + project_selection->show(); + close(); + } + ); + _menuBar->adjustSize(); _buildMapListComponent = std::make_unique(); diff --git a/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.cpp b/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.cpp index 51ea7af0..e2d0e167 100755 --- a/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.cpp +++ b/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.cpp @@ -23,6 +23,73 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application:: { setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint); + //////////////////////////// + // auto load favorite project + QSettings settings; + int favorite_proj_idx = settings.value("favorite_project", -1).toInt(); + + bool load_favorite = settings.value("auto_load_fav_project", true).toBool(); + + // if it has client data, it means it already loaded before and we exited through the menu, skip autoloading favorite + if (noggit_app->hasClientData()) + load_favorite = false; + + if (load_favorite && favorite_proj_idx != -1) + { + Log << "Auto loading favorite project index : " << favorite_proj_idx << std::endl; + + int size = settings.beginReadArray("recent_projects"); + + QString project_final_path; + + // for (int i = 0; i < size; ++i) + if (size > favorite_proj_idx) + { + settings.setArrayIndex(favorite_proj_idx); + std::filesystem::path project_path = settings.value("project_path").toString().toStdString().c_str(); + + if (std::filesystem::exists(project_path) && std::filesystem::is_directory(project_path)) + { + auto project_reader = Noggit::Project::ApplicationProjectReader(); + + auto project = project_reader.readProject(project_path); + + if (project.has_value()) + { + // project->projectVersion; + // project_directory = QString::fromStdString(project_path.generic_string()); + // auto project_name = QString::fromStdString(project->ProjectName); + + project_final_path = QString(project_path.string().c_str()); + } + } + } + settings.endArray(); + + if (!project_final_path.isEmpty()) + { + auto selected_project = _load_project_component->loadProject(this, project_final_path); + + if (!selected_project) + { + LogError << "Selected Project is null, favorite loading failed." << std::endl; + } + else + { + Noggit::Project::CurrentProject::initialize(selected_project.get()); + + _project_selection_page = std::make_unique( + _noggit_application->getConfiguration(), + selected_project); + _project_selection_page->showMaximized(); + + close(); + return; + } + } + } + /////////////////////////// + _ui->setupUi(this); _ui->label->setObjectName("title"); @@ -70,6 +137,7 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application:: return; Component::CreateProjectComponent::createProject(this, project_reference); + resetFavoriteProject(); Component::RecentProjectsComponent::buildRecentProjectsList(this); }); @@ -163,7 +231,7 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application:: }); }*/ - auto _set = new QSettings(this); + // auto _set = new QSettings(this); //auto first_changelog = _set->value("first_changelog", false); // force-changelog @@ -178,7 +246,7 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application:: _set->sync(); } }*/ - + show(); } void NoggitProjectSelectionWindow::handleContextMenuProjectListItemDelete(std::string const& project_path) @@ -208,6 +276,7 @@ void NoggitProjectSelectionWindow::handleContextMenuProjectListItemDelete(std::s default: break; } + resetFavoriteProject(); Component::RecentProjectsComponent::buildRecentProjectsList(this); } @@ -236,9 +305,25 @@ void NoggitProjectSelectionWindow::handleContextMenuProjectListItemForget(std::s break; } + resetFavoriteProject(); Component::RecentProjectsComponent::buildRecentProjectsList(this); } +void Noggit::Ui::Windows::NoggitProjectSelectionWindow::handleContextMenuProjectListItemFavorite(int index) +{ + QSettings settings; + settings.sync(); + settings.setValue("favorite_project", index); + Component::RecentProjectsComponent::buildRecentProjectsList(this); +} + +void Noggit::Ui::Windows::NoggitProjectSelectionWindow::resetFavoriteProject() +{ + QSettings settings; + settings.sync(); + settings.setValue("favorite_project", -1); +} + NoggitProjectSelectionWindow::~NoggitProjectSelectionWindow() { delete _ui; diff --git a/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.hpp b/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.hpp index 3c411646..837d38e5 100755 --- a/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.hpp +++ b/src/noggit/ui/windows/projectSelection/NoggitProjectSelectionWindow.hpp @@ -56,6 +56,9 @@ namespace Noggit::Ui::Windows void handleContextMenuProjectListItemDelete(std::string const& project_path); void handleContextMenuProjectListItemForget(std::string const& project_path); + void handleContextMenuProjectListItemFavorite(int index); + + void resetFavoriteProject(); }; } #endif // NOGGITREDPROJECTPAGE_H \ No newline at end of file diff --git a/src/noggit/ui/windows/projectSelection/components/LoadProjectComponent.hpp b/src/noggit/ui/windows/projectSelection/components/LoadProjectComponent.hpp index 35d77a58..f58eaf35 100755 --- a/src/noggit/ui/windows/projectSelection/components/LoadProjectComponent.hpp +++ b/src/noggit/ui/windows/projectSelection/components/LoadProjectComponent.hpp @@ -21,12 +21,22 @@ namespace Noggit::Ui::Component friend Windows::NoggitProjectSelectionWindow; public: - std::shared_ptr loadProject(Noggit::Ui::Windows::NoggitProjectSelectionWindow* parent) + std::shared_ptr loadProject(Noggit::Ui::Windows::NoggitProjectSelectionWindow* parent, QString force_project_path = "") { - QModelIndex index = parent->_ui->listView->currentIndex(); + QString project_path; + + if (!force_project_path.isEmpty()) + project_path = force_project_path; + else + { + QModelIndex index = parent->_ui->listView->currentIndex(); + project_path = index.data(Qt::UserRole).toString(); + } + auto application_configuration = parent->_noggit_application->getConfiguration(); - auto application_projects_folder_path = std::filesystem::path(application_configuration->ApplicationProjectPath); - QString project_path = index.data(Qt::UserRole).toString(); + // auto application_projects_folder_path = std::filesystem::path(application_configuration->ApplicationProjectPath); + + auto application_project_service = Noggit::Project::ApplicationProject(application_configuration); if (!QDir(project_path).exists()) diff --git a/src/noggit/ui/windows/projectSelection/components/RecentProjectsComponent.cpp b/src/noggit/ui/windows/projectSelection/components/RecentProjectsComponent.cpp index ddb1184e..0219650e 100755 --- a/src/noggit/ui/windows/projectSelection/components/RecentProjectsComponent.cpp +++ b/src/noggit/ui/windows/projectSelection/components/RecentProjectsComponent.cpp @@ -5,6 +5,7 @@ #include #include #include +#include using namespace Noggit::Ui::Component; @@ -13,9 +14,11 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi { parent->_ui->listView->clear(); - auto application_configuration = parent->_noggit_application->getConfiguration(); + // auto application_configuration = parent->_noggit_application->getConfiguration(); QSettings settings; + settings.sync(); + int favorite_proj_idx = settings.value("favorite_project", -1).toInt(); int size = settings.beginReadArray("recent_projects"); for (int i = 0; i < size; ++i) @@ -40,6 +43,7 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi project_data.project_directory = QString::fromStdString(project_path.generic_string()); project_data.project_name = QString::fromStdString(project->ProjectName); project_data.project_last_edited = QDateTime::currentDateTime().date().toString(); + project_data.is_favorite = favorite_proj_idx == i ? true : false; auto project_list_item = new Noggit::Ui::Widget::ProjectListItem(project_data, parent->_ui->listView); @@ -93,6 +97,48 @@ void RecentProjectsComponent::buildRecentProjectsList(Noggit::Ui::Windows::Noggi }); context_menu.addAction(&action_4); + + // if (!project_data.is_favorite) + QAction action_5("Favorite Project(auto load)", project_list_item); + auto fav_icon = QIcon(); + fav_icon.addPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16))); + action_5.setIcon(fav_icon); + + if (project_data.is_favorite) + action_5.setText("Unfavorite Project"); + + QObject::connect(&action_5, &QAction::triggered, [=]() + { + if (!project_data.is_favorite) + parent->handleContextMenuProjectListItemFavorite(i); + else + parent->handleContextMenuProjectListItemFavorite(-1); + // QSettings settings; + // if (!project_data.is_favorite) + // settings.setValue("favorite_project", i); + // else + // settings.setValue("favorite_project", -1); + // buildRecentProjectsList(parent); + }); + context_menu.addAction(&action_5); + // else + // { + // QAction action_6("Unfavorite Project", project_list_item); + // auto fav_icon = QIcon(); + // fav_icon.addPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16))); + // action_6.setIcon(fav_icon); + // + // QObject::connect(&action_6, &QAction::triggered, [=]() + // { + // // TODO + // // parent->handleContextMenuProjectListItemFavorite(); + // QSettings settings; + // settings.setValue("favorite_project", -1); + // // project_data.is_favorite = false; + // }); + // context_menu.addAction(&action_6); + // } + ///// context_menu.exec(project_list_item->mapToGlobal(pos)); }); diff --git a/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.cpp b/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.cpp index eb67d5d9..4ef68f42 100755 --- a/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.cpp +++ b/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.cpp @@ -27,6 +27,7 @@ namespace Noggit::Ui::Widget _project_directory_label->setGeometry(48, 20, max_width, 20); _project_directory_label->setObjectName("project-information"); _project_directory_label->setStyleSheet("QLabel#project-information { font-size: 10px; }"); + _project_directory_label->setToolTip(data.project_directory); auto directory_effect = new QGraphicsOpacityEffect(this); directory_effect->setOpacity(0.5); @@ -64,6 +65,25 @@ namespace Noggit::Ui::Widget _project_last_edited_label->setGraphicsEffect(last_edited_effect); _project_last_edited_label->setAutoFillBackground(true); + if (data.is_favorite) + { + _project_favorite_icon = new QLabel("", this); + _project_favorite_icon->setPixmap(FontAwesomeIcon(FontAwesome::star).pixmap(QSize(16, 16))); + _project_favorite_icon->setGeometry(max_width-10, 10, 125, 20); + _project_favorite_icon->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); + _project_favorite_icon->setObjectName("project-favorite"); + _project_favorite_icon->setStyleSheet("QLabel#project-information { font-size: 10px; }"); + + auto colour = new QGraphicsColorizeEffect(this); + colour->setColor(QColor(255, 204, 0)); + colour->setStrength(1.0f); + + _project_favorite_icon->setGraphicsEffect(colour); + _project_favorite_icon->setAutoFillBackground(true); + + layout.addWidget(_project_favorite_icon); + } + setContextMenuPolicy(Qt::CustomContextMenu); layout.addWidget(_project_version_icon); diff --git a/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.hpp b/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.hpp index ccf1c5c3..d9f08552 100755 --- a/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.hpp +++ b/src/noggit/ui/windows/projectSelection/widgets/ProjectListItem.hpp @@ -17,6 +17,7 @@ namespace Noggit::Ui::Widget QString project_directory; QString project_last_edited; Project::ProjectVersion project_version; + bool is_favorite; }; class ProjectListItem : public QWidget @@ -28,6 +29,7 @@ namespace Noggit::Ui::Widget QLabel* _project_directory_label; QLabel* _project_version_label; QLabel* _project_last_edited_label; + QLabel* _project_favorite_icon; public: ProjectListItem(const ProjectListItemData& data, QWidget* parent); QSize minimumSizeHint() const override; diff --git a/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp b/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp index c039bf46..2d05cfc4 100755 --- a/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp +++ b/src/noggit/ui/windows/settingsPanel/SettingsPanel.cpp @@ -192,6 +192,7 @@ namespace Noggit ui->_adt_unload_dist->setValue(_settings->value("unload_dist", 5).toInt()); ui->_adt_unload_check_interval->setValue(_settings->value("unload_interval", 5).toInt()); ui->_uid_cb->setChecked(_settings->value("uid_startup_check", true).toBool()); + ui->_load_fav_cb->setChecked(_settings->value("auto_load_fav_project", true).toBool()); ui->_systemWindowFrame->setChecked(_settings->value("systemWindowFrame", true).toBool()); ui->_nativeMenubar->setChecked(_settings->value("nativeMenubar", true).toBool()); ui->_classic_ui->setChecked(_settings->value("classicUI", false).toBool()); @@ -275,6 +276,7 @@ namespace Noggit _settings->setValue("unload_dist", ui->_adt_unload_dist->value()); _settings->setValue("unload_interval", ui->_adt_unload_check_interval->value()); _settings->setValue("uid_startup_check", ui->_uid_cb->isChecked()); + _settings->setValue("auto_load_fav_project", ui->_load_fav_cb->isChecked()); _settings->setValue("additional_file_loading_log", ui->_additional_file_loading_log->isChecked()); _settings->setValue("keyboard_locale", ui->_keyboard_locale->currentText()); _settings->setValue("systemWindowFrame", ui->_systemWindowFrame->isChecked()); diff --git a/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui b/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui index 473fea57..211eb896 100755 --- a/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui +++ b/src/noggit/ui/windows/settingsPanel/SettingsPanel.ui @@ -84,86 +84,368 @@ false - + - Paths + Preferences - + - + 8 - + - Paths + Viewport - Qt::AlignHCenter|Qt::AlignTop + Qt::AlignCenter - + - + - + - + + + Qt::Horizontal + + + + 40 + 20 + + + - + - - - - 90 - 0 - - - - Import Path - - + + + + + Requires restart + + + VSync + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Requires restart + + + + + + + - + + + + + Requires restart + + + Anti Aliasing + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Requires restart + + + + + + + - - - Browse - - + + + + + Requires restart + + + Fullscreen + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Requires restart + + + + + + + - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - - - - 90 - 0 - - - - WMV Log Path - - + + + + + View Distance + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1048576.000000000000000 + + + 2000.000000000000000 + + + + - + + + + + FarZ + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1048576.000000000000000 + + + 2048.000000000000000 + + + + - - - Browse - - + + + + + Adt unloading distance (in adt) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1 + + + 64 + + + 2 + + + + + + + + + + + Adt unloading check interval (sec) + + + + + + + 1 + + + 5 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + + + This setting will be effective after a reload + + + + + + + + + 30 + + + + + + + 30 + + + 240 + + + 30 + + + 30 + + + Qt::Horizontal + + + + + + + 180 + + + @@ -171,21 +453,233 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - + + + + Misc + + + Qt::AlignCenter + + + + + + 10 + + + 10 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 0 + + + + + + 200 + 0 + + + + Always check for max UID + + + + + + + + + + true + + + + + + + + 200 + 0 + + + + Undock tool properties + + + + + + + + + + + + + + + 200 + 0 + + + + Undock quick access texture palette + + + + + + + + + + + + + + + 200 + 0 + + + + Additional file loading log + + + + + + + + + + + + + + + 134 + 0 + + + + Keyboard locale + + + + + + + + 0 + 0 + + + + + 80 + 16777215 + + + + + QWERTY + + + + + AZERTY + + + + + + + + + 200 + 0 + + + + Auto load favorite project + + + + + + + + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -647,368 +1141,86 @@ - + - Preferences + Paths - + - + 8 - + - Viewport + Paths (Optional) - Qt::AlignCenter + Qt::AlignHCenter|Qt::AlignTop - + - + - + - - - Qt::Horizontal - - - - 40 - 20 - - - + - + - - - - - Requires restart - - - VSync - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Requires restart - - - - - - - + + + + 90 + 0 + + + + Import Path + + - - - - - Requires restart - - - Anti Aliasing - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Requires restart - - - - - - - + - - - - - Requires restart - - - Fullscreen - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Requires restart - - - - - - - + + + Browse + + - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + - - - - - View Distance - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1048576.000000000000000 - - - 2000.000000000000000 - - - - + + + + 90 + 0 + + + + WMV Log Path + + - - - - - FarZ - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1048576.000000000000000 - - - 2048.000000000000000 - - - - + - - - - - Adt unloading distance (in adt) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1 - - - 64 - - - 2 - - - - - - - - - - - Adt unloading check interval (sec) - - - - - - - 1 - - - 5 - - - - + + + Browse + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - - - - This setting will be effective after a reload - - - - - - - - - 30 - - - - - - - 30 - - - 180 - - - 30 - - - 30 - - - Qt::Horizontal - - - - - - - 180 - - - @@ -1016,210 +1228,21 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + - - - - Misc - - - Qt::AlignCenter - - - - - - 10 - - - 10 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 0 - - - - - - 200 - 0 - - - - Always check for max UID - - - - - - - - - - true - - - - - - - - 200 - 0 - - - - Undock tool properties - - - - - - - - - - - - - - - 200 - 0 - - - - Undock quick access texture palette - - - - - - - - - - - - - - - 200 - 0 - - - - Additional file loading log - - - - - - - - - - - - - - - 134 - 0 - - - - Keyboard locale - - - - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - - QWERTY - - - - - AZERTY - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - -