Skip to content

Commit 0055194

Browse files
authored
Make all settings persist to the ini file (#71)
1 parent 974b028 commit 0055194

36 files changed

Lines changed: 1026 additions & 671 deletions

.idea/dictionaries/project.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.

include/NavKit/Resource.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define IDM_VIEW_AIRG_CELL_COLOR_VISION_DATA 1326
3535
#define IDM_VIEW_AIRG_CELL_COLOR_LAYER 1327
3636
#define IDM_VIEW_LOG_SHOW_LOG 1330
37+
#define IDM_VIEW_SCENE_SHOW_BBOX 1340
3738
#define IDM_EXTRACT_SCENE 1400
3839
#define IDM_EXTRACT_SCENE_AND_BUILD_OBJ 1401
3940
#define IDM_EXTRACT_SCENE_AND_BUILD_ALL 1402
@@ -82,13 +83,12 @@
8283
#define IDC_SLIDER_BBOX_SCALE_X 30204
8384
#define IDC_SLIDER_BBOX_SCALE_Y 30205
8485
#define IDC_SLIDER_BBOX_SCALE_Z 30206
85-
#define IDC_BUTTON_BBOX_RESET 30207
86-
#define IDC_STATIC_BBOX_POS_X_VAL 30208
87-
#define IDC_STATIC_BBOX_POS_Y_VAL 30209
88-
#define IDC_STATIC_BBOX_POS_Z_VAL 30210
89-
#define IDC_STATIC_BBOX_SCALE_X_VAL 30211
90-
#define IDC_STATIC_BBOX_SCALE_Y_VAL 30212
91-
#define IDC_STATIC_BBOX_SCALE_Z_VAL 30213
86+
#define IDC_STATIC_BBOX_POS_X_VAL 30207
87+
#define IDC_STATIC_BBOX_POS_Y_VAL 30208
88+
#define IDC_STATIC_BBOX_POS_Z_VAL 30209
89+
#define IDC_STATIC_BBOX_SCALE_X_VAL 30210
90+
#define IDC_STATIC_BBOX_SCALE_Y_VAL 30211
91+
#define IDC_STATIC_BBOX_SCALE_Z_VAL 30212
9292

9393
#define IDD_RECAST_MENU 30300
9494
#define IDC_SLIDER_CELL_SIZE 30301
@@ -128,7 +128,6 @@
128128
#define IDC_STATIC_TILING_INFO_TILES 30335
129129
#define IDC_STATIC_TILING_INFO_MAX_TILES 30336
130130
#define IDC_STATIC_TILING_INFO_MAX_POLYS 30337
131-
#define IDC_BUTTON_RECAST_RESET 30338
132131

133132
#define IDD_OBJ_SETTINGS 30400
134133
#define IDC_RADIO_MESH_TYPE_ALOC 30401

include/NavKit/adapter/RecastAdapter.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ class RecastAdapter {
103103

104104
dtPolyRef getPolyRefForLink(const dtLink &link) const;
105105

106-
dtPolyRef getFirstLink(dtPolyRef polyRef) const;
107-
108106
bool PFLineBlocked(const Vec3 &recastStart, const Vec3 &recastEnd) const;
109107

110108
dtPolyRef getAdjacentPoly(dtPolyRef poly, int edgeIndex) const;
111109

112110
void doHitTest(int mx, int my);
113111

112+
void loadSettings() const;
113+
114+
void saveSettings() const;
115+
114116
static Vec3 convertFromNavPowerToRecast(Vec3 pos);
115117

116118
static Vec3 convertFromRecastToNavPower(Vec3 pos);
@@ -142,7 +144,9 @@ class RecastAdapter {
142144
std::string selectedObject;
143145

144146
static HWND hRecastDialog;
147+
145148
private:
146149
std::vector<dtPolyRef> pfSeedPointAreas;
147-
static INT_PTR CALLBACK RecastDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
150+
151+
static INT_PTR CALLBACK recastDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
148152
};

include/NavKit/model/ZPathfinding.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ namespace ZPathfinding {
8888

8989
std::string alocHash;
9090
std::string primHash;
91+
std::string roomName;
92+
std::string roomFolderName;
9193
Entity entity;
9294

9395
void readJson(simdjson::ondemand::object json);
@@ -99,6 +101,8 @@ namespace ZPathfinding {
99101

100102
std::string alocHash;
101103
std::string primHash;
104+
std::string roomName;
105+
std::string roomFolderName;
102106
std::string id;
103107
std::string name;
104108
std::string tblu;
@@ -149,7 +153,7 @@ namespace ZPathfinding {
149153
static inline const std::string INCLUDE_TYPE = "PFBT_INCLUDE_MESH_COLLISION";
150154
static inline const std::string EXCLUDE_TYPE = "PFBT_EXCLUDE_MESH_COLLISION";
151155

152-
static inline const std::string NO_EXCLUDE_BOX_FOUND = "NO_EXCLUDE_BOX_FOUND";
156+
static inline const std::string NO_INCLUDE_BOX_FOUND = "NO_EXCLUDE_BOX_FOUND";
153157

154158
PfBoxes(simdjson::ondemand::array);
155159

include/NavKit/module/GameConnection.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class GameConnection {
2727

2828
~GameConnection();
2929

30-
void sendChunk(const std::vector<NavPower::Area> &areas, int chunkIndex, int chunkCount) const;
31-
3230
int connectToGame();
3331

3432
[[nodiscard]] int closeConnection() const;
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
#pragma once
22
#include <SimpleIni.h>
33

4-
class Settings {
5-
static INT_PTR SettingsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
4+
struct DialogSettings {
5+
float backgroundColor{};
6+
std::string hitmanFolder;
7+
std::string outputFolder;
8+
std::string blenderPath;
9+
};
610

7-
explicit Settings();
11+
class NavKitSettings {
12+
static void resetDefaults(DialogSettings &settings);
813

9-
CSimpleIniA ini;
14+
static void setDialogInputs(HWND hDlg, const DialogSettings &tempSettings);
15+
16+
static INT_PTR SettingsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
17+
18+
explicit NavKitSettings();
1019

1120
public:
12-
static Settings &getInstance() {
13-
static Settings instance;
21+
static NavKitSettings &getInstance() {
22+
static NavKitSettings instance;
1423
return instance;
1524
}
1625

@@ -23,17 +32,13 @@ class Settings {
2332
std::string blenderPath;
2433
static HWND hSettingsDialog;
2534

26-
void setValue(const std::string &folder, const std::string &key, const std::string &value);
27-
2835
void setHitmanFolder(const std::string &folderName);
2936

3037
void setOutputFolder(const std::string &folderName);
3138

3239
void setBlenderFile(const std::string &fileName);
3340

34-
void save() const;
35-
36-
void load();
41+
void showNavKitSettingsDialog();
3742

38-
void showSettingsDialog();
43+
void loadSettings();
3944
};

include/NavKit/module/Obj.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class Obj {
5252

5353
static char *openSetBlenderFileDialog(const char *lastBlenderFile);
5454

55+
void loadSettings();
56+
5557
void loadObjMesh();
5658

5759
static void copyObjFile(const std::string &from, const std::string &to);
@@ -98,6 +100,8 @@ class Obj {
98100

99101
void saveObjSettings() const;
100102

103+
void resetDefaults();
104+
101105
static INT_PTR ObjSettingsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
102106

103107
void showObjDialog();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
#include <SimpleIni.h>
3+
4+
class PersistedSettings {
5+
explicit PersistedSettings();
6+
7+
CSimpleIniA ini;
8+
9+
public:
10+
static PersistedSettings &getInstance() {
11+
static PersistedSettings instance;
12+
return instance;
13+
}
14+
15+
const char *getValue(const std::string &folder, const std::string &key, const std::string &defaultValue) const;
16+
17+
void setValue(const std::string &folder, const std::string &key, const std::string &value);
18+
19+
void save() const;
20+
21+
void load();
22+
};

include/NavKit/module/Renderer.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ typedef int GLint;
1010

1111
enum HitTestType {
1212
NONE = 0,
13-
NAVMESH_AREA = 60,
14-
AIRG_WAYPOINT = 61,
15-
PF_SEED_POINT = 62,
16-
PF_EXCLUSION_BOX = 63
13+
NAVMESH_AREA = 240,
14+
AIRG_WAYPOINT = 241,
15+
PF_SEED_POINT = 242,
16+
PF_EXCLUSION_BOX = 243
1717
};
1818

1919
class HitTestResult {
@@ -31,6 +31,8 @@ class Renderer {
3131

3232
~Renderer();
3333

34+
void handleMoved();
35+
3436
static Renderer &getInstance() {
3537
static Renderer instance;
3638
return instance;
@@ -47,6 +49,8 @@ class Renderer {
4749

4850
void closeWindow() const;
4951

52+
void loadSettings();
53+
5054
void initFrameRate(float frameRateValue);
5155

5256
void updateFrameRate();

include/NavKit/module/Scene.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ class Scene {
6363
std::optional<std::jthread> backgroundWorker;
6464
float bBoxPos[3]{};
6565
float bBoxScale[3]{};
66+
bool showBBox;
6667
int version;
6768
static HWND hSceneDialog;
6869

70+
const ZPathfinding::Mesh *findMeshByHashAndIdAndPos(const std::string &hash, const std::string &id, const float *pos) const;
71+
6972
private:
7073
std::string loadSceneName;
7174
std::string saveSceneName;

0 commit comments

Comments
 (0)