| 
									
										
										
										
											2023-09-06 16:56:55 -05:00
										 |  |  | package app | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-06 18:46:09 -05:00
										 |  |  | 	"codeberg.org/danjones000/strip-beats/input/boolean" | 
					
						
							| 
									
										
										
										
											2023-09-06 16:56:55 -05:00
										 |  |  | 	"codeberg.org/danjones000/strip-beats/media" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type AppStep int | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ( | 
					
						
							|  |  |  | 	Pick AppStep = iota | 
					
						
							|  |  |  | 	Watch | 
					
						
							| 
									
										
										
										
											2023-09-08 11:00:07 -05:00
										 |  |  | 	Fade | 
					
						
							| 
									
										
										
										
											2023-09-06 16:56:55 -05:00
										 |  |  | 	Restart | 
					
						
							|  |  |  | 	Quit | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func quit() { | 
					
						
							|  |  |  | 	PickAgain() | 
					
						
							|  |  |  | 	fmt.Println("Goodbye!") | 
					
						
							|  |  |  | 	os.Exit(0) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func Run(step AppStep) { | 
					
						
							|  |  |  | 	for step < Quit { | 
					
						
							|  |  |  | 		switch step { | 
					
						
							|  |  |  | 		case Pick: | 
					
						
							|  |  |  | 			PickAgain() | 
					
						
							|  |  |  | 			PickFileWithConf() | 
					
						
							|  |  |  | 			if file == nil { | 
					
						
							|  |  |  | 				quit() | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2023-09-06 18:46:09 -05:00
										 |  |  | 			watch := boolean.Choose(fmt.Sprintf("Would you like to watch %s?", file.ShortPath())) | 
					
						
							|  |  |  | 			if watch { | 
					
						
							|  |  |  | 				step = Watch | 
					
						
							| 
									
										
										
										
											2023-09-08 11:00:07 -05:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				step = mainMenu() | 
					
						
							| 
									
										
										
										
											2023-09-06 18:46:09 -05:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2023-09-06 16:56:55 -05:00
										 |  |  | 		case Watch: | 
					
						
							|  |  |  | 			media.Watch(file.Format.Path) | 
					
						
							| 
									
										
										
										
											2023-09-08 13:17:12 -05:00
										 |  |  | 			fadeAns := boolean.Choose(fmt.Sprintf("Would you like to trim/fade %s?", file.ShortPath())) | 
					
						
							|  |  |  | 			if fadeAns { | 
					
						
							| 
									
										
										
										
											2023-09-08 11:00:07 -05:00
										 |  |  | 				step = Fade | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				step = mainMenu() | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2023-09-08 13:17:12 -05:00
										 |  |  | 		case Fade: | 
					
						
							|  |  |  | 			fadeFile() | 
					
						
							|  |  |  | 			listenFaded := boolean.Choose(fmt.Sprintf("Would you like to listen to %s?", tmpfile.ShortPath())) | 
					
						
							|  |  |  | 			if listenFaded { | 
					
						
							|  |  |  | 				media.Watch(tmpfile.Format.Path) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			step = mainMenu() // @todo ask to check new file | 
					
						
							| 
									
										
										
										
											2023-09-06 16:56:55 -05:00
										 |  |  | 		case Quit: | 
					
						
							|  |  |  | 			quit() | 
					
						
							| 
									
										
										
										
											2023-09-08 11:00:07 -05:00
										 |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2023-09-08 13:17:12 -05:00
										 |  |  | 			step = mainMenu() | 
					
						
							| 
									
										
										
										
											2023-09-06 16:56:55 -05:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |