Closed MOARdV closed 6 years ago
Here's an example of what I have in mind, with explanations in the next post, since this one is very long.
<PropConfig>
<ToggleSwitch>
<Style name="MOARdV Power Switch">
<Model>
<Comment>Base</Comment>
<Model>ASET/ASET_Props/Control/Switch_Toggle_Modular/models/TgglBase</Model>
<Texture>Switch_TUMBLEDiffuse,ASET/ASET_Props/Control/Switch_Tumble/Switch_TUMBLEDiffuse</Texture>
</Model>
<Model>
<Comment>Basic toggle</Comment>
<Model>ASET/ASET_Props/Control/Switch_Toggle_Modular/models/TgglLever_Type_5</Model>
<Texture>Switch_TUMBLEDiffuse,ASET/ASET_Props/Control/Switch_Tumble/Switch_TUMBLEDiffuse</Texture>
<Texture>Tggl_Cap_Diffuse,ASET/ASET_Props/Control/Switch_Toggle_Modular/models/Tggl_Cap_White</Texture>
</Model>
<Model>
<Comment>Square glow border</Comment>
<Model>ASET/ASET_Props/Control/Switch_Toggle_Modular/models/TgglBase_Bcklt_12</Model>
<Texture>Switch_TUMBLEDiffuse,ASET/ASET_Props/Control/Switch_Tumble/Switch_TUMBLEDiffuse</Texture>
</Model>
<Model>
<Comment>Simple Collider</Comment>
<Model>ASET/ASET_Props/Control/Switch_Toggle_Modular/models/TgglCollider_SNGL</Model>
</Model>
<Collider id="0">
<Name>Collider</Name>
<Collider>SwitchCollider</Collider>
<Sound>ASET/ASET_Props/Sounds/RPB01</Sound>
<Volume>1</Volume>
</Collider>
<Rotation>
<Name>Lever Movement</Name>
<Transform>SwitchGrp</Transform>
<StartRotation>33,0,0</StartRotation>
<EndRotation>-33,0,0</EndRotation>
<Range>0, 1</Range>
<Blend>true</Blend>
<CycleRate>1</CycleRate>
</Rotation>
<Text id="0">
<Name>Top Label</Name>
<Transform>TextTopObj</Transform>
<FontSize>6.1</FontSize>
<LineSpacing></LineSpacing>
<Font></Font>
<Style><Style>
<Alignment></Alignment>
<Anchor></Anchor>
<TransformOffset></TransformOffset>
<Emmissive></Emmissive>
<Blend>true</Blend>
<Range>0, 1</Range>
<ActiveColor></ActiveColor>
<PassiveColor></PassiveColor>
</Text>
<ColorShift id="0">
<Name>Border</Name>
<Transform>GlowBorder, switchCapObj</Transform>
<PassiveColor>0,0,0,255</PassiveColor>
<ActiveColor>COLOR_ASET_SWITCHER_BORDER_POSITIVECOLOR</ActiveColor>
<Blend>true</Blend>
<Range>0, 1</Range>
</ColorShift>
</Style>
<Prop>
<Name>MAS_toggle_IMP_Power</Name>
<Style>MOARdV Power Switch</Style>
<Collider id="0">fc.SetPersistent("MAS_IMP_Mode", fc.TogglePersistent("MAS_IMP_On") * fc.GetPersistentAsNumber("MAS_IMP_Mode_Select"))</Collider>
<Rotation>fc.GetPersistentAsNumber("MAS_IMP_On")</Rotation>
<Text id="0">
<Text>ON</Text>
<Variable>fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))</Variable>
</Text>
<ColorShift id="0">fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))</ColorShift>
</Prop>
<Prop>
<Name>MAS.toggle_ARRT_Power</Name>
<Style>MOARdV Power Switch</Style>
<Collider id="0">ARRT_TogglePower()</Collider>
<Rotation>fc.GetPersistentAsNumber("MAS_ARRT_On")</Rotation>
<Text id="0">
<Text>ON</Text>
<Variable>fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))</Variable>
</Text>
<ColorShift id="0">fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))</ColorShift>
</Prop>
</ToggleSwitch>
</PropConfig>
<PropConfig>
Top level node. Contains all of the prop categories.
<ToggleSwitch>
Denotes that this section of the config file describes toggle switches (Switch_Toggle_Modular). There will be categories for other prop types (Push_Button_Modular, ASET_SignalLamp, CrewManual01, the digital indicator props, Indicator ADV props, and so on are all good candidates).
<Style name="MOARdV Power Switch">
Each category of prop requires at least one Style. There can be as many as are needed. The style lists all of the common copy/paste fields used to configure props with a particular appearance.
<Model>
<Comment>Base</Comment>
<Model>ASET/ASET_Props/Control/Switch_Toggle_Modular/models/TgglBase</Model>
<Texture>Switch_TUMBLEDiffuse,ASET/ASET_Props/Control/Switch_Tumble/Switch_TUMBLEDiffuse</Texture>
</Model>
Each Style lists the Model nodes required for the prop (again, at least one, as many as are required). Each Model node must contain a Model, and it may contain one or more Texture entries. It may optionally have a Comment. The above XML will result in the following config snippet
// Base
MODEL
{
model = ASET/ASET_Props/Control/Switch_Toggle_Modular/models/TgglBase
texture = Switch_TUMBLEDiffuse,ASET/ASET_Props/Control/Switch_Tumble/Switch_TUMBLEDiffuse
}
The remainder of the entries in the Style serve a similar purpose, just for their corresponding node types (eg, ColorShift becomes the COLOR_SHIFT node for MASComponent). The fields inside each of these nodes corresponds to fields in the config node. For components that may appear more than once in a prop, such as Text and Collider, and id
attribute is added to allow the prop configuration to select the correct config node.
<Prop>
<Name>MAS_toggle_IMP_Power</Name>
<Style>MOARdV Power Switch</Style>
<Collider id="0">fc.SetPersistent("MAS_IMP_Mode", fc.TogglePersistent("MAS_IMP_On") * fc.GetPersistentAsNumber("MAS_IMP_Mode_Select"))</Collider>
<Rotation>fc.GetPersistentAsNumber("MAS_IMP_On")</Rotation>
<Text id="0">
<Text>ON</Text>
<Variable>fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))</Variable>
</Text>
<ColorShift id="0">fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))</ColorShift>
</Prop>
This is the entire configuration for a single prop. It names the prop (the prop's name is also used as the .cfg file name, with any '.' in the prop name replaced with '_'), tells the configurator which style to use, and it fills in the fields that make the prop unique.
Things I still need to decide:
activeColor
for a COLOR_SHIFT, this design requires a completely new Style.Looks great. I would like to be able to override the style in the prop, could cut down on the number of styles I need.
I would like to be able to override the style in the prop, could cut down on the number of styles I need.
Yeah, now that I've had a few minutes to walk away from the first draft, I agree. I am going to rename elements to match the case that's used in the config file as well, which will make implementation easier (I hope), and reduce confusion from different names and capitalization patterns.
Okay. I have a beta of the Prop Config tool available on DropBox for anyone feeling adventurous. I've given it basic testing, but there may still be bugs to fix or improvements that need to be done. I've documented it on the wiki, and there is a sample input XML file here that will be included in the next MAS beta release. I'll be updating that XML file as I convert some of the common props over to automatic generation.
EDIT: I should note that the XML schema I used earlier in this issue is not the final schema that I adopted, so don't expect the sample input file to match what I put here earlier in this issue.
90% of the work for modular switches is copy / paste. There are a few small edits needed (file name, part name, a couple of other lines), but it's still a lot of repetitive work ... which means it's a good candidate for automation.
My initial idea is to write a tool in C# (to be consistent with the rest of the KSP stuff) that takes an XML file as input and generates MAS config files. This will eliminate some of the tedium of converting ASET Props to MAS, and it will hopefully eliminate the bugs that crop up in copy/edit/paste.
I need to design the proposed XML schema - I have some ideas, but I need to write them out and see if they make sense.