GoTo EndChampionshipMenuingDef

Menu:
  ;ToolTip, Menuing, 100, 100, Screen
   loop {
      break_point := false
       c2 := BitGrab(pix2x, pix2y, box_size)
      for i, c in c2
      {
          d2 := Distance(c, color_check2)
          if (d2 < tolerance ){
              break_point := true
              break
          }
      }
      if (break_point)
          break
      Press_X()
      sleep %color_2_delay%
      sleep, %bm_delay%
  }
  ResetControllerState()
  ;ToolTip, Found color 2, 100, 100, Screen
  Sleep, 200
  Press_O()
  Sleep, 200
  Press_Right()
  Sleep, 500
  Press_X()
  Sleep, %ps_load_time1%
  Press_X()
  Sleep, 1000
  Press_O()
  loop, 2 {
    Press_X()
    Sleep, 500
  }
  Sleep, %ps_load_time2%
  ;Conduct Maintenance here.
    CheckForOilChange := Mod(A_Index, 29)
    CheckForMaintenance := Mod(A_Index, 107)
   ifEqual, CheckForOilChange, 0
    {
      gosub, DoOilChange
    }

   ifEqual, CheckForMaintenance, 0
    {
      gosub, DoMaintenance
    }

  Press_Down()
  ;Sleep, 500
  loop, %menu_loops% {
    controller.Dpad.SetState(MenuDirect)
    Sleep, 60
    controller.Dpad.SetState("None")
    Sleep, 60
  }
  Press_X() ; Choose Pan-American
  Sleep, 100 ; load Pan-American menu
  Press_X() ; push join
  Sleep, 1000 ; to compensate ps_load_time3
  Sleep, %ps_load_time3% ; Loadtime Pan-American
  Press_X() ; Confirm race 1
  Sleep, 500 ; Load race 1 menu, Start will be pushed by race script.
  return

EndChampionshipMenuingDef:
