1
0
Fork 0
tinmop/src/gui/client/icons.lisp

40 lines
1.3 KiB
Common Lisp

(in-package :icons)
(a:define-constant +icon-dir+ "/icons/" :test #'string=)
(a:define-constant +search+ "fmw_search" :test #'string=)
(a:define-constant +back+ "fmw_back" :test #'string=)
(a:define-constant +go+ "fmw_go" :test #'string=)
(a:define-constant +open-tour+ "fmw_open_tour" :test #'string=)
(a:define-constant +refresh+ "fmw_refresh" :test #'string=)
(defparameter *icon-search* nil)
(defparameter *icon-back* nil)
(defparameter *icon-go* nil)
(defparameter *icon-open-tour* nil)
(defparameter *icon-refresh* nil)
(defun load-icon (filename)
(let ((path (if (not (re:scan "(?i)png$" filename))
(res:get-config-file (fs:cat-parent-dir +icon-dir+
(strcat filename ".png")))
(res:get-config-file (fs:cat-parent-dir +icon-dir+ filename)))))
(with-open-file (stream path :element-type '(unsigned-byte 8))
(let ((data (gui-utils:read-into-array stream (file-length stream))))
(gui:make-image data)))))
(defun load-icons ()
(setf *icon-search* (load-icon +search+))
(setf *icon-back* (load-icon +back+))
(setf *icon-search* (load-icon +go+))
(setf *icon-search* (load-icon +open-tour+))
(setf *icon-search* (load-icon +refresh+)))