Exemplo n.º 1
0
        public void DrawQuestDetails(SpriteBatch b, SpecialOrder order, int x)
        {
            bool dehighlight = false;
            bool found_match = false;

            foreach (SpecialOrder active_order in Game1.player.team.specialOrders)
            {
                if (active_order.questState.Value == SpecialOrder.QuestState.InProgress)
                {
                    foreach (SpecialOrder available_order in Game1.player.team.availableSpecialOrders)
                    {
                        if (!(available_order.orderType.Value != GetOrderType()) && active_order.questKey.Value == available_order.questKey.Value)
                        {
                            if (order.questKey != active_order.questKey)
                            {
                                dehighlight = true;
                            }
                            found_match = true;
                            break;
                        }
                    }
                    if (found_match)
                    {
                        break;
                    }
                }
            }
            if (!found_match && Game1.player.team.acceptedSpecialOrderTypes.Contains(GetOrderType()))
            {
                dehighlight = true;
            }
            SpriteFont font             = (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ko) ? Game1.smallFont : Game1.dialogueFont;
            Color      font_color       = Game1.textColor;
            float      shadow_intensity = 0.5f;
            float      graphic_alpha    = 1f;

            if (dehighlight)
            {
                font_color       = Game1.textColor * 0.25f;
                shadow_intensity = 0f;
                graphic_alpha    = 0.25f;
            }
            if (boardType == "Qi")
            {
                font_color       = Color.White;
                shadow_intensity = 0f;
                if (dehighlight)
                {
                    font_color    = Color.White * 0.25f;
                    graphic_alpha = 0.25f;
                }
            }
            int    header_y   = yPositionOnScreen + 128;
            string order_name = order.GetName();
            KeyValuePair <Texture2D, Rectangle>?drawn_portrait = GetPortraitForRequester(order.requester.Value);

            if (drawn_portrait.HasValue)
            {
                Utility.drawWithShadow(b, drawn_portrait.Value.Key, new Vector2(x, header_y), drawn_portrait.Value.Value, Color.White * graphic_alpha, 0f, Vector2.Zero, 4f, flipped: false, -1f, -1, -1, shadow_intensity * 0.6f);
            }
            Utility.drawTextWithShadow(b, order_name, font, new Vector2((float)(x + 256) - font.MeasureString(order_name).X / 2f, header_y), font_color, 1f, -1f, -1, -1, shadow_intensity);
            string raw_description = order.GetDescription();
            string description     = Game1.parseText(raw_description, font, 512);
            float  height          = font.MeasureString(description).Y;
            float  scale           = 1f;
            float  max_height      = 400f;

            while (height > max_height && !(scale <= 0.25f))
            {
                scale      -= 0.05f;
                description = Game1.parseText(raw_description, font, (int)(512f / scale));
                height      = font.MeasureString(description).Y;
            }
            Utility.drawTextWithShadow(b, description, font, new Vector2(x, yPositionOnScreen + 192), font_color, scale, -1f, -1, -1, shadow_intensity);
            if (dehighlight)
            {
                return;
            }
            int days_left           = order.GetDaysLeft();
            int due_date_y_position = yPositionOnScreen + 576;

            Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2(x, due_date_y_position), new Rectangle(410, 501, 9, 9), Color.White, 0f, Vector2.Zero, 4f, flipped: false, 0.99f, -1, -1, shadow_intensity * 0.6f);
            Utility.drawTextWithShadow(b, Game1.parseText((days_left > 1) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:QuestLog.cs.11374", days_left) : Game1.content.LoadString("Strings\\StringsFromCSFiles:QuestLog.cs.11375", days_left), Game1.dialogueFont, width - 128), Game1.dialogueFont, new Vector2(x + 48, due_date_y_position), font_color, 1f, -1f, -1, -1, shadow_intensity);
            if (boardType == "Qi")
            {
                int        reward = -1;
                GemsReward gems   = null;
                foreach (OrderReward r in order.rewards)
                {
                    if (r is GemsReward)
                    {
                        gems = (r as GemsReward);
                        break;
                    }
                }
                if (gems != null)
                {
                    reward = gems.amount;
                }
                if (reward != -1)
                {
                    Utility.drawWithShadow(b, Game1.objectSpriteSheet, new Vector2((float)x + 512f / scale - Game1.dialogueFont.MeasureString(string.Concat(reward)).X - 12f - 60f, due_date_y_position - 8), new Rectangle(288, 561, 15, 15), Color.White, 0f, Vector2.Zero, 4f, flipped: false, 0.99f, -1, -1, shadow_intensity * 0.6f);
                    Utility.drawTextWithShadow(b, Game1.parseText(string.Concat(reward), Game1.dialogueFont, width - 128), Game1.dialogueFont, new Vector2((float)x + 512f / scale - Game1.dialogueFont.MeasureString(string.Concat(reward)).X - 4f, due_date_y_position), font_color, 1f, -1f, -1, -1, shadow_intensity);
                    Utility.drawTextWithShadow(b, Game1.parseText(Utility.loadStringShort("StringsFromCSFiles", "QuestLog.cs.11376"), Game1.dialogueFont, width - 128), Game1.dialogueFont, new Vector2((float)x + 512f / scale - Game1.dialogueFont.MeasureString(Utility.loadStringShort("StringsFromCSFiles", "QuestLog.cs.11376")).X + 8f, due_date_y_position - 60), font_color * 0.6f, 1f, -1f, -1, -1, shadow_intensity);
                }
            }
        }
Exemplo n.º 2
0
        static public SpecialOrder GetSpecialOrder(SqlConnection connect,
                                                                 Log log,                                                                
                                                                 string  factoryPO)
        {

            SpecialOrder ret = null;

            SqlCommand dbCmd = connect.CreateCommand();
            dbCmd.CommandType = CommandType.Text;
            dbCmd.CommandText = @"select  Category, AssetTag, Qty, Status, Remark
                                                            from SpecialOrder
                                                            where  FactoryPO=@FactoryPO";
            SQLHelper.createInputSqlParameter(dbCmd, "@FactoryPO", 32, factoryPO);





            log.write(LogType.Info, 0, "SQL", "GetSpecialOrder", dbCmd.CommandText);
            log.write(LogType.Info, 0, "SQL", "@FactoryPO", factoryPO);
           


            SqlDataReader sdr = dbCmd.ExecuteReader();
            if (sdr!=null  && sdr.Read())
            {
                ret = new SpecialOrder()
                {
                    FactoryPO = factoryPO,
                    Category = sdr.GetString(0).Trim(),
                    AssetTag = sdr.GetString(1).Trim(),
                    Qty = sdr.GetInt32(2),
                    Status = sdr.GetString(3).Trim(),
                    Remark = sdr.GetString(4)
                };
               
            }
            sdr.Close();

            return ret;
        }
Exemplo n.º 3
0
        public CustomOrderBoard(string board_type = "", Texture2D customTexture = null)
            : base(0, 0, 0, 0, showUpperRightCloseButton: true)
        {
            SpecialOrder.UpdateAvailableSpecialOrders(force_refresh: false);
            this.boardType = board_type;

            if (customTexture != null)
            {
                this._billboardTexture = customTexture;
            }
            else
            {
                this._billboardTexture = Game1.temporaryContent.Load <Texture2D>("LooseSprites\\SpecialOrdersBoard");
            }

            base.width  = 1352;
            base.height = 792;
            Vector2 center = Utility.getTopLeftPositionForCenteringOnScreen(base.width, base.height);

            base.xPositionOnScreen = (int)center.X;
            base.yPositionOnScreen = (int)center.Y;
            Rectangle leftButtonBounds = new Rectangle(
                x: base.xPositionOnScreen + (base.width / 4) - 128, y: base.yPositionOnScreen + base.height - 128,
                width: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).X + 24,
                height: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).Y + 24
                );

            this.acceptLeftQuestButton = new ClickableComponent(leftButtonBounds, "")
            {
                myID            = 0,
                leftNeighborID  = -99998,
                rightNeighborID = -99998,
                upNeighborID    = -99998,
                downNeighborID  = -99998
            };
            Rectangle rightButtonBOunds = new Rectangle(
                x: base.xPositionOnScreen + base.width * 3 / 4 - 128,
                y: base.yPositionOnScreen + base.height - 128,
                width: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).X + 24,
                height: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).Y + 24
                );

            this.acceptRightQuestButton = new ClickableComponent(rightButtonBOunds, "")
            {
                myID            = 1,
                leftNeighborID  = -99998,
                rightNeighborID = -99998,
                upNeighborID    = -99998,
                downNeighborID  = -99998
            };
            this.leftOrder             = Game1.player.team.GetAvailableSpecialOrder(0, this.GetOrderType());
            this.rightOrder            = Game1.player.team.GetAvailableSpecialOrder(1, this.GetOrderType());
            base.upperRightCloseButton = new ClickableTextureComponent(
                bounds: new Rectangle(base.xPositionOnScreen + base.width - 20, base.yPositionOnScreen, 48, 48),
                texture: Game1.mouseCursors,
                sourceRect: new Rectangle(337, 494, 12, 12),
                scale: 4f
                );

            Game1.playSound("bigSelect");
            this.UpdateButtons();

            if (Game1.options.SnappyMenus)
            {
                base.populateClickableComponentList();
                this.snapToDefaultClickableComponent();
            }
        }
