[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs d6260cd30c 417/472: Refactor nickname submission a
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs d6260cd30c 417/472: Refactor nickname submission action (#134) |
Date: |
Thu, 6 Jan 2022 21:59:44 -0500 (EST) |
branch: elpa/pacmacs
commit d6260cd30c45d4a08c342b779376df88fe86a485
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Refactor nickname submission action (#134)
---
pacmacs.el | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/pacmacs.el b/pacmacs.el
index c3f7a30cb3..2e5df3a255 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -559,13 +559,29 @@
(plist-put ghost :current-animation
(pacmacs-load-anim "Red-Ghost-Win"))))
+(defun pacmacs--align-score-record-nickname (nickname)
+ (let* ((padding-size (max 0 (- pacmacs--max-score-nick-size
+ (length nickname))))
+ (padding (make-string padding-size ?\s)))
+ (concat nickname padding)))
+
+(defun pacmacs--make-submit-nickname-action (score)
+ (lambda (widget &optional event)
+ (ignore event)
+ (let ((nickname (widget-value widget)))
+ (pacmacs--add-entry-to-score-table nickname score)
+ (widget-value-set widget (pacmacs--align-score-record-nickname nickname))
+ (widget-delete widget))))
+
(defun pacmacs--switch-to-game-over-state ()
(pacmacs--load-map "game-over")
(pacmacs-destroy)
(setq pacmacs-game-state 'game-over)
(pacmacs--render-state)
+ (fundamental-mode)
(read-only-mode 0)
+
(with-current-buffer pacmacs-buffer-name
(goto-char (point-max))
@@ -581,23 +597,7 @@
(pacmacs--render-score-table))
(widget-create 'editable-field
:size pacmacs--max-score-nick-size
- :action (lambda (widget &optional event)
- (ignore event)
- (let ((nickname (widget-value widget)))
- (pacmacs--add-entry-to-score-table
- nickname
- pacmacs-score)
- (widget-value-set widget
- (format "%s%s"
- nickname
- (make-string
- (max 0
- (-
pacmacs--max-score-nick-size
-
(length nickname)))
- ?\s)))
- (widget-delete widget)))
-
- "")
+ :action (pacmacs--make-submit-nickname-action
pacmacs-score))
(insert (format " %d\n" pacmacs-score))
(->> score-table
(-drop new-score-position)
@@ -605,7 +605,8 @@
(plist-bind ((height :height))
pacmacs--object-board
- (forward-line (+ height pacmacs--score-table-render-offset (1+
new-score-position)))))
+ (goto-char (point-min))
+ (forward-line (+ height pacmacs--score-table-render-offset
new-score-position))))
(pacmacs--render-score-table score-table)
(goto-char (point-min)))
(use-local-map widget-keymap)
- [nongnu] elpa/pacmacs b19ed92514 389/472: Add UT for color-hex-gradient, (continued)
- [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, 2022/01/06
- [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 <=
- [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
- [nongnu] elpa/pacmacs 9b2c497eb9 431/472: Handle error during level list loading (#191), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 2cf174ca7e 434/472: Create signs folder with game over sign (#191), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7d4356c92c 445/472: Implement pacmacs-score-awesome (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0f4eb7aebf 452/472: Decouple score page render from sign render (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a12795e835 455/472: Introduce pacmacs-scores-mode (#203), ELPA Syncer, 2022/01/06