ID:2372551
 
I wish there were more interface/gui tools. Client-side support is extremely limited but I'm grateful for the JavaScript support that does exist. I wish there was inbuilt support for basic things such as tooltips.

Currently there's no way to get the exact position of the mouse when it's over a map element [relative to the user's screen] besides doing it the hacky way. I'll probably have to create a library for it though it should be an inbuilt feature by all means.

I wish there were more support for windows and the ability to keep smaller, draggable windows within the main window. Lack of client-side support is a real problem for me. I will have to make do, I suppose.

Any suggestions on keeping draggable windows within a boundary as opposed to the user having the ability to flat out drag them outside the window?

This thread isn't in feature requests because it isn't directly useful to Lummox.
vis_contents makes a lot of this stuff more doable, if you are planning on ditching GDI elements completely.

Thanks to vis_contents, we can now reposition screen elements on the server by moving a single object rather than moving every single object involved in the UI element.

By adding objects to vis_contents, you essentially can now have hierarchal screen elements that are much more complex and have components that dynamically update with a much smaller cost to the server.

As for your mouse tracking problem:

var/regex/rgx_sloc = regex(@"[:,]")
client
var
list/mouse_cursor_pos
mouse_params

//add MouseMove()/MouseDrag() overrides that store mouse_params every time they are called.
//DO NOT process them until you need the data in the params. You should always call getMousePos()/getMouseWorldPos()
//when you need that data only, because there may be dozens of MouseMove()/MouseDrag() calls per frame.
//It is called too often to do the processing except when you are about to use that data.

MouseMove(atom/object,atom/location,control,params)
mouse_params = params
..()
MouseDrag(atom/src_object,atom/over_object,atom/src_location,atom/over_location,src_control,control,params)
mouse_params = params
..()

proc
//call this when you need to detect where the mouse is sitting on the viewport
getMousePos()
if(mouse_params)
var/list/l = params2list(mouse_params), pos
mouse_params = null
l = splittext(l["screen-loc"],rgx_sloc)
pos = length(l)-3
mouse_cursor_pos[1] = (text2num(l[pos++])-1) * TILE_WIDTH + text2num(l[pos++])
mouse_cursor_pos[2] = (text2num(l[pos++])-1) * TILE_HEIGHT + text2num(l[pos])
return mouse_cursor_pos

//call this when you need to detect where the mouse is sitting in the world
getMouseWorldPos()
if(mouse_params)
getMousePos()
var/list/l = mouse_cursor_pos.Copy()
l[1] += bound_x
l[2] += bound_y
return l
In response to Ter13
error: bad embedded expression [:,]
In response to Czoaf
Czoaf wrote:
error: bad embedded expression [:,]


EDIT: forgot the text2num() bits and the "@" symbol to make it a string literal.
In response to Ter13
runtime error: cannot write to indexed value in this type of list
proc name: getMousePos (/client/proc/getMousePos)
source file: test2.dm,170
usr: Guest-253822146 (/mob/player)
src: Guest-253822146 (/client)
usr.loc: the turf (1,1,1) (/turf)
call stack:
Guest-253822146 (/client): getMousePos()
Guest-253822146 (/client): getMousePos2()


Hi Ter I tried to follow the steps but im not sure how to call getMousePos just then I need then im getting this error at this line

                mouse_cursor_pos[1] = (text2num(l[pos++])-1) * TILE_WIDTH + text2num(l[pos++])

I just used client/verb/TestMouse() getMousePos() for test
Not sure why that is the error you're getting, but it looks like mouse_cursor_pos is not being initialized?
client
var
list/mouse_cursor_pos = new(2) // Creates a list of length 2
In response to Flick
thank you both, yes the mouse_cursor_pos not was being initialized
In response to Flick
just more one question, how should to deny then the client tries to move the Interface out of the screen?
runtime error: list index out of bounds
proc name: getMousePos (/client/proc/getMousePos)

if(mouse_params) seems not check if it's out of bounds
i've tried to check at the MouseDrag(atom/over_object) if there's a over_object and if there is none so return but it seems no work
I'll scope this out later and put it in its own thread.
I already have something like that Ter13, though you have my thanks for taking the time to try and help. I'll write a library to find absolute mouse-position on the user's screen, not just the display and release it later.

Login to reply.