Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

TribesGUI.TribesCreditsMenu


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
// ====================================================================
//  Class:  TribesGui.TribesCreditsMenu
//  Parent: TribesGUIPage
//
//  Menu to display Tribes Credits.
// ====================================================================

class TribesCreditsMenu extends TribesGUIPage
     ;

var(TribesGui) private EditInline Config GUIButton		MyEscapeButton;

var(TribesGui) private EditInline Editconst array<GUILabel>  Credits;

var(CREDITS) private config float ScrollDelay;
var(CREDITS) private config float InitialDelay;
var(CREDITS) private config float RepeatDelay;
var(CREDITS) private config sDynamicPositionSpec InitialPlacement;
var(CREDITS) private config sDynamicPositionSpec FinalPlacement;

var(CREDITS) private int NextToStartScrolling;

function InitComponent(GUIComponent MyOwner)
{
    local int i;
    local TribesCredits CreditObj;
        
    Super.InitComponent(MyOwner);

    MyEscapeButton.OnClick=InternalOnClick;
    
    CreditObj = new() class'TribesCredits';
	//Log("Successfully created CreditObj "$CreditObj);

    assertWithDescription( CreditObj.CreditLines.Length == CreditObj.CreditLineStyles.Length, "The number of lines of credits specified in TribesCredits.ini does not match the number of styles!" );

    for( i = 0; i < CreditObj.CreditLines.Length; i++ )
    {
        Credits[i] = GUILabel(AddComponent("GUI.GUILabel",self.Name$"_"$i$"_Label",true));
        Assert( Credits[i] != None );
        Credits[i].SetCaption( CreditObj.CreditLines[i] );
        Credits[i].StyleName = CreditObj.CreditLineStyles[i];
        Credits[i].Style = Controller.GetStyle( CreditObj.CreditLineStyles[i] );

        Credits[i].MovePositions[0] = FinalPlacement;
        Credits[i].MovePositions[1] = InitialPlacement;
        Credits[i].RePosition( InitialPlacement.KeyName, true );
        Credits[i].OnRePositionCompleted = InternalOnRePositionCompleted;
		Credits[i].Hide();

        Credits[i].TextAlign = TXTA_Center;
        Credits[i].bAllowHTMLTextFormatting=true;
    }
}


private function InternalOnShow()
{
    if( Credits.Length < 1 )
        return;
    NextToStartScrolling = 0;
    SetTimer( InitialDelay );
}

private function InternalOnHide()
{
    local int i;
    
    for( i = 0; i < Credits.Length; i++ )
    {
        Credits[i].RePosition( InitialPlacement.KeyName, true );
    }
}

event Timer()
{
    ScrollNext();
}

private function ScrollNext()
{
//log("ScrollingNext: " $ NextToStartScrolling);
    if( NextToStartScrolling >= Credits.Length )
    {
        ScrollingCompleted();
        return;
    }
	Credits[NextToStartScrolling].Show();
    Credits[NextToStartScrolling].RePosition( FinalPlacement.KeyName );
    NextToStartScrolling++;
    SetTimer( ScrollDelay );
}

private function InternalOnRePositionCompleted( GUIComponent Sender, name NewPosLabel )
{
    if( NewPosLabel == FinalPlacement.KeyName )
        Sender.RePosition( InitialPlacement.KeyName, true );
}

private function ScrollingCompleted()
{
//log("ScrollingCompleted");
    NextToStartScrolling = 0;
    SetTimer( RepeatDelay );
}

////////////////////////////////////////////////////////////////////////////////////
// Component Management
////////////////////////////////////////////////////////////////////////////////////
private function InternalOnClick(GUIComponent Sender)
{
    Close();
}

private function Close()
{
	SetTimer(0);
    Controller.CloseMenu();

	// MJ:  This call to Free prevents the Timer() function from working if the menu
	// is opened a second time
    //Free( true );
}

////////////////////////////////////////////////////////////////////////////////////
// Component Cleanup
////////////////////////////////////////////////////////////////////////////////////
event Free( optional bool bForce) 			
{
	local int i;
	
    for (i=0;i<Credits.Length;i++)
        Credits[i] = None;
    Credits.Remove(0,Credits.Length);

    MyEscapeButton=None;

    Super.Free( bForce );
}


defaultproperties
{
	OnShow=InternalOnShow
	OnHide=InternalOnHide
	
	ScrollDelay=1
	InitialDelay=1
	RepeatDelay=1
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: st 16.4.2014 10:20:44.000 - Creation time: st 23.5.2018 00:10:48.120 - Created with UnCodeX