예제 #1
0
        /// <summary>
        /// Show this dialog.
        /// <b>Don't forget to call dialog.Hide(); when you want to hide it, this is not done auto. just in case you want to animate it instead of hide it.</b>
        /// </summary>
        /// <param name="title">Title of the dialog.</param>
        /// <param name="description">The description of the dialog.</param>
        /// <param name="yes">The name of the yes button.</param>
        /// <param name="no">The name of the no button.</param>
        /// <param name="minValue">The minimal value allowed to be selected.</param>
        /// <param name="maxValue">The max value allowed to be selected.</param>
        /// <param name="yesCallback"></param>
        /// <param name="noCallback"></param>
        public virtual void ShowDialog(Transform caller, string title, string description, int min, int max, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            SetEnabledWhileActive(false);
            this.yesCallback = yesCallback;
            this.noCallback  = noCallback;

            window.Show(); // Have to show it first, otherwise we can't use the elements, as they're disabled.


            minValue = min;
            maxValue = max;

            titleText.text = title;
            if (descriptionText != null)
            {
                descriptionText.text = description;
            }

            inputField.text = minValue.ToString();
            if (amountControl != null)
            {
                amountControl.Set(min, max);
            }

            valueVisualizer.Repaint(GetInputValue(), maxValue);
            NotifyDialogShown(caller);
        }
        public override void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            base.ShowDialog(title, description, yes, no, minValue, maxValue, yesCallback, noCallback);

            inputField.onValueChange.AddListener((string result) =>
            {
                uint amount = uint.Parse(result); // Let's trust Unity on this...

                float finalPrice = 0.0f;
                if (action == ItemBuySellDialogAction.Buying)
                    finalPrice = vendor.GetBuyPrice(inventoryItem, amount);
                else if (action == ItemBuySellDialogAction.Selling)
                    finalPrice = vendor.GetSellPrice(inventoryItem, amount);
                else if (action == ItemBuySellDialogAction.BuyingBack)
                    finalPrice = vendor.GetBuyBackPrice(inventoryItem, amount);

                price.text = InventorySettingsManager.instance.currencyFormatter.Format(finalPrice);
                if(action == ItemBuySellDialogAction.Buying || action == ItemBuySellDialogAction.BuyingBack)
                {
                    if (finalPrice > InventoryManager.instance.inventory.gold)
                        price.color = unAffordableColor;
                    else
                        price.color = affordableColor;
                }
                else
                    price.color = affordableColor;

            });
            inputField.onValueChange.Invoke(inputField.text); // Hit the event on start
        }
 public virtual void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, InventoryItemBase item, ItemBuySellDialogAction action, VendorTriggerer vendor, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     // Don't call base class going directly to this.ShowDialog()
     inventoryItem = item;
     this.action = action;
     this.vendor = vendor;
     ShowDialog(string.Format(string.Format(title, item.name, item.description)), string.Format(description, item.name, item.description), yes, no, minValue, maxValue, yesCallback, noCallback);
 }
        public override void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            base.ShowDialog(caller, title, description, minValue, maxValue, yesCallback, noCallback);

            if(wrapper != null && inventoryItem != null)
            {
                wrapper.item = inventoryItem;
                wrapper.Repaint();
            }
        }
        public override void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            base.ShowDialog(title, description, yes, no, minValue, maxValue, yesCallback, noCallback);

            if(itemIcon != null && inventoryItem != null)
            {
                if (inventoryItem != null)
                {
                    itemIcon.sprite = inventoryItem.icon;
                }
                else
                    itemIcon.sprite = InventorySettingsManager.instance.defaultSlotIcon;
            }
        }
        public override void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            base.ShowDialog(caller, title, description, minValue, maxValue, yesCallback, noCallback);

            inputField.onValueChange.AddListener((string result) =>
            {
                int amount = GetInputValue(); // Let's trust Unity on this...

                string formattedText;
                float finalPrice;
                uint finalCurrencyID;
                GetTransactionInfo(amount, out formattedText, out finalPrice, out finalCurrencyID);

                price.text = formattedText;
                SetPriceColor(finalPrice, finalCurrencyID);

            });
            inputField.onValueChange.Invoke(inputField.text); // Hit the event on start
        }
 public override void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, InventoryItemBase item, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     inventoryItem = item;
     ShowDialog(string.Format(string.Format(title, item.name, item.description)), string.Format(description, item.name, item.description), yes, no, minValue, maxValue, yesCallback, noCallback);
 }
예제 #8
0
        public override void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            base.ShowDialog(title, description, yes, no, minValue, maxValue, yesCallback, noCallback);

            inputField.onValueChange.AddListener((string result) =>
            {
                uint amount = uint.Parse(result); // Let's trust Unity on this...

                float finalPrice = 0.0f;
                if (action == ItemBuySellDialogAction.Buying)
                {
                    finalPrice = vendor.GetBuyPrice(inventoryItem, amount);
                }
                else if (action == ItemBuySellDialogAction.Selling)
                {
                    finalPrice = vendor.GetSellPrice(inventoryItem, amount);
                }
                else if (action == ItemBuySellDialogAction.BuyingBack)
                {
                    finalPrice = vendor.GetBuyBackPrice(inventoryItem, amount);
                }

                price.text = InventorySettingsManager.instance.currencyFormatter.Format(finalPrice);
                if (action == ItemBuySellDialogAction.Buying || action == ItemBuySellDialogAction.BuyingBack)
                {
                    if (finalPrice > InventoryManager.instance.inventory.gold)
                    {
                        price.color = unAffordableColor;
                    }
                    else
                    {
                        price.color = affordableColor;
                    }
                }
                else
                {
                    price.color = affordableColor;
                }
            });
            inputField.onValueChange.Invoke(inputField.text); // Hit the event on start
        }
