Jump to content

[Abandoned] LightSwitch Interface


Razchek

Recommended Posts

Nicely done! I'm looking forward to details on how it all hooks up. How did LightSwitch know to show a Kethane level indicator near the bottom? Was that configured manually?

At the moment it uses a part config for displaying the menu items. The Kethane resource field is displayed this way manually as well.

Using the part config is super ugly and is going to change after the first alpha release. But, to stop delaying this is what will be available right of the bat lol.

I'm working on using an XML node tree for the interface design (positioning, textures, 3D objects, color etc are planned - doing that in a config file would make it even more hideous).

I plan to make the interface editor in-game and also have real-time customization available in the future. This customization will be accessible from other plugins so that other mod developers can customize the UI otg.

MenuItems = Kethane,Drill Status:,Deploy Drill,Retract Drill,,, ,latlong,science
MIActionNames = null,f:Kethane.KethaneExtractor.Status,e:DeployDrill,e:RetractDrill,,,r:Kethane,l:,s:0

ColliderItems = sphereOfHello
CIActionNames = m:d:\Event1.ogg


Above you see a snippet of the config used in that video.
The first line are labels, or prefixes to a label.
The second line consists of actions.
- An empty entry or "null" represents a static non-component label.
- Entries beginning with:
-- "f:" are KSPField displays. The MenuItem in the same index represents the prefix. In the example above the field "Kethane.KethaneExtractor.Status" is referenced.
-- "e:" are KSPEvent invokers. The MenuItem in the same index represents the button text. In the examples above the methods DeployDrill and RetractDrill are located and invoked on mouse down.
-- "r:" are Resource indicators. The MenuItem in the same index represents the prefix. The value to the right of the colon specifies which resource to display.
-- "l:" represents Latitude, Longtitude. The MenuItem in the same index is not used (same goes for "s:").
-- "s:" are used for the Science utilities. 0 - Display All, 1 - Temperature, 2 - Gravity, 3 - Acceleration, 4 - Pressure. Only one number is used at this time. I will probably bit-shift the values later.
-- "m:" are movie player components. To the right of the first semicolon is the local path to the ogg file (you can use http:// but a buffering animation has not been implemented yet, so you will be waiting in suspense lol).

Edited by Razchek
Link to comment
Share on other sites

You might reconsider using config nodes. The System.Xml namespace is banned in plugin code, and config nodes are a bit more powerful than you might first expect. You could have a more complex structure like this:


MenuItems
{
Label
{
Text = Kethane
Color = 0, 0.9, 0
}
Label
{
Text = {
Binding = KSPField
Path = Kethane.KethaneExtractor.Status
}
}
Action
{
Name = DeployDrill
}
}

Link to comment
Share on other sites

just beware that it's easy to get an error that will break the hangar UI if you do a config node save on a part if it's the very first part loaded (i.e. command module) when loading/starting a craft. Loading nodes is no problem though. I have some code you can look at if you want.

Link to comment
Share on other sites

Here is the video I said I would post showing off the event-trigger feature.

I think a release candidate is very soon to follow, only a few more things to touch up before the alpha release.

Info about the video in-scene:

- Resolution: 1280 x 720 @ 6 mb/s (OGG/Theora Codec)

- Audio: 128 kb/s Stereo @ 44.1 khz (OGG/Vorbis Codec)

- Duration: 8 seconds~

- File size: 1,886 KB

As per a restriction in unity, any videos will need to use the OGG (Theora/Vorbis) format.

I used VLC to convert the mp4's I originally created. On the plus side VLC can play the movies back too. (don't worry, my default media player is MPC-HC <3)

--

Oh and sorry for my horrible "event" innovation and bad word-scripting. I'm a software developer, so naturally my voice acting skills are awful. :P

AND yes, there are generators on the stranded vehicle - that's beyond the point of the video. >_>

Amazing!

:D

Link to comment
Share on other sites

The first alpha release will be up in a few hours.

just beware that it's easy to get an error that will break the hangar UI if you do a config node save on a part if it's the very first part loaded (i.e. command module) when loading/starting a craft. Loading nodes is no problem though. I have some code you can look at if you want.

I ended up implementing the node config system for the first alpha release. The nodes are not in the part config file, they're stored in separate files in a folder (multiple interfaces). :)

Download is here. See the first post. :)

Edited by Razchek
Link to comment
Share on other sites

Sorry to double post, but I feel subscribers would like to be notified.

Check the first post for download information! :cool:

Please, I would love to hear feedback, bugs, suggestions.

What would you like to see? :D

Link to comment
Share on other sites

I'm impressed at how much of the node structure you got done already. One note on config node loading: you can use the GameDatabase to load nodes from any file, which is really handy for keeping mods in their own directories. For example, GameDatabase.Instance.GetConfigNodes("LightswitchInterface") will enumerate all the LightswitchInterface{} nodes in any of the config files under the GameData folder.

I'm not at my development computer, but I'll play with this a bit when I get back.

Link to comment
Share on other sites

I'm impressed at how much of the node structure you got done already. One note on config node loading: you can use the GameDatabase to load nodes from any file, which is really handy for keeping mods in their own directories. For example, GameDatabase.Instance.GetConfigNodes("LightswitchInterface") will enumerate all the LightswitchInterface{} nodes in any of the config files under the GameData folder.

I'm not at my development computer, but I'll play with this a bit when I get back.

Thank you, it was quick work once I understood enough about the nodes. The code is dirty, but cleaning and optimization comes later. :)

I've added your suggestion to my to do list. Definitely something I overlooked lol.

Link to comment
Share on other sites

Hehe, it wont be long until someone comes along and says all the actions on his boat dont show up...all it does is show Thank you for downloading.

I do have a bug to report - the text floated from off the projection screen and onto the screen from some low part of the craft.

All I done with the mod is copy the Huds folder to the gamedata folder with the rest of my mods, and slapped on the part onto a pre-existing craft, and then right-click show LSI interface, it opened up nicely with nothing on the screen...then the text floated up onto the screen.

Am I right in thinking this interface could be used as a action group event that can ...say turn on the lights, or even better turn on specified set of lights?

I am thinking slap this on a space station, and then use it to activate components of the station..say strobe lights from the aviation light pack when you dock, unpack all the solar panels when docking a large craft.

Will the interface allow for 'programming' actions on such ?

Woah, what about servos and rotatrons from the Infernal Robotics mod, or its little extra mod that allows for sliding gantries and rotating docking ports. I better stop thinking, my mind she is blown :P

Link to comment
Share on other sites

Well it seems on an initial glance that there will be a lot of interfaces, or parts of interfaces, that will be very common and duplicated, like fuel displays on stock tanks. Maybe there could be a repository for interfaces?

Link to comment
Share on other sites

Hey guys just downloaded the alpha and attempted to make my own parts with my own interfaces. Creating the parts was successful. They show up in the VAB with their modified names and descriptions, however, something's wrong when referencing the interface. I got the default part to work with the modified config file explained in the readme

Code:

MenuItems
{
Label
{
Text = Vessel Status
Color = 0,0,0
}
Label
{
Text
{
Binding = Resource
Name = ElectricCharge
}
Prefix = Electricity:_
Suffix = _units
Color = 0,0,0.6
}
Label
{
Text
{
Binding = Environment
Type = LatAndLong
}
Color32 = 255,70,0
}
}

And all of that shows up except for latitude and longitude.

But for the custom parts and interfaces I made, it simply won't even project the interface let alone display anything on it.

Here's the code I made for a vessel status interface. The file is named "VesselStatus.cfg" and is located in GameData/Hubs/Interface Designs

Code:

MenuItems
{
Label
{
Text = Vessel Status:
Color = 1, 1, 1, 0.25
}
Label
{
Text
{
Binding = Resource
Name = ElectricCharge
}
Prefix = Electricity:_
Suffix = _units
Color32 = 255, 255, 0, 0.75
}
Label
{
Text
{
Binding = Resource
Name = LiquidFuel
}
Prefix = Liquid_Fuel:_
Suffix = _units
Color32 = 255, 119, 0, 0.75
}
Label
{
Text
{
Binding = Resource
Name = Oxidizer
}
Prefix = Oxidizer:_
Suffix = _units
Color32 = 51, 255, 238, 0.75
}
Label
{
Text
{
Binding = Resource
Name = MonoPropellant
}
Prefix = Mono_Propellant:_
Suffix = _units
Color32 = 238, 238, 238, 0.75
}
Label
{

Text
{
Binding = Environment
Type = LatAndLong
}
Color32 = 0, 0, 0, 0
}
}

