@ -22,13 +22,26 @@ namespace SCJMapper_V2
{
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 @@ namespace SCJMapper_V2
for ( int i = 0 ; i < JoystickCls . JSnum_MAX ; i + + ) {
m_js [ i ] = "" ; m_GUIDs [ i ] = "" ;
}
LoadActionMaps ( ) ; // get them from config
}
@ -76,8 +91,13 @@ namespace SCJMapper_V2
{
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 @@ namespace SCJMapper_V2
}
}
/// <summary>
/// Dump the ActionMaps as partial XML nicely formatted
/// </summary>
@ -117,13 +137,39 @@ namespace SCJMapper_V2
{
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 @@ namespace SCJMapper_V2
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 @@ namespace SCJMapper_V2
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 ;
}
}
}