Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Feature request
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 08-17-2007, 10:47 PM
Relinquish Relinquish is offline
Banned
Join Date: Aug 2007
Posts: 7
Relinquish is on a distinguished road
findgui() function

Any chance of getting a findgui() function? It returns a reference to the GUI control with the name given.

I'd like to have a class that draws on whichever DrawingPanel control I pass it, but as far as I can tell, there's no way to pass a reference to it or get it from the name. Unless I'm doing something wrong.

I've tried
PHP Code:
with (@guinamedrawstuff();
(@
guiname).drawstuff();
guiname.drawstuff(); 
Am I missing anything?
Reply With Quote
  #2  
Old 08-17-2007, 11:00 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
GuiControls are objects, so yes

GuiName.drawStuff();
Should work, unless you're doing something wrong in the script itself..

Post some part of your script?
__________________
Reply With Quote
  #3  
Old 08-17-2007, 11:15 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
with ("guiname") {
blah...
}
or, the same thing Chompy said.
The quotations aren't necessary, but needed if you have spaces in the gui name(which you shouldn't), and the gui name is case sensitive, so make sure you do the name exactly as the gui name is when created.
Reply With Quote
  #4  
Old 08-17-2007, 11:30 PM
Relinquish Relinquish is offline
Banned
Join Date: Aug 2007
Posts: 7
Relinquish is on a distinguished road
Echoes nothing (guiref is treated as a string)
PHP Code:
DrawText(("TextTip"));

function 
DrawText(guiref) {
  echo(
guiref.position);

Echoes nothing (guiref is treated as a string)
PHP Code:
DrawText("TextTip");

function 
DrawText(guiref) {
  echo((@
guiref).position);

Echoes nothing (I'm not sure what it's getting, I'm assuming nothing)
PHP Code:
DrawText("TextTip");

function 
DrawText(guiref) {
  
with (guiref) echo(this.position);

TextTip is the name of a GuiDrawingPanel.
Reply With Quote
  #5  
Old 08-17-2007, 11:40 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
echo(TextTip.position);
Reply With Quote
  #6  
Old 08-17-2007, 11:41 PM
Relinquish Relinquish is offline
Banned
Join Date: Aug 2007
Posts: 7
Relinquish is on a distinguished road
You don't understand the original problem.

I want to be able to pass the function which GUI control I want it to draw on; it's dynamic, not static.
Reply With Quote
  #7  
Old 08-17-2007, 11:46 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
I am not entirely sure I understand what you are trying to do, but in order to pass a GUI object to a function:
PHP Code:
//#CLIENTSIDE

function moveMyControl(temp.obj)
{
  
// Check if temp.obj is an object
  // This will usually be your GuiControl object reference

  
if (temp.obj.type() != 2)
  {
    return 
false;
  }

  
// Check if it has a child this.drawingpanel

  
if (temp.obj.drawingpanel == NULL)
  {
    return 
false;
  }

  
// Perform your action in the scope of the control

  
with (temp.obj)
  {
    
this.position = {2020};
  }

  return 
true;
}

function 
onCreated()
{
  new 
GuiWindowCtrl(TestControl)
  {
    
position = {4040};
    
extent = {100100};

    
text "My Window";
  }

  
// Provide a direct object reference

  
this.moveMyControl(TestControl);

  
// Alternatively use the (@ "") syntax to pass an object reference from a string name

  
this.moveMyControl((@ "TestControl"));

Now let's say each control has a child object, you can probably do something like this:
PHP Code:
//#CLIENTSIDE

function drawAction(temp.obj)
{
  
// Check if temp.obj is an object
  // This will usually be your GuiControl object reference

  
if (temp.obj.type() != 2)
  {
    return 
false;
  }

  
// Perform your action in the scope of the control

  
with (temp.obj.drawingpanel)
  {
    
this.drawimagerectangle(...);
  }

  return 
true;
}

function 
onCreated()
{
  new 
GuiWindowCtrl(TestControl)
  {
    
position = {4040};
    
extent = {100100};

    
text "My Window";

    
this.drawingpanel = new GuiDrawingPanel();
  }

  
// Provide a direct object reference

  
this.drawAction(TestControl);

__________________
Skyld

Last edited by Skyld; 08-17-2007 at 11:57 PM..
Reply With Quote
  #8  
Old 08-18-2007, 12:05 AM
Relinquish Relinquish is offline
Banned
Join Date: Aug 2007
Posts: 7
Relinquish is on a distinguished road
Very messy/inconvenient, but it works, thanks.
Reply With Quote
  #9  
Old 08-28-2007, 11:05 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
(@guiname).drawstuff() is the prefered method, but guiname must be correctly written
Reply With Quote
  #10  
Old 08-28-2007, 05:02 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
I'm not sure if there is anything that holds priority with variable names over GUIs but if there is (for example say that you had a NPC named ChatBar that held priority over the GUI), such a function might be useful.
__________________
Do it with a DON!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.