MCPcopy Index your code
hub / github.com/WendellCraft/ModpackDebuggerKit / LoadProject

Method LoadProject

app.go:327–384  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

325}
326
327func (a *App) LoadProject() error {
328 a.mu.Lock()
329 if a.ActiveScan {
330 a.mu.Unlock()
331 return fmt.Errorf("cannot load project during active scan")
332 }
333 a.mu.Unlock()
334
335 filePath, err := wailsRuntime.OpenFileDialog(a.ctx, wailsRuntime.OpenDialogOptions{
336 Title: "Load Project",
337 Filters: []wailsRuntime.FileFilter{
338 {DisplayName: "JSON Files", Pattern: "*.json"},
339 },
340 })
341 if err != nil {
342 return err
343 }
344 if filePath == "" {
345 return nil
346 }
347
348 data, err := os.ReadFile(filePath)
349 if err != nil {
350 return fmt.Errorf("error reading project file: %w", err)
351 }
352
353 var projectData ProjectData
354 if err := json.Unmarshal(data, &projectData); err != nil {
355 return fmt.Errorf("error parsing project file: %w", err)
356 }
357
358 if projectData.Dependencies == nil {
359 projectData.Dependencies = make(map[string][]string)
360 }
361 if projectData.SavedNewMods == nil {
362 projectData.SavedNewMods = []string{}
363 }
364 if projectData.DismissedHangingLibs == nil {
365 projectData.DismissedHangingLibs = []string{}
366 }
367 if projectData.Theme == "" {
368 projectData.Theme = "dark"
369 }
370
371 a.mu.Lock()
372 a.ProjectData = &projectData
373 a.ProjectFilePath = filePath
374 a.ProjectModified = false
375 a.mu.Unlock()
376
377 if a.ProjectData.ModsDir != "" {
378 a.emitLog(fmt.Sprintf("Mod folder: %s", a.ProjectData.ModsDir), LogInfo)
379 }
380
381 a.updateHangingLibraries()
382 a.emitLog(fmt.Sprintf("Project loaded from %s", filepath.Base(filePath)), LogSuccess)
383 return nil
384}

Callers

nothing calls this directly

Calls 2

emitLogMethod · 0.95

Tested by

no test coverage detected