Skip to content

Commit

Permalink
[Add]: ToolTips are now supported! By default they have a label and a…
Browse files Browse the repository at this point in the history
… background. A FToolTip can be assigned to any FComponent and will be displayed after idling with the mouse over a component for over 0.5 seconds(customizable) .

[Add]: Position and Size change delegates. Adjust the size of a component if another one has changed its size? No problem!

[Add]: Added two options to FScene: bSuppressKeyInput and bLockRotation that can be disabled to allow players to continue their game even if a menu is actively open.

[Rev]: Redesigned how components are initialized. If you happen to have overriden the function Initialize() of InitializeComponent() you'll have to make modifications to your code! This change fixes a bunch of accessed nones and provides an easier to understand initialization flow.

[Rev]: Redesigned how TabButtons and TabControls work. You can now add your tab button and tab page on completely different and unrelated containers(for design reasons) using the @ExternContainer variable and FTabControl will handle everything on itself without you having to use any hacks.
  • Loading branch information
EliotVU committed Apr 12, 2013
1 parent a83189f commit f97122f
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 145 deletions.
2 changes: 1 addition & 1 deletion Classes/FBindingBox.uc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Free()
ActionSecondaryKey = none;
}

function InitializeComponent()
protected function InitializeComponent()
{
local string bindKey;

Expand Down
2 changes: 1 addition & 1 deletion Classes/FColumnsSet.uc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Free()
OnSelect = none;
}

function InitializeComponent()
protected function InitializeComponent()
{
local int i, j;
local float columnSizeX, columnSizeY;
Expand Down
77 changes: 57 additions & 20 deletions Classes/FComponent.uc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class FComponent extends FObject
const Colors = class'FColors';

/** Cannot be used(same for other objects) from delegate events if that delegate is initialized via the DefaultProperties block! */
var transient noclear noimport edithide editconst FIController Controller;
var protectedwrite transient editconst FIController Controller;

/** Cannot be used(same for other objects) from delegate events if that delegate is initialized via the DefaultProperties block! */
var(Component, Advanced) noclear noimport editconst FComponent Parent;
var(Component, Advanced) protectedwrite noimport editconst FComponent Parent;

/** Is this component visible? */
var(Component, Function) protectedwrite bool bVisible;
Expand Down Expand Up @@ -111,6 +111,26 @@ var(Component, Collision) enum ECollisionShape
CS_Circle
} CollisionShape;

/**
* If assigned to a FToolTip then the assigned component will be rendered upon hovering this component.
*
* Usage example:
begin object name=oQuit class=FButton
RelativePosition=(X=0.00,Y=1.0)
RelativeSize=(X=1.0,Y=0.10)
Text="@UDKGameUI.Generic.Exit"
TextAlign=TA_Center
VerticalDock=VD_Bottom
StyleNames.Add(QuitButton)
begin object name=myToolTip class=FToolTip
ToolTipText="Exit the game?"
end object
ToolTipComponent=myToolTip
end object
Components.Add(oQuit)
*/
var(Component, Display) editinline FToolTip ToolTipComponent;

/** The style for this component to use. */
var(Component, Display) privatewrite editinline FStyle Style;
var private editinline FStyle InitStyle, HoverStyle, ActiveStyle, FocusStyle;
Expand Down Expand Up @@ -171,14 +191,14 @@ delegate bool OnCharInput( string Unicode );
// STATE
delegate OnVisibleChanged( FComponent sender );
delegate OnEnabledChanged( FComponent sender );
delegate OnPositionChanged( FComponent sender );
delegate OnSizeChanged( FComponent sender );

// DRAWING
delegate OnPostRender( FComponent sender, Canvas C );

// UPDATING
/**
* Called when created and/or every time when added to a Components list.
*/
/** Called after this component and any of its children have been initialized. */
delegate OnInitialize( FComponent sender );
delegate OnUpdate( FComponent sender, float DeltaTime );

Expand All @@ -191,30 +211,45 @@ delegate OnActive( FComponent sender );
delegate OnUnActive( FComponent sender );

