Skip to content

Commit 42df333

Browse files
authored
Merge pull request #1959 from TheMasterCreed/master
Qt 6.4 build compat, Windows VFS dedupe fix, scrollbar UX
2 parents bb8b7ef + 7bdc618 commit 42df333

17 files changed

Lines changed: 450 additions & 132 deletions

File tree

3rd_party/oxygine-framework/oxygine/core/none/ShaderProgram.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <QtTypes>
3+
#include <QtGlobal>
44
#include <memory>
55

66
namespace oxygine

3rd_party/oxygine-framework/oxygine/res/Resources.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "coreengine/gameconsole.h"
77

88
#include <QFile>
9+
#include <QtGlobal>
910

1011
namespace oxygine
1112
{
@@ -120,8 +121,19 @@ namespace oxygine
120121
updateName(xmlFile);
121122
m_docs.push_back(QDomDocument());
122123
QDomDocument& doc = m_docs.last();
124+
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
123125
auto result = doc.setContent(&file);
124-
if (result)
126+
bool loaded = static_cast<bool>(result);
127+
QString errorMessage = result.errorMessage;
128+
qsizetype errorLine = result.errorLine;
129+
qsizetype errorColumn = result.errorColumn;
130+
#else
131+
QString errorMessage;
132+
int errorLine = 0;
133+
int errorColumn = 0;
134+
bool loaded = doc.setContent(&file, &errorMessage, &errorLine, &errorColumn);
135+
#endif
136+
if (loaded)
125137
{
126138
QDomElement resources = doc.documentElement();
127139
CONSOLE_PRINT_MODULE("loading xml resources", GameConsole::eDEBUG, GameConsole::eResources);
@@ -167,7 +179,7 @@ namespace oxygine
167179
}
168180
else
169181
{
170-
CONSOLE_PRINT("Error: " + result.errorMessage + " at line " + QString::number(result.errorLine) + " at column " + QString::number(result.errorColumn), GameConsole::eERROR);
182+
CONSOLE_PRINT("Error: " + errorMessage + " at line " + QString::number(errorLine) + " at column " + QString::number(errorColumn), GameConsole::eERROR);
171183
}
172184
#endif
173185
return true;
@@ -218,4 +230,3 @@ namespace oxygine
218230
}
219231

220232
}
221-

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,12 @@ if(NOT DEFINED QT_VERSION)
8383
find_program(QMAKE_EXE NAMES qmake)
8484
execute_process(COMMAND ${QMAKE_EXE} -query QT_VERSION OUTPUT_VARIABLE QT_VERSION)
8585
endif()
86-
message("Qt-Version: ${QT_VERSION}")
87-
88-
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
86+
message("Qt-Version: ${QT_VERSION}")
87+
if(Qt6Core_VERSION VERSION_LESS "6.5.0")
88+
add_compile_definitions(Qt_6_5=Qt_6_4)
89+
endif()
90+
91+
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
8992
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
9093
find_program(ADDR_2_LINE addr2line)
9194
message("addr2Line: ${ADDR_2_LINE}")

ai/capturebuildingselector.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <QtTypes>
3+
#include <QtGlobal>
44
#include "ai/coreai.h"
55

66
class GameAction;
@@ -47,4 +47,3 @@ class CaptureBuildingSelector
4747
CoreAI & m_owner;
4848
QVector<QPoint> m_usedFarAwayBuildings;
4949
};
50-

ai/heavyai/heavyAiSharedData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <QtTypes>
3+
#include <QtGlobal>
44

55
class Unit;
66
class UnitTargetedPathFindingSystem;

ai/transporterselector.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <QtTypes>
3+
#include <QtGlobal>
44
#include "ai/coreai.h"
55

66
class GameAction;
@@ -22,4 +22,3 @@ class TransporterSelector
2222
private:
2323
CoreAI & m_owner;
2424
};
25-

