MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / loadConfig

Function loadConfig

TheForceEngine/TFE_Editor/editorConfig.cpp:55–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 }
54
55 bool loadConfig()
56 {
57 char editorPath[TFE_MAX_PATH];
58 TFE_Paths::appendPath(PATH_USER_DOCUMENTS, "editor.ini", editorPath);
59 // Set to defaults before trying to load.
60 LevelEditor::setDefaultKeyboardShortcuts();
61
62 FileStream configFile;
63 if (!configFile.open(editorPath, Stream::MODE_READ))
64 {
65 return false;
66 }
67
68 const u32 len = (u32)configFile.getSize();
69 WorkBuffer& buffer = getWorkBuffer();
70 buffer.resize(len);
71 configFile.readBuffer(buffer.data(), len);
72 configFile.close();
73
74 TFE_Parser parser;
75 parser.init((char*)buffer.data(), len);
76 parser.addCommentString(";");
77 parser.addCommentString("#");
78
79 s_editorConfig = EditorConfig{};
80 clearRecents();
81
82 size_t bufferPos = 0;
83 while (bufferPos < len)
84 {
85 const char* line = parser.readLine(bufferPos);
86 if (!line) { break; }
87
88 TokenList tokens;
89 parser.tokenizeLine(line, tokens);
90 const s32 tokenCount = (s32)tokens.size();
91
92 if (tokenCount < 2) { continue; }
93 parseValue(tokens[0].c_str(), &tokens[1], tokenCount - 1);
94 }
95 s_configLoaded = true;
96 return true;
97 }
98
99 bool saveConfig()
100 {

Callers 3

enableFunction · 0.85
testOptionsFunction · 0.85
userPreferencesFunction · 0.85

Calls 15

clearRecentsFunction · 0.85
dataMethod · 0.80
addCommentStringMethod · 0.80
readLineMethod · 0.80
tokenizeLineMethod · 0.80
c_strMethod · 0.80
parseValueFunction · 0.70
appendPathFunction · 0.50
openMethod · 0.45
getSizeMethod · 0.45
resizeMethod · 0.45

Tested by 1

testOptionsFunction · 0.68