View Single Post
  #1  
Old 08-18-2009, 09:18 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Anchoring Knockoff.

Trying to emulate the anchoring support I asked for.

It appears to be hitting the proper case in switch statement, yet does not set x and y accordingly.

Adding debug checks such as "player.chat = this.ANCHOR_TOP[0] - (GControl.width / 2);" give me the position I want, but the x/y always ends up being 0.

edit: also not complete, once I get this issue out of the way I'll add x-y offsets as well.

PHP Code:
function onCreated()
{
findplayer("mark sir link").addweapon(this.name);
}

//#CLIENTSIDE
function onCreated()
{
  
this.ANCHOR_TOP = {screenwidth/2, 0}; //12 O'Clock
  
this.ANCHOR_TOPRIGHT = {screenwidth, 0}; //between 1-2 O'Clock
  
this.ANCHOR_RIGHT = {screenwidth, screenheight/2}; //3 O'Clock
  
this.ANCHOR_BOTTOMRIGHT = {screenwidth, screenheight}; //between 4-5 O'Clock
  
this.ANCHOR_BOTTOM = {screenwidth/2, screenheight}; //6 O'Clock
  
this.ANCHOR_BOTTOMLEFT = {0, screenheight}; //between 7-8 O'Clock
  
this.ANCHOR_LEFT = {0, screenheight/2}; //9 O'Clock
  
this.ANCHOR_TOPLEFT = {0, 0}; //between 10-11 O'Clock
  
  
this.ANCHORS = {ANCHOR_TOP, ANCHOR_TOPRIGHT, ANCHOR_RIGHT, ANCHOR_BOTTOMRIGHT, ANCHOR_BOTTOM, ANCHOR_BOTTOMLEFT, ANCHOR_LEFT, ANCHOR_TOPLEFT};  

  new 
GuiWindowCtrl("Test_Window") {
  
profile = "GuiBlueWindowProfile";
  
this.anchor = "TOP";
  
width = 160;
  
height = 80;
  
text = "Window";
  
canmove = true;
  
editing = true;
  
canclose = true;
  
destroyonhide = true;
}
  
anchorPosition(Test_Window);

}


function 
anchorPosition(GControl)
{
  
with(GControl)
  {
    switch (
this.anchor)
    {
    case 
"TOP":
      
text = thiso.test;
      
x = thiso.ANCHOR_TOP[0] - (width / 2);
      
y = thiso.ANCHOR_TOP[1];
      break;
    case 
"TOPRIGHT":
      
x = thiso.ANCHOR_TOPRIGHT[0] - width;
      
y = thiso.ANCHOR_TOPRIGHT[1];
      break;
    case 
"RIGHT":
      
x = thiso.ANCHOR_RIGHT[0] - width;
      
y = thiso.ANCHOR_RIGHT[1] - (height / 2);
      break;
    case 
"BOTTOMRIGHT":
      
x = thiso.ANCHOR_BOTTOMRIGHT[0] - width;
      
y = thiso.ANCHOR_BOTTOMRIGHT[1] - height;
      break;
    case 
"BOTTOM":
      
x = thiso.ANCHOR_BOTTOM[0] - (width / 2);
      
y = thiso.ANCHOR_BOTTOM[1] - height;
      break;
    case 
"BOTTOMLEFT":
      
x = thiso.ANCHOR_BOTTOMLEFT[0];
      
y = thiso.ANCHOR_BOTTOMLEFT[1]; - height;
      break;
    case 
"LEFT":
      
x = thiso.ANCHOR_LEFT[0];
      
y = thiso.ANCHOR_LEFT[1] - (height / 2);
      break;
    case 
"TOPLEFT":
      
x = thiso.ANCHOR_TOPLEFT[0];
      
y = thiso.ANCHOR_TOPLEFT[1];
      break;
    default:
      
x = 0;
      
y = 0;
    }
  }
} 
Reply With Quote