PlayerBase.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. FPrintln( file, "| ClassName | DisplayNmae |" );
  23. FPrintln( file, "| ----------- | ----------- |" );
  24. string paths = "cfgVehicles";
  25. ref TStringArray paths = {
  26. "cfgVehicles", "cfgWeapons"
  27. };
  28. foreach( string path : paths )
  29. {
  30. int childcount = GetGame().ConfigGetChildrenCount( path );
  31. for(int i = 0; i < childcount; i++)
  32. {
  33. string itemname;
  34. GetGame().ConfigGetChildName( path, i, itemname );
  35. string chilepath = path + " " + itemname;
  36. int scope = GetGame().ConfigGetInt( chilepath + " scope" );
  37. if ( scope == 0 || scope == 1 )
  38. continue;
  39. string displayname;
  40. GetGame().ConfigGetText( chilepath + " displayname", displayname );
  41. if ( !displayname || displayname == "" || displayname.Contains( "$UNT$" ) )
  42. continue;
  43. FPrintln( file, "| " + itemname + " | " + Widget.TranslateString( displayname ) + " |" );
  44. }
  45. }
  46. CloseFile( file );
  47. }
  48. string GetCurrentUILanguage()
  49. {
  50. ListOptionsAccess language_option;
  51. GameOptions gameOptions = new GameOptions;
  52. language_option = ListOptionsAccess.Cast( gameOptions.GetOptionByType( OptionAccessType.AT_OPTIONS_LANGUAGE ) );
  53. int idx = -1;
  54. if ( language_option )
  55. idx = language_option.GetIndex();
  56. string languageName;
  57. language_option.GetItemText( idx, languageName );
  58. if ( languageName == "#options_language_CHS" )
  59. return "zh_CN";
  60. return "en_US";
  61. }
  62. }