Add some more helpful error messages, fix CLI (some features still need implementation), add category selection for starting speedrun
This commit is contained in:
parent
f1a99a78d1
commit
e6fe31daef
25
main.lisp
25
main.lisp
@ -19,7 +19,9 @@
|
|||||||
(let ((input (read-line)))
|
(let ((input (read-line)))
|
||||||
(if (ignore-errors (funcall validator input))
|
(if (ignore-errors (funcall validator input))
|
||||||
input
|
input
|
||||||
(get-input prompt validator))))
|
(progn
|
||||||
|
(format t "E: Invalid input. Try again.")
|
||||||
|
(get-input prompt validator)))))
|
||||||
|
|
||||||
;; Options is an alist with the prompt string as the car and the value as the cdr
|
;; Options is an alist with the prompt string as the car and the value as the cdr
|
||||||
(defun select-option (options)
|
(defun select-option (options)
|
||||||
@ -49,8 +51,7 @@
|
|||||||
(format t "That search came up with multiple results:")
|
(format t "That search came up with multiple results:")
|
||||||
(select-option filtered)))
|
(select-option filtered)))
|
||||||
(progn (format t "E: Could not find option that matched query.~%")
|
(progn (format t "E: Could not find option that matched query.~%")
|
||||||
(select-option options))))))
|
(select-option options)))))))
|
||||||
(format t "~%"))
|
|
||||||
|
|
||||||
(defun main ()
|
(defun main ()
|
||||||
(let ((choice (select-option '(("Help" . HELP)
|
(let ((choice (select-option '(("Help" . HELP)
|
||||||
@ -59,23 +60,23 @@
|
|||||||
("Start a speedrun" . START-SPEEDRUN)
|
("Start a speedrun" . START-SPEEDRUN)
|
||||||
("Statistics" . LIST-CATEGORIES)
|
("Statistics" . LIST-CATEGORIES)
|
||||||
("Exit" . EXIT)))))
|
("Exit" . EXIT)))))
|
||||||
(format t "~a~%" choice)
|
|
||||||
(case choice
|
(case choice
|
||||||
('HELP
|
('HELP
|
||||||
(mapcar #'(lambda (x) (format t "~a~%" x)) *lispruns-logo*))
|
(mapcar #'(lambda (x) (format t "~a~%" x)) *lispruns-logo*))
|
||||||
('IMPORT-CATEGORY
|
('IMPORT-CATEGORY
|
||||||
(import-category (get-input (format nil "Relative or absolute path to configuration file [~a]: " (uiop/os:getcwd)) 'probe-file)))
|
(import-category (get-input
|
||||||
|
(format nil "Relative or absolute path to configuration file [~a]: "
|
||||||
|
(uiop/os:getcwd))
|
||||||
|
'probe-file)))
|
||||||
('NEW-CATEGORY
|
('NEW-CATEGORY
|
||||||
(format t "NEW CATEGORY~%"))
|
(format t "NEW CATEGORY~%"))
|
||||||
('START-SPEEDRUN
|
('START-SPEEDRUN
|
||||||
(speedrun-ui (car (mito:select-dao 'category))))
|
(let* ((categories (mito:select-dao 'category))
|
||||||
|
(category-alist (mapcar (lambda (category) `(,(category-name category) . ,category)) categories)))
|
||||||
|
(if categories
|
||||||
|
(speedrun-ui (select-option category-alist))
|
||||||
|
(format t "E: There are no categories. Try creating one or importing one"))))
|
||||||
('EXIT
|
('EXIT
|
||||||
(quit))))
|
(quit))))
|
||||||
(format t "~%")
|
(format t "~%")
|
||||||
(main))
|
(main))
|
||||||
|
|
||||||
|
|
||||||
;; (let ((options (opts:get-opts)))
|
|
||||||
;; (when-option (options :import)
|
|
||||||
;; (import-config (getf options :import)))
|
|
||||||
;; (run-ui (car (mito:select-dao 'category)))))
|
|
||||||
|
40
ui.lisp
40
ui.lisp
@ -96,28 +96,38 @@
|
|||||||
('TITLE
|
('TITLE
|
||||||
(if (member 'title-instance redraws)
|
(if (member 'title-instance redraws)
|
||||||
(croatoan:clear scr)
|
(croatoan:clear scr)
|
||||||
(let* ((padding 3)
|
(let* ((padding 4)
|
||||||
(width (+ (* 2 padding) (max-length *lispruns-logo*)))
|
(title (append *lispruns-logo* '("" "CONTROLS" " SPACE to start or continue to the next split" " Q to quit")))
|
||||||
(height (+ (* 2 padding) (length *lispruns-logo*)))
|
(width (+ (* 2 padding) (max-length title)))
|
||||||
|
(height (+ (* 2 padding) (length title)))
|
||||||
(logo-centered (center-box scr width height))
|
(logo-centered (center-box scr width height))
|
||||||
(logo-box (make-instance 'croatoan:window :border t :width width :height height :position logo-centered)))
|
(logo-box (make-instance 'croatoan:window :border t :width width :height height :position logo-centered)))
|
||||||
(write-horizontal-slice-list logo-box `(,padding ,padding) *lispruns-logo*)
|
(if (< (croatoan:width scr) width)
|
||||||
(croatoan:refresh logo-box))))
|
(progn
|
||||||
|
(croatoan:add scr "Please increase width of your terminal" :position '(0 0))
|
||||||
|
(croatoan:refresh scr))
|
||||||
|
(progn
|
||||||
|
(write-horizontal-slice-list logo-box `(,padding ,padding) title)
|
||||||
|
(croatoan:refresh logo-box))))))
|
||||||
('RUNNING
|
('RUNNING
|
||||||
(update-time speedrun)
|
(if (eq (speedrun-state speedrun) 'RUNNING)
|
||||||
|
(update-time speedrun))
|
||||||
(if (member 'timer-instance redraws)
|
(if (member 'timer-instance redraws)
|
||||||
(croatoan:clear scr))
|
(croatoan:clear scr))
|
||||||
(if (zerop (mod frame 4))
|
(if (zerop (mod frame 4))
|
||||||
(let* ((screen-thirds (floor (/ (croatoan:width scr) 3)))
|
(let* ((max-width (min 90 (croatoan:width scr)))
|
||||||
|
(centered-x (cadr (center-box scr max-width 0)))
|
||||||
|
(timer-height 8)
|
||||||
|
(splits-height (- (croatoan:height scr) timer-height))
|
||||||
(split-list (make-instance 'highlight-list
|
(split-list (make-instance 'highlight-list
|
||||||
:scroll-i scroll
|
:scroll-i scroll
|
||||||
:current-element-index (if (eq (speedrun-state speedrun) 'STOPPED) (1- (length (speedrun-splits speedrun))) (speedrun-current-split-index speedrun))
|
:current-element-index (if (eq (speedrun-state speedrun) 'STOPPED) (1- (length (speedrun-splits speedrun))) (speedrun-current-split-index speedrun))
|
||||||
:height (croatoan:height scr)
|
:height splits-height
|
||||||
:width screen-thirds
|
:width max-width
|
||||||
:elements (mapcar #'category-split-name csplits)))
|
:elements (mapcar #'category-split-name csplits)))
|
||||||
;; :elements `((("FIRST SPLIT IS EPIC" . ,(/ 4 12)) ("" . ,(/ 1 12)) ("10:10:00.22" . ,(/ 3 12)) ("" . ,(/ 1 12)) ("20:00.00" . ,(/ 3 12))))))
|
;; :elements `((("FIRST SPLIT IS EPIC" . ,(/ 4 12)) ("" . ,(/ 1 12)) ("10:10:00.22" . ,(/ 3 12)) ("" . ,(/ 1 12)) ("20:00.00" . ,(/ 3 12))))))
|
||||||
(splits-instance (highlight-list-window split-list '(0 0)))
|
(splits-instance (highlight-list-window split-list `(0 ,centered-x)))
|
||||||
(timer-instance (timer-window speedrun `(0 ,screen-thirds) (* 2 screen-thirds) 8)))
|
(timer-instance (timer-window speedrun `(,splits-height ,centered-x) max-width timer-height)))
|
||||||
(croatoan:refresh splits-instance)
|
(croatoan:refresh splits-instance)
|
||||||
(croatoan:refresh timer-instance)))))
|
(croatoan:refresh timer-instance)))))
|
||||||
(setf redraws '()
|
(setf redraws '()
|
||||||
@ -134,5 +144,11 @@
|
|||||||
(setf redraws '(timer-instance))
|
(setf redraws '(timer-instance))
|
||||||
(setf state 'RUNNING))
|
(setf state 'RUNNING))
|
||||||
('RUNNING (next-split speedrun))))
|
('RUNNING (next-split speedrun))))
|
||||||
(:resize (render))
|
(:resize
|
||||||
|
(case state
|
||||||
|
('TITLE
|
||||||
|
(setf redraws '(title-instance)))
|
||||||
|
('RUNNING
|
||||||
|
(croatoan:clear scr)))
|
||||||
|
(render))
|
||||||
((nil) (render)))))))
|
((nil) (render)))))))
|
||||||
|
Loading…
Reference in New Issue
Block a user