From 88b6eb83ded5d0d3ac5aeb1bf3abf53ee728df6c Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Fri, 8 Oct 2021 15:01:17 -0600 Subject: [PATCH] use mouse to get selection index --- uxn-client/xrxs.tal | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/uxn-client/xrxs.tal b/uxn-client/xrxs.tal index 55b8d16..6df1e5e 100644 --- a/uxn-client/xrxs.tal +++ b/uxn-client/xrxs.tal @@ -51,6 +51,7 @@ @list-elem $32 @list-top $1 @list-height $1 +@select-index $1 @cart $32 @realm $32 @@ -141,7 +142,8 @@ BRK #2000 .File/length DEO2 ;listbuf .File/load DEO2 .File/success DEI2 .list-len STZ2 - INC .state STZ BRK + INC .state STZ + ;get-select-idx-by-mouse .Mouse/vector DEO2 BRK &keep-state POP BRK @@ -437,7 +439,7 @@ RTN [ ;word .Screen/x DEI2 .Screen/y DEI2 - #02 ] ;draw-string JSR2 + ;get-entry-color JSR2 ] ;draw-string JSR2 #0040 .Screen/x DEO2 &no-draw .list-offset LDZ INC .list-offset STZ @@ -451,6 +453,34 @@ RTN &end POP2 POP2 RTN +@get-entry-color ( -- colorByte ) + + .list-offset LDZ + .select-index LDZ + + NEQ ,&normal JCN + + ( selected ) + #0c RTN + &normal + #02 +RTN + +@get-select-idx-by-mouse ( -> ) + + .Mouse/x DEI2 #0040 LTH2 ,&done JCN + .Mouse/x DEI2 .Screen/width DEI2 #0040 SUB2 GTH2 ,&done JCN + + .Mouse/y DEI2 #0028 LTH2 ,&done JCN + .Mouse/y DEI2 .Screen/height DEI2 #0028 SUB2 GTH2 ,&done JCN + + .Mouse/y DEI2 #0028 SUB2 8// TOB .list-top LDZ ADD .select-index STZ + BRK + + &done + #ff .select-index STZ +BRK + ( constants ) @spritesheet "xrxs.chr 00 @fontsheet "zz.chr 00