~melchizedek6809/WolkenWelten

78258f0cc2def46a32d208cb28857eba5047a074 — Ben (Win10) 3 months ago ab3281f
UI Work
3 files changed, 42 insertions(+), 19 deletions(-)

M client/src/mods/client.nuj
M client/src/mods/macro-panel.nuj
M client/src/mods/z_blockchooser.nuj
M client/src/mods/client.nuj => client/src/mods/client.nuj +1 -1
@@ 118,7 118,7 @@

[defun client/selection []
  [cond [blockchooser/active blockchooser/selection]
        [#t blockchooser/selection]]]
        [#t inventory/selection]]]

[defun client/select! [sel]
  [cond [blockchooser/active [blockchooser/select! sel]]

M client/src/mods/macro-panel.nuj => client/src/mods/macro-panel.nuj +8 -3
@@ 1,7 1,12 @@
[def macro-panel #nil]

[defun macro-panel/init! []
  [set! macro-panel [widget :
  ]
  [when-not macro-panel
            [set! macro-panel [widget [ :panel
                                        :width 128
                                        :height 128
                                        :val 8
                                        :x -1
                                        :y -1]]]]]

[event-bind on-join :macro-pnael macro-panel/init!]
[event-bind on-join :blockchooser macro-panel/init!]

M client/src/mods/z_blockchooser.nuj => client/src/mods/z_blockchooser.nuj +33 -15
@@ 1,20 1,29 @@
[def blockchooser/active #f]
[def blockchooser/selection 2]
[def blockchooser/w/panel #nil]
[def blockchooser/w/label #nil]
[def blockchooser/w/sprite #nil]
[def blockchooser/w/popup #nil]

[defun blockchooser/refresh []
  [when-not blockchooser/w/panel [blockchooser/w/init!]]
  [def cur-block blockchooser/selection]
  [widget/val/int! blockchooser/w/sprite cur-block]
  [def name [block/name cur-block]]
[defun blockchooser/refresh/widgets []
  [when-not blockchooser/w/label
            [blockchooser/w/init!]]
  [widget/val/int! blockchooser/w/sprite blockchooser/selection]
  [def name [block/name blockchooser/selection]]
  [widget/label! blockchooser/w/label [fmt "{name}"]]
  [cons-mode/block! cur-block]
  [when-not blockchooser/active
    [widget/label! blockchooser/w/label [fmt "Pears"]]
    [widget/val/int! blockchooser/w/sprite 258]]]
  [cons-mode/block! blockchooser/selection]]

[defun blockchooser/remove/widgets []
  [when blockchooser/w/label
    [widget/parent! blockchooser/w/label #nil]
    [set! blockchooser/w/label #nil]]
  [when blockchooser/w/sprite
    [widget/parent! blockchooser/w/sprite #nil]
    [set! blockchooser/w/label #nil]]]

[defun blockchooser/refresh []
  [if blockchooser/active
      [blockchooser/refresh/widgets]
      [blockchooser/remove/widgets]]]

[defun blockchooser/hide! []
  [widget/parent! blockchooser/w/popup #nil]


@@ 69,11 78,20 @@
      [blockchooser/show!]]]

[defun blockchooser/w/init! []
  [set! blockchooser/w/panel [widget [:panel :width 128 :height 128 :val 8 :x -1 :y -1]]]
  [set! blockchooser/w/label [widget [:label :parent blockchooser/w/panel :width -1 :height 48 :label "Test"]]]
  [set! blockchooser/w/sprite [widget [:sprite :parent blockchooser/w/panel :x 26 :y 32 :width 64 :height 64 :val [- blockchooser/selection 1]]]]
  [widget/bind w-game-screen "focus" blockchooser/hide!]
  [blockchooser/refresh]]
  [macro-panel/init!]
  [set! blockchooser/w/label [widget [ :label
                                       :parent macro-panel
                                       :width -1
                                       :height 48
                                       :label ""]]]
  [set! blockchooser/w/sprite [widget [:sprite
                                       :parent macro-panel
                                       :x 24
                                       :y 32
                                       :width 64
                                       :height 64
                                       :val 0]]]
  [widget/bind w-game-screen "focus" blockchooser/hide!]]

[defun blockchooser/select! [sel]
       "Select a particular block"