[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 6f174d6239 156/472: Access resources in more gener
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 6f174d6239 156/472: Access resources in more general way (#95) |
Date: |
Thu, 6 Jan 2022 21:59:21 -0500 (EST) |
branch: elpa/pacmacs
commit 6f174d623911b5eb8d1409378a497a1fb72c9126
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Access resources in more general way (#95)
---
pacmacs-anim.el | 6 ++++--
pacmacs-image.el | 3 +--
pacmacs-utils.el | 5 +++++
pacmacs.el | 9 +++++++--
4 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/pacmacs-anim.el b/pacmacs-anim.el
index e33f7dcf83..007837fbd1 100644
--- a/pacmacs-anim.el
+++ b/pacmacs-anim.el
@@ -49,8 +49,10 @@
:duration duration))
(defun pacmacs-load-anim (animation-name)
- (let* ((aseprite-json-file (format "sprites/%s.json" animation-name))
- (sprite-sheet-file (format "sprites/%s.xpm" animation-name))
+ (let* ((aseprite-json-file (pacmacs--find-resource-file
+ (format "sprites/%s.json" animation-name)))
+ (sprite-sheet-file (pacmacs--find-resource-file
+ (format "sprites/%s.xpm" animation-name)))
(aseprite-json (json-read-file aseprite-json-file))
(aseprite-frames (cdr (assoc 'frames aseprite-json)))
(sprite-sheet (pacmacs-load-image sprite-sheet-file)))
diff --git a/pacmacs-image.el b/pacmacs-image.el
index b2d3f69f08..be0d5fdbd5 100644
--- a/pacmacs-image.el
+++ b/pacmacs-image.el
@@ -33,8 +33,7 @@
;;; Code:
(defun pacmacs-load-image (filename)
- (create-image (concat default-directory filename)
- 'xpm nil :heuristic-mask t))
+ (create-image filename 'xpm nil :heuristic-mask t))
(defun pacmacs-insert-image (resource resource-vector)
(insert-image resource " " nil resource-vector))
diff --git a/pacmacs-utils.el b/pacmacs-utils.el
index ad5b31aa2a..19fb56a68a 100644
--- a/pacmacs-utils.el
+++ b/pacmacs-utils.el
@@ -32,6 +32,8 @@
;;; Code:
+(defconst pacmacs--base (file-name-directory load-file-name))
+
(defmacro plist-bind (keys expr &rest body)
(declare (indent 2) (debug (sexp form &rest form)))
(let ((expr-name (gensym)))
@@ -50,6 +52,9 @@ side-effects."
(plist-put plist property
(funcall transformer value))))
+(defun pacmacs--find-resource-file (filename)
+ (expand-file-name filename pacmacs--base))
+
(defun pacmacs--direction-vector (direction)
(let ((direction-table (list 'left (cons 0 -1)
'right (cons 0 1)
diff --git a/pacmacs.el b/pacmacs.el
index 057a0aea6b..e16b9a36bb 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -42,6 +42,7 @@
(require 'pacmacs-image)
(require 'pacmacs-utils)
(require 'pacmacs-render)
+(require 'pacmacs-score)
(defconst pacmacs-buffer-name "*Pacmacs*")
(defconst pacmacs-tick-duration-ms 100)
@@ -457,14 +458,18 @@
(pacmacs--switch-direction pacmacs-player-state 'right)))
(defun pacmacs--get-list-of-levels ()
- (->> (directory-files "./maps/")
+ (->> (directory-files (pacmacs--find-resource-file "./maps/"))
(-map #'pacmacs--levelname-from-filename)
(-remove #'null)
(-sort #'string-lessp)
(apply #'vector)))
(defun pacmacs-load-map (map-name)
- (let* ((lines (split-string (pacmacs--file-content (format "maps/%s.txt"
map-name)) "\n" t))
+ (let* ((lines (split-string (->> map-name
+ (format "./maps/%s.txt")
+ (pacmacs--find-resource-file)
+ (pacmacs--file-content))
+ "\n" t))
(board-width (apply 'max (mapcar #'length lines)))
(board-height (length lines)))
(setq pacmacs-board-width board-width)
- [nongnu] elpa/pacmacs 317f9b85b7 114/472: Refactor pacmacs--track-point (#74), (continued)
- [nongnu] elpa/pacmacs 317f9b85b7 114/472: Refactor pacmacs--track-point (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 5233bac0c5 105/472: UT for pacmacs--put-object-test (#75), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d2c449734e 124/472: Merge branch 'pacman-death-69'. Close #69, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1ed9c057cc 127/472: Add padding above the lives, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9e7f67e368 126/472: Implement live mechanics. Close #86, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 86d701a167 131/472: Introduce pacmacs--load-next-level, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 3d49405193 136/472: Reset the score on start, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a0e3b6fe73 138/472: Implement level is beaten state. Close #99, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 359a0facc5 140/472: Optimize empty cell rendering, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 420dbec3e6 150/472: Register score on Game Over (#92), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 6f174d6239 156/472: Access resources in more general way (#95),
ELPA Syncer <=
- [nongnu] elpa/pacmacs 330c69201f 160/472: Fix UTs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 131a070556 163/472: Merge pull request #110 from syohex/fix-package, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs bb622648e3 162/472: Add Package-Requires header for dependencies, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0c0aee723a 170/472: Fix regexp bug in pacmacs--levelname-from-filename, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs f28d928e89 177/472: Update README.md, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8b44939a29 179/472: Merge pull request #121 from kRITZCREEK/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 368609060e 182/472: Add Win animation for Ghost. Close #90, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 2c1881afdf 185/472: Compile the project on CI (#123), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 94c3a3cc1e 191/472: Merge branch 'master' into board-refactoring-105, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b03ee65528 195/472: Merge branch 'board-refactoring-105'. Close #105, ELPA Syncer, 2022/01/06