Exemplo n.º 4
0
        public static void UpdateAvailableSpecialOrders(string[] validTypes)
        {
            SpecialOrder.UpdateAvailableSpecialOrders(true);

            var order_data = Game1.content.Load <Dictionary <string, SpecialOrderData> >("Data\\SpecialOrders");
            var keys       = new List <string>(order_data.Keys);

            for (int k = 0; k < keys.Count; k++)
            {
                string key     = keys[k];
                bool   invalid = false;
                if (!invalid && order_data[key].Repeatable != "True" && Game1.MasterPlayer.team.completedSpecialOrders.ContainsKey(key))
                {
                    invalid = true;
                }
                if (Game1.dayOfMonth >= 16 && order_data[key].Duration == "Month")
                {
                    invalid = true;
                }
                if (!invalid && !SpecialOrder.CheckTags(order_data[key].RequiredTags))
                {
                    invalid = true;
                }
                if (!invalid)
                {
                    foreach (SpecialOrder specialOrder in Game1.player.team.specialOrders)
                    {
                        if (specialOrder.questKey.Value == key)
                        {
                            invalid = true;
                            break;
                        }
                    }
                }
                if (invalid)
                {
                    keys.RemoveAt(k);
                    k--;
                }
            }

            Random r = new Random((int)Game1.uniqueIDForThisGame + (int)((float)Game1.stats.DaysPlayed * 1.3f));

            foreach (string type_to_find in validTypes)
            {
                var typed_keys = new List <string>();
                foreach (string key3 in keys)
                {
                    if (order_data[key3].OrderType == type_to_find)
                    {
                        typed_keys.Add(key3);
                    }
                }

                if (type_to_find != "Qi")
                {
                    for (int j = 0; j < typed_keys.Count; j++)
                    {
                        if (Game1.player.team.completedSpecialOrders.ContainsKey(typed_keys[j]))
                        {
                            typed_keys.RemoveAt(j);
                            j--;
                        }
                    }
                }

                var all_keys = new List <string>(typed_keys);
                for (int i = 0; i < 2; i++)
                {
                    if (typed_keys.Count == 0)
                    {
                        if (all_keys.Count == 0)
                        {
                            break;
                        }
                        typed_keys = new List <string>(all_keys);
                    }

                    int    index = r.Next(typed_keys.Count);
                    string key2  = typed_keys[index];
                    Game1.player.team.availableSpecialOrders.Add(SpecialOrder.GetSpecialOrder(key2, r.Next()));
                    typed_keys.Remove(key2);
                    all_keys.Remove(key2);
                }
            }
        }
 private static void ShowWarning(SpecialOrder order)
 => Game1.showRedMessage(I18n.InvalidSpecialOrder(order.questKey.Value));
