graph TD
  start(start)-->new;
  show_ui("Show game UI");
  show_done_ui>"'All done' page"] --> show_ui

  new{"New setup?"};
  new -.yes.-> show_ui
  new -.no.-> define_root_game_folder>"Location of game folder"];

  define_root_game_folder --> recursive_scan["recursive scan for games"];
  recursive_scan --> games_found{"Games found?"};

  games_found -.yes.-> show_unmatched_software>"Show unmatched software"]
  games_found -.no.-> use_sample_library{"Use sample<br/>library?"}
  use_sample_library -.yes.-> dl_sample_library["Download sample library"]
  dl_sample_library --> recursive_scan

  subgraph Game Matching
    show_unmatched_software --> ask_auto_match{"Attempt to<br>automatch?"}
    ask_auto_match -.yes.-> run_discoid["Run the discoid plugin"]
    ask_auto_match -.no.-> show_metadata_editor>"Show meta editor"]
    run_discoid --> show_metadata_editor
  end

  subgraph Emulator Matching
    show_metadata_editor --> scan_for_emulators["Scan for emulators"]
    scan_for_emulators --> missing_platforms{"Missing platforms?"}
    missing_platforms -.yes.-> ask_download_missing_emulators{"Download missing emulators<br>for current platforms?"}
    ask_download_missing_emulators -.yes.-> download_emulators["download emulators"]
  end

  download_emulators --> show_done_ui
  missing_platforms -.no.-> show_done_ui
  ask_download_missing_emulators -.no.-> show_done_ui