예제 #9
0
        /// <summary>
        /// Show this dialog.
        /// <b>Don't forget to call dialog.Hide(); when you want to hide it, this is not done auto. just in case you want to animate it instead of hide it.</b>
        /// </summary>
        /// <param name="title">Title of the dialog.</param>
        /// <param name="description">The description of the dialog.</param>
        /// <param name="yes">The name of the yes button.</param>
        /// <param name="no">The name of the no button.</param>
        /// <param name="minValue">The minimal value allowed to be selected.</param>
        /// <param name="maxValue">The max value allowed to be selected.</param> 
        /// <param name="yesCallback"></param>
        /// <param name="noCallback"></param>
        public virtual void ShowDialog(Transform caller, string title, string description, int min, int max, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            SetEnabledWhileActive(false);
            this.yesCallback = yesCallback;
            this.noCallback = noCallback;

            window.Show(); // Have to show it first, otherwise we can't use the elements, as they're disabled.


            minValue = min;
            maxValue = max;

            titleText.text = title;
            if (descriptionText != null)
                descriptionText.text = description;
            

            inputField.text = minValue.ToString();
            inputField.onValueChange.RemoveAllListeners();
            inputField.onValueChange.AddListener((string result) => NotifyAmountValueChanged());


            if (plusButton != null)
            {
                plusButton.onClick.RemoveAllListeners();
                plusButton.onClick.AddListener(() =>
                {
                    if (window.isVisible == false)
                        return;

                    if (Input.GetKey(KeyCode.LeftShift))
                        AddToInputValue(10);
                    else
                        AddToInputValue(1);
                });
            }
            if (minusButton != null)
            {
                minusButton.onClick.RemoveAllListeners();
                minusButton.onClick.AddListener(() =>
                {
                    if (window.isVisible == false)
                        return;

                    if (Input.GetKey(KeyCode.LeftShift))
                        AddToInputValue(-10);
                    else
                        AddToInputValue(-1);
                });
            }


            if (yesButton != null)
            {
                yesButton.onClick.RemoveAllListeners();
                yesButton.onClick.AddListener(AcceptAction);
            }

            if (noButton != null)
            {
                noButton.onClick.RemoveAllListeners();
                noButton.onClick.AddListener(DenyAction);
            }

            valueVisualizer.Repaint(GetInputValue(), maxValue);
            NotifyDialogShown(caller);
        }
        public override void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            base.ShowDialog(caller, title, description, minValue, maxValue, yesCallback, noCallback);

            if (slot != null && inventoryItem != null)
            {
                slot.item = inventoryItem;
                slot.Repaint();
            }
        }
 public virtual void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, InventoryItemBase item, ItemBuySellDialogAction action, VendorTrigger vendor, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     // Don't call base class going directly to this.ShowDialog()
     inventoryItem = item;
     this.action   = action;
     this.vendor   = vendor;
     ShowDialog(caller, string.Format(string.Format(title, item.name, item.description)), string.Format(description, item.name, item.description), minValue, maxValue, yesCallback, noCallback);
 }
        /// <summary>
        /// Show this dialog.
        /// <b>Don't forget to call dialog.Hide(); when you want to hide it, this is not done auto. just in case you want to animate it instead of hide it.</b>
        /// </summary>
        /// <param name="title">Title of the dialog.</param>
        /// <param name="description">The description of the dialog.</param>
        /// <param name="yes">The name of the yes button.</param>
        /// <param name="no">The name of the no button.</param>
        /// <param name="minValue">The minimal value allowed to be selected.</param>
        /// <param name="maxValue">The max value allowed to be selected.</param>
        /// <param name="yesCallback"></param>
        /// <param name="noCallback"></param>
        public virtual void ShowDialog(string title, string description, string yes, string no, int min, int max, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            SetEnabledWhileActive(false);


            window.Show(); // Have to show it first, otherwise we can't use the elements, as they're disabled.


            minValue = min;
            maxValue = max;

            titleText.text = title;
            if (descriptionText != null)
            {
                descriptionText.text = description;
            }

            yesButton.GetComponentInChildren <Text>().text = yes;
            noButton.GetComponentInChildren <Text>().text  = no;
            inputField.text = minValue.ToString();


            inputField.onEndEdit.RemoveAllListeners();
            inputField.onValueChange.AddListener((string result) =>
            {
                ValidateInputField(minValue, maxValue);
            });

            if (plusButton != null)
            {
                plusButton.onClick.RemoveAllListeners();
                plusButton.onClick.AddListener(() =>
                {
                    if (window.isVisible == false)
                    {
                        return;
                    }

                    if (inputField.text == "")
                    {
                        inputField.text = maxValue.ToString();
                    }

                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        inputField.text = (int.Parse(inputField.text) + 10).ToString();
                    }
                    else
                    {
                        inputField.text = (int.Parse(inputField.text) + 1).ToString();
                    }
                });
            }
            if (minusButton != null)
            {
                minusButton.onClick.RemoveAllListeners();
                minusButton.onClick.AddListener(() =>
                {
                    if (window.isVisible == false)
                    {
                        return;
                    }

                    if (inputField.text == "")
                    {
                        inputField.text = minValue.ToString();
                    }

                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        inputField.text = (int.Parse(inputField.text) - 10).ToString();
                    }
                    else
                    {
                        inputField.text = (int.Parse(inputField.text) - 1).ToString();
                    }
                });
            }



            yesButton.onClick.RemoveAllListeners();
            yesButton.onClick.AddListener(() =>
            {
                if (window.isVisible == false)
                {
                    return;
                }

                if (ValidateInputField(minValue, maxValue) == false)
                {
                    return;
                }

                SetEnabledWhileActive(true);
                yesCallback(int.Parse(inputField.text));
                window.Hide();
            });

            noButton.onClick.RemoveAllListeners();
            noButton.onClick.AddListener(() =>
            {
                if (window.isVisible == false)
                {
                    return;
                }

                SetEnabledWhileActive(true);
                if (ValidateInputField(minValue, maxValue) == false)
                {
                    noCallback(-1);
                }
                else
                {
                    noCallback(int.Parse(inputField.text));
                }
                window.Hide();
            });
        }
 /// <summary>
 /// Show the dialog.
 /// <b>Don't forget to call dialog.Hide(); when you want to hide it, this is not done auto. just in case you want to animate it instead of hide it.</b>
 /// </summary>
 /// <param name="title">The title of the dialog. Note that {0} is the item ID and {1} is the item name.</param>
 /// <param name="description">The description of the dialog. Note that {0} is the item ID and {1} is the item name.</param>
 /// <param name="yes">The name of the yes button.</param>
 /// <param name="no">The name of the no button.</param>
 /// <param name="minValue">The minimal value allowed to be selected.</param>
 /// <param name="maxValue">The max value allowed to be selected.</param>
 /// <param name="item">
 /// You can add an item, if you're confirming something for that item. This allows you to use {0} for the title and {1} for the description inside the title and description variables of the dialog.
 /// An example:
 ///
 /// ShowDialog("Are you sure you want to drop {0}?", "{0} sure seems valuable..", ...etc..);
 /// This will show the item name at location {0} and the description at location {1}.
 /// </param>
 /// <param name="yesCallback"></param>
 /// <param name="noCallback"></param>
 public virtual void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, InventoryItemBase item, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     ShowDialog(string.Format(string.Format(title, item.name, item.description)), string.Format(description, item.name, item.description), yes, no, minValue, maxValue, yesCallback, noCallback);
 }
