PCB Environment 2

Loading...
Searching...
No Matches
UserSettings.hpp
1
2#ifndef GYM_PCB_USERPARAMETERS_H
3#define GYM_PCB_USERPARAMETERS_H
4
5#include "Defs.hpp"
6#include <string>
7#include <chrono>
8#include <thread>
9
10 class UserSettings
11{
12 public:
13 static const UserSettings& get() { return sInstance; }
14
15 uint32_t MaxGridCells{1u << 26};
16 uint64_t AgentTimeoutUSecs{0};
17 float AStarViaCostFactor{1.0f};
18 struct {
19 uint WindowSize[2]{1024, 768};
20 float PointSize{1.0f};
21 uint FPS{40};
22 uint SidePaneWidth{256};
23 uint LockSteppingGranularity{0};
24 uint ActionDelayUSecs{0};
25 bool EnableRendering{true};
26 bool VSync{true};
27 bool GridLinesVisible{false};
28 bool GridPointsVisible{false};
29 bool FootprintsVisible{false};
30 bool RatsNestVisible{false};
31 bool TriangulationVisible{false};
32 bool RoutePreview{true};
33 } UI;
34 struct {
35 float PerVia{0.0f};
36 float PerDisconnect{-5.0f};
37 float AnyDisconnect{0.0f};
38 } Reward;
39 struct {
40 std::string GLSL;
41 std::string JSON;
42 std::string QTUI;
43 } Paths;
44 static void LoadFile(const std::string &path);
45 static void LoadJSON(const std::string &json) { sInstance.loadJSON(json); }
46 void AddPath(const std::string_view &s);
47
48 void sleepForActionDelay(uint times = 1) const;
49
50 std::string str() const;
51
52 static UserSettings& edit() { return sInstance; }
53 private:
54 UserSettings() { }
55 private:
56 void loadJSON(const std::string &json);
57
58 static UserSettings sInstance;
59};
60
61 inline void UserSettings::sleepForActionDelay(uint times) const
62{
63#ifdef GYM_PCB_ENABLE_UI
64 if (UI.ActionDelayUSecs)
65 std::this_thread::sleep_for(std::chrono::microseconds(uint64_t(UI.ActionDelayUSecs) * times));
66#endif
67}
68
69#endif // GYM_PCB_USERPARAMETERS_H