void DrawAddress() { if (Server.Running) { GUILayout.Label(addressLabelText + " " + Server.Address, labelStyle); } else { GUILayout.Label(addressLabelText, labelStyle); // Get the index of the address in the combo box int selected; if (!manualAddress && address == IPAddress.Loopback.ToString()) { selected = 0; } else if (!manualAddress && address == IPAddress.Any.ToString()) { selected = 1; } else if (!manualAddress && availableAddresses.Contains(address)) { selected = availableAddresses.IndexOf(address); } else { selected = availableAddresses.Count - 1; } // Display the combo box selected = GUILayoutExtensions.ComboBox("address", selected, availableAddresses, buttonStyle, comboOptionsStyle, comboOptionStyle); // Get the address from the combo box selection if (selected == 0) { address = IPAddress.Loopback.ToString(); manualAddress = false; } else if (selected == 1) { address = IPAddress.Any.ToString(); manualAddress = false; } else if (selected < availableAddresses.Count - 1) { address = availableAddresses [selected]; manualAddress = false; } else { // Display a text field when "Manual" is selected address = GUILayout.TextField(address, addressMaxLength, stretchyTextFieldStyle); manualAddress = true; } } }
public void Draw() { GUILayout.BeginHorizontal(); GUILayout.Label(protocolLabelText, window.labelStyle); protocol = (Protocol)GUILayoutExtensions.ComboBox("protocol", (int)protocol, availableProtocols, window.buttonStyle, window.comboOptionsStyle, window.comboOptionStyle); GUILayout.EndHorizontal(); if (protocol == Protocol.ProtocolBuffersOverTCP || protocol == Protocol.ProtocolBuffersOverWebsockets) { GUILayout.BeginHorizontal(); GUILayout.Label(addressLabelText, window.labelStyle); if (!settings.ContainsKey("address")) { settings["address"] = IPAddress.Loopback.ToString(); } var address = settings["address"]; // Get the index of the address in the combo box int addressSelected; if (!manualAddress && address == IPAddress.Loopback.ToString()) { addressSelected = 0; } else if (!manualAddress && address == IPAddress.Any.ToString()) { addressSelected = 1; } else if (!manualAddress && availableAddresses.Contains(address)) { addressSelected = availableAddresses.IndexOf(address); } else { addressSelected = availableAddresses.Count - 1; } // Display the combo box addressSelected = GUILayoutExtensions.ComboBox("address", addressSelected, availableAddresses, window.buttonStyle, window.comboOptionsStyle, window.comboOptionStyle); // Get the address from the combo box selection if (addressSelected == 0) { address = IPAddress.Loopback.ToString(); manualAddress = false; } else if (addressSelected == 1) { address = IPAddress.Any.ToString(); manualAddress = false; } else if (addressSelected < availableAddresses.Count - 1) { address = availableAddresses[addressSelected]; manualAddress = false; } else { // Display a text field when "Manual" is selected address = GUILayout.TextField(address, addressMaxLength, window.stretchyTextFieldStyle); manualAddress = true; } settings["address"] = address; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(rpcPortLabelText, window.labelStyle); if (!settings.ContainsKey("rpc_port")) { settings["rpc_port"] = "50000"; } settings["rpc_port"] = GUILayout.TextField(settings["rpc_port"], portMaxLength, window.longTextFieldStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(streamPortLabelText, window.labelStyle); if (!settings.ContainsKey("stream_port")) { settings["stream_port"] = "50000"; } settings["stream_port"] = GUILayout.TextField(settings["stream_port"], portMaxLength, window.longTextFieldStyle); GUILayout.EndHorizontal(); } }
public void Draw() { GUILayout.BeginHorizontal(); GUILayout.Label(protocolLabelText, window.labelStyle); protocol = (Protocol)GUILayoutExtensions.ComboBox("protocol", (int)protocol, availableProtocols, window.buttonStyle, window.comboOptionsStyle, window.comboOptionStyle); GUILayout.EndHorizontal(); if (protocol == Protocol.ProtocolBuffersOverTCP || protocol == Protocol.ProtocolBuffersOverWebsockets) { GUILayout.BeginHorizontal(); GUILayout.Label(addressLabelText, window.labelStyle); if (!settings.ContainsKey("address")) { settings["address"] = IPAddress.Loopback.ToString(); } var address = settings["address"]; // Get the index of the address in the combo box int addressSelected; if (!manualAddress && address == IPAddress.Loopback.ToString()) { addressSelected = 0; } else if (!manualAddress && address == IPAddress.Any.ToString()) { addressSelected = 1; } else if (!manualAddress && availableAddresses.Contains(address)) { addressSelected = availableAddresses.IndexOf(address); } else { addressSelected = availableAddresses.Count - 1; } // Display the combo box addressSelected = GUILayoutExtensions.ComboBox("address", addressSelected, availableAddresses, window.buttonStyle, window.comboOptionsStyle, window.comboOptionStyle); // Get the address from the combo box selection if (addressSelected == 0) { address = IPAddress.Loopback.ToString(); manualAddress = false; } else if (addressSelected == 1) { address = IPAddress.Any.ToString(); manualAddress = false; } else if (addressSelected < availableAddresses.Count - 1) { address = availableAddresses[addressSelected]; manualAddress = false; } else { // Display a text field when "Manual" is selected address = GUILayout.TextField(address, addressMaxLength, window.stretchyTextFieldStyle); manualAddress = true; } settings["address"] = address; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(rpcPortLabelText, window.labelStyle); if (!settings.ContainsKey("rpc_port")) { settings["rpc_port"] = "50000"; } settings["rpc_port"] = GUILayout.TextField(settings["rpc_port"], portMaxLength, window.longTextFieldStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(streamPortLabelText, window.labelStyle); if (!settings.ContainsKey("stream_port")) { settings["stream_port"] = "50000"; } settings["stream_port"] = GUILayout.TextField(settings["stream_port"], portMaxLength, window.longTextFieldStyle); GUILayout.EndHorizontal(); } else { if (!settings.ContainsKey("baud_rate")) { settings["baud_rate"] = "9600"; } if (!settings.ContainsKey("data_bits")) { settings["data_bits"] = "8"; } GUILayout.BeginHorizontal(); GUILayout.Label(portLabelText, window.labelStyle); if (!settings.ContainsKey("port")) { settings["port"] = new KRPC.IO.Ports.SerialPort().PortName; } settings["port"] = GUILayout.TextField( settings["port"], portNameMaxLength, window.longTextFieldStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(baudRateLabelText, window.labelStyle); if (!settings.ContainsKey("baud_rate")) { settings["baud_rate"] = "9600"; } settings["baud_rate"] = GUILayout.TextField( settings["baud_rate"], baudRateMaxLength, window.longTextFieldStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(dataBitsLabelText, window.labelStyle); if (!settings.ContainsKey("data_bits")) { settings["data_bits"] = "8"; } settings["data_bits"] = GUILayout.TextField( settings["data_bits"], dataBitsMaxLength, window.longTextFieldStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(parityLabelText, window.labelStyle); if (!settings.ContainsKey("parity")) { settings["parity"] = "None"; } settings["parity"] = parityOptions [GUILayoutExtensions.ComboBox( "parity", parityOptions.IndexOf(settings["parity"]), parityOptions, window.buttonStyle, window.comboOptionsStyle, window.comboOptionStyle)]; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(stopBitsLabelText, window.labelStyle); if (!settings.ContainsKey("stop_bits")) { settings["stop_bits"] = "One"; } settings["stop_bits"] = stopBitsOptions [GUILayoutExtensions.ComboBox( "stop_bits", stopBitsOptions.IndexOf(settings["stop_bits"]), stopBitsOptions, window.buttonStyle, window.comboOptionsStyle, window.comboOptionStyle)]; GUILayout.EndHorizontal(); } }