예제 #14
0
 public override void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, InventoryItemBase item, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     // Don't call base class going directly to this.ShowDialog()
     inventoryItem = item;
     ShowDialog(string.Format(string.Format(title, item.name, item.description)), string.Format(description, item.name, item.description), yes, no, minValue, maxValue, yesCallback, noCallback);
 }
예제 #15
0
        public override void ShowDialog(string title, string description, string yes, string no, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            base.ShowDialog(title, description, yes, no, minValue, maxValue, yesCallback, noCallback);

            if (itemIcon != null && inventoryItem != null)
            {
                if (inventoryItem != null)
                {
                    itemIcon.sprite = inventoryItem.icon;
                }
                else
                {
                    itemIcon.sprite = InventorySettingsManager.instance.defaultSlotIcon;
                }
            }
        }
예제 #16
0
 public override void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, InventoryItemBase item, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     // Don't call base class going directly to this.ShowDialog()
     inventoryItem = item;
     ShowDialog(caller, string.Format(title, item.name, item.description), string.Format(description, item.name, item.description), minValue, maxValue, yesCallback, noCallback);
 }
 public override void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, InventoryItemBase item, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     inventoryItem = item;
     ShowDialog(caller, string.Format(string.Format(title, item.name, item.description)), string.Format(description, item.name, item.description), minValue, maxValue, yesCallback, noCallback);
 }
        /// <summary>
        /// Show this dialog.
        /// <b>Don't forget to call dialog.Hide(); when you want to hide it, this is not done auto. just in case you want to animate it instead of hide it.</b>
        /// </summary>
        /// <param name="title">Title of the dialog.</param>
        /// <param name="description">The description of the dialog.</param>
        /// <param name="yes">The name of the yes button.</param>
        /// <param name="no">The name of the no button.</param>
        /// <param name="minValue">The minimal value allowed to be selected.</param>
        /// <param name="maxValue">The max value allowed to be selected.</param> 
        /// <param name="yesCallback"></param>
        /// <param name="noCallback"></param>
        public virtual void ShowDialog(string title, string description, string yes, string no, int min, int max, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
        {
            SetEnabledWhileActive(false);

            window.Show(); // Have to show it first, otherwise we can't use the elements, as they're disabled.

            minValue = min;
            maxValue = max;

            titleText.text = title;
            if (descriptionText != null)
                descriptionText.text = description;

            yesButton.GetComponentInChildren<Text>().text = yes;
            noButton.GetComponentInChildren<Text>().text = no;
            inputField.text = minValue.ToString();

            inputField.onEndEdit.RemoveAllListeners();
            inputField.onValueChange.AddListener((string result) =>
            {
                ValidateInputField(minValue, maxValue);
            });

            if (plusButton != null)
            {
                plusButton.onClick.RemoveAllListeners();
                plusButton.onClick.AddListener(() =>
                {
                    if (window.isVisible == false)
                        return;

                    if (inputField.text == "")
                        inputField.text = maxValue.ToString();

                    if (Input.GetKey(KeyCode.LeftShift))
                        inputField.text = (int.Parse(inputField.text) + 10).ToString();
                    else
                        inputField.text = (int.Parse(inputField.text) + 1).ToString();
                });
            }
            if(minusButton != null)
            {
                minusButton.onClick.RemoveAllListeners();
                minusButton.onClick.AddListener(() =>
                {
                    if (window.isVisible == false)
                        return;

                    if (inputField.text == "")
                        inputField.text = minValue.ToString();

                    if(Input.GetKey(KeyCode.LeftShift))
                        inputField.text = (int.Parse(inputField.text) - 10).ToString();
                    else
                        inputField.text = (int.Parse(inputField.text) - 1).ToString();
                });
            }

            yesButton.onClick.RemoveAllListeners();
            yesButton.onClick.AddListener(() =>
            {
                if (window.isVisible == false)
                    return;

                if (ValidateInputField(minValue, maxValue) == false)
                    return;

                SetEnabledWhileActive(true);
                yesCallback(int.Parse(inputField.text));
                window.Hide();
            });

            noButton.onClick.RemoveAllListeners();
            noButton.onClick.AddListener(() =>
            {
                if (window.isVisible == false)
                    return;

                SetEnabledWhileActive(true);
                if (ValidateInputField(minValue, maxValue) == false)
                    noCallback(-1);
                else
                    noCallback(int.Parse(inputField.text));
                window.Hide();
            });
        }
 public override void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     base.ShowDialog(caller, title, description, minValue, maxValue, yesCallback, noCallback);
     OnAmountValueChanged(inputField.text);
 }
