MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / LoadLevel

Function LoadLevel

Source/Editors/map_editor.cpp:297–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297void LoadLevel(bool local) {
298 const int BUF_SIZE = kPathSize;
299 char buffer[BUF_SIZE];
300 char input_buffer[BUF_SIZE];
301
302 const char* start_dir = "Data/Levels";
303
304 if (local) {
305 FormatString(input_buffer, BUF_SIZE, "%s/Data/Levels", GetWritePath(CoreGameModID).c_str());
306 start_dir = input_buffer;
307 }
308
309 Dialog::DialogErr err = Dialog::readFile("xml", 1, start_dir, buffer, BUF_SIZE);
310
311 if (err != Dialog::NO_ERR) {
312 LOGE << Dialog::DialogErrString(err) << std::endl;
313 } else {
314 ApplicationPathSeparators(buffer);
315 Path level = FindFilePath(buffer, kAnyPath);
316 if (level.isValid()) {
317 level = FindShortestPath2(level.GetFullPath());
318 LevelInfoAssetRef levelinfo = Engine::Instance()->GetAssetManager()->LoadSync<LevelInfoAsset>(buffer);
319 if (levelinfo.valid()) {
320 Engine::Instance()->QueueState(EngineState(levelinfo->GetName(), kEngineEditorLevelState, level));
321 } else {
322 LOGE << "Unable to load level info, will not queue level for load." << std::endl;
323 }
324 }
325 }
326}
327
328void MapEditor::RibbonItemClicked(const std::string& item, bool param) {
329 if (item == "prefab") {

Callers 4

UpdateControlsMethod · 0.85
UpdateMethod · 0.85
LoadLevelDataMethod · 0.85
DrawImGuiFunction · 0.85

Calls 15

FormatStringFunction · 0.85
GetWritePathFunction · 0.85
readFileFunction · 0.85
DialogErrStringFunction · 0.85
FindFilePathFunction · 0.85
FindShortestPath2Function · 0.85
EngineStateClass · 0.85
GetFullPathMethod · 0.80
GetAssetManagerMethod · 0.80
QueueStateMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected