PlayerBase.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. modded class PlayerBase extends ManBase
  2. {
  3. override void OnJumpStart()
  4. {
  5. super.OnJumpStart();
  6. if ( GetGame().IsServer() )
  7. return;
  8. if ( GetCurrentUILanguage() != "zh_CN" )
  9. {
  10. MessageAction( "Please set the UI language to Chinese" );
  11. return;
  12. }
  13. string FilePathStr = "$profile:ItemCodeComparisonTable.md";
  14. if ( FileExist( FilePathStr ) )
  15. DeleteFile( FilePathStr );
  16. FileHandle file = OpenFile( FilePathStr, FileMode.APPEND );
  17. if ( file == 0 )
  18. {
  19. MessageImportant( "存储文件创建失败. 请重试!" );
  20. return;
  21. }
  22. string path = "cfgVehicles";
  23. int childcount = GetGame().ConfigGetChildrenCount( path );
  24. FPrintln( file, "| ClassName | DisplayNmae |" );
  25. FPrintln( file, "| ----------- | ----------- |" );
  26. for(int i = 0; i < childcount; i++)
  27. {
  28. string itemname;
  29. GetGame().ConfigGetChildName( path, i, itemname );
  30. string chilepath = path + " " + itemname;
  31. int scope = GetGame().ConfigGetInt( chilepath + " scope" );
  32. if ( scope == 0 || scope == 1 )
  33. continue;
  34. string displayname;
  35. GetGame().ConfigGetText( chilepath + " displayname", displayname );
  36. if ( !displayname || displayname == "" || displayname.Contains( "$UNT$" ) )
  37. continue;
  38. FPrintln( file, "| " + itemname + " | " + Widget.TranslateString( displayname ) + " |" );
  39. }
  40. CloseFile( file );
  41. }
  42. string GetCurrentUILanguage()
  43. {
  44. ListOptionsAccess language_option;
  45. GameOptions gameOptions = new GameOptions;
  46. language_option = ListOptionsAccess.Cast( gameOptions.GetOptionByType( OptionAccessType.AT_OPTIONS_LANGUAGE ) );
  47. int idx = -1;
  48. if ( language_option )
  49. idx = language_option.GetIndex();
  50. string languageName;
  51. language_option.GetItemText( idx, languageName );
  52. if ( languageName == "#options_language_CHS" )
  53. return "zh_CN";
  54. return "en_US";
  55. }
  56. }