Пример #1
0
 private void Window(int window)
 {
     if (_bold_label == null)
     {
         _bold_label           = new GUIStyle(GUI.skin.label);
         _bold_label.fontStyle = FontStyle.Bold;
     }
     if (GUI.Button(new Rect(_window_position.width - 20, 2, 18, 18), "x"))
     {
         _render_window = false;
     }
     GUILayout.BeginVertical();
     if (_current_activity == null || !refinery_is_enabled)
     {
         _refinery_activities.ForEach(act =>
         {
             GUILayout.BeginHorizontal();
             if (GUILayout.Button(act.ActivityName, GUILayout.ExpandWidth(true)) && act.HasActivityRequirements)
             {
                 _current_activity   = act;
                 refinery_is_enabled = true;
             }
             GUILayout.EndHorizontal();
         });
     }
     else
     {
         GUILayout.BeginHorizontal();
         GUILayout.Label("Current Activity", _bold_label, GUILayout.Width(150));
         GUILayout.Label(_current_activity.ActivityName, GUILayout.Width(150));
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         GUILayout.Label("Status", _bold_label, GUILayout.Width(150));
         GUILayout.Label(_current_activity.Status, GUILayout.Width(150));
         GUILayout.EndHorizontal();
         _current_activity.UpdateGUI();
         GUILayout.BeginHorizontal();
         if (GUILayout.Button("Deactivate", GUILayout.ExpandWidth(true)))
         {
             refinery_is_enabled = false;
             _current_activity   = null;
         }
         GUILayout.EndHorizontal();
     }
     GUILayout.EndVertical();
     GUI.DragWindow();
 }
        private void Window(int window)
        {
            if (_bold_label == null)
            {
                _bold_label           = new GUIStyle(GUI.skin.label);
                _bold_label.fontStyle = FontStyle.Bold;
                _bold_label.font      = PluginHelper.MainFont;
            }

            if (_value_label == null)
            {
                _value_label = new GUIStyle(GUI.skin.label)
                {
                    font = PluginHelper.MainFont
                }
            }
            ;

            if (_enabled_button == null)
            {
                _enabled_button           = new GUIStyle(GUI.skin.button);
                _enabled_button.fontStyle = FontStyle.Bold;
                _enabled_button.font      = PluginHelper.MainFont;
            }

            if (_disabled_button == null)
            {
                _disabled_button           = new GUIStyle(GUI.skin.button);
                _disabled_button.fontStyle = FontStyle.Normal;
                _disabled_button.font      = PluginHelper.MainFont;
            }

            if (GUI.Button(new Rect(_window_position.width - 20, 2, 18, 18), "x"))
            {
                _render_window = false;
            }

            GUILayout.BeginVertical();

            if (_current_activity == null || !refinery_is_enabled) // if there is no processing going on or the refinery is not enabled
            {
                _refinery_activities.ForEach(act =>                // per each activity (notice the end brackets are there, 13 lines below)
                {
                    GUILayout.BeginHorizontal();
                    bool hasRequirement = act.HasActivityRequirements();                           // if the requirements for the activity are fulfilled
                    GUIStyle guistyle   = hasRequirement ? _enabled_button : _disabled_button;     // either draw the enabled, bold button, or the disabled one

                    if (GUILayout.Button(act.ActivityName, guistyle, GUILayout.ExpandWidth(true))) // if user clicks the button and has requirements for the activity
                    {
                        if (hasRequirement)
                        {
                            _current_activity   = act;  // the activity will be treated as the current activity
                            refinery_is_enabled = true; // refinery is now on
                        }
                        else
                        {
                            act.PrintMissingResources();
                        }
                    }
                    GUILayout.EndHorizontal();
                });
            }
            else
            {
                bool hasRequirement = _current_activity.HasActivityRequirements();

                // show button to enable/disable resource overflow
                GUILayout.BeginHorizontal();
                if (overflowAllowed)
                {
                    if (GUILayout.Button(Localizer.Format("#LOC_KSPIE_Refinery_DisableOverflow"), GUILayout.ExpandWidth(true)))//"Disable Overflow"
                    {
                        overflowAllowed = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(Localizer.Format("#LOC_KSPIE_Refinery_EnableOverflow"), GUILayout.ExpandWidth(true)))//"Enable Overflow"
                    {
                        overflowAllowed = true;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(Localizer.Format("#LOC_KSPIE_Refinery_CurrentActivity"), _bold_label, GUILayout.Width(RefineryActivityBase.labelWidth));//"Current Activity"
                GUILayout.Label(_current_activity.ActivityName, _value_label, GUILayout.Width(RefineryActivityBase.valueWidth * 2));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(Localizer.Format("#LOC_KSPIE_Refinery_Status"), _bold_label, GUILayout.Width(RefineryActivityBase.labelWidth));//"Status"
                GUILayout.Label(_current_activity.Status, _value_label, GUILayout.Width(RefineryActivityBase.valueWidth * 2));
                GUILayout.EndHorizontal();

                // allow current activity to show feedback
                _current_activity.UpdateGUI();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(Localizer.Format("#LOC_KSPIE_Refinery_DeactivateProcess"), GUILayout.ExpandWidth(true)))//"Deactivate Process"
                {
                    refinery_is_enabled = false;
                    _current_activity   = null;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
    }
Пример #3
0
        private void Window(int window)
        {
            if (_bold_label == null)
            {
                _bold_label           = new GUIStyle(GUI.skin.label);
                _bold_label.fontStyle = FontStyle.Bold;
            }

            if (_enabled_button == null)
            {
                _enabled_button           = new GUIStyle(GUI.skin.button);
                _enabled_button.fontStyle = FontStyle.Bold;
            }

            if (_disabled_button == null)
            {
                _disabled_button           = new GUIStyle(GUI.skin.button);
                _disabled_button.fontStyle = FontStyle.Normal;
            }



            if (GUI.Button(new Rect(_window_position.width - 20, 2, 18, 18), "x"))
            {
                _render_window = false;
            }

            GUILayout.BeginVertical();

            if (_current_activity == null || !refinery_is_enabled)
            {
                _refinery_activities.ForEach(act =>
                {
                    GUILayout.BeginHorizontal();
                    bool hasRequirement = act.HasActivityRequirements;
                    GUIStyle guistyle   = hasRequirement ? _enabled_button : _disabled_button;

                    if (GUILayout.Button(act.ActivityName, guistyle, GUILayout.ExpandWidth(true)) && hasRequirement)
                    {
                        _current_activity   = act;
                        refinery_is_enabled = true;
                    }
                    GUILayout.EndHorizontal();
                });
            }
            else
            {
                // show button to enable/disable resource overflow
                GUILayout.BeginHorizontal();
                if (overflowAllowed)
                {
                    if (GUILayout.Button("Disable Overflow", GUILayout.ExpandWidth(true)))
                    {
                        overflowAllowed = false;
                    }
                }
                else
                {
                    if (GUILayout.Button("Enable Overflow", GUILayout.ExpandWidth(true)))
                    {
                        overflowAllowed = true;
                    }
                }
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Current Activity", _bold_label, GUILayout.Width(labelWidth));
                GUILayout.Label(_current_activity.ActivityName, GUILayout.Width(valueWidth));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label("Status", _bold_label, GUILayout.Width(labelWidth));
                GUILayout.Label(_current_activity.Status, GUILayout.Width(valueWidth));
                GUILayout.EndHorizontal();

                // allow current activity to show feedback
                _current_activity.UpdateGUI();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Deactivate Proces", GUILayout.ExpandWidth(true)))
                {
                    refinery_is_enabled = false;
                    _current_activity   = null;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
        private void Window(int window)
        {
            if (_boldLabel == null)
            {
                _boldLabel = new GUIStyle(GUI.skin.label)
                {
                    fontStyle = FontStyle.Bold, font = PluginHelper.MainFont
                }
            }
            ;

            if (_valueLabel == null)
            {
                _valueLabel = new GUIStyle(GUI.skin.label)
                {
                    font = PluginHelper.MainFont
                }
            }
            ;

            if (_enabledButton == null)
            {
                _enabledButton = new GUIStyle(GUI.skin.button)
                {
                    fontStyle = FontStyle.Bold, font = PluginHelper.MainFont
                }
            }
            ;

            if (_disabledButton == null)
            {
                _disabledButton = new GUIStyle(GUI.skin.button)
                {
                    fontStyle = FontStyle.Normal, font = PluginHelper.MainFont
                }
            }
            ;

            if (GUI.Button(new Rect(_windowPosition.width - 20, 2, 18, 18), "x"))
            {
                showWindow = false;
            }

            GUILayout.BeginVertical();

            if (currentActivity == null || !refinery_is_enabled) // if there is no processing going on or the refinery is not enabled
            {
                availableRefineries.ForEach(activity =>          // per each activity (notice the end brackets are there, 13 lines below)
                {
                    GUILayout.BeginHorizontal();
                    bool hasRequirement = activity.HasActivityRequirements();                // if the requirements for the activity are fulfilled
                    GUIStyle guiStyle   = hasRequirement ? _enabledButton : _disabledButton; // either draw the enabled, bold button, or the disabled one

                    var buttonText = string.IsNullOrEmpty(activity.Formula) ? activity.ActivityName : activity.ActivityName + " : " + activity.Formula;

                    if (GUILayout.Button(buttonText, guiStyle, GUILayout.ExpandWidth(true))) // if user clicks the button and has requirements for the activity
                    {
                        ToggleRefinery(activity);
                    }
                    GUILayout.EndHorizontal();
                });
            }
            else
            {
                bool hasRequirement = currentActivity.HasActivityRequirements();

                // show button to enable/disable resource overflow
                GUILayout.BeginHorizontal();
                if (_overflowAllowed)
                {
                    if (GUILayout.Button(Localizer.Format("#LOC_KSPIE_Refinery_DisableOverflow"), GUILayout.ExpandWidth(true)))//"Disable Overflow"
                    {
                        _overflowAllowed = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(Localizer.Format("#LOC_KSPIE_Refinery_EnableOverflow"), GUILayout.ExpandWidth(true)))//"Enable Overflow"
                    {
                        _overflowAllowed = true;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(Localizer.Format("#LOC_KSPIE_Refinery_CurrentActivity"), _boldLabel, GUILayout.Width(RefineryActivity.labelWidth));//"Current Activity"
                GUILayout.Label(currentActivity.ActivityName, _valueLabel, GUILayout.Width(RefineryActivity.valueWidth * 2));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(Localizer.Format("#LOC_KSPIE_Refinery_Status"), _boldLabel, GUILayout.Width(RefineryActivity.labelWidth));//"Status"
                GUILayout.Label(currentActivity.Status, _valueLabel, GUILayout.Width(RefineryActivity.valueWidth * 2));
                GUILayout.EndHorizontal();

                // allow current activity to show feedback
                currentActivity.UpdateGUI();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(Localizer.Format("#LOC_KSPIE_Refinery_DeactivateProcess"), GUILayout.ExpandWidth(true)))//"Deactivate Process"
                {
                    refinery_is_enabled = false;
                    currentActivity     = null;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
    }
}