Jump to content

The Crzy Doctor

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by The Crzy Doctor

  1. I hate to double post. Though as this still pertains to my first plugin, I'm hoping its okay. I built the gui and everything is going good. My only issue is that I can't figure out how to capture inputting text. I've been looking that API and the wiki and haven't really found anything. Along with searching the forums. I may have over looked something. Here is what I have so far. Connects to server, able to send the current text just fine. Just need some direction on changing the current text. /*Programmer: JR Padfield Description: Simple multiplayer chat plugin Version: 1 Date: 08/20/2015 */ using Lidgren.Network; using UnityEngine; namespace KSPChat { [KSPAddon(KSPAddon.Startup.EveryScene, false)] public class ChatMod : MonoBehaviour { string currentText = "Press Enter to chat"; double currentValue = 10.0; private Rect windowPostion = new Rect(); private Vector2 scrollPostion; public void Start() { RenderingManager.AddToPostDrawQueue(0, OnDraw); // Lets initiate the network. NetworkManager.Instance.InitNetwork(); } public void Update() { NetIncomingMessage im; im = NetworkManager.Instance.client.ReadMessage(); if (im != null) { // lets handle the message and update the text in a text box area. switch (im.MessageType) { case NetIncomingMessageType.DiscoveryResponse: NetworkManager.Instance.client.Connect(im.SenderEndPoint); break; case NetIncomingMessageType.Data: HandleTCP.Instance.HandleData(im); break; case NetIncomingMessageType.StatusChanged: if ((NetConnectionStatus)NetworkManager.Instance.client.ConnectionStatus == NetConnectionStatus.Disconnected) { // TODO: Figure out what to do here. } break; default: break; } } } private void OnDraw() { windowPostion = GUILayout.Window(10, windowPostion, OnWindow, "KSP Chat Program: Made by The Crzy Doctor"); } private void OnWindow(int windowId) { scrollPostion = GUILayout.BeginScrollView(scrollPostion, GUILayout.Width(400f), GUILayout.Height(200f)); GUILayout.BeginHorizontal(GUILayout.Width(400f)); HandleTCP.Instance.chatText = GUILayout.TextArea(HandleTCP.Instance.chatText); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.BeginVertical(GUILayout.Height(2f)); GUILayout.EndVertical(); GUILayout.BeginHorizontal(GUILayout.Width(400f)); this.currentText = GUILayout.TextField(currentText); if(GUILayout.Button("Send Text")) { NetworkManager.Instance.sendChat(currentText); } GUILayout.EndHorizontal(); GUI.DragWindow(); } } }
  2. Thanks for all the help. THe gui is now working and I'm working on adding in Lidgren networking so I can get a basic chat system going. Once its up and working, I'll be sure to post about it.
  3. Thanks for the help. Only thing I needed to change was to add Startup between KSPAddon and EveryScene. I'll be testing it here in a moment. Though after I get it all loaded up and actually printing to the debug console, will I need to change it back to PartModule one I start to implement a gui system? Or will this way allow to draw as well? Sorry for all the questions, I tried to follow the wiki and got lost.
  4. Thanks for the help. I'll look into it tomorrow or this coming weekend. And Yes this will eventually be a serious plugin which I'll eventually have on all the screens of the game, well the ones when your actually playing. My friend, his roommate and I all play this game. Only difference is my friend didn't buy it from steam, his roommate and I did though. Be nice to have a little text chat instead of having to run skype or something else to talk to each other while playing.
  5. As of right now it is only a print statement to make sure I have things working before i jump into making my plugin. Here is what is in the output_log pertaining to my plugin. Here is my code. (It is straight out of the wiki) Though I can't find the print statement anywhere in the log file in which the wiki says to look for. using System;using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace KSPChat { public class ChatMod : PartModule { public override void OnStart(StartState state) { Debug.Log("KSPChat system test!"); } } } Where am I going wrong? Do I need to create a Part cfg for a plugin that wont be using any thing other than gui?
×
×
  • Create New...