Skip to content
Permalink
Browse files

Add login window

  • Loading branch information
borodust committed Apr 24, 2017
1 parent e395466 commit 4d626a13cd890911de3c01b3962cad0b96dfbcea
Showing with 53 additions and 13 deletions.
  1. +3 −0 client/src/events.lisp
  2. +24 −13 client/src/main.lisp
  3. +25 −0 client/src/ui.lisp
  4. +1 −0 mortar-combat.asd
@@ -43,3 +43,6 @@

(defevent trigger-pulled ()
(player))


(defevent exit-requested () ())
@@ -77,13 +77,17 @@


(defun scenegraph-flow ()
(scenegraph
(transform-node
((projection-node :aspect (/ 800 600))
((player-camera :name :camera)
(room-model)
((scene-node :name :ball-group))
((scene-node :name :dude-group)))))))
(>> (resource-flow (font-resource-name "NotoSansUI-Regular.ttf"))
(->> (font)
(scenegraph
(transform-node
((scene-node :name :arena)
((projection-node :aspect (/ 800 600))
((player-camera :name :camera)
(room-model)
((scene-node :name :ball-group))
((scene-node :name :dude-group)))))
((interactive-board-node :width 800 :height 600 :font font :name :ui)))))))


(defmethod dispatch ((this mortar-combat) (task function) invariant &key)
@@ -112,7 +116,9 @@
'game-state-updated
'camera-rotated
'movement-changed
'trigger-pulled)
'trigger-pulled
'button-click-event
'exit-requested)
(setf keymap (make-instance 'keymap)
task-queue (make-task-queue))
(let ((prev-x nil)
@@ -168,7 +174,6 @@
(enable-keymap keymap)

(run (>> (-> ((host)) ()
(lock-cursor)
(setf (viewport-title) "Mortar Combat")
(setf (viewport-size) (vec2 800 600)))
(-> ((physics)) ()
@@ -179,8 +184,9 @@
(instantly (scenegraph-root)
(setf scene (make-scene (make-pass-chain (make-simulation-pass)
(make-rendering-pass))
scenegraph-root)))
(concurrently ()
scenegraph-root))
(let ((board (find-node (root-of scene) :ui)))
(make-ui this board))
(let ((accumulated-time 0)
start looped-flow)
(setf looped-flow
@@ -220,10 +226,15 @@


(defun stop ()
(shutdown))
(shutdown)
(mt:open-latch *main-latch* ))


(define-event-handler on-exit viewport-hiding-event (ev)
(define-event-handler on-close viewport-hiding-event (ev)
(post (make-exit-requested) (events)))


(define-event-handler on-exit exit-requested (ev)
(in-new-thread "exit-thread"
(stop)))

@@ -0,0 +1,25 @@
(in-package :mortar-combat)


(defun make-ui (context board)
(enable-mouse-input board)
(enable-character-input board)
(enable-cursor-input board)
(enable-keyboard-input board)
(let ((login (make-board-window board 300 200 200 145
:title "Enter your name:"
:headerless nil)))
(adopt-layout-by (login)
((dynamic-row-layout 32)
((text-edit :name :nickname)))
((static-row-layout 16 1))
((dynamic-row-layout 32)
((label-button "Quit" :name :quit))
((spacing))
((label-button "Log in" :name :login))))

(let ((nickname-edit (find-element login :nickname)))
(subscribe-body-to (button-click-event (poiu-button)) (events)
(case (name-of poiu-button)
(:login (connect (text-of nickname-edit)))
(:quit (post (make-exit-requested) (events))))))))
@@ -43,6 +43,7 @@
(:file "connector")
(:file "game-server")
(:file "game-client")
(:file "ui")
(:file "main")))


0 comments on commit 4d626a1

Please sign in to comment.
You can’t perform that action at this time.