coreengine/audiomanager.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <QFile>
1010
#include <QFileInfo>
1111
#include <QDir>
12+
#include <QtGlobal>
1213
#include <QDirIterator>
1314
#include <QList>
1415
#ifdef AUDIOSUPPORT
@@ -173,8 +174,19 @@ void AudioManager::readSoundCacheFromXml(QString folder)
173174
QFile file(folder + "res.xml");
174175
if (file.open(QIODevice::ReadOnly))
175176
{
177+
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
176178
auto result = document.setContent(&file);
177-
if (result)
179+
bool loaded = static_cast<bool>(result);
180+
QString errorMessage = result.errorMessage;
181+
qsizetype errorLine = result.errorLine;
182+
qsizetype errorColumn = result.errorColumn;
183+
#else
184+
QString errorMessage;
185+
int errorLine = 0;
186+
int errorColumn = 0;
187+
bool loaded = document.setContent(&file, &errorMessage, &errorLine, &errorColumn);
188+
#endif
189+
if (loaded)
178190
{
179191
auto rootElement = document.documentElement();
180192
auto node = rootElement.firstChild();
@@ -200,7 +212,7 @@ void AudioManager::readSoundCacheFromXml(QString folder)
200212
else
201213
{
202214
CONSOLE_PRINT_MODULE("Unable to load: " + folder + "res.xml", GameConsole::eERROR, GameConsole::eAudio);
203-
CONSOLE_PRINT_MODULE("Error: " + result.errorMessage + " at line " + QString::number(result.errorLine) + " at column " + QString::number(result.errorColumn), GameConsole::eERROR, GameConsole::eAudio);
215+
CONSOLE_PRINT_MODULE("Error: " + errorMessage + " at line " + QString::number(errorLine) + " at column " + QString::number(errorColumn), GameConsole::eERROR, GameConsole::eAudio);
204216
}
205217
}
206218
}

coreengine/globalutils.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ QString GlobalUtils::stripStartPath(QString path)
5252
{
5353
if (path.startsWith(start))
5454
{
55-
for (auto i = 0; i < start.length(); ++i)
56-
{
57-
path = path.removeFirst();
58-
}
55+
path.remove(0, start.length());
5956
}
6057
}
6158
return path;

coreengine/virtualpaths.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <QCoreApplication>
2+
#include <QDir>
23
#include <QFile>
34
#include <QFileInfo>
45
#include <QList>
@@ -8,6 +9,20 @@
89

910
QList<VirtualPaths::SearchPathInfo> VirtualPaths::m_searchPath;
1011

12+
QString VirtualPaths::normalizedPath(const QFileInfo& info)
13+
{
14+
QString path = info.canonicalFilePath();
15+
if (path.isEmpty())
16+
{
17+
path = info.absoluteFilePath();
18+
}
19+
path = QDir::cleanPath(path);
20+
#ifdef _WIN32
21+
path = path.toLower();
22+
#endif
23+
return path;
24+
}
25+
1126
void VirtualPaths::setSearchPath(const QString& userPath, const QStringList& mods)
1227
{
1328
CONSOLE_PRINT("Initializing VFS...", GameConsole::eINFO);
@@ -19,7 +34,8 @@ void VirtualPaths::setSearchPath(const QString& userPath, const QStringList& mod
1934
#ifndef USEAPPCONFIGPATH
2035
// USEAPPCONFIGPATH is primarily set on Linux, where the "current directory" of programs launched from the start
2136
// menu is normally the user's home directory. This is very unexpected behavior, and this should not be checked.
22-
if (QFileInfo(".") != QFileInfo(userPath))
37+
QFileInfo currentPath(".");
38+
if (normalizedPath(currentPath) != normalizedPath(QFileInfo(userPath)))
2339
{
2440
m_searchPath.append({ "." });
2541
}

coreengine/virtualpaths.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class VirtualPaths final
7070
static QStringList createSearchPathInternal(const QString& name, bool checkMods = true, bool firstPriority = false);
7171
static QStringList findAllInternal(const QString& name, bool checkMods = true, bool firstPriority = false);
7272
static VirtualPaths::ProcessedName processName(const QString& pName);
73+
static QString normalizedPath(const QFileInfo& info);
7374

7475
private:
7576
static QList<SearchPathInfo> m_searchPath;

0 commit comments

Comments
 (0)