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

GUI2K4.ID3TagEditor


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
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
//==============================================================================
//	Created on: 10/21/2003
//	A small menu for viewing/editing ID3 v1/v2 tags
//
//	Written by Ron Prestenback
//	© 2003, Epic Games, Inc.  All Rights Reserved
//==============================================================================
class ID3TagEditor extends FloatingWindow;

var automated GUIPanel  p_Main;

var StreamInterface   FileManager;
var StreamInteraction Handler;

var GUIMultiOptionListBox  lb_Fields;
var GUIMultiOptionList     li_Fields;
var array<AnimatedEditbox> ed_Fields;

var string FileName;
var Stream Stream;
var StreamTag ID3Tag;

var localized string EditBoxHint;

function InitComponent( GUIController MyController, GUIComponent MyOwner )
{
    Super.InitComponent(MyController, MyOwner);
    p_Main.OnCreateComponent = InternalOnCreateComponent;
    p_Main.AppendComponent(lb_Fields);

    li_Fields = lb_Fields.List;
    li_Fields.OnCreateComponent = ListCreateComponent;
    li_Fields.bDrawSelectionBorder = False;

    SetFileManager();
}

event Closed(GUIComponent Sender, bool bCancelled )
{
    Super.Closed(Sender, bCancelled);

    Stream.SaveID3Tag();
}

function bool SetFileManager()
{
    if ( FileManager != None )
    {
        if ( Handler == None && !SetHandler() )
            return false;

        return true;
    }

    if ( Handler == None && !SetHandler() )
        return false;

    FileManager = Handler.FileManager;
    return FileManager != None;
}

function bool SetHandler()
{
    local int i;

    if ( Controller == None || Controller.ViewportOwner == None )
        return false;

    for ( i = 0; i < Controller.ViewportOwner.LocalInteractions.Length; i++ )
    {
        if ( StreamInteraction(Controller.ViewportOwner.LocalInteractions[i]) != None )
        {
            Handler = StreamInteraction(Controller.ViewportOwner.LocalInteractions[i]);
            return true;
        }
    }


    log("StreamPlayer.SetHandler() - no StreamInteractions found!",'MusicPlayer');
    return false;
}

function HandleObject( Object Obj, optional Object OptionalObject_1, optional Object OptionalObj_2 )
{
    // REMOVE ME
    Assert(FileName != "");

    if ( Obj != None )
        Stream = Stream(Obj);

    if ( Stream == None )
        Stream = FileManager.CreateStream(FileName);

    if ( Stream != None )
        ID3Tag = Stream.GetTag();

    ReadTag();
}

function HandleParameters( string ParamA, string ParamB )
{
    Filename = ParamA;
}

function InternalOnChange(GUIComponent Sender)
{
    local int i, idx;
    local GUIMenuOption mo;

//	log(Name@"InternalOnChange Sender:"$Sender);
    if ( GUIMultiOptionList(Sender) != None )
    {
        mo = li_Fields.Get();
        if ( mo == None )
        {
            warn("mo was None"); // FIXME
            return;
        }
        idx = FindFieldIndex( mo.Caption );
        if ( i != -1 )
            ID3Tag.Fields[i].FieldValue = mo.GetComponentValue();
    }
}

function int FindFieldIndex( string Caption )
{
    local int i;

    for ( i = 0; i < ID3Tag.Fields.Length; i++ )
    {
        if ( ID3Tag.Fields[i].FieldName == Caption )
            return i;
    }

    return -1;
}

function ReadTag()
{
    local int i;
    local AnimatedEditBox box;

    if ( ID3Tag == None )
        return;

    for ( i = 0; i < ID3Tag.Fields.Length; i++ )
    {
        box = AnimatedEditBox( li_Fields.AddItem("GUI2K4.AnimatedEditBox", None, ID3Tag.Fields[i].FieldName) );
        box.SetComponentValue( ID3Tag.Fields[i].FieldValue, True );
    }
}
/*
function InternalOnCreateComponent( GUIComponent NewComp, GUIComponent Sender )
{
    if ( GUILabel(NewComp) != None )
    {
        NewComp.StyleName = "TextLabel";
        NewComp.bScaleToParent=True;
        NewComp.bBoundToParent=True;
        NewComp.ScalingType=SCALE_X;
    }

    if ( AnimatedEditBox(NewComp) != None )
    {
        NewComp.OnChange = InternalOnChange;
        AnimatedEditBox(NewComp).LabelStyleName = "TextLabel";
        NewComp.Hint = EditBoxHint;
        NewComp.bScaleToParent=True;
        NewComp.bBoundToParent=True;
        NewComp.ScalingType=SCALE_X;
    }

}
*/

function SetPanelPosition(Canvas C)
{
    local float AT;

    AT = t_WindowTitle.ActualTop() + t_WindowTitle.ActualHeight() + 2;
    p_Main.WinTop = p_Main.RelativeTop( AT );
    p_Main.WinHeight = p_Main.RelativeHeight( (Bounds[3] - ActualHeight(0.015)) - AT );
}

function ListCreateComponent(GUIMenuOption NewComp, GUIMultiOptionList Sender)
{
    NewComp.bAutoSizeCaption = False;
}

defaultproperties
{
     Begin Object Class=GUIPanel Name=MainPanel
         WinTop=0.091595
         WinLeft=0.011250
         WinWidth=0.978750
         WinHeight=0.896250
         RenderWeight=0.200000
     End Object
     p_Main=GUIPanel'GUI2K4.ID3TagEditor.MainPanel'

     Begin Object Class=GUIMultiOptionListBox Name=FieldList
         bVisibleWhenEmpty=True
         OnCreateComponent=FieldList.InternalOnCreateComponent
         WinHeight=1.000000
         bBoundToParent=True
         bScaleToParent=True
     End Object
     lb_Fields=GUIMultiOptionListBox'GUI2K4.ID3TagEditor.FieldList'

     EditBoxHint="Click to edit"
     WindowName="Tag Editor"
     MinPageWidth=0.458984
     MinPageHeight=0.330155
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Tue 24/10/2006 17:13:18.000 - Creation time: Wed 7/2/2007 19:16:42.015 - Created with UnCodeX