Ejemplo n.º 1
0
        /// <summary>
        /// Simple CheckBox which returns "true" of "false". The fixedSize is 24x24.
        /// </summary>
        /// <param name="pos">LeftBottom of Position</param>
        /// <param name="key">Unique <see cref="UIconfig.key"/></param>
        /// <param name="defaultBool">default bool</param>
        public OpCheckBox(Vector2 pos, string key, bool defaultBool = false) : base(pos, new Vector2(24f, 24f), key, "false")
        {
            this.fixedSize = new Vector2(24f, 24f);
            if (defaultBool)
            {
                this._value = "true";
            }
            else
            {
                this._value = "false";
            }
            this.defaultValue = this.value;

            if (!_init)
            {
                return;
            }
            this.colorEdge = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.MediumGrey);
            this.colorFill = Color.black;
            this.rect      = new DyeableRect(menu, owner, this.pos, this.size, true);
            this.subObjects.Add(rect);
            this.symbolSprite = new FSprite("Menu_Symbol_CheckBox", true);
            this.myContainer.AddChild(this.symbolSprite);
            this.symbolSprite.SetAnchor(0f, 0f);
            this.symbolSprite.SetPosition(2f, 2f);
            this.description = InternalTranslator.Translate("Click to Check/Uncheck");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This returns value in "true" of "false", although this is NOT a <see cref="UIconfig"/> thus this value won't be saved.
        /// <para>Initialize <see cref="OpRadioButtonGroup"/> first before these, then bind these to the Group using <see cref="OpRadioButtonGroup.SetButtons(OpRadioButton[])"/></para>
        /// </summary>
        /// <param name="pos">LeftBottom of the Button (The size is fixed to 24x24)</param>
        public OpRadioButton(Vector2 pos) : base(pos, new Vector2(24f, 24f))
        {
            this._value    = "false";
            this.fixedSize = new Vector2(24f, 24f);
            if (!_init)
            {
                return;
            }
            this.colorEdge = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.MediumGrey);
            this.colorFill = Color.black;
            this.rect      = new DyeableRect(menu, owner, this.pos, this.size, true);
            this.subObjects.Add(rect);
            this.symbolSprite = new FSprite("Menu_Symbol_Clear_All", true);
            this.myContainer.AddChild(this.symbolSprite);
            this.symbolSprite.SetAnchor(0f, 0f);
            this.symbolSprite.SetPosition(2f, 2f);

            //this.group = group;
            this.index     = -1;
            this.greyedOut = false;
            this.bumpBehav = new BumpBehaviour(this);

            this.click = false;

            this.description = InternalTranslator.Translate("Click to choose this option");
        }
        private void LoadTranslation()
        {
            curLang        = OptionScript.curLang;
            transConverter = new Dictionary <string, string>();

            if (transData == null)
            {
                if (!ReadTransTXT())
                {
                    return;
                }
                ;
            }
            for (int i = 0; i < transData.Length; i++)
            {
                if (transData[i].StartsWith("//") || transData[i].Length < 5)
                {
                    continue;
                }
                string[] langs = transData[i].Split('|'); //Regex.Split(data[i], "/\|/");
                if (langs.Length < 2)
                {
                    continue;
                }
                bool hasDefault = false;
                for (int j = 1; j < langs.Length; j++)
                {
                    string[] piece = langs[j].Split('$'); //Regex.Split(langs[j], @"$");
                    if (piece.Length < 2)
                    {
                        Debug.LogError($"CompletelyOptional: Specify Language for your translation in this format: \'lang$translation\'\n Allowed Language Codes are: {InternalTranslator.allowedCodes}"); continue;
                    }
                    if (curLang == InternalTranslator.LangToCode(piece[0]))
                    {
                        //string cvt = Regex.Replace(piece[1], "/\\en/i", Environment.NewLine);
                        if (transConverter.ContainsKey(langs[0]))
                        {
                            if (!hasDefault)
                            {
                                Debug.LogError($"Conflicting Key found: \'{langs[0]}\'");
                            }
                            transConverter.Remove(langs[0]);
                        }
                        transConverter.Add(langs[0], piece[1]);
                        //Debug.Log($"{transConverter.Count}: {langs[0]}|{piece[1]}");
                    }
                    else if (InternalTranslator.LangToCode(piece[0]) == "eng")
                    {
                        if (transConverter.ContainsKey(langs[0]))
                        {
                            continue;
                        }
                        transConverter.Add(langs[0], piece[1]); //add default translation
                        hasDefault = true;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// ListBox that also can be searched
 /// </summary>
 /// <param name="pos">LeftBottom Position of this <see cref="UIelement"/></param>
 /// <param name="width">The width of this element. The height is calculated by lineCount.</param>
 /// <param name="key">Unique <see cref="UIconfig.key"/></param>
 /// <param name="array">The index will be <see cref="ListItem.value"/>, so the order will be kept</param>
 /// <param name="defaultName">Set to empty to have no default selection</param>
 /// <param name="lineCount"><see cref="OpComboBox.listHeight"/> for its height. Use <see cref="GetLineCountFromHeight(float)"/> to calculate this from pixel height.</param>
 /// <param name="downward">whether this goes downward or not</param>
 /// <exception cref="ElementFormatException">Thrown when list has no <see cref="ListItem"/>.</exception>
 public OpListBox(Vector2 pos, float width, string key, string[] array, int lineCount = 5, bool downward = true, string defaultName = "") : base(pos, width, key, array, defaultName)
 {
     this.description = InternalTranslator.Translate("Scroll the list, Double Click to search");
     this.listHeight  = lineCount;
     this.downward    = downward;
     if (_init && !(this is OpResourceList))
     {
         this.OpenList();
     }
 }
Ejemplo n.º 5
0
 public override void OnChange()
 {
     base.OnChange();
     if (!_init)
     {
         return;
     }
     if (!cosmetic)
     {
         OptionScript.configChanged = true;
         (menu as ConfigMenu).saveButton.menuLabel.text = InternalTranslator.Translate("APPLY");
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Simple TextBox.
        /// </summary>
        /// <param name="pos">LeftBottom <see cref="UIelement.pos"/>.</param>
        /// <param name="sizeX">Horizontal size (min = 30 pxl). The height is fixed to 24 pxl.</param>
        /// <param name="key">Unique <see cref="UIconfig.key"/></param>
        /// <param name="defaultValue">Default string value</param>
        /// <param name="accept">Which type of text you want to <see cref="Accept"/></param>
        public OpTextBox(Vector2 pos, float sizeX, string key, string defaultValue = "TEXT", Accept accept = Accept.StringASCII) : base(pos, new Vector2(30f, 24f), key, defaultValue)
        {
            this._size       = new Vector2(Mathf.Max(IsUpdown ? 40f : 30f, sizeX), IsUpdown ? 30f : 24f);
            this.description = InternalTranslator.Translate("Click and Type text");

            this.accept       = accept;
            this._value       = defaultValue;
            this._lastValue   = defaultValue;
            this.defaultValue = this.value;
            this.maxLength    = Mathf.FloorToInt((size.x - 20f) / 6f);
            if (this.accept == Accept.Float || this.accept == Accept.Int)
            {
                this.allowSpace = float.Parse(defaultValue) < 0f;
            }
            else
            {
                this.allowSpace = defaultValue.Contains(" ");
            }
            this.password  = false;
            this.mouseDown = false;

            if (!_init)
            {
                return;
            }

            //this.keyboardOn = false;
            this.colorEdge = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.MediumGrey);
            this.colorText = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.MediumGrey);
            this.colorFill = Color.black;
            this.rect      = new DyeableRect(menu, owner, this.pos, this.size, true)
            {
                fillAlpha = 0.5f
            };
            this.subObjects.Add(this.rect);

            this.label = new MenuLabel(menu, owner, defaultValue, this.pos + new Vector2(5f - this._size.x * 0.5f, IsUpdown ? 13f : 10f), new Vector2(this._size.x, 20f), false);
            this.label.label.alignment = FLabelAlignment.Left;
            this.label.label.SetAnchor(0f, 1f);
            this.label.label.color = this.colorText;
            //this.label.label.SetPosition(new Vector2(5f, 3f) - (this._size * 0.5f));
            this.subObjects.Add(this.label);

            this.cursor = new FCursor();
            cursor.SetPosition(LabelTest.GetWidth(value, false) + LabelTest.CharMean(false), this.size.y * 0.5f - 7f);
            this.myContainer.AddChild(this.cursor);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// DropDown box that can be also be searched
 /// </summary>
 /// <param name="pos">LeftBottom Position of folded <see cref="OpComboBox"/></param>
 /// <param name="width">The box width of folded <see cref="OpComboBox"/>. The height is fixed to 24f.</param>
 /// <param name="key">Unique <see cref="UIconfig.key"/></param>
 /// <param name="list">Will be sorted automatically by <see cref="ListItem.value"/>, then <see cref="ListItem.name"/></param>
 /// <param name="defaultName">Set to empty to have no default selection</param>
 /// <exception cref="ElementFormatException">Thrown when list has no <see cref="ListItem"/>.</exception>
 public OpComboBox(Vector2 pos, float width, string key, List <ListItem> list, string defaultName = "") : base(pos, new Vector2(width, 24f), key, defaultName)
 {
     this._size       = new Vector2(Mathf.Max(24f, size.x), 24f);
     this.description = InternalTranslator.Translate("Click to open the list, Double Click to search");
     if (IsResourceSelector)
     {
         return;
     }
     if (list is null || list.Count < 1)
     {
         throw new ElementFormatException(this, "The list must contain at least one ListItem", this.key);
     }
     list.Sort(ListItem.Comparer);
     this.itemList = list.ToArray();
     this.ResetIndex();
     this.Initialize(defaultName);
     // throw new NotImplementedException("OpComboBox will come to you, Soon(tm)! If you're seeing this error as an user, download the latest ConfigMachine.");
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Slider that let you input integer more visually.
        /// </summary>
        /// <param name="pos">LeftBottom position. (excluding extra length in the end of slider line)</param>
        /// <param name="key">unique keyword for this UIconfig</param>
        /// <param name="range">x = min, y = max</param>
        /// <param name="multi">Length of this slider will be this value * range. minimum 1f. (The width is 30 pxl)</param>
        /// <param name="vertical">if true, the slider will go vertical and the length will be used as height</param>
        /// <param name="defaultValue">default integer value</param>
        public OpSlider(Vector2 pos, string key, IntVector2 range, float multi = 1.0f, bool vertical = false, int defaultValue = 0) : base(pos, new Vector2(), key, defaultValue.ToString())
        {
            this.vertical    = vertical;
            this.description = InternalTranslator.Translate(this.vertical ?
                                                            "Hold your mouse button and Drag up/down to adjust value" : "Hold your mouse button and Drag left/right to adjust value");
            this.min = range.x; this.max = range.y;
            int r = this.max - this.min + 1;

            this.wheelTick = r > 5 ? Math.Max(Mathf.CeilToInt(r / 12f), 4) : 1;
            this.mul       = Mathf.Max(multi, 1.0f);
            this._size     = this.vertical ? new Vector2(30f, (r - 1) * this.mul) : new Vector2((r - 1) * this.mul, 30f);
            this.fixedSize = this._size;
            this._value    = Custom.IntClamp(defaultValue, min, max).ToString();
            if (!_init)
            {
                return;
            }
            Initialize();
        }
Ejemplo n.º 9
0
 public string GetDescription()
 {
     if (!string.IsNullOrEmpty(_desError))
     {
         return(_desError);
     }
     if (!string.IsNullOrEmpty(_description))
     {
         return(_description);
     }
     if (IsJoystick(this.value))
     {
         return(InternalTranslator.Translate("Click this and Press any button to bind (Ctrl + No to set controller number)"));
     }
     else
     {
         return(InternalTranslator.Translate("Click this and Press any key/button to bind (Esc to unbind)"));
     }
 }
Ejemplo n.º 10
0
        private void Initialize()
        {
            // rectUp = new DyeableRect(menu, owner, this.pos + new Vector2(this.size.x - 40f, 3f), new Vector2(16f, 24f), true);
            // rectDown = new DyeableRect(menu, owner, this.pos + new Vector2(this.size.x - 20f, 3f), new Vector2(16f, 24f), true);
            // subObjects.Add(rectUp); subObjects.Add(rectDown);

            this.description = InternalTranslator.Translate("Click and Type numbers, Use Arrows or Scrollwheel to adjust");

            arrUp = new FSprite("Big_Menu_Arrow", true)
            {
                scale = 0.5f, rotation = 0f, anchorX = 0.5f, anchorY = 0.5f, x = this.size.x - 15f, y = 20f, color = this.colorText
            };
            arrDown = new FSprite("Big_Menu_Arrow", true)
            {
                scale = 0.5f, rotation = 180f, anchorX = 0.5f, anchorY = 0.5f, x = this.size.x - 15f, y = 10f, color = this.colorText
            };
            myContainer.AddChild(arrUp); myContainer.AddChild(arrDown);

            bumpUp = new BumpBehaviour(this); bumpDown = new BumpBehaviour(this);
            OnChange();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Dragger to adjust int value in a cramped space. The fixedSize is 24x24.
        /// </summary>
        /// <param name="pos">BottomLeft</param>
        /// <param name="key">Unique <see cref="UIconfig.key"/></param>
        /// <param name="defaultInt">default value</param>
        public OpDragger(Vector2 pos, string key, int defaultInt = 0) : base(pos, new Vector2(24f, 24f), key, defaultInt.ToString())
        {
            this.fixedSize = new Vector2(24f, 24f);
            if (!_init)
            {
                return;
            }
            this.colorText = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.MediumGrey);
            this.colorEdge = Menu.Menu.MenuRGB(Menu.Menu.MenuColors.MediumGrey);
            this.colorFill = Color.black;

            this.rect = new DyeableRect(menu, owner, this.pos, this.size, true);
            this.subObjects.Add(this.rect);
            this.label = new MenuLabel(menu, owner, defaultInt.ToString(), this.pos + new Vector2(0f, 2f), new Vector2(24f, 20f), false);
            this.subObjects.Add(this.label);

            this.min         = 0; this._min = 0; this.max = 99; this._max = 99;
            this.description = InternalTranslator.Translate("Hold your mouse button and Drag up/down to adjust value");

            this.useCT = false;
        }
 /// <summary>
 /// Returns <see cref="CultureInfo"/> according to Rain World Language Settings.
 /// <seealso cref="GetLanguageID"/>
 /// </summary>
 /// <remarks>Example: <c>DateTime.ParseExact("20200123", "yyyyMMdd", null).ToString("D", GetCultureInfo());</c></remarks>
 public static CultureInfo GetCultureInfo() => InternalTranslator.GetCultureInfo();
Ejemplo n.º 13
0
 public GeneralInitializeException(string message) : base(string.Concat("GeneralInitializeException: OI had a problem in Initialize!",
                                                                        Environment.NewLine, InternalTranslator.Translate("This issue might be resolved by downloading the latest ConfigMachine."),
                                                                        Environment.NewLine, message
                                                                        ))
 {
 }