Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 00665 |
//============================================================================== // Created on: 08/29/2003 // This panel contains in-game voice chat controls, such as banning controls, etc. // // Written by Ron Prestenback // © 2003, Epic Games, Inc. All Rights Reserved // TODO: Allow players to restrict speech based on type (taunt, order, etc.) //============================================================================== class UT2K4Tab_MidGameVoiceChat extends MidGamePanel; struct ChatItem { var int PlayerID; var bool bNoText; var bool bNoSpeech; var bool bNoVoice; var bool bBanned; var bool bDirty; }; var array<ChatItem> ChatList; var automated GUISectionBackground sb_Players, sb_Specs, sb_Options; var automated GUIListBox lb_Players, lb_Specs; var automated GUIList li_Players, li_Specs; var automated moCheckbox ch_NoVoiceChat, ch_NoSpeech, ch_NoText, ch_Ban; var automated GUIButton b_Reset; var() int SelectIndex; var() localized string ApplySuccessText, ApplyFailText; var() editconst bool bTeamGame; var int RedTeamIndex, BlueTeamIndex; var localized string RedTeamDesc, BlueTeamDesc; function GameReplicationInfo GRI() { return PlayerOwner().GameReplicationInfo; } function InitComponent(GUIController MyController, GUIComponent MyOwner) { Super.InitComponent(MyController, MyOwner); // Tie lists together with buttons li_Players = lb_Players.List; li_Specs = lb_Specs.List; li_Players.bInitializeList = false; li_Specs.bInitializeList = false; sb_Players.ManageComponent( lb_Players ); sb_Specs.ManageComponent( lb_Specs ); sb_Options.ManageComponent( ch_NoText ); sb_Options.ManageComponent( ch_NoSpeech ); sb_Options.ManageComponent( ch_NoVoiceChat ); sb_Options.ManageComponent( ch_Ban ); AssociateButtons(); } function ShowPanel( bool bShow ) { Super.ShowPanel(bShow); if ( !bShow ) { ClearIndexes(None); SaveRestrictions(); } } event Closed( GUIComponent Sender, bool bCancelled ) { SaveRestrictions(); Super.Closed(Sender,bCancelled); } // ===================================================================================================================== // ===================================================================================================================== // GUI Interface // ===================================================================================================================== // ===================================================================================================================== function bool PreDraw(Canvas Canvas) { if ( GRI() != None ) { bTeamGame = GRI().bTeamGame; FillPlayerLists(); } return false; } function bool InternalOnClick(GUIComponent Sender) { if ( Sender == b_Reset ) { ResetRestrictions(); ChatList.Remove(0,ChatList.Length); } UpdateButtonStates(); return true; } // Called when an player's name is clicked on function ListChange( GUIComponent Sender ) { local int ID; local GUIList List; List = GUIListBox(Sender).List; if ( List == None ) return; ClearIndexes( List ); // grab the associated PlayerID from the selected player id = int(List.GetExtra()); if ( PlayerIDIsMine(id) ) { SelectedSelf(); return; } SelectIndex = FindChatListIndex(id); LoadRestrictions(SelectIndex); } function InternalOnChange(GUIComponent Sender) { local bool bResult; if ( !ValidIndex(SelectIndex) ) return; bResult = moCheckbox(Sender).IsChecked(); ChatList[SelectIndex].bDirty = true; switch (Sender) { case ch_NoText: ChatList[SelectIndex].bNoText = bResult; break; case ch_NoSpeech: ChatList[SelectIndex].bNoSpeech = bResult; break; case ch_NoVoiceChat: ChatList[SelectIndex].bNoVoice = bResult; break; case ch_Ban: ChatList[SelectIndex].bBanned = bResult; break; } if ( ChatList[SelectIndex].bDirty && ApplyRestriction(SelectIndex) ) { ModifiedChatRestriction(Self, ChatList[SelectIndex].PlayerID); ChatList[SelectIndex].bDirty = False; } UpdateButtonStates(); } // ===================================================================================================================== // ===================================================================================================================== // Implementation // ===================================================================================================================== // ===================================================================================================================== // Get a list of all players, and put them into the appropriate list function FillPlayerLists() { local string idx; if ( GRI() == None ) return; // if an item was selected, remember the selected PlayerID while we clear and refill the lists if ( li_Players.IsValid() ) idx = li_Players.GetExtra(); else if ( li_Specs.IsValid() ) idx = ""; // Disable all list notification while we're clearing and refilling the lists li_Players.bNotify = false; li_Specs.bNotify = false; ClearLists(); PopulateLists( GRI() ); // if we had a PlayerID selected, attempt to reselect that PlayerID in any list if ( idx != "" ) { if ( li_Players.Find(idx,false,true) != "" ) { if ( !PlayerIDIsMine(idx) ) li_Players.CheckLinkedObjects(li_Players); } else if ( li_Specs.Find(idx,false,true) != "" ) { if ( !PlayerIDIsMine(idx) ) li_Specs.CheckLinkedObjects(li_Specs); } } li_Players.bNotify = true; li_Specs.bNotify = true; } function PopulateLists(GameReplicationInfo GRI) { local int i; local PlayerReplicationInfo PRI; if (bTeamGame) { li_Players.Add(RedTeamDesc,,,true); li_Players.Add(BlueTeamDesc,,,True); BlueTeamIndex=1; } for ( i = 0; i < GRI.PRIArray.Length; i++ ) { PRI = GRI.PRIArray[i]; if ( PRI == None || PRI.bBot || xPlayerReplicationInfo(PRI) == none || (bTeamGame && PRI.Team==None && !PRI.bOnlySpectator) ) continue; // If this is the first time seeing this playerid, request the ban/ignore info from our ChatManager if ( FindChatListIndex(PRI.PlayerID) == -1 ) AddPlayerInfo(PRI.PlayerID); if ( PRI.bOnlySpectator ) li_Specs.Add(PRI.PlayerName,,string(PRI.PlayerID)); else AddtoPlayers(PRI); } } function AddToPlayers(PlayerReplicationInfo PRI) { if (bTeamGame ) { if ( PRI.Team.TeamIndex==0 ) // Red Team { if ( RedTeamIndex == -1 ) { li_Players.Add(RedTeamDesc,,,true); RedTeamIndex = 0; } if ( BlueTeamIndex < 0 ) li_Players.Add(PRI.PlayerName,,string(PRI.PlayerID)); else { li_Players.Insert(BlueTeamIndex,PRI.PlayerName,,string(PRI.PlayerID)); BlueTeamIndex++; } } else { if ( BlueTeamIndex == -1 ) { BlueTeamIndex = li_Players.ItemCount; li_Players.Add(BlueTeamDesc,,,true); } li_Players.Add(PRI.PlayerName,,string(PRI.PlayerID)); } } else li_Players.Add( PRI.PlayerName,,string(PRI.PlayerID) ); } // When a list item is selected, clear the indexes of the other lists function ClearIndexes( GUIList List ) { if ( List != li_Players) li_Players.SilentSetIndex(-1); if ( List != li_Specs ) li_Specs.SilentSetIndex(-1); if ( List == None ) SelectedSelf(); } // ===================================================================================================================== // ===================================================================================================================== // Chat Manager Interface // ===================================================================================================================== // ===================================================================================================================== // Set the checkboxes to the values associated with the given player function LoadRestrictions(int i) { if ( !ValidIndex(i) ) { ch_NoText.SetComponentValue(False, True); ch_NoSpeech.SetComponentValue(False, True); ch_NoVoiceChat.SetComponentValue(False, True); ch_Ban.SetComponentValue(False, True); } else { ch_NoText.SetComponentValue(ChatList[i].bNoText, True); ch_NoSpeech.SetComponentValue(ChatList[i].bNoSpeech, True); ch_NoVoiceChat.SetComponentValue(ChatList[i].bNoVoice, True); ch_Ban.SetComponentValue(ChatList[i].bBanned, True); } UpdateButtonStates(); } // Called when a new playerID is found while filling the lists // Request stored chat restrictions for this PlayerID from the ChatManager function int AddPlayerInfo(int PlayerID) { local int i; local PlayerController PC; local byte Restriction; PC = PlayerOwner(); if ( PC.ChatManager == None ) return -1; // Verify that we don't already have this player ID in the list i = FindChatListIndex( PlayerID ); if ( i == -1 ) { i = ChatList.Length; ChatList.Length = i+1; } ChatList[i].PlayerID = PlayerID; // Query the ChatManager for the settings for this player Restriction = PC.ChatManager.GetPlayerRestriction(PlayerID); UnpackRestriction(i, Restriction); return i; } function PackRestriction(int i, out byte Restriction) { Restriction = 0; if ( ValidIndex(i) ) { if ( ChatList[i].bNoText ) Restriction = Restriction | 1; if ( ChatList[i].bNoSpeech ) Restriction = Restriction | 2; if ( ChatList[i].bNoVoice ) Restriction = Restriction | 4; if ( ChatList[i].bBanned ) Restriction = Restriction | 8; } } function UnpackRestriction(int i, byte Restriction) { if ( ValidIndex(i) ) { ChatList[i].bNoText = bool(Restriction & 1); ChatList[i].bNoSpeech = bool(Restriction & 2); ChatList[i].bNoVoice = bool(Restriction & 4); ChatList[i].bBanned = bool(Restriction & 8); Chatlist[i].bDirty = false; } } function bool ApplyRestriction(int i) { local byte Restriction; // Send restrictions to player's chat manager if ( ValidIndex(i) ) { PackRestriction(i, Restriction); return PlayerOwner().ChatBan(ChatList[i].PlayerID, Restriction); } return false; } function SaveRestrictions() { local int i; for ( i = 0; i < ChatList.Length; i++ ) { if ( Chatlist[i].bDirty && ApplyRestriction(i) ) { ModifiedChatRestriction(Self, Chatlist[i].PlayerID); Chatlist[i].bDirty = false; } } } function ResetRestrictions() { local int i; local byte Restriction; for ( i = 0; i < ChatList.Length; i++ ) { PackRestriction(i, Restriction); if ( Restriction != 0 ) PlayerOwner().ChatBan(ChatList[i].PlayerID, 0); } PlayerOwner().ChatManager.ClearConfig(); } function UpdateChatRestriction( int PlayerID ) { local int i; Super.UpdateChatRestriction(PlayerID); i = FindChatListIndex(PlayerID); if ( ValidIndex(i) ) UnpackRestriction( i, PlayerOwner().ChatManager.GetPlayerRestriction(PlayerID) ); UpdateButtonStates(); } // ===================================================================================================================== // ===================================================================================================================== // Utility / Helper functions // ===================================================================================================================== // ===================================================================================================================== function UpdateButtonStates() { local int i; local PlayerController PC; PC = PlayerOwner(); for ( i = 0; i < ChatList.Length; i++ ) { if ( Chatlist[i].bDirty ) { EnableComponent(b_Reset); return; } } if ( PC != None && PC.ChatManager != None && PC.ChatManager.Count() > 0 ) { EnableComponent(b_Reset); return; } DisableComponent(b_Reset); } function ClearLists() { if ( li_Players.ItemCount > 0 ) li_Players.Clear(); if ( li_Specs.ItemCount > 0 ) li_Specs.Clear(); } // Disable/enable these components based on whether or not a list has a valid index function AssociateButtons() { LinkList(li_Players); LinkList(li_Specs); } function LinkList( GUIList List ) { if ( List == None ) return; List.AddLinkObject( ch_NoVoiceChat ); List.AddLinkObject( ch_NoSpeech ); List.AddLinkObject( ch_NoText ); List.AddLinkObject( ch_Ban ); } function int FindChatListIndex(int PlayerID) { local int i; for ( i = 0; i < ChatList.Length; i++ ) if ( PlayerID == ChatList[i].PlayerID ) return i; return -1; } function bool ValidIndex(int i) { return i >= 0 && i < ChatList.Length; } function SelectedSelf() { ch_NoText.SetComponentValue(False, True); ch_NoSpeech.SetComponentValue(False, True); ch_NoVoiceChat.SetComponentValue(False, True); ch_Ban.SetComponentValue(False, True); DisableComponent(ch_NoText); DisableComponent(ch_NoSpeech); DisableComponent(ch_NoVoiceChat); DisableComponent(ch_Ban); } // ===================================================================================================================== // ===================================================================================================================== // Defaults // ===================================================================================================================== // ===================================================================================================================== defaultproperties { Begin Object Class=AltSectionBackground Name=PlayersBackground Caption="Players" LeftPadding=0.000000 RightPadding=0.000000 WinTop=0.030325 WinLeft=0.019250 WinWidth=0.462019 WinHeight=0.899506 bBoundToParent=Wahr bScaleToParent=Wahr OnPreDraw=PlayersBackground.InternalPreDraw End Object sb_Players=AltSectionBackground'GUI2K4.UT2K4Tab_MidGameVoiceChat.PlayersBackground' Begin Object Class=AltSectionBackground Name=SpecBackground Caption="Spectators" LeftPadding=0.000000 RightPadding=0.000000 WinTop=0.030325 WinLeft=0.512544 WinWidth=0.462019 WinHeight=0.468385 bBoundToParent=Wahr bScaleToParent=Wahr OnPreDraw=SpecBackground.InternalPreDraw End Object sb_Specs=AltSectionBackground'GUI2K4.UT2K4Tab_MidGameVoiceChat.SpecBackground' Begin Object Class=AltSectionBackground Name=OptionBackground Caption="Voice Options" TopPadding=0.040000 WinTop=0.508063 WinLeft=0.512544 WinWidth=0.462019 WinHeight=0.394391 bBoundToParent=Wahr bScaleToParent=Wahr OnPreDraw=OptionBackground.InternalPreDraw End Object sb_Options=AltSectionBackground'GUI2K4.UT2K4Tab_MidGameVoiceChat.OptionBackground' Begin Object Class=GUIListBox Name=PlayersList bInitializeList=Falsch OnCreateComponent=PlayersList.InternalOnCreateComponent WinTop=0.041667 WinLeft=0.056250 WinWidth=0.431250 WinHeight=0.518750 TabOrder=0 OnChange=UT2K4Tab_MidGameVoiceChat.ListChange End Object lb_Players=GUIListBox'GUI2K4.UT2K4Tab_MidGameVoiceChat.PlayersList' Begin Object Class=GUIListBox Name=SpecList bInitializeList=Falsch OnCreateComponent=SpecList.InternalOnCreateComponent WinTop=0.041667 WinLeft=0.531250 WinWidth=0.431250 WinHeight=0.518750 TabOrder=1 OnChange=UT2K4Tab_MidGameVoiceChat.ListChange End Object lb_Specs=GUIListBox'GUI2K4.UT2K4Tab_MidGameVoiceChat.SpecList' Begin Object Class=moCheckBox Name=NoVoiceChat Caption="Ignore Voice Chat" OnCreateComponent=NoVoiceChat.InternalOnCreateComponent Hint="Do not receive any voice chat messages from this player, in any voice chat room" WinTop=0.750178 WinLeft=0.647884 WinWidth=0.338524 WinHeight=0.049840 TabOrder=4 OnChange=UT2K4Tab_MidGameVoiceChat.InternalOnChange End Object ch_NoVoiceChat=moCheckBox'GUI2K4.UT2K4Tab_MidGameVoiceChat.NoVoiceChat' Begin Object Class=moCheckBox Name=NOSPEECH Caption="Ignore Speech" OnCreateComponent=NOSPEECH.InternalOnCreateComponent Hint="Do not receive any speech messages, such as "Incoming!" from this player" WinTop=0.685424 WinLeft=0.647884 WinWidth=0.338524 WinHeight=0.049840 TabOrder=3 OnChange=UT2K4Tab_MidGameVoiceChat.InternalOnChange End Object ch_NoSpeech=moCheckBox'GUI2K4.UT2K4Tab_MidGameVoiceChat.NOSPEECH' Begin Object Class=moCheckBox Name=NOTEXT Caption="Ignore Text" OnCreateComponent=NOTEXT.InternalOnCreateComponent Hint="Do not receive any text messages from this player" WinTop=0.620670 WinLeft=0.647884 WinWidth=0.338524 WinHeight=0.049840 TabOrder=2 OnChange=UT2K4Tab_MidGameVoiceChat.InternalOnChange End Object ch_NoText=moCheckBox'GUI2K4.UT2K4Tab_MidGameVoiceChat.NOTEXT' Begin Object Class=moCheckBox Name=BanPlayer Caption="Ban Player" OnCreateComponent=BanPlayer.InternalOnCreateComponent Hint="Ban this player from your personal voice chat channel" WinTop=0.814932 WinLeft=0.647884 WinWidth=0.338524 WinHeight=0.049840 TabOrder=5 OnChange=UT2K4Tab_MidGameVoiceChat.InternalOnChange End Object ch_Ban=moCheckBox'GUI2K4.UT2K4Tab_MidGameVoiceChat.BanPlayer' Begin Object Class=GUIButton Name=ResetButton Caption="Reset" Hint="Reset & reload all player chat restrictions" WinTop=0.899668 WinLeft=0.682745 WinWidth=0.120067 WinHeight=0.051836 TabOrder=7 bStandardized=Wahr OnClick=UT2K4Tab_MidGameVoiceChat.InternalOnClick OnKeyEvent=ResetButton.InternalOnKeyEvent End Object b_Reset=GUIButton'GUI2K4.UT2K4Tab_MidGameVoiceChat.ResetButton' ApplySuccessText="Changes were saved successfully!" ApplyFailText="Changes could not be saved!" RedTeamIndex=-1 BlueTeamIndex=-1 RedTeamDesc="RED TEAM" BlueTeamDesc="BLUE TEAM" OnPreDraw=UT2K4Tab_MidGameVoiceChat.PreDraw } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |