[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 54e77a2d10 408/472: Use Emacs Widget Library to as
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 54e77a2d10 408/472: Use Emacs Widget Library to ask nickname (#134) |
Date: |
Thu, 6 Jan 2022 21:59:44 -0500 (EST) |
branch: elpa/pacmacs
commit 54e77a2d10c56b9ad1ab927307d6e371ab49c6bd
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Use Emacs Widget Library to ask nickname (#134)
---
pacmacs.el | 109 +++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 62 insertions(+), 47 deletions(-)
diff --git a/pacmacs.el b/pacmacs.el
index 1de9f5a3be..34e997d899 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -400,7 +400,8 @@
(pacmacs--load-next-level)
(pacmacs--switch-to-prepare-state)))))
- (pacmacs--render-state))
+ (when (not (equal pacmacs-game-state 'game-over))
+ (pacmacs--render-state)))
(defun pacmacs--step-ghosts ()
(dolist (ghost pacmacs--ghosts)
@@ -576,23 +577,43 @@
(pacmacs--read-score-table)))
(new-score-position (pacmacs--position-of-new-score
score-table
- pacmacs-score)))
- (->> score-table
- (-take new-score-position)
- (pacmacs--render-score-table))
- (pacmacs--render-score-record (cons "" pacmacs-score))
- (->> score-table
- (-drop new-score-position)
- (pacmacs--render-score-table))
-
- (plist-bind ((width :width)
- (height :height))
- pacmacs--object-board
- (goto-line (+ height pacmacs--score-table-render-offset (1+
new-score-position)))
- (put-text-property (point-min) (point-max) 'read-only t)
- (let ((inhibit-read-only t))
- (remove-text-properties (point) (+ (point)
pacmacs--max-score-nick-size) '(read-only nil)))
- (overwrite-mode 1)))))
+ pacmacs-score))
+ (nickname-widget nil))
+ (if (< new-score-position pacmacs--max-score-table-size)
+ (progn
+ (->> score-table
+ (-take new-score-position)
+ (pacmacs--render-score-table))
+ (setq nickname-widget
+ (widget-create 'editable-field
+ :size pacmacs--max-score-nick-size
+ :action (lambda (widget &optional event)
+ (let ((nickname (widget-value
widget)))
+ (pacmacs--add-entry-to-score-table
+ nickname
+ pacmacs-score)
+ (widget-delete widget)
+ (let ((inhibit-read-only t))
+ (insert (format "%s"
+ (make-string
+ (max 0
+ (-
pacmacs--max-score-nick-size
+
(length nickname)))
+ ?\s))))))
+
+ ""))
+ (insert (format " %d\n" pacmacs-score))
+ (->> score-table
+ (-drop new-score-position)
+ (pacmacs--render-score-table))
+
+ (plist-bind ((width :width)
+ (height :height))
+ pacmacs--object-board
+ (goto-line (+ height pacmacs--score-table-render-offset (1+
new-score-position)))))
+ (pacmacs--render-score-table score-table))
+ (use-local-map widget-keymap)
+ (widget-setup))))
(defun pacmacs--switch-to-play-state ()
(setq pacmacs-game-state 'play)
@@ -625,35 +646,29 @@
(pacmacs--put-object wall)))
(defun pacmacs--render-state ()
- (when (or (not (equal pacmacs-game-state 'game-over))
- (not pacmacs-game-over-state-rendered))
- (with-current-buffer pacmacs-buffer-name
- (let ((inhibit-read-only t))
- (erase-buffer)
-
- (insert (format "Score: %d\n\n" pacmacs-score))
-
- (when pacmacs-debug-output
- (pacmacs--render-track-board pacmacs--track-board))
-
- (plist-bind ((width :width)
- (height :height))
- pacmacs--object-board
- (dotimes (row height)
- (dotimes (column width)
- (let ((anim-object (car (pacmacs--cell-wrapped-get
pacmacs--object-board
- row column))))
- (pacmacs--render-object anim-object)))
- (insert "\n")))
- (insert "\n")
- (dotimes (i pacmacs-lives)
- (ignore i)
- (pacmacs--render-life-icon))
-
- (when (equal pacmacs-game-state 'game-over)
- (setq pacmacs-game-over-state-rendered t))
-
- (goto-char 0)))))
+ (with-current-buffer pacmacs-buffer-name
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+
+ (insert (format "Score: %d\n\n" pacmacs-score))
+
+ (when pacmacs-debug-output
+ (pacmacs--render-track-board pacmacs--track-board))
+
+ (plist-bind ((width :width)
+ (height :height))
+ pacmacs--object-board
+ (dotimes (row height)
+ (dotimes (column width)
+ (let ((anim-object (car (pacmacs--cell-wrapped-get
pacmacs--object-board
+ row column))))
+ (pacmacs--render-object anim-object)))
+ (insert "\n")))
+ (insert "\n")
+ (dotimes (i pacmacs-lives)
+ (ignore i)
+ (pacmacs--render-life-icon))
+ (goto-char 0))))
(defun pacmacs--unpaused-play-state-p ()
(and (equal pacmacs-game-state 'play)
- [nongnu] elpa/pacmacs 470f11b433 357/472: Reset terrified timer on eating BP (#173), (continued)
- [nongnu] elpa/pacmacs 470f11b433 357/472: Reset terrified timer on eating BP (#173), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 46219c3370 368/472: Smaller default weight for walls (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 52f1ba4237 366/472: Regenerate gradiate for walls (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a36eb746ce 379/472: Fix put-wall-tile-corner UT (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs e0a315600b 383/472: Get rid of redundant code (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b19ed92514 389/472: Add UT for color-hex-gradient, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 56e280cd51 395/472: Add Usage section for att.el script, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8ec58f38d9 394/472: Add Usage section for compile.el script, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a9ab4c18c8 397/472: Merge pull request #190 from codingteam/usage-for-tools, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs bdbf7144d2 396/472: Move pacmacs-rr to top of README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 54e77a2d10 408/472: Use Emacs Widget Library to ask nickname (#134),
ELPA Syncer <=
- [nongnu] elpa/pacmacs 92eeeae98e 407/472: Ask for nickname at Game Over page (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 76f2dbe41b 409/472: Do nick padding inside of the widget (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 54be118510 413/472: Remove pacmacs-game-over-mode (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 429294ea94 416/472: Fix render-score-table UT (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d6260cd30c 417/472: Refactor nickname submission action (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 71ffcfb208 419/472: Add UT for align-score-record-nickname func (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 861aa9543e 422/472: Add UT for make-wall-cell func, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 2e881d27e0 424/472: Remove commented chunk of code (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1e4cbd5f4f 426/472: Sort score table on reading and writing (#194), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0d62e0346a 427/472: Remove redundant score sorting (#194), ELPA Syncer, 2022/01/06