class_pckpacker.rst 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the PCKPacker.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_PCKPacker:
  6. PCKPacker
  7. =========
  8. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. Creates packages that can be loaded into a running project.
  10. Description
  11. -----------
  12. The ``PCKPacker`` is used to create packages that can be loaded into a running project using :ref:`ProjectSettings.load_resource_pack<class_ProjectSettings_method_load_resource_pack>`.
  13. .. tabs::
  14. .. code-tab:: gdscript
  15. var packer = PCKPacker.new()
  16. packer.pck_start("test.pck")
  17. packer.add_file("res://text.txt", "text.txt")
  18. packer.flush()
  19. .. code-tab:: csharp
  20. var packer = new PCKPacker();
  21. packer.PckStart("test.pck");
  22. packer.AddFile("res://text.txt", "text.txt");
  23. packer.Flush();
  24. The above ``PCKPacker`` creates package ``test.pck``, then adds a file named ``text.txt`` at the root of the package.
  25. Methods
  26. -------
  27. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`add_file<class_PCKPacker_method_add_file>` **(** :ref:`String<class_String>` pck_path, :ref:`String<class_String>` source_path, :ref:`bool<class_bool>` encrypt=false **)** |
  29. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`flush<class_PCKPacker_method_flush>` **(** :ref:`bool<class_bool>` verbose=false **)** |
  31. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`pck_start<class_PCKPacker_method_pck_start>` **(** :ref:`String<class_String>` pck_name, :ref:`int<class_int>` alignment=32, :ref:`String<class_String>` key="0000000000000000000000000000000000000000000000000000000000000000", :ref:`bool<class_bool>` encrypt_directory=false **)** |
  33. +---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. Method Descriptions
  35. -------------------
  36. .. _class_PCKPacker_method_add_file:
  37. - :ref:`Error<enum_@GlobalScope_Error>` **add_file** **(** :ref:`String<class_String>` pck_path, :ref:`String<class_String>` source_path, :ref:`bool<class_bool>` encrypt=false **)**
  38. Adds the ``source_path`` file to the current PCK package at the ``pck_path`` internal path (should start with ``res://``).
  39. ----
  40. .. _class_PCKPacker_method_flush:
  41. - :ref:`Error<enum_@GlobalScope_Error>` **flush** **(** :ref:`bool<class_bool>` verbose=false **)**
  42. Writes the files specified using all :ref:`add_file<class_PCKPacker_method_add_file>` calls since the last flush. If ``verbose`` is ``true``, a list of files added will be printed to the console for easier debugging.
  43. ----
  44. .. _class_PCKPacker_method_pck_start:
  45. - :ref:`Error<enum_@GlobalScope_Error>` **pck_start** **(** :ref:`String<class_String>` pck_name, :ref:`int<class_int>` alignment=32, :ref:`String<class_String>` key="0000000000000000000000000000000000000000000000000000000000000000", :ref:`bool<class_bool>` encrypt_directory=false **)**
  46. Creates a new PCK file with the name ``pck_name``. The ``.pck`` file extension isn't added automatically, so it should be part of ``pck_name`` (even though it's not required).
  47. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  48. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  49. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  50. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  51. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  52. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`