Exemplo n.º 6
0
        /// <summary>
        /// Reads in a XML file informations about the design of the 'Textview' and posible acronyms
        /// </summary>
        /// <param name="path">path to the XML file</param>
        private void loadTemplateAllElementsTextview(String path = null)
        {
            if (path == null)
            {
                path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "TemplateAllElementsTextview.xml");
            }
            if (!File.Exists(path))
            {
                Debug.WriteLine("The XML file dosn't exist!"); return;
            }
            XElement xmlDoc = XElement.Load(@path);
            //TODO: hier gegen XSD validieren
            TextviewObject tvo = new TextviewObject();

            #region default order
            IEnumerable <XElement> uiElementDefaultOrders = xmlDoc.Elements("Orders").Elements("DefaultOrder").Elements("Element");
            if (uiElementDefaultOrders == null || !uiElementDefaultOrders.Any())
            {
                return;
            }
            Orders orders = new Orders();
            orders.defaultOrder  = new List <TextviewElement>();
            orders.specialOrders = new List <SpecialOrder>();
            tvo.orders           = orders;
            foreach (XElement xmlElement in uiElementDefaultOrders)
            {
                TextviewElement tve = new TextviewElement();
                tve.order    = Int32.Parse(xmlElement.Element("Order").Value);
                tve.property = xmlElement.Element("Property").Value;
                tve.minWidth = Int32.Parse(xmlElement.Element("MinWidth").Value);
                XElement xElementSeparator = xmlElement.Element("Separator");
                if (xElementSeparator != null)
                {
                    tve.separator = xElementSeparator.Value;
                    if (tve.separator.Equals(""))
                    {
                        tve.separator = " ";
                    }
                }
                tvo.orders.defaultOrder.Add(tve);
            }
            #endregion
            #region special order
            IEnumerable <XElement> uiElementOrders = xmlDoc.Elements("Orders").Elements("SpecialOrders");
            if (uiElementOrders == null || !uiElementOrders.Any())
            {
                return;
            }
            foreach (XElement xmlElement in uiElementOrders)
            {
                IEnumerable <XElement> oneSpecialOrder = xmlElement.Elements("SpecialOrder");

                foreach (XElement elementOrder in oneSpecialOrder)
                {
                    SpecialOrder           so = new SpecialOrder();
                    List <TextviewElement> oneSpecialOrderList = new List <TextviewElement>();
                    so.controltypeName = elementOrder.Attribute("controlType").Value;
                    foreach (XElement element in elementOrder.Elements("Element"))
                    {
                        TextviewElement tve = new TextviewElement();
                        tve.order    = Int32.Parse(element.Element("Order").Value);
                        tve.property = element.Element("Property").Value;
                        tve.minWidth = Int32.Parse(element.Element("MinWidth").Value);
                        XElement xElementSeparator = element.Element("Separator");
                        if (xElementSeparator != null)
                        {
                            tve.separator = xElementSeparator.Value;
                            if (tve.separator.Equals(""))
                            {
                                tve.separator = " ";
                            }
                        }
                        oneSpecialOrderList.Add(tve);
                    }
                    so.order = oneSpecialOrderList;
                    tvo.orders.specialOrders.Add(so);
                }
            }
            #endregion
            tvo.typeOfView = xmlDoc.Element("TypeOfView").Value;
            tvo.screenName = xmlDoc.Element("Screenname").Value;
            XElement itemenumarate = xmlDoc.Element("ItemEnumerate");
            if (itemenumarate != null)
            {
                tvo.itemEnumerate = itemenumarate.Value;
                if (tvo.itemEnumerate.Equals(""))
                {
                    tvo.itemEnumerate = " ";
                }
            }

            IEnumerable <XElement> uiElementAcronyms = xmlDoc.Elements("Acronyms").Elements("Acronym");

            if (!(uiElementAcronyms == null || !uiElementAcronyms.Any()))
            {
                tvo.acronymsOfPropertyContent = new List <AcronymsOfPropertyContent>();
                foreach (XElement xmlElement in uiElementAcronyms)
                {
                    AcronymsOfPropertyContent aopc = new AcronymsOfPropertyContent();
                    aopc.name    = xmlElement.Element("Name").Value;
                    aopc.acronym = xmlElement.Element("Short").Value;
                    tvo.acronymsOfPropertyContent.Add(aopc);
                }
            }
            this.TextviewObject = tvo;
        }
 public bool UpdateSpecialOrder(int SO_ID, SpecialOrder SO)
 {
     return(lck.UpdateSpecialOrder(SO_ID, SO));
 }
 public bool AddSpecialOrder(SpecialOrder SO)
 {
     return(lck.AddSpecialOrder(SO));
 }
