public class XUiC_QuestOfferWindowRebirth : XUiC_QuestOfferWindow { public Quest quest; public XUiV_Sprite prefabPreview; public XUiV_Label Label; public XUiV_Label LabelNumToGo; public XUiV_Panel Panel; public XUiV_Panel PanelHeader; public XUiV_Label LabelBiome; public int windowX = 0; public int windowY = 0; private XUiController btnAccept; private XUiController btnDecline; private XUiV_Button btnAccept_Background; private XUiV_Button btnDecline_Background; private bool btnAcceptHovered; private bool btnDeclineHovered; private bool questAccepted; private Action OnCancel; public override void Init() { if (this.viewComponent != null) { this.viewComponent.InitView(); } for (int i = 0; i < this.children.Count; i++) { this.children[i].Init(); } this.btnAccept = base.GetChildById("btnAccept"); this.btnAccept_Background = (XUiV_Button)this.btnAccept.GetChildById("clickable").ViewComponent; this.btnAccept_Background.Controller.OnPress += this.btnAccept_OnPress; this.btnAccept_Background.Controller.OnHover += this.btnAccept_OnHover; this.btnDecline = base.GetChildById("btnDecline"); this.btnDecline_Background = (XUiV_Button)this.btnDecline.GetChildById("clickable").ViewComponent; this.btnDecline_Background.Controller.OnPress += this.btnDecline_OnPress; this.btnDecline_Background.Controller.OnHover += this.btnDecline_OnHover; //prefabPreview = base.GetChildById("poiPreview").ViewComponent as XUiV_Texture; this.prefabPreview = (XUiV_Sprite)GetChildById("previewImage").ViewComponent; Panel = (XUiV_Panel)GetChildById("content").ViewComponent; Label = (XUiV_Label)Panel.Controller.GetChildById("descriptionText").ViewComponent; PanelHeader = (XUiV_Panel)GetChildById("header").ViewComponent; LabelNumToGo = (XUiV_Label)PanelHeader.Controller.GetChildById("numToGo").ViewComponent; } private void btnAccept_OnHover(XUiController _sender, bool _isOver) { this.btnAcceptHovered = _isOver; base.RefreshBindings(false); } private void btnDecline_OnHover(XUiController _sender, bool _isOver) { this.btnDeclineHovered = _isOver; base.RefreshBindings(false); } private void btnAccept_OnPress(XUiController _sender, int _mouseButton) { Quest quest = this.Quest; quest.QuestGiverID = this.QuestGiverID; if (this.OfferType == XUiC_QuestOfferWindow.OfferTypes.Item) { ItemStack itemStack = this.ItemStackController.ItemStack; if (itemStack.count > 1) { itemStack.count--; this.ItemStackController.ForceSetItemStack(itemStack.Clone()); this.ItemStackController.WindowGroup.Controller.SetAllChildrenDirty(false); } else { this.ItemStackController.ItemStack = ItemStack.Empty.Clone(); this.ItemStackController.WindowGroup.Controller.SetAllChildrenDirty(false); } } if (this.QuestGiverID != -1) { base.xui.Dialog.Respondent.PlayVoiceSetEntry("questaccepted", base.xui.playerUI.entityPlayer, true, true); } this.questAccepted = true; base.xui.playerUI.windowManager.Close(base.WindowGroup.ID); base.xui.playerUI.entityPlayer.QuestJournal.AddQuest(quest); } private void btnDecline_OnPress(XUiController _sender, int _mouseButton) { EntityNPC respondent = base.xui.Dialog.Respondent; if (this.QuestGiverID != -1) { base.xui.Dialog.Respondent.PlayVoiceSetEntry("questdeclined", base.xui.playerUI.entityPlayer, true, true); } base.xui.playerUI.windowManager.Close(base.WindowGroup.ID); if (this.OnCancel != null) { this.OnCancel(respondent); } } public override bool GetBindingValue(ref string value, string bindingName) { if (bindingName != null) { if (bindingName == "questname") { string biome = ""; if (this.Quest != null && !GameUtils.IsPlaytesting()) { Vector3 QuestLocation = this.Quest.GetLocation(); string biomeName = RebirthUtilities.GetBiomeName(QuestLocation); if (biomeName == "wasteland") { biome = "[bd5959]" + Localization.Get("xuiWasteland") + "[-]"; } else if (biomeName == "desert") { biome = "[bfbc5a]" + Localization.Get("xuiDesert") + "[-]"; } else if (biomeName == "forest" || biomeName == "pine_forest") { biome = "[5fb056]" + Localization.Get("xuiPineForest") + "[-]"; } else if (biomeName == "burnt_forest") { biome = "[bf9b5c]" + Localization.Get("xuiBurntForest") + "[-]"; } else if (biomeName == "snow") { biome = "[bf9b5c]" + Localization.Get("xuiSnow") + "[-]"; } } value = ((this.Quest != null) ? this.Quest.GetParsedText(this.Quest.QuestClass.Name) : ""); if (biome.Trim().Length > 0) { value = value + " (" + biome.Trim() + ")"; } return true; } else if (bindingName == "questicon") { value = ((this.Quest != null) ? this.Quest.QuestClass.Icon : ""); return true; } else if (bindingName == "questoffer") { value = ((this.Quest != null) ? this.Quest.GetParsedText(this.Quest.QuestClass.Offer) : ""); return true; } else if (bindingName == "questdifficulty") { value = ((this.Quest != null) ? this.Quest.QuestClass.Difficulty : ""); return true; } else if (bindingName == "windowX") { value = this.windowX.ToString(); return true; } else if (bindingName == "windowY") { value = this.windowY.ToString(); return true; } } return false; } public override void OnOpen() { base.OnOpen(); string strPrefabName = ""; if (this.Quest.QuestPrefab != null) { strPrefabName = base.Quest.QuestPrefab.name; } //strPrefabName = base.Quest.QuestPrefab.name; // base.Quest.GetPOIName(); string[] parts = strPrefabName.Split('.'); strPrefabName = parts[0]; string strQuestTags = base.Quest.QuestTags.ToString(); int questType = 0; Entity entity = GameManager.Instance.World.GetEntity(Quest.QuestGiverID); EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer(); if (entity is EntityTrader) { EntityTrader entityTrader = (EntityTrader)entity; //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen entityTrader.EntityName: " + entityTrader.EntityName); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen entityTrader.EntityClass.entityClassName: " + entityTrader.EntityClass.entityClassName); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen entityTrader.NPCInfo.QuestFaction: " + entityTrader.NPCInfo.QuestFaction); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestsPerTier: " + Quest.QuestsPerTier); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestFactionPoints: " + GameManager.Instance.World.GetPrimaryPlayer().QuestJournal.QuestFactionPoints); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.GetCurrentFactionTier: " + GameManager.Instance.World.GetPrimaryPlayer().QuestJournal.GetCurrentFactionTier(entityTrader.NPCInfo.QuestFaction)); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen GetQuestFactionPoints: " + GameManager.Instance.World.GetPrimaryPlayer().QuestJournal.GetQuestFactionPoints(entityTrader.NPCInfo.QuestFaction)); int jobsToNextTier = RebirthVariables.customJobsToNextTier; int numQuests = jobsToNextTier; // Quest.QuestsPerTier; int questPoints = 0; int questTier = 0; if (primaryPlayer != null) { questPoints = primaryPlayer.QuestJournal.GetQuestFactionPoints(entityTrader.NPCInfo.QuestFaction); questTier = primaryPlayer.QuestJournal.GetCurrentFactionTier(entityTrader.NPCInfo.QuestFaction); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen questPoints: " + questPoints); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen questTier: " + questTier); int tierPoints = 0; for (int i = 1; i <= questTier; i++) { tierPoints = tierPoints + (i * numQuests); } int pointsLeft = tierPoints - questPoints; int jobsLeft = pointsLeft / questTier; int numPointsLeft = tierPoints - pointsLeft; if (pointsLeft > 0 && pointsLeft < questTier) { jobsLeft = 1; } //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen pointsLeft: " + pointsLeft); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen tierPoints: " + tierPoints); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen jobsLeft: " + jobsLeft); if (questTier < 6) { LabelNumToGo.Text = "[cf8080]" + (int)jobsLeft + "[-] " + Localization.Get("ttTier") + " [d4d483]" + questTier + "[-] " + Localization.Get("ttJobsLeft") + " [8dc987]" + (questTier + 1) + "[-]"; } } } //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.ID: " + base.Quest.ID); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestClass.Name: " + base.Quest.QuestClass.Name); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestClass.ID: " + base.Quest.QuestClass.ID); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestClass.QuestType: " + base.Quest.QuestClass.QuestType); for (int i = 0; i < base.Quest.Objectives.Count; i++) { /*//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen ToString(): " + base.Quest.Objectives[i].ToString()); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen ObjectiveValueType: " + base.Quest.Objectives[i].ObjectiveValueType); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Value: " + base.Quest.Objectives[i].Value); //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen ID: " + base.Quest.Objectives[i].ID);*/ if (base.Quest.Objectives[i].ToString() == "ObjectiveTreasureChest") { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 1"); questType = 1; strPrefabName = "buried_supplies"; } } if (base.Quest.ID.ToLower().Contains("challenge_furiousramsaystarter")) { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 1a"); questType = 2; strPrefabName = base.Quest.ID.ToLower(); } else if (base.Quest.ID.ToLower().Contains("contraband_collection")) { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 1a2"); questType = 3; strPrefabName = "ContrabandCollection"; } Vector2i labelSize = new Vector2i(990, 710); Label.Size = labelSize; string ModsBasePath = GameIO.GetUserGameDataDir() + "/Mods"; string ModsBasePathLegacy = Application.platform != UnityEngine.RuntimePlatform.OSXPlayer ? (Application.dataPath + "/../Mods") : (Application.dataPath + "/../../Mods"); string prefabImagePath = ""; if (Directory.Exists(ModsBasePathLegacy + "/zzz_REBIRTH__Utils")) { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 3"); if (questType == 1) { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 4"); prefabImagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/buried_supplies.jpg"; } else if (questType == 3) { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 4a"); prefabImagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/ContrabandCollection.jpg"; } else { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 6"); prefabImagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/" + strPrefabName + ".jpg"; } } else { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 7"); if (questType == 1) { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 8"); prefabImagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/buried_supplies.jpg"; } else if (questType == 3) { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 8a"); prefabImagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/ContrabandCollection.jpg"; } else { //Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 9"); prefabImagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/" + strPrefabName + ".jpg"; } } if (primaryPlayer != null) { this.windowX = 6; this.windowY = -350; } prefabPreview.SpriteName = strPrefabName; if (!File.Exists(prefabImagePath)) { this.windowX = 6; this.windowY = -10; } else { labelSize = new Vector2i(998, 440); Label.Size = labelSize; } } }