Skip to content

Commit 2ae7ecc

Browse files
committed
Bump version to 2.16.0, update game version to 3.270.0, add fullscreen mode to ini, fix log panel auto-scroll
1 parent cf942c3 commit 2ae7ecc

10 files changed

Lines changed: 138 additions & 46 deletions

File tree

.idea/editor.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0141 NEW)
33
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<CONFIG:Debug>,EditAndContinue,ProgramDatabase>" CACHE STRING "MSVC debug information format")
44
project(
55
NavKit
6-
VERSION 2.15.0
6+
VERSION 2.16.0
77
DESCRIPTION "An app to create NAVP and AIRG files for use with Hitman: World of Assassination"
88
LANGUAGES CXX)
99
set(CMAKE_CXX_STANDARD 20)

include/NavKit/module/Renderer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class SceneMeshHitTestResult {
4242

4343
class Renderer {
4444
public:
45+
enum FullscreenMode {
46+
WINDOWED,
47+
MAXIMIZED,
48+
BORDERLESS_FULLSCREEN
49+
};
50+
4551
Renderer();
4652

4753
~Renderer();
@@ -74,6 +80,8 @@ class Renderer {
7480

7581
void handleResize();
7682

83+
void handleFullscreen(FullscreenMode mode) const;
84+
7785
void renderFrame();
7886

7987
void finalizeFrame() const;

src/module/Gui.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,33 @@ void Gui::drawGui() {
7575
imguiRGBA(255, 255, 255, 128));
7676

7777
if (showLog) {
78-
if (imguiBeginScrollArea("Log", 20, 20,
79-
renderer.width - 40,
80-
renderer.height > 440
81-
? 220
82-
: static_cast<int>(static_cast<double>(renderer.height) * 0.2),
83-
&logScroll)) {
84-
mouseOverMenu = true;
85-
}
78+
const int logAreaHeight = renderer.height > 440
79+
? 220
80+
: static_cast<int>(static_cast<double>(renderer.height) * 0.2);
8681
Logger &logger = Logger::getInstance();
8782
std::lock_guard lock(logger.getLogMutex());
88-
8983
const std::deque<std::string>& logBuffer = logger.getLogBuffer();
90-
for (auto it = logBuffer.cbegin();
91-
it != logBuffer.cend(); ++it) {
92-
imguiLabel(it->c_str());
84+
const int totalLogCount = logger.getLogCount();
85+
constexpr int lineHeight = 20;
86+
constexpr int headerHeight = 25;
87+
constexpr int padding = 10;
88+
const int visibleHeight = logAreaHeight - headerHeight;
89+
const int contentHeight = static_cast<int>(logBuffer.size()) * lineHeight + padding;
90+
const int maxScroll = std::max(0, contentHeight - visibleHeight);
91+
if (lastLogCount != totalLogCount) {
92+
const int addedLogs = (lastLogCount == -1) ? totalLogCount : (totalLogCount - lastLogCount);
93+
const int prevBufferSize = std::max(0, static_cast<int>(logBuffer.size()) - addedLogs);
94+
const int prevMaxScroll = std::max(0, (prevBufferSize * lineHeight + padding) - visibleHeight);
95+
if (constexpr int threshold = 1; lastLogCount == -1 || logScroll >= prevMaxScroll - threshold || logScroll >= maxScroll - threshold) {
96+
logScroll = maxScroll;
97+
}
98+
lastLogCount = totalLogCount;
9399
}
94-
if (const int logCount = logger.getLogCount(); lastLogCount != logCount) {
95-
logScroll = std::max(0, logCount * 20 - 160);
96-
lastLogCount = logCount;
100+
if (imguiBeginScrollArea("Log", 20, 20, renderer.width - 40, logAreaHeight, &logScroll)) {
101+
mouseOverMenu = true;
102+
}
103+
for (auto it = logBuffer.cbegin(); it != logBuffer.cend(); ++it) {
104+
imguiLabel(it->c_str());
97105
}
98106
imguiEndScrollArea();
99107
}

src/module/InputHandler.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,17 @@ int InputHandler::handleInput() {
3838
while (SDL_PollEvent(&event)) {
3939
switch (event.type) {
4040
case SDL_WINDOWEVENT:
41-
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
41+
if (event.window.event == SDL_WINDOWEVENT_RESIZED || event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
4242
renderer.handleResize();
43+
44+
const Uint32 windowFlags = SDL_GetWindowFlags(renderer.window);
45+
Renderer::FullscreenMode mode = Renderer::WINDOWED;
46+
if (windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) {
47+
mode = Renderer::BORDERLESS_FULLSCREEN;
48+
} else if (windowFlags & SDL_WINDOW_MAXIMIZED) {
49+
mode = Renderer::MAXIMIZED;
50+
}
51+
renderer.handleFullscreen(mode);
4352
}
4453
if (event.window.event == SDL_WINDOWEVENT_MOVED) {
4554
renderer.handleMoved();
@@ -51,6 +60,14 @@ int InputHandler::handleInput() {
5160
if (event.key.keysym.sym == SDLK_TAB) {
5261
Gui::getInstance().showMenu = !gui.showMenu;
5362
}
63+
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
64+
const Uint32 windowFlags = SDL_GetWindowFlags(renderer.window);
65+
if (windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) {
66+
renderer.handleFullscreen(Renderer::WINDOWED);
67+
} else {
68+
renderer.handleFullscreen(Renderer::BORDERLESS_FULLSCREEN);
69+
}
70+
}
5471
break;
5572

5673
case SDL_MOUSEWHEEL:

src/module/Logger.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ void Logger::doLog(const char* msg, const int len) {
2121
}
2222

2323
std::lock_guard lock(logMutex);
24-
if (logBuffer.size() >= MAX_MESSAGES - 1) {
24+
if (logBuffer.size() >= MAX_MESSAGES) {
2525
logBuffer.pop_front();
26-
} else {
27-
messageCount++;
2826
}
27+
messageCount++;
2928
logBuffer.push_back(msg);
3029
}
3130

src/module/Navp.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ void Navp::buildNavp() {
740740
building = true;
741741
Menu::updateMenuState();
742742
Logger::log(NK_INFO, "Beginning Recast build...");
743-
if (recastAdapter.handleBuild()) {
743+
if (recastAdapter.handleBuild()) {
744744
Logger::log(NK_INFO, "Done with Recast build.");
745745
Logger::log(NK_INFO, "Pruning areas unreachable by PF Seed Points.");
746746
recastAdapter.findPfSeedPointAreas();
@@ -754,13 +754,11 @@ void Navp::buildNavp() {
754754
Logger::log(NK_INFO, msg.data());
755755
setSelectedNavpAreaIndex(-1);
756756
Menu::updateMenuState();
757-
758-
}else {
757+
} else {
759758
Logger::log(NK_ERROR, "Error building Navp");
760759
building = false;
761760
navpBuildDone.store(false);
762761
Menu::updateMenuState();
763-
764762
}
765763
}
766764
CPPTRACE_CATCH(const std::exception & e)

src/module/Renderer.cpp

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,33 @@ bool Renderer::initWindowAndRenderer() {
132132
return false;
133133
}
134134
SDL_SetWindowMinimumSize(window, 200, 100);
135-
initFrameBuffer(width, height);
136135

137136
if (!window) {
138137
printf("Could not initialise SDL opengl\nError: %s\n", SDL_GetError());
139138
SDL_Quit();
140139
return false;
141140
}
142-
const float x = atof(persistedSettings.getValue("Renderer", "windowX", "-1.0f")),
143-
y = atof(persistedSettings.getValue("Renderer", "windowY", "-1.0f"));
144-
if (x == -1.0f || y == -1.0f) {
145-
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
141+
const char* modeStr = persistedSettings.getValue("Renderer", "fullscreen", "WINDOWED");
142+
if (strcmp(modeStr, "BORDERLESS_FULLSCREEN") == 0) {
143+
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
144+
SDL_GetWindowSize(window, &width, &height);
145+
SDL_SetWindowPosition(window, 0, 0);
146+
} else if (strcmp(modeStr, "MAXIMIZED") == 0) {
147+
SDL_MaximizeWindow(window);
148+
SDL_GetWindowSize(window, &width, &height);
149+
SDL_SetWindowPosition(window, 0, 0);
146150
} else {
147-
SDL_SetWindowPosition(window, x, y);
151+
const float x = atof(persistedSettings.getValue("Renderer", "windowX", "-1.0f")),
152+
y = atof(persistedSettings.getValue("Renderer", "windowY", "-1.0f"));
153+
if (x == -1.0f || y == -1.0f) {
154+
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
155+
} else {
156+
SDL_SetWindowPosition(window, static_cast<int>(x), static_cast<int>(y));
157+
}
148158
}
149-
const std::string navKitVersion = NavKit_VERSION_MAJOR
159+
initFrameBuffer(width, height);
160+
161+
constexpr std::string_view navKitVersion = NavKit_VERSION_MAJOR
150162
"."
151163
NavKit_VERSION_MINOR
152164
"."
@@ -207,6 +219,9 @@ void Renderer::loadSettings() {
207219

208220
void Renderer::handleMoved() {
209221
updateFrameRate();
222+
if (const Uint32 windowFlags = SDL_GetWindowFlags(window); windowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP || windowFlags & SDL_WINDOW_MAXIMIZED) {
223+
return;
224+
}
210225
PersistedSettings& persistedSettings = PersistedSettings::getInstance();
211226
int x;
212227
int y;
@@ -217,6 +232,52 @@ void Renderer::handleMoved() {
217232
persistedSettings.save();
218233
}
219234

235+
void Renderer::handleFullscreen(const FullscreenMode mode) const {
236+
if (!window) {
237+
return;
238+
}
239+
PersistedSettings& persistedSettings = PersistedSettings::getInstance();
240+
FullscreenMode currentMode = WINDOWED;
241+
if (const char* modeStr = persistedSettings.getValue("Renderer", "fullscreen", "WINDOWED"); strcmp(modeStr, "BORDERLESS_FULLSCREEN") == 0) {
242+
currentMode = BORDERLESS_FULLSCREEN;
243+
} else if (strcmp(modeStr, "MAXIMIZED") == 0) {
244+
currentMode = MAXIMIZED;
245+
}
246+
if (currentMode == mode) {
247+
return;
248+
}
249+
250+
std::string modeStr = "WINDOWED";
251+
switch (mode) {
252+
case BORDERLESS_FULLSCREEN:
253+
SDL_SetWindowPosition(window, 0, 0);
254+
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
255+
modeStr = "BORDERLESS_FULLSCREEN";
256+
break;
257+
case MAXIMIZED:
258+
SDL_SetWindowFullscreen(window, 0);
259+
SDL_MaximizeWindow(window);
260+
modeStr = "MAXIMIZED";
261+
break;
262+
case WINDOWED:
263+
default:
264+
const float x = atof(persistedSettings.getValue("Renderer", "windowX", "-1.0f")),
265+
y = atof(persistedSettings.getValue("Renderer", "windowY", "-1.0f"));
266+
if (x == -1.0f || y == -1.0f) {
267+
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
268+
} else {
269+
SDL_SetWindowPosition(window, static_cast<int>(x), static_cast<int>(y));
270+
}
271+
SDL_SetWindowFullscreen(window, 0);
272+
SDL_RestoreWindow(window);
273+
break;
274+
}
275+
276+
Logger::log(NK_INFO, (std::string("Setting fullscreen mode to: ") + modeStr).c_str());
277+
persistedSettings.setValue("Renderer", "fullscreen", modeStr);
278+
persistedSettings.save();
279+
}
280+
220281
void Renderer::initShaders() {
221282
shader = Shader();
222283
shader.loadShaders("vertex.glsl", "fragment.glsl");

src/module/Rpkg.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,26 @@ void Rpkg::initExtractionData() {
148148
void Rpkg::checkHitmanVersion() {
149149
const NavKitSettings& navKitSettings = NavKitSettings::getInstance();
150150
const std::string hitmanFolder = navKitSettings.hitmanFolder;
151-
std::map<std::string, std::string> gameHashes({
152-
std::pair("1c3e5cb4e51944f8374a6ca039cb530e", "epic"), // base game
153-
std::pair("53c768cc385875e422880361fc05b9e3", "epic"), // ansel unlock
154-
std::pair("6dd73b2cd3a76ae5d2699411964b9c1a", "steam"), // base game
155-
std::pair("0ccb38015165d2879b3e15cd5a90afaf", "steam"), // ansel unlock
156-
std::pair("5a5e69504fc410338ae07ef611acd718", "microsoft")
151+
static constexpr const char* GAME_VERSION = "3.270.0";
152+
static std::map<std::string, std::string> gameHashes({
153+
std::pair("3b4b9ce155c1b00828613b18506dd795", "epic"), // base game
154+
std::pair("831fa458660ca9e4a1f6ee1b2fc098e5", "epic"), // ansel unlock
155+
std::pair("9ea2968927e7fd69d7a6f3104b193726", "steam"), // base game
156+
std::pair("a09ba30672470b517f075a7d707e5f9f", "steam"), // ansel unlock
157+
std::pair("4fd41b03dfd8a780b959c74ad155245f", "microsoft")
157158
});
158159

159-
if (!(std::filesystem::exists(hitmanFolder + "\\Retail\\Runtime\\chunk0.rpkg") || std::filesystem::exists(
160+
if (!(std::filesystem::exists(hitmanFolder + R"(\Retail\Runtime\chunk0.rpkg)") || std::filesystem::exists(
160161
hitmanFolder + "\\Retail\\HITMAN3.exe"))) {
161162
Logger::log(NK_ERROR, "HITMAN3.exe couldn't be located, please re-read the installation instructions!");
162163
}
163164

164-
if (std::filesystem::exists(hitmanFolder + "\\Retail\\Runtime\\chunk0.rpkg") && !std::filesystem::exists(
165+
if (std::filesystem::exists(hitmanFolder + R"(\Retail\Runtime\chunk0.rpkg)") && !std::filesystem::exists(
165166
hitmanFolder + "\\MicrosoftGame.Config")) {
166167
Logger::log(NK_ERROR, "The game config couldn't be located, please re-read the installation instructions!");
167168
}
168169
std::string platform;
169-
if (std::filesystem::exists(hitmanFolder + "\\Retail\\Runtime\\chunk0.rpkg")) {
170+
if (std::filesystem::exists(hitmanFolder + R"(\Retail\Runtime\chunk0.rpkg)")) {
170171
const std::string hash = QuickDigest5::fileToHash(hitmanFolder + "\\MicrosoftGame.Config");
171172
platform = gameHashes.contains(hash) ? gameHashes[hash] : "undefined";
172173
} else {
@@ -180,7 +181,7 @@ void Rpkg::checkHitmanVersion() {
180181
);
181182
unknownGameVersion = true;
182183
} else {
183-
Logger::log(NK_INFO, "Detected game platform: %s", platform.c_str());
184+
Logger::log(NK_INFO, "Detected game platform: %s version %s", platform.c_str(), GAME_VERSION);
184185
}
185186
}
186187

@@ -198,15 +199,13 @@ int Rpkg::extractResourcesFromRpkgs(const std::vector<std::string>& hashes, cons
198199
: type == AIRG
199200
? "airg"
200201
: "tga");
201-
char** hashesNeeded = new char*[hashes.size()];
202-
202+
std::vector<const char*> hashPtrs(hashes.size());
203203
for (size_t i = 0; i < hashes.size(); ++i) {
204-
hashesNeeded[i] = new char[hashes[i].size() + 1];
205-
std::strcpy(hashesNeeded[i], hashes[i].c_str());
204+
hashPtrs[i] = hashes[i].c_str();
206205
}
207206
extract_resources_from_rpkg(
208207
runtimeFolder.c_str(),
209-
hashesNeeded,
208+
hashPtrs.data(),
210209
hashes.size(),
211210
partitionManager,
212211
resourceFolder.c_str(),

src/resource/NavKit.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ windowHeight = -1.0f
5858
windowWidth = -1.0f
5959
windowX = -1.0f
6060
windowY = -1.0f
61+
fullscreen = WINDOWED

0 commit comments

Comments
 (0)