コード例 #1
0
 public void AddRuntimeLockedResource(int stage, string s)
 {
     if (!runtimeLockedResources.TryGetValue(StageRes.Key2(stage, s), out sr))
     {
         sr = new StageRes(stage, s);
         runtimeLockedResources.Add(sr.Key, sr);
         LockedToNode(runtimeLockedResources);
     }
 }
コード例 #2
0
        public void RemoveRuntimeLockedResource(int stage, string s)
        {

            if (runtimeLockedResources.TryGetValue(StageRes.Key2(stage, s), out sr))
            {
                sr = new StageRes(stage, s);
                runtimeLockedResources.Remove(sr.Key);
                LockedToNode(runtimeLockedResources);
            }
        }
コード例 #3
0
        public void RemoveRuntimeLockedResource(int stage, string s)
        {
            Debug.Log("RemoveRuntimeLockedResource, stage: " + stage + ", res: " + s);

            if (runtimeLockedResources.TryGetValue(StageRes.Key2(stage, s), out sr))
            {
                sr = new StageRes(stage, s);
                runtimeLockedResources.Remove(sr.Key);
                LoadRuntimeLockedResources(false);
                LockedToNode(runtimeLockedResources);
            }
        }
コード例 #4
0
        void DoSingleStage(int stage, FuelTypes.StageResDef _fuelTypes, FuelModel _resources, ref float allFuels)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Use the sliders or [E]mpty and [F]ull buttons to adjust fuel in all tanks.");
            GUILayout.EndHorizontal();

            foreach (var ftype in _fuelTypes.resources)
            {
                GUILayout.BeginHorizontal();
                int  stg    = stage;
                bool locked = FillItUp.Instance._config.RuntimeLockedResources.ContainsKey(StageRes.Key2(stg, ftype.First));
                var  s3     = "all stages";
                if (stage != StageRes.ALLSTAGES)
                {
                    s3 = "this stage";
                }
                var newLocked = GUILayout.Toggle(locked, new GUIContent(" ", "Lock this resource in " + s3));
                if (newLocked != locked)
                {
                    if (newLocked)
                    {
                        FillItUp.Instance._config.AddRuntimeLockedResource(stg, ftype.First);
                    }
                    else
                    {
                        FillItUp.Instance._config.RemoveRuntimeLockedResource(stg, ftype.First);
                    }
                }

                GUILayout.Label(ftype.First, GUILayout.Width(maxLabelSize + 5));
                if (GUILayout.Button(new GUIContent("E", "Empty"), GUILayout.Width(25)))
                {
                    _resources.Set(stage, ftype.Second, 0);
                }
                float f = _resources.Get(stage, ftype.Second) * 100;

                //GUIStyle sliderStyle = new GUIStyle("horizontalslider");
                //sliderStyle.padding.top += 5;
                //GUI.skin.horizontalSlider = sliderStyle;
                var newf = GUILayout.HorizontalSlider(f, 0, 100, GUILayout.Width(200));
                if (newf != f)
                {
                    newf = Math.Max(0, Math.Min(100, newf));
                    _resources.Set(stage, ftype.Second, newf / 100);
                }
                if (GUILayout.Button(new GUIContent("F", "Full"), GUILayout.Width(25)))
                {
                    _resources.Set(stage, ftype.Second, 1);
                }
                f = (float)Math.Round(_resources.Get(stage, ftype.Second) * 100);
                string s = GUILayout.TextField(f.ToString(), GUILayout.Width(35));
                //if (s != s1)
                {
                    try
                    {
                        var f1 = float.Parse(s);
                        if (f1 != f)
                        {
                            _resources.Set(stage, ftype.Second, f1 / 100);
                        }
                    }
                    catch
                    {
                        Log.Error("Error parsing number");
                    }
                }
                GUILayout.Label("%");
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginHorizontal();
            GUILayout.Label("All Active Fuels", boldLabelFont);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Empty", GUILayout.Width(60)))
            {
                _resources.SetAll(stage, 0);
                allFuels = 0;
            }
            GUILayout.FlexibleSpace();
            var newAllFuels = GUILayout.HorizontalSlider(allFuels, 0, 100, GUILayout.Width(250));

            if (allFuels != newAllFuels)
            {
                allFuels = newAllFuels;
                _resources.SetAll(stage, allFuels / 100);
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Full", GUILayout.Width(50)))
            {
                _resources.SetAll(stage, 1);
                allFuels = 100;
            }

            var    f2 = (float)Math.Truncate(allFuels);
            string s1 = GUILayout.TextField(f2.ToString("F0"), GUILayout.Width(35));

            //if (s != s1)
            {
                try
                {
                    var f = float.Parse(s1);
                    if (f2 != f)
                    {
                        allFuels = f;
                        _resources.SetAll(stage, allFuels / 100);
                    }
                }
                catch
                {
                    Log.Error("Error parsing number");
                }
            }
            GUILayout.Label("%");

            GUILayout.EndHorizontal();
        }
コード例 #5
0
 public void SetAll(int stage, float amount)
 {
     foreach (var fuelType in fuelTypes.resources)
     {
         bool ignored = FillItUp.Instance._config.RuntimeLockedResources.ContainsKey(StageRes.Key2(stage, fuelType.First));
         if (!ignored)
         {
             Set(stage, fuelType.Second, amount);
         }
     }
 }