mirror of
https://github.com/SCToolsfactory/SCJMapper-V2.git
synced 2024-11-04 18:00:26 +00:00
support option tags #18
support version and ignoreversion, can force ignoreversion does not longer dump empty maps supported actionmaps are preset in config file (instead of code) Doc Update
This commit is contained in:
parent
4a06ab6654
commit
7a0ec928e6
@ -190,6 +190,15 @@ public String IgnoreActionmaps
|
||||
}
|
||||
|
||||
|
||||
[UserScopedSettingAttribute( )]
|
||||
[DefaultSettingValueAttribute( "False" )] // false
|
||||
public Boolean ForceIgnoreversion
|
||||
{
|
||||
get { return ( Boolean )this["ForceIgnoreversion"]; }
|
||||
set { this["ForceIgnoreversion"] = value; }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
42
FormSettings.Designer.cs
generated
42
FormSettings.Designer.cs
generated
@ -55,14 +55,17 @@ private void InitializeComponent( )
|
||||
this.chkLbActionMaps = new System.Windows.Forms.CheckedListBox();
|
||||
this.btCancel = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
this.cbxForceIgnoreversion = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btDone
|
||||
//
|
||||
this.btDone.Location = new System.Drawing.Point(657, 340);
|
||||
this.btDone.Location = new System.Drawing.Point(658, 405);
|
||||
this.btDone.Name = "btDone";
|
||||
this.btDone.Size = new System.Drawing.Size(93, 31);
|
||||
this.btDone.TabIndex = 1;
|
||||
@ -291,7 +294,7 @@ private void InitializeComponent( )
|
||||
this.groupBox3.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.groupBox3.Location = new System.Drawing.Point(579, 12);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(274, 322);
|
||||
this.groupBox3.Size = new System.Drawing.Size(274, 387);
|
||||
this.groupBox3.TabIndex = 24;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Ignore Actionmaps - check the ones to hide";
|
||||
@ -303,13 +306,13 @@ private void InitializeComponent( )
|
||||
this.chkLbActionMaps.FormattingEnabled = true;
|
||||
this.chkLbActionMaps.Location = new System.Drawing.Point(3, 18);
|
||||
this.chkLbActionMaps.Name = "chkLbActionMaps";
|
||||
this.chkLbActionMaps.Size = new System.Drawing.Size(268, 301);
|
||||
this.chkLbActionMaps.Size = new System.Drawing.Size(268, 366);
|
||||
this.chkLbActionMaps.TabIndex = 0;
|
||||
//
|
||||
// btCancel
|
||||
//
|
||||
this.btCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btCancel.Location = new System.Drawing.Point(756, 340);
|
||||
this.btCancel.Location = new System.Drawing.Point(757, 405);
|
||||
this.btCancel.Name = "btCancel";
|
||||
this.btCancel.Size = new System.Drawing.Size(93, 31);
|
||||
this.btCancel.TabIndex = 25;
|
||||
@ -320,19 +323,42 @@ private void InitializeComponent( )
|
||||
// label1
|
||||
//
|
||||
this.label1.ForeColor = System.Drawing.Color.Red;
|
||||
this.label1.Location = new System.Drawing.Point(227, 344);
|
||||
this.label1.Location = new System.Drawing.Point(228, 409);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(414, 28);
|
||||
this.label1.TabIndex = 26;
|
||||
this.label1.Text = "Note: Accepting changes will clear the action tree to apply the new settings; Can" +
|
||||
"cel now if you want to save your work first.";
|
||||
this.label1.Click += new System.EventHandler(this.label1_Click);
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.cbxForceIgnoreversion);
|
||||
this.groupBox4.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.groupBox4.Location = new System.Drawing.Point(12, 340);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(561, 59);
|
||||
this.groupBox4.TabIndex = 27;
|
||||
this.groupBox4.TabStop = false;
|
||||
this.groupBox4.Text = "Advanced Options ...";
|
||||
//
|
||||
// cbxForceIgnoreversion
|
||||
//
|
||||
this.cbxForceIgnoreversion.AutoSize = true;
|
||||
this.cbxForceIgnoreversion.Location = new System.Drawing.Point(6, 27);
|
||||
this.cbxForceIgnoreversion.Name = "cbxForceIgnoreversion";
|
||||
this.cbxForceIgnoreversion.Size = new System.Drawing.Size(133, 17);
|
||||
this.cbxForceIgnoreversion.TabIndex = 5;
|
||||
this.cbxForceIgnoreversion.Text = "force \'ignoreversion\'";
|
||||
this.cbxForceIgnoreversion.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormSettings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.btCancel;
|
||||
this.ClientSize = new System.Drawing.Size(861, 381);
|
||||
this.ClientSize = new System.Drawing.Size(861, 446);
|
||||
this.Controls.Add(this.groupBox4);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.btCancel);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
@ -352,6 +378,8 @@ private void InitializeComponent( )
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox4.ResumeLayout(false);
|
||||
this.groupBox4.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -385,5 +413,7 @@ private void InitializeComponent( )
|
||||
private System.Windows.Forms.CheckedListBox chkLbActionMaps;
|
||||
private System.Windows.Forms.Button btCancel;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.GroupBox groupBox4;
|
||||
private System.Windows.Forms.CheckBox cbxForceIgnoreversion;
|
||||
}
|
||||
}
|
@ -59,6 +59,9 @@ private void LoadSettings( )
|
||||
chkLbActionMaps.SetItemChecked(i, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ForceIgnoreversion
|
||||
cbxForceIgnoreversion.Checked = m_owner.ForceIgnoreversion;
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +89,10 @@ private void SaveSettings( )
|
||||
}
|
||||
}
|
||||
m_owner.IgnoreActionmaps = ignore;
|
||||
|
||||
|
||||
// ForceIgnoreversion
|
||||
m_owner.ForceIgnoreversion = cbxForceIgnoreversion.Checked;
|
||||
|
||||
m_owner.Save( );
|
||||
}
|
||||
|
||||
@ -151,6 +157,11 @@ private void btChooseSCDir_Click( object sender, EventArgs e )
|
||||
}
|
||||
}
|
||||
|
||||
private void label1_Click( object sender, EventArgs e )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace SCJMapper_V2
|
||||
/// <actionmap name="spaceship_view">
|
||||
/// <action name="v_view_cycle_fwd">
|
||||
/// <rebind device="joystick" input="js2_button2" />
|
||||
/// </action>
|
||||
/// </action>
|
||||
/// <action name="v_view_dynamic_focus_toggle">
|
||||
/// <rebind device="joystick" input="js2_button25" />
|
||||
/// </action>
|
||||
@ -71,13 +71,19 @@ public void Merge( ActionMapCls newAcm )
|
||||
/// <returns>the action as XML fragment</returns>
|
||||
public String toXML( )
|
||||
{
|
||||
String r = String.Format( "\t<actionmap name=\"{0}\">\n", name );
|
||||
String acs = "";
|
||||
foreach ( ActionCls ac in this ) {
|
||||
String x = ac.toXML( );
|
||||
if ( !String.IsNullOrEmpty(x) ) r += String.Format( "\t{0}", x);
|
||||
if ( !String.IsNullOrEmpty( x ) ) acs += String.Format( "\t{0}", x );
|
||||
}
|
||||
r += String.Format( "\t</actionmap>\n");
|
||||
return r;
|
||||
if ( !String.IsNullOrWhiteSpace( acs ) ) {
|
||||
String r = String.Format( "\t<actionmap name=\"{0}\">\n", name );
|
||||
r += acs;
|
||||
r += String.Format( "\t</actionmap>\n" );
|
||||
return r;
|
||||
}
|
||||
// nothing to dump
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@ -108,12 +114,12 @@ public Boolean fromXML( String xml )
|
||||
reader.Read( ); // move to next element
|
||||
|
||||
String x = reader.ReadOuterXml( );
|
||||
while ( ! String.IsNullOrEmpty(x) ) {
|
||||
while ( !String.IsNullOrEmpty( x ) ) {
|
||||
ActionCls ac = new ActionCls( );
|
||||
if ( ac.fromXML( x ) ) {
|
||||
this.Add( ac ); // add to list
|
||||
}
|
||||
x=reader.ReadOuterXml();
|
||||
x = reader.ReadOuterXml( );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -22,13 +22,26 @@ class ActionMapsCls : List<ActionMapCls>
|
||||
{
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
|
||||
|
||||
#region Static Part of ActionMaps
|
||||
|
||||
// actionmap names to gather (do we need them to be cofigurable ??)
|
||||
public static String[] ActionMaps = { "multiplayer", "singleplayer", "player", "flycam", "spaceship_general", "spaceship_view", "spaceship_movement", "spaceship_targeting", "spaceship_turret",
|
||||
"spaceship_weapons", "spaceship_missiles", "spaceship_defensive", "spaceship_auto_weapons", "spaceship_radar" , "spaceship_hud" , "IFCS_controls" };
|
||||
public static String[] ActionMaps = { };
|
||||
public static void LoadActionMaps( )
|
||||
{
|
||||
// load actionmaps
|
||||
String acm = AppConfiguration.AppConfig.scActionmaps;
|
||||
ActionMaps = acm.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries );
|
||||
}
|
||||
|
||||
#endregion Static Part of ActionMaps
|
||||
|
||||
private String version { get; set; }
|
||||
private String ignoreversion { get; set; }
|
||||
|
||||
private UICustHeader uiCustHeader = new UICustHeader( );
|
||||
private Deviceoptions deviceOptions = new Deviceoptions( );
|
||||
private Options options = new Options( );
|
||||
|
||||
|
||||
public String version { get; set; }
|
||||
|
||||
// own additions for JS mapping - should not harm..
|
||||
private String[] m_js;
|
||||
@ -64,6 +77,8 @@ public ActionMapsCls( )
|
||||
for ( int i=0; i < JoystickCls.JSnum_MAX; i++ ) {
|
||||
m_js[i] = ""; m_GUIDs[i] = "";
|
||||
}
|
||||
|
||||
LoadActionMaps( ); // get them from config
|
||||
}
|
||||
|
||||
|
||||
@ -76,8 +91,13 @@ public ActionMapsCls ReassignJsN( Dictionary<int, int> newJsList )
|
||||
{
|
||||
ActionMapsCls newMaps = new ActionMapsCls( );
|
||||
// full copy from 'this'
|
||||
|
||||
newMaps.uiCustHeader = this.uiCustHeader;
|
||||
newMaps.deviceOptions = this.deviceOptions;
|
||||
newMaps.options = this.options;
|
||||
|
||||
for ( int i=0; i < JoystickCls.JSnum_MAX; i++ ) {
|
||||
newMaps.jsN[i] = this.jsN[i]; newMaps.jsNGUID[i] = this.jsNGUID[i];
|
||||
newMaps.jsN[i] = this.jsN[i]; newMaps.jsNGUID[i] = this.jsNGUID[i];
|
||||
}
|
||||
|
||||
foreach ( ActionMapCls am in this ) {
|
||||
@ -108,7 +128,7 @@ private void Merge( ActionMapCls newAcm )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Dump the ActionMaps as partial XML nicely formatted
|
||||
/// </summary>
|
||||
@ -117,13 +137,39 @@ public String toXML( )
|
||||
{
|
||||
log.Debug( "toXML - Entry" );
|
||||
|
||||
String r = String.Format( "<ActionMaps version=\"{0}\" \n", version );
|
||||
AppSettings appSettings = new AppSettings( );
|
||||
|
||||
// handle the versioning of the actionmaps
|
||||
String r = "<ActionMaps ";
|
||||
if ( !String.IsNullOrEmpty( ignoreversion ) ) {
|
||||
r += String.Format( "ignoreVersion=\"{0}\" \n", ignoreversion );
|
||||
}
|
||||
else if ( appSettings.ForceIgnoreversion ) {
|
||||
ignoreversion = "1"; // preset if missing
|
||||
r += String.Format( "ignoreVersion=\"{0}\" \n", ignoreversion );
|
||||
}
|
||||
else if ( !String.IsNullOrEmpty( version ) ) {
|
||||
r += String.Format( "version=\"{0}\" \n", version );
|
||||
}
|
||||
else {
|
||||
version = "0"; // preset if missing
|
||||
r += String.Format( "version=\"{0}\" \n", version );
|
||||
}
|
||||
|
||||
// now the devices (our addition)
|
||||
for ( int i=0; i < JoystickCls.JSnum_MAX; i++ ) {
|
||||
if ( !String.IsNullOrEmpty( jsN[i] ) ) r += String.Format( "\tjs{0}=\"{1}\" ", i+1, jsN[i] );
|
||||
if ( !String.IsNullOrEmpty( jsN[i] ) ) r += String.Format( "\tjs{0}=\"{1}\" ", i + 1, jsN[i] );
|
||||
if ( !String.IsNullOrEmpty( jsNGUID[i] ) ) r += String.Format( "js{0}G=\"{1}\" \n", i + 1, jsNGUID[i] );
|
||||
}
|
||||
|
||||
// close the tag
|
||||
r += String.Format( ">\n" );
|
||||
|
||||
// and dump the contents
|
||||
if ( uiCustHeader.Count > 0 ) r += uiCustHeader.toXML( ) + String.Format( "\n" );
|
||||
if ( deviceOptions.Count > 0 ) r += deviceOptions.toXML( ) + String.Format( "\n" );
|
||||
if ( options.Count > 0 ) r += options.toXML( ) + String.Format( "\n" );
|
||||
|
||||
foreach ( ActionMapCls amc in this ) {
|
||||
r += String.Format( "{0}\n", amc.toXML( ) );
|
||||
}
|
||||
@ -154,6 +200,8 @@ public Boolean fromXML( String xml )
|
||||
if ( reader.Name == "ActionMaps" ) {
|
||||
if ( reader.HasAttributes ) {
|
||||
version = reader["version"];
|
||||
ignoreversion = reader["ignoreVersion"]; // could be either / or ..
|
||||
|
||||
// get the joystick mapping if there is one
|
||||
for ( int i=0; i < JoystickCls.JSnum_MAX; i++ ) {
|
||||
jsN[i] = reader[String.Format( "js{0}", i + 1 )];
|
||||
@ -167,16 +215,37 @@ public Boolean fromXML( String xml )
|
||||
|
||||
reader.Read( ); // move to next element
|
||||
|
||||
String x = reader.ReadOuterXml( );
|
||||
while ( !String.IsNullOrEmpty( x ) ) {
|
||||
ActionMapCls acm = new ActionMapCls( );
|
||||
if ( acm.fromXML( x ) ) {
|
||||
this.Merge( acm ); // merge list
|
||||
// could be actionmap OR (AC 0.9) deviceoptions OR options
|
||||
|
||||
while ( !reader.EOF ) { //!String.IsNullOrEmpty( x ) ) {
|
||||
|
||||
if ( reader.Name == "actionmap" ) {
|
||||
String x = reader.ReadOuterXml( );
|
||||
ActionMapCls acm = new ActionMapCls( );
|
||||
if ( acm.fromXML( x ) ) {
|
||||
this.Merge( acm ); // merge list
|
||||
}
|
||||
}
|
||||
else if ( reader.Name == "CustomisationUIHeader" ) {
|
||||
String x = reader.ReadOuterXml( );
|
||||
uiCustHeader.fromXML( x );
|
||||
}
|
||||
else if ( reader.Name == "deviceoptions" ) {
|
||||
String x = reader.ReadOuterXml( );
|
||||
deviceOptions.fromXML( x );
|
||||
}
|
||||
else if ( reader.Name == "options" ) {
|
||||
String x = reader.ReadOuterXml( );
|
||||
options.fromXML( x );
|
||||
}
|
||||
else {
|
||||
reader.Read( );
|
||||
}
|
||||
x = reader.ReadOuterXml( );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -270,6 +270,9 @@ private Boolean ReadXML( XmlReader xr )
|
||||
|
||||
Boolean retVal = true;
|
||||
|
||||
if ( ActionMapsCls.ActionMaps.Length == 0 ) ActionMapsCls.LoadActionMaps( ); // make sure we have them loaded ( refactoring to get a singleton or so...)
|
||||
|
||||
|
||||
try {
|
||||
do {
|
||||
if ( xr.IsStartElement( ) ) {
|
||||
|
76
Joystick/Deviceoptions.cs
Normal file
76
Joystick/Deviceoptions.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SCJMapper_V2
|
||||
{
|
||||
/// <summary>
|
||||
/// Maintains an Deviceoptions - something like:
|
||||
///
|
||||
/// <deviceoptions name="Joystick - HOTAS Warthog">
|
||||
/// <!-- Reduce the deadzone -->
|
||||
/// <option input="x" deadzone="0.015" />
|
||||
/// <option input="y" deadzone="0.015" />
|
||||
/// </deviceoptions>
|
||||
///
|
||||
/// [device] : set to device name (name shown in Windows Game Controllers control panel), currently known names follow
|
||||
/// Joystick - HOTAS Warthog
|
||||
/// Saitek X52 Pro Flight Controller
|
||||
///
|
||||
/// </summary>
|
||||
class Deviceoptions : List<String>
|
||||
{
|
||||
|
||||
private String[] FormatXml( string xml )
|
||||
{
|
||||
try {
|
||||
XDocument doc = XDocument.Parse( xml );
|
||||
return doc.ToString( ).Split( new String[] { String.Format( "\n" ) }, StringSplitOptions.RemoveEmptyEntries );
|
||||
}
|
||||
catch ( Exception ) {
|
||||
return new String[] { xml };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dump the CustomisationUIHeader as partial XML nicely formatted
|
||||
/// </summary>
|
||||
/// <returns>the action as XML fragment</returns>
|
||||
public String toXML( )
|
||||
{
|
||||
String r = "";
|
||||
|
||||
// and dump the contents
|
||||
foreach ( String x in this ) {
|
||||
|
||||
if ( !String.IsNullOrWhiteSpace( x ) ) {
|
||||
foreach ( String line in FormatXml( x ) ) {
|
||||
r += String.Format( "\t{0}", line );
|
||||
}
|
||||
}
|
||||
|
||||
r += String.Format( "\n" );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read an CustomisationUIHeader from XML - do some sanity check
|
||||
/// </summary>
|
||||
/// <param name="xml">the XML action fragment</param>
|
||||
/// <returns>True if an action was decoded</returns>
|
||||
public Boolean fromXML( String xml )
|
||||
{
|
||||
if ( !this.Contains( xml ) ) this.Add( xml );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -74,7 +74,7 @@ static public String JSTag( int jsNum )
|
||||
static public int JSNum( String jsTag )
|
||||
{
|
||||
int retNum = JSnum_UNKNOWN;
|
||||
if ( !String.IsNullOrEmpty( jsTag ) ) {
|
||||
if ( !String.IsNullOrWhiteSpace( jsTag ) ) {
|
||||
if ( !int.TryParse( jsTag.Substring( 2, 1 ), out retNum ) ) {
|
||||
retNum = JSnum_UNKNOWN;
|
||||
}
|
||||
|
78
Joystick/Options.cs
Normal file
78
Joystick/Options.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SCJMapper_V2
|
||||
{
|
||||
/// <summary>
|
||||
/// Maintains an Options - something like:
|
||||
///
|
||||
/// <options type="joystick" instance="1">
|
||||
/// <!-- Make all piloting input linear -->
|
||||
/// <pilot exponent="1" />
|
||||
/// </options>
|
||||
///
|
||||
/// [type] : set to shared, keyboard, xboxpad, or joystick
|
||||
/// [instance] : set to the device number; js1=1, js2=2, etc
|
||||
/// [optiongroup] : set to what group the option should affect (for available groups see default actionmap)
|
||||
/// [option] : instance, sensitivity, exponent, nonlinearity *instance is a bug that will be fixed to 'invert' in the future
|
||||
/// [value] : for invert use 0/1; for others use 0.0 to 2.0
|
||||
///
|
||||
/// </summary>
|
||||
class Options : List<String>
|
||||
{
|
||||
|
||||
private String[] FormatXml( string xml )
|
||||
{
|
||||
try {
|
||||
XDocument doc = XDocument.Parse( xml );
|
||||
return doc.ToString( ).Split( new String[] { String.Format( "\n" ) }, StringSplitOptions.RemoveEmptyEntries );
|
||||
}
|
||||
catch ( Exception ) {
|
||||
return new String[] { xml };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dump the CustomisationUIHeader as partial XML nicely formatted
|
||||
/// </summary>
|
||||
/// <returns>the action as XML fragment</returns>
|
||||
public String toXML( )
|
||||
{
|
||||
String r = "";
|
||||
|
||||
// and dump the contents
|
||||
foreach ( String x in this ) {
|
||||
|
||||
if ( !String.IsNullOrWhiteSpace( x ) ) {
|
||||
foreach ( String line in FormatXml( x ) ) {
|
||||
r += String.Format( "\t{0}", line );
|
||||
}
|
||||
}
|
||||
|
||||
r += String.Format( "\n" );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read an CustomisationUIHeader from XML - do some sanity check
|
||||
/// </summary>
|
||||
/// <param name="xml">the XML action fragment</param>
|
||||
/// <returns>True if an action was decoded</returns>
|
||||
public Boolean fromXML( String xml )
|
||||
{
|
||||
if ( !this.Contains( xml ) ) this.Add( xml );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
68
Joystick/UICustHeader.cs
Normal file
68
Joystick/UICustHeader.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace SCJMapper_V2
|
||||
{
|
||||
/// <summary>
|
||||
/// Maintains an CustomisationUIHeader - something like:
|
||||
///
|
||||
/// <CustomisationUIHeader device="joystick" label="JoystickTMWarthog" description="@ui_JoystickTMWarthogDesc" image="JoystickTMWarthog" />
|
||||
///
|
||||
/// </summary>
|
||||
class UICustHeader : List<String>
|
||||
{
|
||||
|
||||
private String[] FormatXml( string xml )
|
||||
{
|
||||
try {
|
||||
XDocument doc = XDocument.Parse( xml );
|
||||
return doc.ToString( ).Split( new String[] { String.Format( "\n" ) }, StringSplitOptions.RemoveEmptyEntries );
|
||||
}
|
||||
catch ( Exception ) {
|
||||
return new String[] { xml };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dump the CustomisationUIHeader as partial XML nicely formatted
|
||||
/// </summary>
|
||||
/// <returns>the action as XML fragment</returns>
|
||||
public String toXML( )
|
||||
{
|
||||
String r = "";
|
||||
|
||||
// and dump the contents
|
||||
foreach ( String x in this ) {
|
||||
if ( !String.IsNullOrWhiteSpace( x ) ) {
|
||||
foreach ( String line in FormatXml( x ) ) {
|
||||
r += String.Format( "\t{0}", line );
|
||||
}
|
||||
}
|
||||
}
|
||||
r += String.Format( "\n" );
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read an CustomisationUIHeader from XML - do some sanity check
|
||||
/// </summary>
|
||||
/// <param name="xml">the XML action fragment</param>
|
||||
/// <returns>True if an action was decoded</returns>
|
||||
public Boolean fromXML( String xml )
|
||||
{
|
||||
if ( !this.Contains( xml ) ) this.Add( xml );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -32,5 +32,5 @@
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion( "2.4.0.24" )]
|
||||
[assembly: AssemblyFileVersion( "2.4.0.24" )]
|
||||
[assembly: AssemblyVersion( "2.5.0.25" )]
|
||||
[assembly: AssemblyFileVersion( "2.5.0.25" )]
|
||||
|
@ -26,8 +26,8 @@
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>24</ApplicationRevision>
|
||||
<ApplicationVersion>2.4.0.%2a</ApplicationVersion>
|
||||
<ApplicationRevision>25</ApplicationRevision>
|
||||
<ApplicationVersion>2.5.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
@ -105,6 +105,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="appConfiguration.cs" />
|
||||
<Compile Include="AppSettings.cs" />
|
||||
<Compile Include="Joystick\Deviceoptions.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -137,12 +138,14 @@
|
||||
<Compile Include="Joystick\UC_JoyPanel.Designer.cs">
|
||||
<DependentUpon>UC_JoyPanel.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Joystick\Options.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SC\SCDefaultProfile.cs" />
|
||||
<Compile Include="SC\SCMappings.cs" />
|
||||
<Compile Include="SC\SCPath.cs" />
|
||||
<Compile Include="TheUser.cs" />
|
||||
<Compile Include="Joystick\UICustHeader.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
18
app.config
18
app.config
@ -13,5 +13,21 @@
|
||||
|
||||
<!-- This is the minimal change that detects a movement of an axis
|
||||
default is 150 - you may change it to get the detection less sensitive -->
|
||||
<AppConfiguration jsSenseLimit="150" />
|
||||
<AppConfiguration jsSenseLimit="150"
|
||||
scAcionmaps="multiplayer,
|
||||
singleplayer,
|
||||
player,
|
||||
flycam,
|
||||
spaceship_general,
|
||||
spaceship_view,
|
||||
spaceship_movement,
|
||||
spaceship_targeting,
|
||||
spaceship_turret,
|
||||
spaceship_weapons,
|
||||
spaceship_missiles,
|
||||
spaceship_defensive,
|
||||
spaceship_auto_weapons,
|
||||
spaceship_radar,
|
||||
spaceship_hud,
|
||||
IFCS_controls"/>
|
||||
</configuration>
|
||||
|
@ -15,7 +15,13 @@ public sealed class AppConfiguration : ConfigurationSection
|
||||
|
||||
// The jsSenseLimit property.
|
||||
private static readonly ConfigurationProperty _jsSenseLimit =
|
||||
new ConfigurationProperty( "jsSenseLimit", typeof( int ), ( int )150, ConfigurationPropertyOptions.None );
|
||||
new ConfigurationProperty( "jsSenseLimit", typeof( int ), ( int )150, ConfigurationPropertyOptions.None );
|
||||
|
||||
// The scActionmaps property.
|
||||
private static String _defaultActionmaps = "multiplayer,singleplayer,player,flycam,spaceship_general,spaceship_view,spaceship_movement,spaceship_targeting,spaceship_turret"
|
||||
+ ",spaceship_weapons,spaceship_missiles,spaceship_defensive,spaceship_auto_weapons,spaceship_radar,spaceship_hud,IFCS_controls";
|
||||
private static readonly ConfigurationProperty _scActionmaps =
|
||||
new ConfigurationProperty( "scActionmaps", typeof( String ), (String)_defaultActionmaps, ConfigurationPropertyOptions.None );
|
||||
|
||||
// ctor
|
||||
public AppConfiguration( )
|
||||
@ -23,6 +29,7 @@ public AppConfiguration( )
|
||||
// initialization
|
||||
_Properties = new ConfigurationPropertyCollection( );
|
||||
_Properties.Add( _jsSenseLimit );
|
||||
_Properties.Add( _scActionmaps );
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +54,19 @@ public int jsSenseLimit
|
||||
}
|
||||
}
|
||||
|
||||
[StringValidator( InvalidCharacters = " ~!@#$%^&*()[]{}/;'\"|\\", MinLength = 10, MaxLength = 500 )]
|
||||
public String scActionmaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return ( String )this["scActionmaps"];
|
||||
}
|
||||
set
|
||||
{
|
||||
this["scActionmaps"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -84,6 +104,19 @@ static public int jsSenseLimit
|
||||
else return 150; // default if things go wrong...
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actionmaps supported
|
||||
/// </summary>
|
||||
static public String scActionmaps
|
||||
{
|
||||
get
|
||||
{
|
||||
AppConfiguration s = GetAppSection( );
|
||||
if ( s != null ) return s.scActionmaps;
|
||||
else return _defaultActionmaps; // default if things go wrong...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
SC Joystick Mapper V 2.4
|
||||
(c) Cassini, StandardToaster - 14-September-2014
|
||||
SC Joystick Mapper V 2.5
|
||||
(c) Cassini, StandardToaster - 20-September-2014
|
||||
|
||||
Contains 9 files:
|
||||
|
||||
SCJMapper.exe The program
|
||||
SCJMapper.exe.config Program config - MUST be in the same folder as the Exe file
|
||||
SCJMapper.exe The program (V2.5)
|
||||
SCJMapper.exe.config Program config (V2.5) - MUST be in the same folder as the Exe file
|
||||
SharpDX.DirectInput.dll Managed DirectInput Assembly - MUST be in the same folder as the Exe file
|
||||
SharpDX.dll Managed DirectX Assembly - MUST be in the same folder as the Exe file
|
||||
Ionic.Zip.Reduced.dll Managed Zip Assembly - MUST be in the same folder as the Exe file
|
||||
log4net.dll Managed Logging Assembly - MUST be in the same folder as the Exe file
|
||||
log4net.config.OFF Config file for logging - To use it - rename as log4net.config and run the program
|
||||
then look for trace.log in the same folder
|
||||
SCJMapper_QGuide V2.4.pdf Quick Guide
|
||||
SCJMapper_QGuide V2.5.pdf Quick Guide
|
||||
ReadMe.txt This file
|
||||
|
||||
Read the Guide first RTFM ;-)
|
||||
@ -24,6 +24,11 @@ Scanned for viruses before packing...
|
||||
cassini@burri-web.org
|
||||
|
||||
Changelog:
|
||||
V 2.5
|
||||
- new feature - support and maintain option tags
|
||||
- improvement - support and maintain version and ignoreversion attribute / can force ignoreversion="1"
|
||||
- improvement - makes backup copy before each save (in my documents e.g. layout_my_xyz.xml.backup)
|
||||
- Update of the Guide for V2.5
|
||||
V 2.4
|
||||
- improvement - add new actionmaps for AC 0.9 (flycam, spaceship_turret)
|
||||
- improvement - supports now assignment of js1 .. js8 - SC may not support all though...
|
||||
|
BIN
doc/SCJMapper_QGuide V2.5.pdf
Normal file
BIN
doc/SCJMapper_QGuide V2.5.pdf
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user