Interface

by Forum_account
Provides a better way to interact with interface controls than the built-in winset/winget procs.
ID:871973
 
How can i center a window being viewed like custom alert, just want it to be in center of player screen.
You'd need to know the client's resolution. This library doesn't provide that directly but there are probably some that do. You just need to run some javascript in a browser on the client to grab their resolution.

Once you know their resolution you can create a /Window object and call its Pos() proc to center it.
mob
var
//scr = screen
scrwidth
scrheight
Login()
..()
src<<output({"<script type='text/Javascript'>
document.location.href = 'byond://?action=resol&width=' + screen.width+'&height='+screen.height;
</script>"}
,"resodet")
mob/Stat()
statpanel("You")
stat("Resolution: [scrwidth]x[scrheight]")//Displays the Resolution (Will appear as "x" before scrwidth & height is set.)
sleep(10)//1 second update.(Prevents massive lag in big games :3)
client
Topic(t)
var/nlist[] = params2list(t)
if(nlist["action"] && (nlist["action"] == "resol"))//If action exists & is set to assign resolution
src.mob.scrwidth=text2num(nlist["width"])//assigns width to mob
src.mob.scrheight=text2num(nlist["height"])//same here (with height)

this gets the player screen resolution but how can i center skin
If you know the width and height of the screen and window, you can compute the x/y position to place the window at that'll make it centered in the screen:

var/Window/window = new("windowname", src)

// set these to the bounds of the window, you can
// hard code the values or read them at runtime.
var/win_width = 400
var/win_height = 300

window.Pos(round(scrwidth / 2 - win_width / 2), round(scrheight / 2 - win_height / 2))
also
MedalDisplay
var
mob/owner
Window/MedalWindow
Label/Desc

New(mob/m)
owner=m
MedalWindow=new("MedalWindow", owner)
Desc=new("MedalWindow", "Desc", owner)


proc
show_medal(Medal/m)
MedalWindow.Pos(8,44)
MedalWindow.IsVisible("true")
Desc.Text("[m.name]\n[m.Desc]")
sleep(Constant.MedalDisplay)
MedalWindow.IsVisible("false")

mob
var
MedalDisplay/medal_display

this proc dosnt make MedalWindow disappear.
You just need to pass the IsVisible() proc 0 or 1, it gets converted to "true" and "false" inside the library.