using Audio; internal class XUiC_ResetQuestsPopupRebirth : XUiController { public XUiV_Label Label; public XUiV_Panel Panel; public override void Init() { //Log.Out("XUiC_ResetQuestsPopupRebirth-Init START"); base.Init(); Panel = (XUiV_Panel)GetChildById("Popup").ViewComponent; ((XUiC_SimpleButton)Panel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancel_OnPressed; ((XUiC_SimpleButton)Panel.Controller.GetChildById("btnConfirm")).OnPressed += BtnConfirm_OnPressed; Label = (XUiV_Label)Panel.Controller.GetChildById("Label").ViewComponent; //Log.Out("XUiC_ResetQuestsPopupRebirth-Init END"); } public override void OnOpen() { //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen START"); EntityPlayer player = xui.playerUI.entityPlayer; var entityID = 0; if (player.Buffs.HasCustomVar("CurrentNPC")) { //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 1"); entityID = (int)player.Buffs.GetCustomVar("CurrentNPC"); } if (entityID == 0) { //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 2"); return; } EntityTrader myEntity = player.world.GetEntity(entityID) as EntityTrader; float numQuestCompletionTier = 0; if (player.Buffs.HasCustomVar("$varFuriousRamsayQuestCompletionTier")) { //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 3"); numQuestCompletionTier = player.Buffs.GetCustomVar("$varFuriousRamsayQuestCompletionTier"); } int numPrice = 100 + ((int)numQuestCompletionTier * 100); if (numPrice > 500) { //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 4"); numPrice = 500; } if (myEntity != null) { Label.Text = "Pay " + numPrice + " cash to reset the Quests?"; //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen RESPONDANT: " + myEntity.EntityName); } else { //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen NO RESPONDANT"); } base.OnOpen(); //Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen END"); } private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed START"); EntityPlayer player = xui.playerUI.entityPlayer; var entityID = 0; if (player.Buffs.HasCustomVar("CurrentNPC")) entityID = (int)player.Buffs.GetCustomVar("CurrentNPC"); if (entityID == 0) return; EntityTrader myEntity = player.world.GetEntity(entityID) as EntityTrader; //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed RESPONDANT: " + myEntity.EntityName); if (myEntity != null) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 1"); float numQuestCompletionTier = 0; if (player.Buffs.HasCustomVar("$varFuriousRamsayQuestCompletionTier")) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 2"); numQuestCompletionTier = player.Buffs.GetCustomVar("$varFuriousRamsayQuestCompletionTier"); } int numPrice = 100 + ((int)numQuestCompletionTier * 100); ItemValue item = ItemClass.GetItem("casinoCoin", false); ItemClass itemClass = item.ItemClass; if (itemClass != null) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 3"); int itemCount = player.bag.GetItemCount(item, -1, -1, false); int itemCount2 = player.inventory.GetItemCount(item, false, -1, -1); if (itemCount + itemCount2 > 0) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 4"); if (itemCount2 > 0) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 5"); player.inventory.DecItem(item, 1, false); } else { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 6"); player.bag.DecItem(item, 1, false); } if (myEntity is EntityTrader) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 7"); myEntity.ClearActiveQuests(player.entityId); } } else { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 8"); var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal); Manager.PlayInsidePlayerHead("misc/missingitemtorepair"); GameManager.ShowTooltip(uiforPlayer.entityPlayer, Localization.Get("ttMissingCash")); ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0); uiforPlayer.entityPlayer.AddUIHarvestingItem(@is, true); } } } else { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 9"); } xui.playerUI.windowManager.Close(windowGroup.ID); //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed END"); } private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton) { //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnCancel_OnPressed START"); Panel.IsVisible = false; xui.playerUI.windowManager.Close(windowGroup.ID); //Log.Out("XUiC_ResetQuestsPopupRebirth-BtnCancel_OnPressed END"); } public override void OnClose() { //Log.Out("XUiC_ResetQuestsPopupRebirth-OnClose START"); if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog")) xui.playerUI.windowManager.Close("dialog"); base.OnClose(); //Log.Out("XUiC_ResetQuestsPopupRebirth-OnClose END"); } }