예제 #20
0
 /// <summary>
 /// Show the dialog.
 /// <b>Don't forget to call dialog.Hide(); when you want to hide it, this is not done auto. just in case you want to animate it instead of hide it.</b>
 /// </summary>
 /// <param name="title">The title of the dialog. Note that {0} is the item ID and {1} is the item name.</param>
 /// <param name="description">The description of the dialog. Note that {0} is the item ID and {1} is the item name.</param>
 /// <param name="yes">The name of the yes button.</param>
 /// <param name="no">The name of the no button.</param>
 /// <param name="minValue">The minimal value allowed to be selected.</param>
 /// <param name="maxValue">The max value allowed to be selected.</param> 
 /// <param name="item">
 /// You can add an item, if you're confirming something for that item. This allows you to use {0} for the title and {1} for the description inside the title and description variables of the dialog.
 /// An example:
 /// 
 /// ShowDialog("Are you sure you want to drop {0}?", "{0} sure seems valuable..", ...etc..);
 /// This will show the item name at location {0} and the description at location {1}.
 /// </param>
 /// <param name="yesCallback"></param>
 /// <param name="noCallback"></param>
 public virtual void ShowDialog(Transform caller, string title, string description, int minValue, int maxValue, InventoryItemBase item, IntValDialogCallback yesCallback, IntValDialogCallback noCallback)
 {
     ShowDialog(caller, string.Format(string.Format(title, item.name, item.description)), string.Format(description, item.name, item.description), minValue, maxValue, yesCallback, noCallback);
 }