And here is the code for the corresponding part config

Code:

PART {

// --- general parameters ---
name = LSGUI_VesselStatus
module = Part
author = Razchek | Hubs.co.nz

// --- asset parameters ---
mesh = LSGUI_VesselStatus.mu

// --- node definitions ---
node_attach = 0.038, 0.0, 0.0, 1, 0, 0

// --- editor parameters ---
cost = 750
category = Utility
subcategory = 0
title = L.S.I Projector MkI - Vessel Status
manufacturer = Hubs' Electrical
description = A clean-cut external projection computer module for displaying current resource amount for any craft.

// attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
attachRules = 0,1,0,0,1

// --- standard part parameters ---
mass = 0.0005
dragModelType = default
maximum_drag = 0.0
minimum_drag = 0.0
angularDrag = 0
crashTolerance = 6
maxTemp = 2900

MODULE
{
name = LSPartModule
InterfaceName = VesselStatus
}
}

The name of the part config file is "LSGUI_VesselStatus.cfg" and is located in GameData\Hubs\Parts\Utility\LSGUI_VesselStatus

Can anyone point out what I'm doing wrong?

Thanks Razchek for the cool mod!

Link to comment
Share on other sites

I do have a bug to report - the text floated from off the projection screen and onto the screen from some low part of the craft.

A quick video replicating the bug ASnogarD mentioned:

Link to comment
Share on other sites

@ASnogarD:

I had forgotten to test the latest code addition at launch and at zero and negative speed. I will upload a fix shortly for that bug lol sorry.

You could potentially assign it to switch individual lights on/off, at this stage only if you've written a plugin with a KSPEvent for different sets. I plan to implement the stock modules into the events at some point.

Well it seems on an initial glance that there will be a lot of interfaces, or parts of interfaces, that will be very common and duplicated, like fuel displays on stock tanks. Maybe there could be a repository for interfaces?

That will happen. :)

And all of that shows up except for latitude and longitude.
Fixed for the next update. Thanks for that pointing that out.
But for the custom parts and interfaces I made, it simply won't even project the interface let alone display anything on it.

Here's the code I made for a vessel status interface. The file is named "VesselStatus.cfg" and is located in GameData/Hubs/Interface Designs ...

Color values can be single precision floating point numbers. Values between 0.0 to 1.0 are valid.

Color32 values can only be absolute numbers varying between 0 to 255. (0.75 wouldn't work for example)

Both are in the format R,G,B,A

The following interface worked. I did notice that I had to delete the part from my ship in the VAB/SPH and put it on there again for it to update the vessel information (because it persisted, I believe that should be a bug so I'll look at that).

Also, does your part have the same components (including the light) as the prefab provided?

MenuItems{
Label
{
Text = Vessel Status:
Color = 1, 1, 1, 0.25
}
Label
{
Text
{
Binding = Resource
Name = ElectricCharge
}
Prefix = Electricity:_
Suffix = _units
Color32 = 255, 255, 0, 100
}
Label
{
Text
{
Binding = Resource
Name = LiquidFuel
}
Prefix = Liquid_Fuel:_
Suffix = _units
Color32 = 255, 119, 0, 190
}
Label
{
Text
{
Binding = Resource
Name = Oxidizer
}
Prefix = Oxidizer:_
Suffix = _units
Color32 = 51, 255, 238, 190
}
Label
{
Text
{
Binding = Resource
Name = MonoPropellant
}
Prefix = Mono_Propellant:_
Suffix = _units
Color32 = 238, 238, 238, 190
}
Label
{


Text
{
Binding = Environment
Type = LatAndLong
}
Color32 = 0, 0, 0, 0
}
}

A quick video replicating the bug ASnogarD mentioned:

--

Thank you. :) When I tested this before releasing I had just updated the alignment code to account for speed (so the hit boxes would catch up at higher speeds). I had already started moving before I switched the interface on so the text position was already being modified.

I will post an update shortly that will fix this problem.

Razchek, You might want to include an example button Interface, because the readme is a bit confusing

Sorry about that, the documentation was rushed. Was there something in particular you'd like me to cover better?

Put a LT-2 Landing Strut (or a few) on your ship and try this:

MenuItems
{
Button
{
Text = Toggle Thy Legs
Type = Animation
Target = newlandingleg
}
}

Edited by Razchek
Link to comment
Share on other sites

Color values can be single precision floating point numbers. Values between 0.0 to 1.0 are valid.

Color32 values can only be absolute numbers varying between 0 to 255. (0.75 wouldn't work for example)

Doh! I knew I was missing something simple. :D

Also, does your part have the same components (including the light) as the prefab provided?

I basically copied the prefab part and changed the config file to reference the corresponding interface for that part.

And what do you know, I corrected the color32 a values and it works like a charm! Awesome stuff!

However, I have run into one more predicament: I cannot get the resources Metal and RocketParts to show up on the interface. I'm new to all of this, so I don't know if I'm doing something wrong, or if it's just not supported. I got Ore to work so I figured Metal and RocketParts would be the same. Code follows

Code:

MenuItems
{
Label
{
Text = Mining Status:
Color = 1, 1, 1, 0.75
}
Label
{
Text
{
Binding = Resource
Name = ElectricCharge
}
Prefix = Electricity:_
Suffix = _units
Color32 = 255, 255, 0, 190
}
Label
{
Text
{
Binding = Resource
Name = Kethane
}
Prefix = Kethane:_
Suffix = _units
Color32 = 51, 255, 0, 190
}
Label
{
Text
{
Binding = Resource
Name = Ore
}
Prefix = Ore:_
Suffix = _units
Color32 = 204, 0, 0, 190
}
Label
{
Label
{
Text
{
Binding = Resource
Name = Metal
}
Prefix = Metal:_
Suffix = _units
Color32 = 153, 153, 153, 190
}
Label
{
Text
{
Binding = Resource
Name = RocketParts
}
Prefix = Rocket_Parts:_
Suffix = _units
Color32 = 102, 34, 0, 190
}
}

Link to comment
Share on other sites

What I don't understand is how you find what the "Target =" value should be. As far as I could find, there was no kind of way to figure out what the name of the part is. Aha, found where you can find them. The Names are listed inside the part.cfg. You might want to mention that in the Documentation.

Edit Edit: Only some of the part.cfg's have the target name. The rest I don't know what you should put. The part name?

Edited by Nicky89107
Link to comment
Share on other sites

..

However, I have run into one more predicament: I cannot get the resources Metal and RocketParts to show up on the interface. I'm new to all of this, so I don't know if I'm doing something wrong, or if it's just not supported. I got Ore to work so I figured Metal and RocketParts would be the same. Code follows ..

Could you link me the mod that has those resources? :) I'll take a look.

What I don't understand is how you find what the "Target =" value should be. As far as I could find, there was no kind of way to figure out what the name of the part is. Aha, found where you can find them. The Names are listed inside the part.cfg. You might want to mention that in the Documentation.

Edit Edit: Only some of the part.cfg's have the target name. The rest I don't know what you should put. The part name?

At the moment LightSwitch Interface doesn't natively support KSP Module events like lights, landing legs, etc.

What is supported for Button Events (again, at the moment - more in the future) are Animations, KSPEvent attributed methods and Movie Playback.

For animations - you need to know the animation name. A lot of stock parts have animations, and most of their names can be found in the part config. How-ever some will not function as you'd like (Lights, for example).

For KSPEvent attributed methods - you would need to look at the source code of a plugin and find the class and method name which you wish to use. - This is definitely aimed towards developers, but a Wiki will become available which will hopefully allow contributions on developing your own interface.

For Movie playback - well, the target is the file on your system or the internet.

Once I have implemented menu item positioning I will develop an Interface Editor which you will be able to use to create your interfaces without having to use the text file (this will be available in the beta stage).

The documentation will continue to be updated. I'll keep trying to cover everything I can in the documentation, your feedback is vital to that so thank you.

I also have a bug to report, The interface, when left open, will be invisible if you leave to the space center menu and reload the world.

This will be fixed in the next update. It is because the interface activity is persisted but not initialized on load.

Link to comment
Share on other sites

Extraplanetary Launchpads v2

Also I have a suggestion: It'd be nice to have the part assignable to Action Groups to toggle the interface so we don't have to right click on each individual one if we have multiple devices on our ship.

I literally just put that into the code. :P I will check out that mod in a few moments.

Update coming shortly. :)

Link to comment
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...