Update DBCFile.cpp, MapView.cpp, and 10 more files... | fix project path duplicated setting, fix crash on return to map
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <noggit/DBCFile.h>
|
||||
#include <noggit/Log.h>
|
||||
#include <noggit/application/NoggitApplication.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
#include <ClientFile.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -60,8 +61,7 @@ void DBCFile::open(std::shared_ptr<BlizzardArchive::ClientData> clientData)
|
||||
|
||||
void DBCFile::save()
|
||||
{
|
||||
QSettings app_settings;
|
||||
QString str = app_settings.value ("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <noggit/ui/hole_tool.hpp>
|
||||
#include <noggit/ui/texture_palette_small.hpp>
|
||||
#include <noggit/ui/MinimapCreator.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
#include <opengl/scoped.hpp>
|
||||
#include <noggit/ui/tools/ViewToolbar/Ui/ViewToolbar.hpp>
|
||||
#include <noggit/ui/tools/AssetBrowser/Ui/AssetBrowser.hpp>
|
||||
@@ -955,12 +956,10 @@ void MapView::setupDetailInfos()
|
||||
_main_window->addDockWidget(Qt::BottomDockWidgetArea, _detail_infos_dock);
|
||||
_detail_infos_dock->setFloating(true);
|
||||
_detail_infos_dock->hide();
|
||||
connect(this, &QObject::destroyed, _detail_infos_dock, &QObject::deleteLater);
|
||||
// End Dock
|
||||
|
||||
guidetailInfos = new Noggit::Ui::detail_infos(this);
|
||||
_detail_infos_dock->setWidget(guidetailInfos);
|
||||
connect(this, &QObject::destroyed, guidetailInfos, &QObject::deleteLater);
|
||||
_detail_infos_dock->setWidget(guidetailInfos);;
|
||||
|
||||
|
||||
connect ( &_show_detail_info_window, &Noggit::BoolToggleProperty::changed
|
||||
@@ -2556,7 +2555,7 @@ MapView::MapView( math::degrees camera_yaw0
|
||||
, math::degrees camera_pitch0
|
||||
, glm::vec3 camera_pos
|
||||
, Noggit::Ui::Windows::NoggitWindow* NoggitWindow
|
||||
, std::shared_ptr<Noggit::Project::NoggitProject> Project
|
||||
, std::shared_ptr<Noggit::Project::NoggitProject> Project
|
||||
, std::unique_ptr<World> world
|
||||
, uid_fix_mode uid_fix
|
||||
, bool from_bookmark
|
||||
@@ -2597,9 +2596,6 @@ MapView::MapView( math::degrees camera_yaw0
|
||||
_main_window->setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
||||
_main_window->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
||||
|
||||
if(QString pathProject{_settings->value("project/path").toString()}; !(pathProject.endsWith('\\') || pathProject.endsWith('/')))
|
||||
_settings->setValue("project/path", pathProject.append('/'));
|
||||
|
||||
_main_window->statusBar()->addWidget (_status_position);
|
||||
connect ( this
|
||||
, &QObject::destroyed
|
||||
@@ -2897,7 +2893,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
|
||||
{
|
||||
QString image_path = QString(std::string(_world->basename + "_combined_minimap.png").c_str());
|
||||
QSettings app_settings;
|
||||
QString str = app_settings.value("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());;
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
@@ -3012,8 +3008,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
|
||||
if (settings->combined_minimap)
|
||||
{
|
||||
QString image_path = QString(std::string(_world->basename + "_combined_minimap.png").c_str());
|
||||
QSettings app_settings;
|
||||
QString str = app_settings.value("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
@@ -3233,6 +3228,8 @@ MapView::~MapView()
|
||||
ModelManager::report();
|
||||
TextureManager::report();
|
||||
WMOManager::report();
|
||||
|
||||
NOGGIT_ACTION_MGR->disconnect();
|
||||
}
|
||||
|
||||
void MapView::tick (float dt)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <noggit/ui/ObjectEditor.h>
|
||||
#include <noggit/ui/TexturingGUI.h>
|
||||
#include <noggit/application/NoggitApplication.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
#include <noggit/ActionManager.hpp>
|
||||
#include <external/tracy/Tracy.hpp>
|
||||
#include <QByteArray>
|
||||
@@ -1638,7 +1639,7 @@ void World::exportADTAlphamap(glm::vec3 const& pos)
|
||||
for_tile_at ( pos
|
||||
, [&] (MapTile* tile)
|
||||
{
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -1666,7 +1667,7 @@ void World::exportADTNormalmap(glm::vec3 const& pos)
|
||||
for_tile_at ( pos
|
||||
, [&] (MapTile* tile)
|
||||
{
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -1690,7 +1691,7 @@ void World::exportADTAlphamap(glm::vec3 const& pos, std::string const& filename)
|
||||
for_tile_at ( pos
|
||||
, [&] (MapTile* tile)
|
||||
{
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -1716,7 +1717,7 @@ void World::exportADTHeightmap(glm::vec3 const& pos, float min_height, float max
|
||||
for_tile_at ( pos
|
||||
, [&] (MapTile* tile)
|
||||
{
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -1742,7 +1743,7 @@ void World::exportADTVertexColorMap(glm::vec3 const& pos)
|
||||
for_tile_at ( pos
|
||||
, [&] (MapTile* tile)
|
||||
{
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -1802,7 +1803,7 @@ void World::importADTAlphamap(glm::vec3 const& pos)
|
||||
NOGGIT_CUR_ACTION->registerChunkTextureChange(chunk);
|
||||
});
|
||||
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -1871,7 +1872,7 @@ void World::importADTHeightmap(glm::vec3 const& pos, float multiplier, unsigned
|
||||
, [&] (MapTile* tile)
|
||||
{
|
||||
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -1908,7 +1909,7 @@ void World::importADTVertexColorMap(glm::vec3 const& pos, int mode)
|
||||
, [&] (MapTile* tile)
|
||||
{
|
||||
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -2526,7 +2527,7 @@ void World::exportAllADTsAlphamap()
|
||||
{
|
||||
mTile->wait_until_loaded();
|
||||
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -2591,7 +2592,7 @@ void World::exportAllADTsAlphamap(const std::string& filename)
|
||||
if (!found)
|
||||
continue;
|
||||
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -2665,7 +2666,7 @@ void World::exportAllADTsHeightmap()
|
||||
{
|
||||
mTile->wait_until_loaded();
|
||||
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -2705,7 +2706,7 @@ void World::exportAllADTsVertexColorMap()
|
||||
{
|
||||
mTile->wait_until_loaded();
|
||||
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -2732,7 +2733,7 @@ void World::exportAllADTsVertexColorMap()
|
||||
void World::importAllADTsAlphamaps()
|
||||
{
|
||||
ZoneScoped;
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -2791,7 +2792,7 @@ void World::importAllADTsAlphamaps()
|
||||
void World::importAllADTsHeightmaps(float multiplier, unsigned int mode)
|
||||
{
|
||||
ZoneScoped;
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
@@ -2846,7 +2847,7 @@ void World::importAllADTsHeightmaps(float multiplier, unsigned int mode)
|
||||
void World::importAllADTVertexColorMaps(unsigned int mode)
|
||||
{
|
||||
ZoneScoped;
|
||||
QString path = _settings->value("project/path").toString();
|
||||
QString path = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(path.endsWith('\\') || path.endsWith('/')))
|
||||
{
|
||||
path += "/";
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <noggit/World.h>
|
||||
#include <noggit/ActionManager.hpp>
|
||||
#include <noggit/Action.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
#ifdef USE_MYSQL_UID_STORAGE
|
||||
#include <mysql/mysql.h>
|
||||
#endif
|
||||
@@ -440,8 +441,7 @@ void MapIndex::saveTile(const TileIndex& tile, World* world, bool save_unloaded)
|
||||
// save given tile
|
||||
if (save_unloaded)
|
||||
{
|
||||
QSettings settings;
|
||||
auto filepath = std::filesystem::path (settings.value ("project/path").toString().toStdString())
|
||||
auto filepath = std::filesystem::path (Noggit::Project::CurrentProject::get()->ProjectPath)
|
||||
/ BlizzardArchive::ClientData::normalizeFilenameInternal (mTiles[tile.z][tile.x].tile->file_key().filepath());
|
||||
|
||||
QFile file(filepath.string().c_str());
|
||||
@@ -483,8 +483,7 @@ void MapIndex::saveChanged (World* world, bool save_unloaded)
|
||||
continue;
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
auto filepath = std::filesystem::path (settings.value ("project/path").toString().toStdString())
|
||||
auto filepath = std::filesystem::path (Noggit::Project::CurrentProject::get()->ProjectPath)
|
||||
/ BlizzardArchive::ClientData::normalizeFilenameInternal (mTiles[i][j].tile->file_key().filepath());
|
||||
|
||||
if (mTiles[i][j].flags & 0x1)
|
||||
@@ -1096,8 +1095,7 @@ void MapIndex::loadMinimapMD5translate()
|
||||
|
||||
void MapIndex::saveMinimapMD5translate()
|
||||
{
|
||||
QSettings settings;
|
||||
QString str = settings.value ("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
|
||||
27
src/noggit/project/CurrentProject.hpp
Normal file
27
src/noggit/project/CurrentProject.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#ifndef NOGGIT_CURRENTPROJECT_HPP
|
||||
#define NOGGIT_CURRENTPROJECT_HPP
|
||||
|
||||
#include <noggit/project/ApplicationProject.h>
|
||||
#include <cassert>
|
||||
|
||||
namespace Noggit::Project
|
||||
{
|
||||
class CurrentProject
|
||||
{
|
||||
public:
|
||||
static NoggitProject* get()
|
||||
{
|
||||
assert(_app_project && "Current project was not initialized");
|
||||
return _app_project;
|
||||
};
|
||||
|
||||
static void initialize(NoggitProject* project) { _app_project = project; }
|
||||
|
||||
private:
|
||||
static inline NoggitProject* _app_project = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //NOGGIT_CURRENTPROJECT_HPP
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <noggit/World.h>
|
||||
#include <external/PNG2BLP/Png2Blp.h>
|
||||
#include <noggit/DBC.h>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
|
||||
#include <QDir>
|
||||
#include <QBuffer>
|
||||
@@ -1592,7 +1593,7 @@ bool WorldRender::saveMinimap(TileIndex const& tile_idx, MinimapRenderSettings*
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888);
|
||||
|
||||
QSettings app_settings;
|
||||
QString str = app_settings.value ("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <noggit/MapView.h>
|
||||
#include <noggit/World.h>
|
||||
#include <noggit/Log.h>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
|
||||
#include <util/qt/overload.hpp>
|
||||
|
||||
@@ -1027,8 +1028,7 @@ namespace Noggit
|
||||
|
||||
void MinimapCreator::loadFiltersFromJSON()
|
||||
{
|
||||
QSettings settings;
|
||||
QString str = settings.value ("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
@@ -1096,8 +1096,7 @@ namespace Noggit
|
||||
|
||||
void MinimapCreator::saveFiltersToJSON()
|
||||
{
|
||||
QSettings settings;
|
||||
QString str = settings.value ("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <noggit/TextureManager.h> // TextureManager, Texture
|
||||
#include <noggit/ui/TextureList.hpp>
|
||||
#include <noggit/application/NoggitApplication.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -89,8 +90,8 @@ namespace Noggit
|
||||
}
|
||||
|
||||
{
|
||||
QSettings settings;
|
||||
auto const prefix (std::filesystem::path (settings.value("project/path").toString().toStdString()));
|
||||
|
||||
auto const prefix (std::filesystem::path ( Noggit::Project::CurrentProject::get()->ProjectPath ));
|
||||
auto const prefix_size (prefix.string().length());
|
||||
|
||||
if (std::filesystem::exists (prefix))
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <noggit/ui/FontNoggit.hpp>
|
||||
#include <noggit/MapView.h>
|
||||
#include <noggit/application/NoggitApplication.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QItemSelectionModel>
|
||||
@@ -307,7 +308,7 @@ void AssetBrowserWidget::updateModelData()
|
||||
|
||||
|
||||
QSettings settings;
|
||||
QString project_dir = settings.value("project/path").toString();
|
||||
QString project_dir = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
recurseDirectory(tree_mgr, project_dir, project_dir);
|
||||
|
||||
_sort_model->setSortRole(Qt::UserRole);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <noggit/ui/FontAwesome.hpp>
|
||||
#include <noggit/ui/windows/noggitWindow/NoggitWindow.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
#include <blizzard-database-library/include/structures/Types.h>
|
||||
#include <noggit/MapView.h>
|
||||
#include <noggit/World.h>
|
||||
@@ -432,8 +433,7 @@ void MapCreationWizard::saveCurrentEntry()
|
||||
std::stringstream filename;
|
||||
filename << "World\\Maps\\" << map_internal_name << "\\" << map_internal_name << ".wdt";
|
||||
|
||||
QSettings settings;
|
||||
auto project_path = std::filesystem::path (settings.value ("project/path").toString().toStdString());
|
||||
auto project_path = std::filesystem::path(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
|
||||
QDir dir((project_path / "/world/maps/" / map_internal_name).string().c_str());
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <noggit/ui/windows/projectSelection/components/ExistingProjectEnumerationComponent.hpp>
|
||||
#include <noggit/ui/windows/projectSelection/components/CreateProjectComponent.hpp>
|
||||
#include <noggit/ui/windows/projectSelection/components/LoadProjectComponent.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <QString>
|
||||
|
||||
@@ -56,6 +58,8 @@ namespace Noggit::Ui::Windows
|
||||
{
|
||||
auto selectedProject = _loadProjectComponent->LoadProject(this);
|
||||
|
||||
Noggit::Project::CurrentProject::initialize(selectedProject.get());
|
||||
|
||||
projectSelectionPage = std::make_unique<Noggit::Ui::Windows::NoggitWindow>(_noggitApplication->GetConfiguration(), selectedProject);
|
||||
projectSelectionPage->showMaximized();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <noggit/uid_storage.hpp>
|
||||
#include <noggit/project/CurrentProject.hpp>
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
@@ -8,8 +9,7 @@ namespace
|
||||
{
|
||||
QString uid_file_path()
|
||||
{
|
||||
QSettings settings;
|
||||
QString str = settings.value ("project/path").toString();
|
||||
QString str = QString(Noggit::Project::CurrentProject::get()->ProjectPath.c_str());
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
|
||||
Reference in New Issue
Block a user