Jump to content

TextEdit / TextArea not working in FLIGHT Mode


Recommended Posts

I'm sure I'm just misunderstanding something fundamental, but I have a window that contains a textedit and a textarea.  When the window is rendered on the VAB, I can type into the textedit and area fields, when I am in flight mode I cannot.  Do I need to do anything special?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSP.UI.Screens;
using StatiK.Utils;
using UnityEngine;

namespace StatiK.Windows
{
    public class MissionWindow : BaseWindow
    {
        private ILogger log = StatikLogManager.Instance.GetLogger(typeof(MissionWindow).Name);

        private ApplicationLauncherButton _appButton;
        private string _missionName = "";
        private string _missionDescription = "";

        public MissionWindow(WindowSettings settings) : base(settings) { }

        public static WindowSettings GetDefaultSettings()
        {
            return new WindowSettings
            {
                Name = "MissionWindow",
                Title = "Mission",
                Dimensions = new GUIDimensions { Top = 500, Left = 800, Height = 600, Width = 400 }
            };
        }

        public override void ScrollableContent()
        {
            GUILayout.Label("Mission Name");
            _missionName = GUILayout.TextField(_missionName);
            GUILayout.Label("Mission Description");
            _missionDescription = GUILayout.TextArea(_missionDescription);
            if(GUILayout.Button("Save"))
            {
                log.Info("Mission Saved: " + _missionName + "   " + _missionDescription);
            }
        }

        public override void InitializeAppLauncherButton()
        {
            ApplicationLauncher.AppScenes eligibleGameScenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.VAB;
            if (_appButton == null)
            {
                _appButton = ApplicationLauncher.Instance.AddModApplication(this.Show, this.Hide, null, null, null, null, eligibleGameScenes, ResourceUtil.Instance.StatiKIcon);
            }
        }

        public override void DestoryAppLauncherButton()
        {
            ApplicationLauncher.Instance.RemoveApplication(_appButton);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace StatiK.Windows
{
    public abstract class BaseWindow
    {
        public Rect _container;
        public WindowSettings _settings;
        private Vector2 scrollPosition = Vector2.zero;
        private bool _shouldReDraw = false;


        public BaseWindow(WindowSettings settings)
        {
            _settings = settings;
            _container = _settings.Dimensions.GetRect();
        }

        public void OnGUI()
        {
            if (_shouldReDraw)
            {
                _container = GUILayout.Window(_settings.Id, _container, DrawWindow, _settings.Title);
            }
        }
        
        void DrawWindow(int windowId)
        {
            
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(_settings.Dimensions.Width), GUILayout.Height(_settings.Dimensions.Height));
            ScrollableContent();
            GUILayout.EndScrollView();
            GUI.DragWindow();
        }

        public void Show()
        {
            _shouldReDraw = true;
        }

        public void Hide()
        {
            _shouldReDraw = false;
        }

        public abstract void InitializeAppLauncherButton();
        public abstract void DestoryAppLauncherButton();
        public abstract void ScrollableContent();
    }
}

 

Note that the window id is generated when setting the WindowSetting's Name property: _id = _name.GetHashCode();

Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...