File tree Expand file tree Collapse file tree 3 files changed +35
-14
lines changed Expand file tree Collapse file tree 3 files changed +35
-14
lines changed Original file line number Diff line number Diff line change @@ -280,14 +280,30 @@ public string SanitizeNames(string text)
280280 private string SanitizeMemberName ( string memberName )
281281 {
282282 string ret = memberName ;
283- foreach ( string name in Names )
283+ bool altSubstitution = false ;
284+
285+ // Try alternate substitution first
286+ foreach ( KeyValuePair < string , string > substitutionPair in TypeInfo . AlternateEnumPrefixSubstitutions )
287+ {
288+ if ( memberName . StartsWith ( substitutionPair . Key ) )
289+ {
290+ ret = ret . Replace ( substitutionPair . Key , substitutionPair . Value ) ;
291+ altSubstitution = true ;
292+ break ;
293+ }
294+ }
295+
296+ if ( ! altSubstitution )
284297 {
285- if ( memberName . StartsWith ( name ) )
298+ foreach ( string name in Names )
286299 {
287- ret = memberName . Substring ( name . Length ) ;
288- if ( ret . StartsWith ( "_" ) )
300+ if ( memberName . StartsWith ( name ) )
289301 {
290- ret = ret . Substring ( 1 ) ;
302+ ret = memberName . Substring ( name . Length ) ;
303+ if ( ret . StartsWith ( "_" ) )
304+ {
305+ ret = ret . Substring ( 1 ) ;
306+ }
291307 }
292308 }
293309 }
@@ -297,7 +313,7 @@ private string SanitizeMemberName(string memberName)
297313 ret = ret . Substring ( 0 , ret . Length - 1 ) ;
298314 }
299315
300- if ( Char . IsDigit ( ret . First ( ) ) )
316+ if ( char . IsDigit ( ret . First ( ) ) )
301317 ret = "_" + ret ;
302318
303319 return ret ;
Original file line number Diff line number Diff line change @@ -67,7 +67,12 @@ public class TypeInfo
6767 {
6868 { "ImGuiKey" , "ImGuiMod" } ,
6969 } ;
70-
70+
71+ public static readonly Dictionary < string , string > AlternateEnumPrefixSubstitutions = new Dictionary < string , string > ( )
72+ {
73+ { "ImGuiMod_" , "Mod" } ,
74+ } ;
75+
7176 public static readonly Dictionary < string , string > WellKnownFieldReplacements = new Dictionary < string , string > ( )
7277 {
7378 { "bool" , "bool" } , // Force bool to remain as bool in type-safe wrappers.
Original file line number Diff line number Diff line change @@ -144,13 +144,13 @@ public enum ImGuiKey
144144 ReservedForModAlt = 650 ,
145145 ReservedForModSuper = 651 ,
146146 COUNT = 652 ,
147- None = 0 ,
148- Ctrl = 4096 ,
149- Shift = 8192 ,
150- Alt = 16384 ,
151- Super = 32768 ,
152- Mask = 61440 ,
153- Shortcut = 4096 ,
147+ ModNone = 0 ,
148+ ModCtrl = 4096 ,
149+ ModShift = 8192 ,
150+ ModAlt = 16384 ,
151+ ModSuper = 32768 ,
152+ ModMask = 61440 ,
153+ ModShortcut = 4096 ,
154154 NamedKey_BEGIN = 512 ,
155155 NamedKey_END = 652 ,
156156 NamedKey_COUNT = 140 ,
You can’t perform that action at this time.
0 commit comments