ID:2381690
 
So, I've been working on a project and I like the idea of using different windows for dialog, quest menu, and even for a fade-to-black screen I just create a window over the main window and add/remove transparency until all is revealed, or hidden.

Below is my screen positioning loop which I run under mob/Stat() [The proc won't be used otherwise]

mob
var/tmp
maximize
verb
ExitFullScreen()
set hidden=1;
winset(usr,"1-main","titlebar=true;is-maximized=false");
maximize=0;
Stat() //Using temporary to update window
stat(world.cpu);
var/screenvars=params2list(winget(src,"1-main","pos;size;is-maximized;titlebar"));
var/pos[2];
var/size[2];
var/offsets[2];
for(var/X in screenvars)
stat("Screenvars",X);
stat(screenvars[X]);
switch(X)
if("pos")
var/POS=screenvars[X];
var/comma=findtext(POS,",");
var/pX=copytext(POS,1,comma);
var/pY=copytext(POS,comma+1);
pos[1]=text2num(pX);
pos[2]=text2num(pY);
if("size")
var/SIZE=screenvars[X];
var/comma=findtext(SIZE,"x");
var/sX=copytext(SIZE,1,comma);
var/sY=copytext(SIZE,comma+1);
size[1]=text2num(sX)
size[2]=text2num(sY)
if("titlebar")
if(screenvars[X]=="true")
offsets[1]=8;
offsets[2]=32;
else
offsets[1]=8
offsets[2]=8
if("is-maximized")
if(screenvars[X]=="true")
if(!maximize)
maximize=1;
winset(usr,"1-main","titlebar=false;is-maximized=false;pos=0,0")
winset(usr,"1-main","is-maximized=false;size=999999x999999");
spawn(1)
winset(usr,"1-main","is-maximized=true");
stat("pos","[pos[1]] by [pos[2]]")
stat("size","[size[1]] by [size[2]]")
winset(src,"4-fade","pos=[pos[1]+offsets[1]],[pos[2]+offsets[2]];size=[size[1]]x[size[2]]");
winset(src,"5-quests","pos=[pos[1]+offsets[1]+size[1]-150],[pos[2]+offsets[2]+size[2]/6]");
var/commvars=winget(src,"3-comms","size");
if(commvars)
var/SIZE=commvars
var/split=findtext(SIZE,"x")
var/sX=copytext(SIZE,1,split)
var/sY=copytext(SIZE,split+1)
if(text2num(sX)<640)sX=size[1];
else sX=640;
sY=112;
var/pX=pos[1]+offsets[1]+size[2]/2;
if(sX/1.5+pos[1]>pos[1]+size[1]/2)pX=pos[1]+offsets[1]
winset(usr,"3-comms","pos=[pX],[pos[2]+size[2]-sY+offsets[2]-100];size=[sX]x[sY];");


What's happening is I'm updating the positioning each tick, the problem is if you're moving the main window there's a drag...

Now, the reason I'm using this method instead of slapping the window to overlay the map is because I use transparency in all my windows. Even a light transparency will help the window blend into the environment.

Thoughts? Is there a better way?
Don't do winset() foo in stat. Stat() doesn't run every frame, and winset() should never be done on the server every frame. You probably shouldn't overlay transparent windows on the map. BYOND's client rendering gets notoriously choppy when you do this.

You will need:

1) A hidden output element on top of your map.

2) A screen object that shows the most recent chat messages using maptext.


Rig up the screen object so that when you mouse over it on the map, it shows the hidden output element and covers the screen object.

When you detect that the client is mousing back over the screen, hide the output element again and show the maptext.

That way you get the look of transparent text when the client doesn't want to interact with it, plus the scrollable window, selectable text, and other bullshit when the client wants to interact with the chat.

It will still look like shit, but it will do the job and won't murder renderer and server performance like what you are doing will.

Nobody is sold on a game by how pretty their chat window is.
Haven't even started working on a chat window. These elements are 3 different items.

1. Fade screen, which has the alpha adjusted in/out
2. NPC Dialog which displays messages from NPC characters.
3. Quest log which displays active quests and uses buttons to interact with said quests.

Also, I need to check if the screen is ever maximized to fix set into full screen.

Stat() runs every tick and I use world.tick_lag=0.12

Ideally I don't need to use winset as often, I just need to run a check to see if the screen position has changed or not. If so then do updates using winset()

New 512 features are fantastic for doing what you are doing. Way better than interfaces.

New features you should read up on to put you on the right track:

vis_contents.

screen_loc precentages and screen_loc top, bottom, left, right anchors.

Using vis_contents, it should be trivial to create a draggable window in the viewport that is anchored based on the edges of the map element using percentages. Albeit, it will be server-side, not client-side, and thus not as lightweight, but it will look more professional and won't require these bizarre workarounds you find yourself doing.
I looked into vis_contents and from the help document it just seems like an alternative overlay system. I can't see it being applicable.

However, I did come up with an alternative solution that still going to be a bizarre work around.

Instead of having the windows follow the main window, when movement is detected, I can just temporarily dock the windows so it creates the illusion of it being dragged along, giving up the transparency temporarily during transition and then un-dock when movement stops.

I was really hoping vis_contents would work, but I'm just not seeing it being applicable for this unless I use HUDs for this, which would require twice the amount of work with half the flexibility.
I looked into vis_contents and from the help document it just seems like an alternative overlay system. I can't see it being applicable.

You are well beyond wrong.

Instead of having the windows follow the main window, when movement is detected, I can just temporarily dock the windows so it creates the illusion of it being dragged along, giving up the transparency temporarily during transition and then un-dock when movement stops.

You are wrong. The docking will not match, the performance will blow.

I was really hoping vis_contents would work, but I'm just not seeing it being applicable for this unless I use HUDs for this, which would require twice the amount of work with half the flexibility.

You are half right.