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

From Graal Bible
(→‎Available Attributes: Added text shadow attributes)
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Scripting Reference]]
== Introduction ==
== 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".
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".
Line 30: Line 31:
   transparency = 0.5;
   transparency = 0.5;
}</pre>
}</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 ==
== Available Attributes ==
Here are the attributes that you can set in a GUI profile.
 
<pre>GuiControlProfile (TGraalVar):
See [[Creation/Dev/Script/Client/GuiControlProfile|GuiControlProfile]].
align - string - controls justification of text
autosizeheight - boolean
autosizewidth - boolean
bitmap - string - the image map to be used with the control
border - integer - border setting
bordercolor - string - colour of the border
bordercolorhl - string
bordercolorna - string
borderthickness - integer - thickness of the border
cankeyfocus - boolean
cursorcolor - string - colour of the cursor for editable text controls
fillcolor - string
fillcolorhl - string
fillcolorna - string
fontcolor - string
fontcolorhl - string
fontcolorlink - string
fontcolorlinkhl - string
fontcolorna - string
fontcolorsel - string
fontsize - integer - size of the font to be used
fontstyle - string - font attribute (bold, italics, underline, ...)
fonttype - string - name of the font to be used
justify - string - the same like "align"; controls justification of text
linespacing - integer - adjusts line spacing for multi-line controls
modal - boolean
mouseoverselected - boolean
numbersonly - boolean
opaque - boolean - controls whether the object is transparent or opaque
returntab - boolean
shadowcolor - {red,green,blue} - specifies the color of the shadow (use in combination with textshadow=true)
shadowoffset - array of format {offsetx,offsety} - specifies the position of the shadow (use in combination with textshadow=true)
soundbuttondown - string - sound to play when the control is active
soundbuttonover - string - sound to play when the control is rolled over
tab - boolean
textoffset - string - controls how far offset the text is from the top-left of the control
textshadow - boolean - enables or disables the shadow
transparency - float - controls the transparency of the control</pre>


== Editing control-specific profile information ==
== Editing control-specific profile information ==

Latest revision as of 01:59, 12 September 2009

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.