Advertisement
Guest User

Untitled

a guest
May 25th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.64 KB | None | 0 0
  1. #version something.12
  2.  
  3. namespace eval kv_overlay {
  4.  
  5.     proc drawgrid {} {
  6.  
  7.         #                   rrggbbaa
  8.         variable color [list "0xffffff50" "0x0000ff50"]
  9.  
  10.         for {set x 0} {$x < 33} {incr x} {
  11.         osd create rectangle kv.linex$x -scaled true -relx [expr {($x*8)} ] -y   0 -relh 193 -w 1 -rgba [lindex $color [expr {$x % 2}]]
  12.         }
  13.  
  14.         for {set y 0} {$y < 25} {incr y} {
  15.         osd create rectangle kv.liney$y -scaled true -rely [expr {($y*8)} ] -x 0 -h 1 -relw 257 -rgba [lindex $color [expr {$y % 2}]]
  16.         }
  17.  
  18.  
  19.        
  20.     }
  21.  
  22.  
  23.     proc activate_kv2_editor {} {
  24.         osd_widgets::msx_init kv
  25.         osd create text kv.coords -relx -10 -rely -10 -text "Coordinates" -rgba 0xffffff80 -size 8
  26.  
  27.         drawgrid
  28.  
  29.         activate_input_layer kv
  30.         FollowMouse
  31.     }
  32.  
  33.     proc FollowMouse {} {
  34.         osd_widgets::msx_update kv
  35.        
  36.         lassign [osd info "kv" -mousecoord] x y
  37.         # make sure you register only on the MSX screen
  38.         set x [expr {floor($x)*1}]
  39.         set y [expr {floor($y)*1}]
  40.  
  41.         if ($x<0) {set x -1}
  42.         if ($y<0) {set y -1}
  43.         if ($y>191) {set y 191}
  44.         if ($x=="Inf") {set x -1}
  45.         if ($y=="Inf") {set y -1}
  46.  
  47.  
  48.         if {$x>-1 && $y>-1} {
  49.             poke 0xe265  [expr {int($x / 8)}]
  50.             poke 0xe264  [expr {int($y / 8)}]
  51.         }
  52.    
  53.         # put coordinates on screen
  54.         osd configure  kv.coords -text "[expr {int($x)}] - [expr {int($y)}]"
  55.  
  56.         bind -layer kv "mouse button1 down" {keymatrixdown 8 0x01}
  57.         bind -layer kv "mouse button1 up" {keymatrixup 8 0x01}
  58.  
  59.         bind -layer kv "mouse button3 down" {keymatrixdown 4 0x04}
  60.         bind -layer kv "mouse button3 up" {keymatrixup 4 0x04}
  61.  
  62.  
  63.         after frame kv_overlay::FollowMouse
  64.     }
  65.  
  66.  
  67. namespace export activate_kv2_editor
  68. }
  69.  
  70. namespace import kv_overlay::*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement