KF2-Server-Extension/ServerExt/Classes/UI_UnloadInfo.uc
2020-06-26 09:32:40 +03:00

109 lines
2.7 KiB
Ucode

Class UI_UnloadInfo extends KFGUI_FloatingWindow;
var class<Ext_PerkBase> PerkToReset;
var KFGUI_Button YesButten;
var KFGUI_TextField InfoLabel;
var byte CurCallCode;
function InitMenu()
{
YesButten = KFGUI_Button(FindComponentID('Yes'));
InfoLabel = KFGUI_TextField(FindComponentID('Info'));
Super.InitMenu();
}
final function SetupTo( class<Ext_PerkBase> P )
{
PerkToReset = P;
WindowTitle = "NOTICE: Unload stats for "$P.Default.PerkName; // TODO: localize
YesButten.SetDisabled(true);
InfoLabel.SetText("Please wait..."); // TODO: localize
++CurCallCode;
ExtPlayerController(GetPlayer()).OnClientGetResponse = ReceivedInfo;
ExtPlayerController(GetPlayer()).ServerGetUnloadInfo(CurCallCode,PerkToReset,false);
}
function ButtonClicked( KFGUI_Button Sender )
{
switch( Sender.ID )
{
case 'Yes':
ExtPlayerController(GetPlayer()).ServerGetUnloadInfo(0,PerkToReset,true);
DoClose();
break;
case 'No':
DoClose();
break;
}
}
function CloseMenu()
{
Super.CloseMenu();
PerkToReset = None;
ExtPlayerController(GetPlayer()).OnClientGetResponse = ExtPlayerController(GetPlayer()).DefClientResponse;
}
function ReceivedInfo( byte CallID, byte Code, int DataA, int DataB )
{
if( CurCallCode!=CallID )
return;
// TODO: localize
switch( Code )
{
case 0:
InfoLabel.SetText("ERROR: Perk unloading is disabled on this server!");
break;
case 1:
InfoLabel.SetText("ERROR: You need to be at least on level #{FFFF00}"$DataA$"#{DEF} before you can use this feature!");
break;
case 2:
InfoLabel.SetText("#{FF0000}WARNING:#{DEF} By using this feature you will lose #{FFFF00}"$DataA$"#{DEF} XP points, and by that you will drop down #{FF0000}"$DataB$"#{DEF} levels!|In addition you will be forced to suicide to reset specific stats.||Are you sure you want to continue?");
YesButten.SetDisabled(false);
break;
}
}
defaultproperties
{
XPosition=0.35
YPosition=0.2
XSize=0.3
YSize=0.45
bAlwaysTop=true
bOnlyThisFocus=true
Begin Object Class=KFGUI_TextField Name=WarningLabel
ID="Info"
XPosition=0.01
YPosition=0.12
XSize=0.98
YSize=0.775
End Object
// TODO: localize
Begin Object Class=KFGUI_Button Name=YesButten
ID="Yes"
ButtonText="YES"
Tooltip="Reset the perk (you can not undo this action!)"
XPosition=0.2
YPosition=0.9
XSize=0.29
YSize=0.07
ExtravDir=1
OnClickLeft=ButtonClicked
OnClickRight=ButtonClicked
End Object
Begin Object Class=KFGUI_Button Name=NoButten
ID="No"
ButtonText="ABORT"
Tooltip="Abort without doing anything"
XPosition=0.5
YPosition=0.9
XSize=0.29
YSize=0.07
OnClickLeft=ButtonClicked
OnClickRight=ButtonClicked
End Object
Components.Add(WarningLabel)
Components.Add(YesButten)
Components.Add(NoButten)
}