mirror of
https://github.com/SCToolsfactory/SCJMapper-V2.git
synced 2024-11-04 18:00:26 +00:00
BETA 2.12 - Update for joystick CustomizationUIHeader of AC 1.03 (add instance from jsN)
This commit is contained in:
parent
e209baced6
commit
5cf5c6174b
2
Form1.cs
2
Form1.cs
@ -581,7 +581,7 @@ private void Dump( )
|
||||
{
|
||||
log.Debug( "Dump - Entry" );
|
||||
|
||||
rtb.Text = String.Format( "<!-- {0} - SC Joystick Mapping - {1} -->\n{2}", DateTime.Now, txMappingName.Text, m_AT.toXML( ) );
|
||||
rtb.Text = String.Format( "<!-- {0} - SC Joystick Mapping - {1} -->\n{2}", DateTime.Now, txMappingName.Text, m_AT.toXML( txMappingName.Text ) );
|
||||
|
||||
btDump.BackColor = btClear.BackColor; btDump.UseVisualStyleBackColor = btClear.UseVisualStyleBackColor; // neutral again
|
||||
btGrab.BackColor = btClear.BackColor; btGrab.UseVisualStyleBackColor = btClear.UseVisualStyleBackColor; // neutral again
|
||||
|
@ -13,10 +13,54 @@ namespace SCJMapper_V2
|
||||
///
|
||||
/// <CustomisationUIHeader device="joystick" label="JoystickTMWarthog" description="@ui_JoystickTMWarthogDesc" image="JoystickTMWarthog" />
|
||||
///
|
||||
/// or
|
||||
///
|
||||
/// <CustomisationUIHeader label="JoystickSaitekX55" description="@ui_JoystickSaitekX55Desc" image="JoystickSaitekX55">
|
||||
/// <Devices>
|
||||
/// <joystick instance="1" />
|
||||
/// <joystick instance="2" />
|
||||
/// </Devices>
|
||||
/// </CustomisationUIHeader>
|
||||
/// </summary>
|
||||
class UICustHeader : List<String>
|
||||
public class UICustHeader
|
||||
{
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
|
||||
|
||||
List<String> m_stringOptions = new List<String>( );
|
||||
|
||||
public struct DevRec
|
||||
{
|
||||
public String devType;
|
||||
public int instNo;
|
||||
}
|
||||
List<DevRec> m_devInstances = new List<DevRec>( );
|
||||
|
||||
private String m_label = "";
|
||||
private String m_description = "";
|
||||
private String m_image = "";
|
||||
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return ( m_stringOptions.Count + m_devInstances.Count ); }
|
||||
}
|
||||
|
||||
public String Label
|
||||
{
|
||||
get { return m_label; }
|
||||
set { m_label = value; }
|
||||
}
|
||||
|
||||
public void ClearInstances( )
|
||||
{
|
||||
m_devInstances.Clear();
|
||||
}
|
||||
public void AddInstances( DevRec dr )
|
||||
{
|
||||
m_devInstances.Add( dr );
|
||||
}
|
||||
|
||||
|
||||
private String[] FormatXml( string xml )
|
||||
{
|
||||
try {
|
||||
@ -36,8 +80,20 @@ public String toXML( )
|
||||
{
|
||||
String r = "";
|
||||
|
||||
// and dump the contents
|
||||
foreach ( String x in this ) {
|
||||
r += String.Format( "\t<CustomisationUIHeader label=\"{0}\" description=\"{1}\" image=\"{2}\">\n", m_label, m_description, m_image );
|
||||
if ( m_devInstances.Count > 0 ) {
|
||||
r += String.Format( "\t\t<Devices>\n" );
|
||||
|
||||
foreach ( DevRec dr in m_devInstances ) {
|
||||
r += String.Format( "\t\t\t<{0} instance=\"{1}\"/>\n", dr.devType, dr.instNo.ToString( ) );
|
||||
}
|
||||
|
||||
r += String.Format( "\t\t</Devices>\n" );
|
||||
}
|
||||
r += String.Format( "\t</CustomisationUIHeader>\n" );
|
||||
|
||||
// and dump the plain contents if needed
|
||||
foreach ( String x in m_stringOptions ) {
|
||||
if ( !String.IsNullOrWhiteSpace( x ) ) {
|
||||
foreach ( String line in FormatXml( x ) ) {
|
||||
r += String.Format( "\t{0}", line );
|
||||
@ -50,6 +106,38 @@ public String toXML( )
|
||||
|
||||
|
||||
|
||||
/// <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 Instance_fromXML( XmlReader reader )
|
||||
{
|
||||
reader.Read( );
|
||||
|
||||
while ( !reader.EOF ) {
|
||||
String devType = reader.Name;
|
||||
String instance = reader["instance"];
|
||||
int instNo = 0;
|
||||
if ( !String.IsNullOrWhiteSpace( instance ) ) {
|
||||
if ( !int.TryParse( instance, out instNo ) ) {
|
||||
instNo = 0;
|
||||
}
|
||||
else {
|
||||
DevRec dr = new DevRec( );
|
||||
dr.devType = devType;
|
||||
dr.instNo = instNo;
|
||||
m_devInstances.Add( dr );
|
||||
}
|
||||
}
|
||||
reader.Read( );
|
||||
if ( reader.NodeType == XmlNodeType.EndElement ) break; // expect end of <Devices> here
|
||||
}//while
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read an CustomisationUIHeader from XML - do some sanity check
|
||||
/// </summary>
|
||||
@ -57,7 +145,49 @@ public String toXML( )
|
||||
/// <returns>True if an action was decoded</returns>
|
||||
public Boolean fromXML( String xml )
|
||||
{
|
||||
if ( !this.Contains( xml ) ) this.Add( xml );
|
||||
// if ( !this.Contains( xml ) ) this.Add( xml );
|
||||
|
||||
|
||||
XmlReaderSettings settings = new XmlReaderSettings( );
|
||||
settings.ConformanceLevel = ConformanceLevel.Fragment;
|
||||
settings.IgnoreWhitespace = true;
|
||||
settings.IgnoreComments = true;
|
||||
XmlReader reader = XmlReader.Create( new StringReader( xml ), settings );
|
||||
|
||||
reader.Read( );
|
||||
|
||||
if ( reader.HasAttributes ) {
|
||||
m_label = reader["label"];
|
||||
m_description = reader["description"];
|
||||
if ( String.IsNullOrEmpty( m_description ) ) m_description = "@ui_JoystickDefaultDesc";
|
||||
m_image = reader["image"];
|
||||
if ( String.IsNullOrEmpty( m_image ) ) m_image = "JoystickDefault";
|
||||
|
||||
reader.Read( );
|
||||
// try to disassemble the items
|
||||
/*
|
||||
* <Devices>
|
||||
* <joystick instance="1" />
|
||||
* <joystick instance="2" />
|
||||
* </Devices>
|
||||
*/
|
||||
while ( !reader.EOF ) {
|
||||
|
||||
if ( reader.Name == "Devices" ) {
|
||||
Instance_fromXML( reader );
|
||||
}
|
||||
else {
|
||||
//??
|
||||
log.InfoFormat( "UICustHeader.fromXML: unknown node - {0} - stored as is", reader.Name );
|
||||
if ( !m_stringOptions.Contains( xml ) ) m_stringOptions.Add( xml );
|
||||
}
|
||||
|
||||
reader.Read( );
|
||||
if ( reader.NodeType == XmlNodeType.EndElement ) break; // expect end of <CustomisationUIHeader> here
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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.11.0.44" )]
|
||||
[assembly: AssemblyFileVersion( "2.11.0.44" )]
|
||||
[assembly: AssemblyVersion( "2.12.0.45" )]
|
||||
[assembly: AssemblyFileVersion( "2.12.0.45" )]
|
||||
|
@ -14,8 +14,8 @@ class SCMappings
|
||||
{
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType );
|
||||
|
||||
|
||||
private const String c_UserMapStartsWith = "layout_my_"; // we only allow those mapping names
|
||||
public const String c_MapStartsWith = "layout_"; // we only allow those mapping names
|
||||
private const String c_UserMapStartsWith = c_MapStartsWith + "my_"; // we only allow those mapping names
|
||||
|
||||
static private List<String> m_scMappings = new List<string>( );
|
||||
|
||||
|
@ -232,14 +232,14 @@ static public String SCClientMappingPath
|
||||
get
|
||||
{
|
||||
log.Debug( "SCClientMappingPath - Entry" );
|
||||
String scp = SCClientDataPath;
|
||||
String scp = SCClientUSERPath; // AC1.03 new here
|
||||
if ( String.IsNullOrEmpty( scp ) ) return "";
|
||||
//
|
||||
scp = Path.Combine( scp, "Controls" );
|
||||
scp = Path.Combine( scp, "Mappings" );
|
||||
if ( Directory.Exists( scp ) ) return scp;
|
||||
|
||||
log.WarnFormat( "SCClientMappingPath - CitizenClient.Data.Controls.Mappings subfolder does not exist: {0}", scp );
|
||||
log.WarnFormat( "SCClientMappingPath - CitizenClient.USER.Controls.Mappings subfolder does not exist: {0}", scp );
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>44</ApplicationRevision>
|
||||
<ApplicationVersion>2.11.0.%2a</ApplicationVersion>
|
||||
<ApplicationRevision>45</ApplicationRevision>
|
||||
<ApplicationVersion>2.12.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
|
@ -226,7 +226,7 @@ private void Merge( ActionMapCls newAcm )
|
||||
/// Dump the ActionMaps as partial XML nicely formatted
|
||||
/// </summary>
|
||||
/// <returns>the action as XML fragment</returns>
|
||||
public String toXML( )
|
||||
public String toXML( String fileName )
|
||||
{
|
||||
log.Debug( "toXML - Entry" );
|
||||
|
||||
@ -259,7 +259,19 @@ public String toXML( )
|
||||
r += String.Format( ">\n" );
|
||||
|
||||
// and dump the option contents
|
||||
if ( m_uiCustHeader.Count > 0 ) r += m_uiCustHeader.toXML( ) + String.Format( "\n" );
|
||||
if ( m_uiCustHeader.Count > 0 ) {
|
||||
// prepare with new data
|
||||
m_uiCustHeader.ClearInstances( );
|
||||
UICustHeader.DevRec dr = new UICustHeader.DevRec( );
|
||||
for ( int i=0; i < JoystickCls.JSnum_MAX; i++ ) {
|
||||
if ( !String.IsNullOrEmpty( jsN[i] ) ) {
|
||||
dr.devType = "joystick"; dr.instNo = i + 1;
|
||||
m_uiCustHeader.AddInstances( dr );
|
||||
}
|
||||
}
|
||||
m_uiCustHeader.Label = fileName.Replace( SCMappings.c_MapStartsWith, "" ); // remove redundant part
|
||||
r += m_uiCustHeader.toXML( ) + String.Format( "\n" );
|
||||
}
|
||||
if ( m_options.Count > 0 ) r += m_options.toXML( ) + String.Format( "\n" );
|
||||
if ( m_deviceOptions.Count > 0 ) r += m_deviceOptions.toXML( ) + String.Format( "\n" );
|
||||
|
||||
|
@ -257,12 +257,12 @@ private void UpdateDeviceInformation( )
|
||||
/// Dumps the actions to an XML String
|
||||
/// </summary>
|
||||
/// <returns>A string containing the XML</returns>
|
||||
public String toXML( )
|
||||
public String toXML( String fileName )
|
||||
{
|
||||
if ( ActionMaps != null ) {
|
||||
// must update the devices and instances for inversion before dumping the XML
|
||||
UpdateDeviceInformation( );
|
||||
return ActionMaps.toXML( ); // just propagate if possible
|
||||
return ActionMaps.toXML( fileName ); // just propagate if possible
|
||||
}
|
||||
else {
|
||||
log.Error( "ActionTree-toXML: Program error - ActionMaps not yet created" );
|
||||
|
@ -1,10 +1,10 @@
|
||||
SC Joystick Mapper V 2.10 - Build 43
|
||||
(c) Cassini, StandardToaster - 04-January-2015
|
||||
SC Joystick Mapper V 2.11 - Build 44 BETA
|
||||
(c) Cassini, StandardToaster - 14-January-2015
|
||||
|
||||
Contains 9 files:
|
||||
|
||||
SCJMapper.exe The program (V2.10)
|
||||
SCJMapper.exe.config Program config (V2.10) - MUST be in the same folder as the Exe file
|
||||
SCJMapper.exe The program (V2.11)
|
||||
SCJMapper.exe.config Program config (V2.11) - 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
|
||||
OpenTK.dll Managed OpenGL Assembly - MUST be in the same folder as the Exe file
|
||||
@ -29,6 +29,12 @@ Scanned for viruses before packing...
|
||||
cassini@burri-web.org
|
||||
|
||||
Changelog:
|
||||
V 2.11 - BETA Build 44
|
||||
- fix - reading of deadzone value (if not a number should not break anymore)
|
||||
- fix - writing the proper deadzone XML if first used
|
||||
- fix - reading addbind commands from existing mappings will appear now in the tree
|
||||
- improvement - better handling of the default mapping name from config file
|
||||
- improvement - mapping name added to XML mapping (first line comment extended with mapping name)
|
||||
V 2.10 - Build 43 - Production
|
||||
- new feature - added Action Tree context menu for Assign, Clear and Blend
|
||||
- fix - issue for Js Reassignment if more than one was not yet assigned
|
||||
|
Loading…
Reference in New Issue
Block a user