Skip to content

Commit

Permalink
Add prompt helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Dec 9, 2018
1 parent 3a97aeb commit 865fa3d
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 3 deletions.
Binary file added data/PromptFont.ttf
Binary file not shown.
91 changes: 91 additions & 0 deletions prompt.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#|
This file is a part of trial
(c) 2018 Shirakumo http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#

(in-package #:org.shirakumo.fraf.trial)

(define-asset (trial prompt-font) font
#p"PromptFont.ttf"
:charset " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~↞↟↠↡↤↥↦↧↰↱↲↳↺↻↼↽↾↿⇀⇁⇂⇃⇇⇈⇉⇊⇖⇗⇘⇙⇷⇸⇹␧␨␩␪␫␬␭␮␯␰␱␲␳␴␵␶␷␸␹①②③④⑤⑥⑦⑧⑨⑩⑪⑫"
:font-size 32)

(defun prompt-char (thing)
(etypecase thing
(character thing)
(symbol
(ecase thing
(:dpad-l #\↞)
(:dpad-u #\↟)
(:dpad-r #\↠)
(:dpad-d #\↡)
(:x #\↤)
(:y #\↥)
(:b #\↦)
(:a #\↧)
(:l1 #\↰)
(:r1 #\↱)
(:l2 #\↲)
(:r2 #\↳)
(:l #\↺)
(:r #\↻)
(:l-l #\↼)
(:r-l #\↽)
(:l-u #\↾)
(:r-u #\↿)
(:l-r #\⇀)
(:r-r #\⇁)
(:l-d #\⇂)
(:r-d #\⇃)
(:a-l #\⇇)
(:a-u #\⇈)
(:a-r #\⇉)
(:a-d #\⇊)
(:a-ul #\⇖)
(:a-ur #\⇗)
(:a-dr #\⇘)
(:a-dl #\⇙)
(:select #\⇷)
(:start #\⇸)
(:home #\⇹)
(:ctrl #\␧)
(:alt #\␨)
(:shift #\␩)
(:super #\␪)
(:tab #\␫)
(:caps #\␬)
(:backspace #\␭)
(:enter #\␮)
(:esc #\␯)
(:prtsc #\␰)
(:scrlk #\␱)
(:pause #\␲)
(:numlock #\␳)
(:insert #\␴)
(:home #\␵)
(:pageup #\␶)
(:delete #\␷)
(:end #\␸)
(:pagedown #\␹)
(:f1 #\①)
(:f2 #\②)
(:f3 #\③)
(:f4 #\④)
(:f5 #\⑤)
(:f6 #\⑥)
(:f7 #\⑦)
(:f8 #\⑧)
(:f9 #\⑨)
(:f10 #\⑩)
(:f11 #\⑪)
(:f12 #\⑫)))))

(define-shader-subject prompt (text)
((tetxure :initform (asset 'trial 'prompt-font))))

(defmethod (setf text) ((character character) (prompt prompt))
(setf (text prompt) (string character)))

(defmethod (setf text) ((symbol symbol) (prompt prompt))
(setf (text prompt) (string (prompt-char symbol))))
5 changes: 2 additions & 3 deletions text.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(in-package #:org.shirakumo.fraf.trial)

(define-shader-entity text (located-entity vertex-entity colored-entity textured-entity readied)
((texture :initarg :font :accessor font)
((texture :initarg :font :initform (error "FONT required.") :accessor font)
(text :initarg :text :accessor text)
(size :initarg :size :accessor size)
(wrap :initarg :wrap :accessor wrap)
Expand All @@ -19,8 +19,7 @@
:text ""
:wrap NIL
:width NIL
:height NIL
:font (error "FONT required."))
:height NIL)
(:inhibit-shaders (colored-entity :fragment-shader)
(textured-entity :fragment-shader)))

Expand Down
1 change: 1 addition & 0 deletions trial.asd
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
(:file "phong" :depends-on ("package" "helpers"))
(:file "pipeline" :depends-on ("package" "event-loop" "toolkit"))
(:file "pipelined-scene" :depends-on ("package" "pipeline" "scene" "loader"))
(:file "prompt" :depends-on ("package" "text"))
(:file "rails" :depends-on ("package" "subject" "helpers"))
(:file "render-texture" :depends-on ("package" "pipeline" "entity"))
(:file "renderable" :depends-on ("package" "toolkit"))
Expand Down

0 comments on commit 865fa3d

Please sign in to comment.