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

XInterface.GUIScrollTextBox


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
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
//====================================================================
//  Parent: GUIListBoxBase
//   Class: UT2K4UI.GUIScrollTextBox
//    Date: 05-01-2003
//
//  ListBox container for a scrolling text list
//
//  Updated by Ron Prestenback
//  (c) 2003, Epic Games, Inc.  All Rights Reserved
// ====================================================================
class GUIScrollTextBox extends GUIListBoxBase
    native;

var GUIScrollText MyScrollText;

var(GUIScrollText) bool         bRepeat;        // Should the sequence be repeated ?
var(GUIScrollText) bool         bNoTeletype;    // Dont do the teletyping effect at all
var(GUIScrollText) bool         bStripColors;   // Strip out IRC-style colour characters (^C)
var(GUIScrollText) float        InitialDelay;   // Initial delay after new content was set
var(GUIScrollText) float        CharDelay;      // This is the delay between each char
var(GUIScrollText) float        EOLDelay;       // This is the delay to use when reaching end of line
var(GUIScrollText) float        RepeatDelay;    // This is used after all the text has been displayed and bRepeat is true
var(GUIScrollText) eTextAlign   TextAlign;      // How is text Aligned in the control
var(GUIScrollText) string       Separator;      // Propagate to GUIScrollText

var() string ESC, COMMA;    // fake const's

event Created()
{
    ESC = Chr(3);
    COMMA = Chr(44);
}

function InternalOnCreateComponent(GUIComponent NewComp, GUIComponent Sender)
{
    if (GUIScrollText(NewComp) != None && Sender == Self)
        GUIScrollText(NewComp).bNoTeleType = bNoTeleType;

    Super.InternalOnCreateComponent(NewComp, Sender);
}


function InitBaseList(GUIListBase LocalList)
{
    if ((MyScrollText == None || MyScrollText != LocalList) && GUIScrollText(LocalList) != None)
        MyScrollText = GUIScrollText(LocalList);

    Super.InitBaseList(LocalList);

    MyScrollText.Separator = Separator;
    MyScrollText.InitialDelay = InitialDelay;
    MyScrollText.CharDelay = CharDelay;
    MyScrollText.EOLDelay = EOLDelay;
    MyScrollText.RepeatDelay = RepeatDelay;
    MyScrollText.TextAlign = TextAlign;
    MyScrollText.bRepeat = bRepeat;
    MyScrollText.bNoTeletype = bNoTeletype;
    MyScrollText.OnAdjustTop  = InternalOnAdjustTop;
}

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
    Super.InitComponent(MyController, MyOwner);

    if (DefaultListClass != "")
    {
        MyScrollText = GUIScrollText(AddComponent(DefaultListClass));
        if (MyScrollText == None)
        {
            log(Class$".InitComponent - Could not create default list ["$DefaultListClass$"]");
            return;
        }
    }

    if (MyScrollText == None)
    {
        Warn("Could not initialize list!");
        return;
    }

    InitBaseList(MyScrollText);
}

function SetContent(string NewContent, optional string sep)
{
    MyScrollText.SetContent(NewContent, sep);
}

function Restart()
{
    MyScrollText.Restart();
}

function Stop()
{
    MyScrollText.Stop();
}

function InternalOnAdjustTop(GUIComponent Sender)
{
    MyScrollText.EndScrolling();

}

function bool IsNumber(string Num)
{
    if ( Num > Chr(47) && Num < Chr(58) )
        return true;

    return false;
}

function string StripColors(string MyString)
{
    local int EscapePos, RemCount, LenFromEscape;

    EscapePos = InStr(MyString, ESC); // Chr(3) == ^C
    while(EscapePos != -1)
    {
        LenFromEscape = Len(MyString) - (EscapePos + 1); // how far after the escape character the string goes on for

        // Now we have to work out how many characters follow the ^C and should be removed. This is rather unpleasant..!

        for (RemCount = 0; RemCount < LenFromEscape && RemCount < 7; RemCount++)
        {
            if ( Mid(MyString, EscapePos+RemCount, 1) == ESC ||
                IsNumber(Mid(MyString, EscapePos + RemCount, 1)) ||
                Mid(MyString, EscapePos + RemCount, 1) == COMMA )
                RemCount++;
            else break;
        }
/*      RemCount = 1; // strip the ctrl-C regardless
        if( LenFromEscape >= 1 && IsNumber(Mid(MyString, EscapePos+1, 1)) ) // If a digit follows the ctrl-C, strip that
        {
            RemCount = 2; // #
            if( LenFromEscape >= 3 && Mid(MyString, EscapePos+2, 1) == Chr(44) && IsNumber(Mid(MyString, EscapePos+3, 1)) ) // If we have a comma and another digit, strip those
            {
                RemCount = 4; // #,#
                if( LenFromEscape >= 4 && IsNumber(Mid(MyString, EscapePos+4, 1)) ) // if there is another digit after that, strip it
                    RemCount = 5; // #,##
            }
            else if( LenFromEscape >= 2 && IsNumber(Mid(MyString, EscapePos+2, 1)) )// if there is a second digit, strip that
            {
                RemCount = 3; // ##
                if( LenFromEscape >= 4 && Mid(MyString, EscapePos+3, 1) == Chr(44) && IsNumber(Mid(MyString, EscapePos+4, 1)) ) // If we have a comma and another digit, strip those
                {
                    RemCount = 5; // ##,#
                    if( LenFromEscape >= 5 && IsNumber(Mid(MyString, EscapePos+5, 1)) ) // if there is another digit after that, strip it
                        RemCount = 6; // ##,##
                }
            }
        }
*/
        MyString = Left(MyString, EscapePos)$Mid(MyString, EscapePos+RemCount);

        EscapePos = InStr(MyString, Chr(3));
    }

    return MyString;
}

function AddText(string NewText)
{
    local string StrippedText;

    if(NewText == "")
        return;

    if(bStripColors)
        StrippedText = StripColors(NewText);
    else
        StrippedText = NewText;

    if ( MyScrollText.NewText != "" )
        MyScrollText.NewText $= MyScrollText.Separator;

    MyScrollText.NewText $= StrippedText;
}

defaultproperties
{
     CharDelay=0.250000
     EOLDelay=0.750000
     RepeatDelay=3.000000
     Separator="|"
     DefaultListClass="XInterface.GUIScrollText"
     FontScale=FNS_Medium
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 30.3.2007 08:43:46.000 - Creation time: Mo 16.4.2007 11:20:48.109 - Created with UnCodeX