Creation/Dev/GScript/Understanding GUI Profiles: Difference between revisions

From Graal Bible
(Replacing page with '{{antiunix}}')
m (Reverted edits by Anti-Up (Talk); changed back to last version by Twinny)
Line 1: Line 1:
{{antiunix}}
== Introduction ==
GUI profiles are a set of characteristics that define how a GUI control looks. By default when you create a GUI control, it will be using the default profile for the control type; for example, "GuiButtonControl" by default uses "GuiButtonProfile".
 
This profile tells the program that this button needs to be red with a golden border and have orange text. It can define various things such as font face, size, colour, background colour, borders, images, etc.
 
A GUI profile is created in a similar way to a GUI control itself.
<pre>new GuiControlProfile("ProfileName")
{
  attr = value;
  attr = value;
}</pre>
 
It can then be applied to a control like so:
<pre>new GuiControl("ControlName")
{
  profile = "ProfileName";
}</pre>
 
The control will then be formatted as is directed by the GUI profile.
 
An example profile looks like this:
<pre>new GuiControlProfile("MyProfile")
{
  fillColor = {255, 0, 0};
  fontColor = {255, 255, 255};
 
  bitmap = "myEvilImage.png";
 
  opaque = false;
  transparency = 0.5;
}</pre>
 
You can copy existing profiles to create a new one. Instead of creating a "GuiControlProfile" just use the name of the existing profile which you want to copy:
<pre>new GuiButtonProfile("MyButtonProfile") {
  fontsize = 20;
}
</pre>
 
== Available Attributes ==
 
See [[Creation/Dev/Script/Client/GuiControlProfile|GuiControlProfile]].
 
== Editing control-specific profile information ==
You can also edit the profile attributes of a single control. This is using the "profile" object of each GUI control.
 
The profile object contains members exactly the same as a normal GUI profile (i.e. "transparency" => "controlname.profile.transparency". This provides a way to edit the profile.
 
However! You must be careful. A variable, "useOwnProfile", plays an important role here. useOwnProfile tells the control not to share any changes made to the profile.
 
For example, if you did the following:
<pre>profile = "MyProfile";
profile.transparency = 1;</pre>
... then every control using the profile "MyProfile" would set transparency to 1.
 
useOwnProfile stops this happening:
<pre>profile = "MyProfile";
useOwnProfile = true;
profile.transparency = 1;</pre>
... causes only the current control to have transparency set to 1.

Revision as of 10:40, 1 July 2007

Introduction

GUI profiles are a set of characteristics that define how a GUI control looks. By default when you create a GUI control, it will be using the default profile for the control type; for example, "GuiButtonControl" by default uses "GuiButtonProfile".

This profile tells the program that this button needs to be red with a golden border and have orange text. It can define various things such as font face, size, colour, background colour, borders, images, etc.

A GUI profile is created in a similar way to a GUI control itself.

new GuiControlProfile("ProfileName")
{
  attr = value;
  attr = value;
}

It can then be applied to a control like so:

new GuiControl("ControlName")
{
  profile = "ProfileName";
}

The control will then be formatted as is directed by the GUI profile.

An example profile looks like this:

new GuiControlProfile("MyProfile")
{
  fillColor = {255, 0, 0};
  fontColor = {255, 255, 255};

  bitmap = "myEvilImage.png";

  opaque = false;
  transparency = 0.5;
}

You can copy existing profiles to create a new one. Instead of creating a "GuiControlProfile" just use the name of the existing profile which you want to copy:

new GuiButtonProfile("MyButtonProfile") {
  fontsize = 20;
}

Available Attributes

See GuiControlProfile.

Editing control-specific profile information

You can also edit the profile attributes of a single control. This is using the "profile" object of each GUI control.

The profile object contains members exactly the same as a normal GUI profile (i.e. "transparency" => "controlname.profile.transparency". This provides a way to edit the profile.

However! You must be careful. A variable, "useOwnProfile", plays an important role here. useOwnProfile tells the control not to share any changes made to the profile.

For example, if you did the following:

profile = "MyProfile";
profile.transparency = 1;

... then every control using the profile "MyProfile" would set transparency to 1.

useOwnProfile stops this happening:

profile = "MyProfile";
useOwnProfile = true;
profile.transparency = 1;

... causes only the current control to have transparency set to 1.