Skip to content

Commit

Permalink
Merge pull request #6007 from cardboardtech/KeepDiscardOpen
Browse files Browse the repository at this point in the history
Don't close discard/deck popup when clicking in the popup
  • Loading branch information
NoahTheDuke authored Aug 2, 2021
2 parents 88ee3b7 + 48b661b commit db8f566
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/clj/game/core/diffs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,4 @@
{:runner-diff (differ/diff old-runner new-runner)
:corp-diff (differ/diff old-corp new-corp)
:spect-diff (differ/diff old-spect new-spect)
:hist-diff (differ/diff old-hist new-hist)}))
:hist-diff (differ/diff old-hist new-hist)}))
2 changes: 1 addition & 1 deletion src/clj/game/core/eid.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(defn register-effect-completed
[state eid effect]
(if (get-in @state [:effect-completed (:eid eid)])
(throw (Exception. (str "Eid has alreasy been registered")))
(throw (Exception. (str "Eid has already been registered")))
(swap! state assoc-in [:effect-completed (:eid eid)] effect)))

(defn clear-eid-wait-prompt
Expand Down
68 changes: 36 additions & 32 deletions src/cljs/nr/gameboard/board.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,14 @@
facedown))

(defn card-view
[card flipped]
[card flipped disable-click]
(let [c-state (r/atom {})]
(fn [{:keys [zone code type abilities counter advance-counter advancementcost current-advancement-requirement
subtype subtypes advanceable rezzed strength current-strength title selected hosted
side rec-counter facedown server-target subtype-target icon new runner-abilities subroutines
corp-abilities]
:as card}
flipped]
flipped disable-click]
[:div.card-frame
[:div.blue-shade.card {:class (str (when selected "selected")
(when new " new")
Expand All @@ -614,7 +614,8 @@
(= (:side @game-state) (keyword (lower-case side))))
(put! zoom-channel card))
:on-mouse-leave #(put! zoom-channel false)
:on-click #(handle-card-click card c-state)}
:on-click #(when (not disable-click)
(handle-card-click card c-state))}
(if (or (not code) flipped facedown)
(let [facedown-but-known (or (not (or (not code) flipped facedown))
(spectator-view-hidden?)
Expand Down Expand Up @@ -804,12 +805,12 @@
(fn [render-side player-side identity deck]
; deck-count is only sent to live games and does not exist in the replay
(let [deck-count-number (if (nil? @deck-count) (count @deck) @deck-count)]
[:div.blue-shade.deck
(drop-area title {:on-click #(-> (menu-ref @board-dom) js/$ .toggle)})
(when (pos? deck-count-number)
[facedown-card (:side @identity) ["bg"] nil])
[:div.header {:class "darkbg server-label"}
(str title " (" deck-count-number ")")]
[:div.deck-container (drop-area title {})
[:div.blue-shade.deck {:on-click #(-> (menu-ref @board-dom) js/$ .toggle)}
(when (pos? deck-count-number)
[facedown-card (:side @identity) ["bg"] nil])
[:div.header {:class "darkbg server-label"}
(str title " (" deck-count-number ")")]]
(when (= render-side player-side)
[:div.panel.blue-shade.menu {:ref #(swap! board-dom assoc menu-ref %)}
[:div {:on-click #(do (send-command "shuffle")
Expand All @@ -830,12 +831,12 @@
(defn discard-view-runner [player-side discard]
(let [s (r/atom {})]
(fn [player-side discard]
[:div.blue-shade.discard
(drop-area "Heap" {:on-click #(-> (:popup @s) js/$ .fadeToggle)})
(when-not (empty? @discard)
[card-view (last @discard)])
[:div.header {:class "darkbg server-label"}
(str (tr [:game.heap "Heap"]) " (" (count @discard) ")")]
[:div.discard-container (drop-area "Heap" {})
[:div.blue-shade.discard {:on-click #(-> (:popup @s) js/$ .fadeToggle)}
(when-not (empty? @discard)
[card-view (last @discard) nil true])
[:div.header {:class "darkbg server-label"}
(str (tr [:game.heap "Heap"]) " (" (count @discard) ")")]]
[:div.panel.blue-shade.popup {:ref #(swap! s assoc :popup %)
:class (if (= player-side :runner) "me" "opponent")}
[:div
Expand All @@ -849,22 +850,22 @@
(let [s (r/atom {})]
(fn [player-side discard]
(let [faceup? #(or (:seen %) (:rezzed %))
draw-card #(if (faceup? %)
[card-view %]
draw-card #(if (faceup? %1)
[card-view %1 nil %2]
(if (or (= player-side :corp)
(spectator-view-hidden?))
[:div.unseen [card-view %]]
[:div.unseen [card-view %1 nil %2]]
[facedown-card "corp"]))]
[:div.blue-shade.discard
(drop-area "Archives" {:on-click #(-> (:popup @s) js/$ .fadeToggle)})
(when-not (empty? @discard)
[:<> {:key "discard"} (draw-card (last @discard))])
[:div.header {:class "darkbg server-label"}
(let [total (count @discard)
face-up (count (filter faceup? @discard))]
(str (tr [:game.archives "Archives"])
;; use non-breaking space to keep counts on same line
" (" (tr [:game.up-down-count] total face-up) ")"))]
[:div.discard-container (drop-area "Archives" {})
[:div.blue-shade.discard {:on-click #(-> (:popup @s) js/$ .fadeToggle)}
(when-not (empty? @discard)
[:<> {:key "discard"} (draw-card (last @discard) true)])
[:div.header {:class "darkbg server-label"}
(let [total (count @discard)
face-up (count (filter faceup? @discard))]
(str (tr [:game.archives "Archives"])
;; use non-breaking space to keep counts on same line
" (" (tr [:game.up-down-count] total face-up) ")"))]]
[:div.panel.blue-shade.popup {:ref #(swap! s assoc :popup %)
:class (if (= (:side @game-state) :runner) "opponent" "me")}
[:div
Expand All @@ -875,7 +876,7 @@
(doall
(for [[idx c] (map-indexed vector @discard)]
^{:key idx}
[:div (draw-card c)]))]]))))
[:div (draw-card c false)]))]]))))

(defn rfg-view [cards name popup]
(let [dom (atom {})]
Expand Down Expand Up @@ -1626,16 +1627,19 @@
(defn button-pane [{:keys [side prompt-state]}]
(let [autocomp (r/track (fn [] (get-in @prompt-state [:choices :autocomplete])))
show-discard? (r/track (fn [] (get-in @prompt-state [:show-discard])))
prompt-type (r/track (fn [] (get-in @prompt-state [:prompt-type])))]
prompt-type (r/track (fn [] (get-in @prompt-state [:prompt-type])))
opened-by-system (r/atom false)]
(r/create-class
{:display-name "button-pane"

:component-did-update
(fn []
(when (pos? (count @autocomp))
(-> "#card-title" js/$ (.autocomplete (clj->js {"source" @autocomp}))))
(when @show-discard?
(-> ".me .discard .popup" js/$ .fadeIn))
(cond @show-discard? (do (-> ".me .discard-container .popup" js/$ .fadeIn)
(reset! opened-by-system true))
@opened-by-system (do (-> ".me .discard-container .popup" js/$ .fadeOut)
(reset! opened-by-system false)))
(if (= "select" @prompt-type)
(set! (.-cursor (.-style (.-body js/document))) "url('/img/gold_crosshair.png') 12 12, crosshair")
(set! (.-cursor (.-style (.-body js/document))) "default"))
Expand Down
12 changes: 5 additions & 7 deletions src/css/gameboard.styl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
top: 100%
transform: translate(0, -100%)

.card-frame, .deck, .identity, .discard
.card-frame, .deck-container, .identity, .discard-container
pointer-events: auto

.card-frame
Expand Down Expand Up @@ -241,7 +241,8 @@

.card
float: left
margin: 2px
margin-right: 4px
margin-bottom: 2px

a
label
Expand Down Expand Up @@ -305,10 +306,7 @@
margin-left: 16px
margin-right: 16px

.discard
position: relative

.hand-container
.hand-container, .deck-container, .discard-container
position: relative

.hand-controls
Expand Down Expand Up @@ -683,7 +681,7 @@
padding: 5px 0
display-flex()

.deck, .discard, .identity
.deck-container, .discard-container, .identity
margin-left: 16px
margin-right: 16px

Expand Down

0 comments on commit db8f566

Please sign in to comment.