Exemplo n.º 9
0
        private static bool Before_checkAction(NPC __instance, Farmer who, ref bool __result)
        {
            try
            {
                if (Game1.eventUp || __instance.IsInvisible || __instance.isSleeping.Value || !who.CanMove || who.isRidingHorse())
                {
                    return(true);
                }

                if (who.ActiveObject != null && who.ActiveObject.canBeGivenAsGift() && !who.isRidingHorse())
                {
                    return(true);
                }

                if (Game1.dialogueUp)
                {
                    return(true);
                }

                Instance.QuestManager.AdjustQuest(new TalkMessage(who, __instance));

                if (Game1.dialogueUp && Game1.currentSpeaker == __instance)
                {
                    __result = true;
                    return(false);
                }

                Instance.Monitor.VerboseLog($"Checking for new quest from NPC `{__instance.Name}`.");

                if (Instance.OfferController.TryOfferNpcQuest(__instance, out QuestOffer <NpcOfferAttributes> offer))
                {
                    __result = true;
                    Game1.drawDialogue(__instance, $"{offer.OfferDetails.DialogueText}[quest:{offer.QuestName.Replace('@', ' ')}]");
                    QuestFrameworkMod.Instance.Monitor.Log($"Getting new quest `{offer.QuestName}` to quest log from NPC `{__instance.Name}`.");

                    return(false);
                }

                if (Instance.OfferController.TryOfferNpcSpecialOrder(__instance, out SpecialOrder specialOrder))
                {
                    if (!__instance.Dialogue.TryGetValue($"offerOrder_{specialOrder.questKey.Value}", out string dialogue))
                    {
                        dialogue = specialOrder.GetDescription();
                    }

                    __result = true;
                    Game1.player.team.specialOrders.Add(SpecialOrder.GetSpecialOrder(specialOrder.questKey.Value, specialOrder.generationSeed.Value));
                    Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Farmer.cs.2011"), 2));
                    Game1.drawDialogue(__instance, dialogue);
                    QuestFrameworkMod.Multiplayer.globalChatInfoMessage("AcceptedSpecialOrder", Game1.player.Name, specialOrder.GetName());
                    Instance.OfferController.RefreshActiveIndicators();

                    return(false);
                }
            }
            catch (Exception e)
            {
                Instance.LogFailure(e, nameof(Instance.Before_checkAction));
            }

            return(true);
        }