HWPFormat.wiki
changeset 1433 19945dc3944e
parent 1432 549afbe978a8
child 1434 83da47a13028
equal deleted inserted replaced
1432:549afbe978a8 1433:19945dc3944e
    18 == Using HWP ==
    18 == Using HWP ==
    19 If you download any add-on from DLC, you must restart Hedgewars for the change to take effect.
    19 If you download any add-on from DLC, you must restart Hedgewars for the change to take effect.
    20 
    20 
    21 To install a HWP file manually, just put it in the `Data/` subdirectory of your [https://www.hedgewars.org/node/6761 user directory].
    21 To install a HWP file manually, just put it in the `Data/` subdirectory of your [https://www.hedgewars.org/node/6761 user directory].
    22 
    22 
    23 == Creating HWPs ==
    23 == Creating simple HWPs ==
    24 === The short description ===
       
    25 Creating a HWP is easy.
    24 Creating a HWP is easy.
    26 
    25 
    27 A HWP file is just a Zip file, but with the file name suffix “.hwp” instead of “.zip”. They reflect the content of the `Data/` directory of Hedgewars. Any file in a HWP will be treated as if it were in the `Data` directory.
    26 A HWP file is just a Zip file, but with the file name suffix “.hwp” instead of “.zip”. They reflect the content of the `Data/` directory of Hedgewars. Any file in a HWP will be treated as if it were in the `Data` directory.
    28 
    27 
    29 ==== Example ====
    28 === Example ===
    30 Suppose you have made a theme with the name “!MyTheme_v1” (!MyTheme, version 1). If you want to package it in a HWP, you just create a Zip file (e.g. “MyTheme.zip”) with the following directory structure:
    29 Suppose you have made a theme with the name “!MyTheme_v1” (!MyTheme, version 1). If you want to package it in a HWP, you just create a Zip file (e.g. “MyTheme.zip”) with the following directory structure:
    31 
    30 
    32 {{{
    31 {{{
    33     Themes
    32     Themes
    34         MyTheme_v1
    33         MyTheme_v1
    42 
    41 
    43 Then the only thing you need to do is to rename the Zip file to have the correct suffix, i.e. “MyTheme_v1.hwp”. Note only the suffix is important. The name before that can be whatever you like.
    42 Then the only thing you need to do is to rename the Zip file to have the correct suffix, i.e. “MyTheme_v1.hwp”. Note only the suffix is important. The name before that can be whatever you like.
    44 
    43 
    45 If you're done, you probably want to test it as well. Just put your fresh HWP into the `Data/` directory, restart Hedgewars and check if the theme shows up.
    44 If you're done, you probably want to test it as well. Just put your fresh HWP into the `Data/` directory, restart Hedgewars and check if the theme shows up.
    46 
    45 
    47 === The long description ===
    46 == Full description of HWPs ==
    48 HWPs have a couple additional features which allow you to do more sophisticated things. This section explains the HWP files in greater detail.
    47 The section above explained all things you need to know about HWPs to get started.
    49 
    48 
    50 ==== Format specification ====
    49 HWPs have a couple additional features which allow you to do more sophisticated things, but are not alway needed. This section explains the HWP files in greater detail.
       
    50 
       
    51 === Format specification ===
    51 Technically, a HWP file is actually just a Zip file with an unusual file name suffix. The specification of HWP files itself is thus identical to the specification of Zip files.
    52 Technically, a HWP file is actually just a Zip file with an unusual file name suffix. The specification of HWP files itself is thus identical to the specification of Zip files.
    52 
    53 
    53 The complete Zip file format specification can be found at [http://www.pkware.com/documents/casestudies/APPNOTE.TXT].
    54 The complete Zip file format specification can be found at [http://www.pkware.com/documents/casestudies/APPNOTE.TXT].
    54 
    55 
    55 ==== How Hedgewars uses HWPs ====
    56 === How Hedgewars uses HWPs ===
    56 All HWPs must have the file name suffix “.hwp” for Hedgewars to recognize it as such. This is a bit unusual, since the usual file name suffix for .ZIP files (which HWP files actually are) is “.zip”. Don’t worry about that, Hedgewars can cope with that.
    57 All HWPs must have the file name suffix “.hwp” for Hedgewars to recognize it as such. This is a bit unusual, since the usual file name suffix for .ZIP files (which HWP files actually are) is “.zip”. Don’t worry about that, Hedgewars can cope with that.
    57 
    58 
    58 HWP files reflect the content of the `Data/` directory of Hedgewars. Therefore, the structure of the HWP file must be as if it were inside the `Data/` directory of Hedgewars and using the same directory tree.
    59 HWP files reflect the content of the `Data/` directory of Hedgewars. Therefore, the structure of the HWP file must be as if it were inside the `Data/` directory of Hedgewars and using the same directory tree.
    59 
    60 
    60 HWP files will either add or replace a file. If there is no file with a identical name at the same sub-directory of `Data/`, then Hedgewars will simply add that file, making it available for Hedgewars. This is the most commonly used form of HWPs, used to create add-ons, like new missions, flag packs, themes, etc. If there is already a file with such a name there, Hedgewars will prefer the file in the HWP and ignore the other one. This has to be done with care, some files are safe to replace while other files cannot be simply replaced, as this will cause network games to fail. For example, if you have a HWP which replaces an object of a theme and you play that theme online, the online game will fail, unless your fellow players have the same HWP installed.
    61 HWP files will either add or replace a file. If there is no file with a identical name at the same sub-directory of `Data/`, then Hedgewars will simply add that file, making it available for Hedgewars. This is the most commonly used form of HWPs, used to create add-ons, like new missions, flag packs, themes, etc. If there is already a file with such a name there, Hedgewars will prefer the file in the HWP and ignore the other one. This has to be done with care, some files are safe to replace while other files cannot be simply replaced, as this will cause network games to fail. For example, if you have a HWP which replaces an object of a theme and you play that theme online, the online game will fail, unless your fellow players have the same HWP installed.
    61 
    62 
    62 It is a special case when you have multiple HWPs activated, when some of them try to include a file with identical name. This is a conflict, see the conflict section for more information about this.
    63 It is a special case when you have multiple HWPs activated, when some of them try to include a file with identical name. This is a conflict, see the conflict section for more information about this.
    63 
    64 
    64 ===== Custom sprites and sounds =====
    65 ==== Custom sprites and sounds ====
    65 For Lua scripts you can add a few custom sounds and sprites without actually replacing any useful resources. For this, Hedgewars offers a 8 dummy sprites and 8 dummy sounds which only exist so they can be added in a HWP.
    66 For Lua scripts you can add a few custom sounds and sprites without actually replacing any useful resources. For this, Hedgewars offers a 8 dummy sprites and 8 dummy sounds which only exist so they can be added in a HWP.
    66 
    67 
    67 The custom sprites are named `Graphics/custom1.png` to `Graphics/custom8.png` and are accessed in Lua with `sprCustom1` to `sprCustom8`.
    68 The custom sprites are named `Graphics/custom1.png` to `Graphics/custom8.png` and are accessed in Lua with `sprCustom1` to `sprCustom8`.
    68 
    69 
    69 The custom sounds are named `Sounds/custom1.ogg` to `Sounds/custom8.ogg` and are accessed in Lua with `sndCustom1` to `sndCustom8`.
    70 The custom sounds are named `Sounds/custom1.ogg` to `Sounds/custom8.ogg` and are accessed in Lua with `sndCustom1` to `sndCustom8`.
    70 
    71 
    71 ===== Custom ammo icons =====
    72 ==== Custom ammo icons ====
    72 Overwriting ammo icons is a special case. If `Graphics/AmmoMenu/Ammos.png` or `Graphics/AmmoMenu/Ammos_bw.png` is found in the HWP, it will be overlayed over the original images `Graphics/AmmoMenu/Ammos_base.png` and `Graphics/AmmoMenu/Ammos_bw_base.png`, respectively. This is useful if you only need to replace a few certain ammo icons, and not the entire set of ammo icons. This is especially important to ensure forwards-compability of your sidecar HWPs for your scripts (see below).
    73 Overwriting ammo icons is a special case. If `Graphics/AmmoMenu/Ammos.png` or `Graphics/AmmoMenu/Ammos_bw.png` is found in the HWP, it will be overlayed over the original images `Graphics/AmmoMenu/Ammos_base.png` and `Graphics/AmmoMenu/Ammos_bw_base.png`, respectively. This is useful if you only need to replace a few certain ammo icons, and not the entire set of ammo icons. This is especially important to ensure forwards-compability of your sidecar HWPs for your scripts (see below).
    73 
    74 
    74 For example, if you want to replace the “Air Attack” icon with a crosshair icon, but leave everything else alone, just draw the cross hair icon on the correct position and make all other frames fully transparent.
    75 For example, if you want to replace the “Air Attack” icon with a crosshair icon, but leave everything else alone, just draw the cross hair icon on the correct position and make all other frames fully transparent.
    75 
    76 
    76 === Possible locations for HWPs ===
    77 == Possible locations for HWPs ==
    77 
    78 
    78 ==== HWPs in `Data/` ====
    79 === HWPs in `Data/` ===
    79 The most common HWPs will be stored in the `Data/` directory of Hedgewars. Note that there are two `Data/` directories for Hedgewars, one is system-wide and one is intended for the current user. In case of conflicts between both, the user directory will take precendence.
    80 The most common HWPs will be stored in the `Data/` directory of Hedgewars. Note that there are two `Data/` directories for Hedgewars, one is system-wide and one is intended for the current user. In case of conflicts between both, the user directory will take precendence.
    80 
    81 
    81 Storing HWPs in the user `Data/` directory is the most common form of installing a HWP to Hedgewars. This is what happens when you use DLCs. HWPs distributed in webforums are usually intended to be installed into the user `Data/` directory.
    82 Storing HWPs in the user `Data/` directory is the most common form of installing a HWP to Hedgewars. This is what happens when you use DLCs. HWPs distributed in webforums are usually intended to be installed into the user `Data/` directory.
    82 
    83 
    83 
    84 
    84 ==== Sidecar HWPs ====
    85 === Sidecar HWPs ===
    85 Sidecar HWPs are HWPs installed in the same directory as a Lua script. Sidecar HWPs always serve as a companion for one single Lua script. Sidecar HWPs will be activated only if the script in question is run by Hedgewars. Otherwise, the HWP remains inactive and its resources are unavailable.
    86 Sidecar HWPs are HWPs installed in the same directory as a Lua script. Sidecar HWPs always serve as a companion for one single Lua script. Sidecar HWPs will be activated only if the script in question is run by Hedgewars. Otherwise, the HWP remains inactive and its resources are unavailable.
    86 
    87 
    87 The name of a sidecar HWP equals the name of the Lua script it serves as a “sidecar”, with the file name suffix replaced by “.hwp”. Sidecar HWPs must be in the same directory as the script.
    88 The name of a sidecar HWP equals the name of the Lua script it serves as a “sidecar”, with the file name suffix replaced by “.hwp”. Sidecar HWPs must be in the same directory as the script.
    88 
    89 
    89 Example: The sidecar HWP of the Lua script in `/Data/Missions/Training/MyAwesomeMission.lua` would be `Data/Missions/Training/MyAwesomeMission.hwp`.
    90 Example: The sidecar HWP of the Lua script in `/Data/Missions/Training/MyAwesomeMission.lua` would be `Data/Missions/Training/MyAwesomeMission.hwp`.
    90 
    91 
    91 Using sidecar HWPs is useful for Lua scripters who want to provide a few resources for your script but don’t want to force users to install them globally or to fiddle around with their user data directory. Especially if using the resources only really makes sense together with the script.
    92 Using sidecar HWPs is useful for Lua scripters who want to provide a few resources for your script but don’t want to force users to install them globally or to fiddle around with their user data directory. Especially if using the resources only really makes sense together with the script.
    92 
    93 
    93 Please remember how Hedgewars uses ammo icons in HWPs (see above).
    94 Please remember how Hedgewars uses ammo icons in HWPs (see above).
    94 
    95 
    95 ==== Limitations ====
    96 === Limitations ===
    96 Important: HWPs are not recursive! This means if you put a HWP inside another HWP, Hedgewars will only load the actual contents of the outermost HWP. The contents of the inner HWP are not loaded. This implies that there is currently no way (via HWP) to distribute a script with custom data. You have to ask users to just extract a normal Zip file with your script data instead.
    97 Important: HWPs are not recursive! This means if you put a HWP inside another HWP, Hedgewars will only load the actual contents of the outermost HWP. The contents of the inner HWP are not loaded. This implies that there is currently no way (via HWP) to distribute a script with custom data. You have to ask users to just extract a normal Zip file with your script data instead.
    97 
    98 
    98 This is considered a bug, see https://issues.hedgewars.org/show_bug.cgi?id=174.
    99 This is considered a bug, see https://issues.hedgewars.org/show_bug.cgi?id=174.
    99 
   100 
   100 ==== Order of precedence ====
   101 === Order of precedence ===
   101 
   102 
   102   # Sidecar HWPs
   103   # Sidecar HWPs
   103   # All HWPs
   104   # All HWPs
   104   # Alphabetically
   105   # Alphabetically
   105   # User `Data/` directory
   106   # User `Data/` directory