예제 #1
0
 public override void OnSave()
 {
     Items.DropAll();
     MySettings.Save(SavePath);
 }
예제 #2
0
        public override void OnGUI()
        {
            if (_listVisible)
            {
                GUI.Label(new Rect(_listPosLeft - 20.0f, Screen.height - _listPosBottom - _listLineHeight, Screen.width, _listLineHeight), $"Backpack ({Items.Count} / {Items.Capacity})", _listStyle);
                for (int i = 0; i < Items.Count; ++i)
                {
                    float  top  = Screen.height - _listPosBottom - (_listLineHeight * ((Items.Count - i) + 1));
                    string name = Items[i].name.Replace("(Clone)", "").Replace("(itemx)", "").Replace("(xxxxx)", "");
                    if (i == Items.SelectedIndex)
                    {
                        GUI.Label(new Rect(_listPosLeft - 20.0f, top, 20.0f, _listLineHeight), ">", _listStyle);
                    }
                    GUI.Label(new Rect(_listPosLeft, top, Screen.width, _listLineHeight), name, _listStyle);
                }
            }

            if (MySettings.GuiVisible)
            {
                _playerInMenu.Value = true;
                GUI.Box(MySettings.GuiBackground, "Settings");

                GUILayout.BeginArea(MySettings.GuiArea);

                GUILayout.BeginVertical();
                MySettings.Temporary.LogAll     = GUILayout.Toggle(MySettings.Temporary.LogAll, "Log everything");
                MySettings.Temporary.LogSome    = GUILayout.Toggle(MySettings.Temporary.LogSome, "Log pick-up and drop events");
                MySettings.Temporary.AddIfOpen  = GUILayout.Toggle(MySettings.Temporary.AddIfOpen, "Pick up only if the list is visible");
                MySettings.Temporary.DropIfOpen = GUILayout.Toggle(MySettings.Temporary.DropIfOpen, "Drop only if the list is visible");
                GUILayout.Label(string.Format("\nCapacity: {0}", MySettings.Temporary.MaxItems));
                MySettings.Temporary.MaxItems = Mathf.RoundToInt(GUILayout.HorizontalSlider(MySettings.Temporary.MaxItems, 1.0f, 50.0f));
                GUILayout.Label("WARNING:\nBackpack must be emptied in order to apply the settings.");
                GUILayout.EndVertical();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("OK"))
                {
                    if (Items.Count > 0)
                    {
                        ModConsole.Error($"[Backpack] Can't apply settings - backpack is not empty ({Items.Count})");
                    }
                    else
                    {
                        MySettings.Settings.AddIfOpen  = MySettings.Temporary.AddIfOpen;
                        MySettings.Settings.DropIfOpen = MySettings.Temporary.DropIfOpen;
                        MySettings.Settings.LogAll     = MySettings.Temporary.LogAll;
                        MySettings.Settings.LogSome    = MySettings.Temporary.LogSome;
                        MySettings.Settings.MaxItems   = MySettings.Temporary.MaxItems;
                        Items.Realloc();
                        MySettings.Save(SavePath);
                        MySettings.GuiVisible = false;
                        if (!_pauseMenu.activeInHierarchy)
                        {
                            _playerInMenu.Value = false;
                        }
                    }
                }
                if (GUILayout.Button("Cancel"))
                {
                    MySettings.GuiVisible = false;
                    if (!_pauseMenu.activeInHierarchy)
                    {
                        _playerInMenu.Value = false;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
            }
        }