/** Initializes this object. */
function Initialize( FIController c )
final function Initialize( FComponent within )
{
Controller = c;
//`Log( Name $ "Initialize",, 'FormsInit' );

//`Log( Name @ "Initialize",, 'FormsInit' );
if( bInitialized )
return;

if( FMultiComponent(Parent) != none )

bInitialized = true;
Parent = within;
if( Parent != none )
{
FMultiComponent(Parent).OnComponentInitialized( self );
Controller = Parent.Controller;
}

Scene().AddToPool( self );
OnVisibleChanged( self );
OnEnabledChanged( self );

InitializeComponent();
bInitialized = true;

// Post initialize
if( FMultiComponent(Parent) != none )
{
FMultiComponent(Parent).OnComponentInitialized( self );
}
OnInitialize( self );

`if( `isdefined( DEBUG ) )
SaveConfig();
`endif

}

/** Called after this component has been fully registered but not yet completely initialized. */
protected function InitializeComponent()
{
if( ToolTipComponent != none )
{
ToolTipComponent.Initialize( Scene() );
Scene().AddToPool( ToolTipComponent );
}

OnVisibleChanged( self );
OnEnabledChanged( self );
BindStyle();
}

Expand Down Expand Up @@ -255,9 +290,6 @@ private final function FStyle GetStateStyle( string styleIdentifier, string stat
return Scene().GetStyle( styleIdentifier $ ":" $ stateName, StyleClass, InitStyle );
}

/** Initializes this component. Override this to add other components or objects to this component. */
function InitializeComponent();

/** Called every tick if Enabled and Visible. */
function Update( float DeltaTime )
{
Expand Down Expand Up @@ -353,6 +385,7 @@ function Free()
Controller = none;
Parent = none;
Style = none; InitStyle = none; HoverStyle = none; ActiveStyle = none; FocusStyle = none;
ToolTipComponent = none;

// DELEGATES
OnClick = none;
Expand All @@ -365,6 +398,8 @@ function Free()
OnCharInput = none;
OnVisibleChanged = none;
OnEnabledChanged = none;
OnPositionChanged = none;
OnSizeChanged = none;
OnPostRender = none;
OnInitialize = none;
OnUpdate = none;
Expand All @@ -390,12 +425,14 @@ final function SetPos( const float X, const float Y )
{
RelativePosition.X = X;
RelativePosition.Y = Y;
OnPositionChanged( self );
}

final function SetSize( const float X, const float Y )
{
RelativeSize.X = X;
RelativeSize.Y = Y;
OnSizeChanged( self );
}

final function SetMargin( const float leftPixels, const float topPixels, const float rightPixels, const float bottomPixels )
Expand Down
2 changes: 1 addition & 1 deletion Classes/FController.uc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final function InitializeScene( optional class<FScene> sceneClass = class'FScene
ScenePointer = new( none, "Forms" ) sceneClass;
if( ScenePointer != none )
{
ScenePointer.Initialize( self );
ScenePointer.InitializeScene( self );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/FDialog.uc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Free()
OnDialogResult = none;
}

function InitializeComponent()
protected function InitializeComponent()
{
local FButton nextButton;

Expand Down
2 changes: 1 addition & 1 deletion Classes/FGroupBox.uc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Free()
Text = none;
}

function InitializeComponent()
protected function InitializeComponent()
{
super.InitializeComponent();
if( Text != none )
Expand Down
2 changes: 1 addition & 1 deletion Classes/FLabel.uc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function Free()
OnTextChanged = none;
}

function InitializeComponent()
protected function InitializeComponent()
{
super.InitializeComponent();
LocalizeText();
Expand Down
11 changes: 4 additions & 7 deletions Classes/FMultiComponent.uc
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ var(MultiComponent, Advanced) protectedwrite editinline editfixedsize array<FCom
/** Called for each component that is initialized and owned by this component. */
delegate OnComponentInitialized( FComponent component ); // Instigated in FComponent.Initialize(...)

/** Initialize all associated Components. */
function Initialize( FIController c )
protected function InitializeComponent()
{
local FComponent component;

super.Initialize( c );
super.InitializeComponent();
foreach Components( component )
{
component.Parent = self;
component.Initialize( c );
component.Initialize( self );
}
}

Expand Down Expand Up @@ -110,8 +108,7 @@ function bool IsHover( IntPoint mousePosition, out FComponent hoveredComponent )
/** Add a component to the associated Components. */
function AddComponent( FComponent component )
{
component.Parent = self;
component.Initialize( Controller );
component.Initialize( self );
Components.AddItem( component );
}

Expand Down
1 change: 1 addition & 0 deletions Classes/FPage.uc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ defaultproperties
bClipComponent=true
Margin=(X=0,Y=0,Z=0,W=0)
Padding=(X=8,Y=8,Z=8,W=8)
RelativeSize=(X=0.8,Y=0.8)

StyleNames.Add(Page)
}
Loading

0 comments on commit f97122f

Please sign in to comment.